XGetKeyboardMapping()
Trevor Woerner
twoerner at gmail.com
Fri Jul 2 10:22:36 PDT 2010
Hi,
I have a situation where I have the user pass in a string which I then
send to a window using XTestFakeKeyEvent(). XTestFakeKeyEvent() takes
a KeyCode (as opposed to a KeySym) so I need to also simulate keyboard
modifier states as well (e.g. Shift). According to chapter 9 of the
O'Reilly Xlib Programming Manual (Volume One) I can use
XGetKeyboardMapping() to get from the server an array of the symbols
which will be generated by a given KeyCode with various combinations
of keyboard modifiers in effect:
<quote>
For each keycode, the server defines a list of keysyms, corresponding
to the key pressed while various modifier keys are being held. There
are conventions for the meanings of the first two keysyms in the list.
The first keysym in the list for a particular key should be construed
as the symbol corresponding to a KeyPress when no modifier keys are
down. The second keysym in the list, if present, usually should be
construed as the symbol when the Shift or Shift Lock modifier keys are
down.
</quote>
Is there a way to make this less wishy-washy? Instead of hoping the
second one is for shift, is there no way to know for sure that it is,
and code it in such a way that if the Shift result is somewhere else
in the list the code would find it anyway? The server knows how it is
filling the returned array, is there no way to tap into that to know
for sure that 0 is no modifier and 1 is shifted? As it is my code has
"magic" values in them of 0 and 1 for the two states I'm interested
in. Luckily I'm only interested in the states "no modifier" and
"shift". Is there at least a #define somewhere I could use instead of
0 and 1?
Best regards,
Trevor
More information about the xorg-devel
mailing list