Re: Key snooper / piano keyboard



In message <Pine LNX 4 33 0112042127570 27485-100000 crafter house>you write:
>I'm having a problem with the key snooper. It appears to generate events
>coresponding to how they would be entered e.g. in a text box, rather than
>the actual keyboard status.
>
>The program is intended to turn your computer keyboard into a piano. When
>you push a key, a note sounds, when you lift up, it stops.
>
>One of the key-getting modules uses GTK. I am getting the key events using
>the key snooper.
>
>The only problem is, the keycodes still appear to be "cooked": If you hold
>down a key, you get repeating events. Immediately after the key is
>pressed, a GDK_KEY_PRESS is recieved, then immediately followed by a
>GDK_KEY_RELEASE. Then after the key repeat delay, pairs of GDK_KEY_PRESS
>and GDK_KEY_RELEASE events are recieved at the key repeat frequency.
>
>Obviously this is not what I want. Is there a way to get the actual status
>of the key on the keyboard?

its not GTK+ that is doing that.

its your X server. if you don't want keys to autorepeat, turn off
autorepeat either from your shell or inside your code (but note that
users will hate you if you fail to restore it when your program exits
under any circumstances, and that can be hard to do).

and note: your plan will not work, in general. i know because i've
tried this myself.

the hardware design of computer keyboards does not allow for arbitrary
chords. there are lots of potential chord combinations that will never
result in any signal being generated by your keyboard because of the
way the sub-key matrix is wired.

i have code that does pretty much what you are describing using Xlib
calls. but as i said, it doesn't work well enough because of the chord
issues, and i don't use it anymore.

--p







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]