View previous topic :: View next topic |
Author |
Message |
ManDay Apprentice
Joined: 22 Jan 2008 Posts: 247
|
Posted: Sun Oct 07, 2012 8:44 am Post subject: How does a keystroke reach the (X) software? |
|
|
I'm having troubles making a key work.
If I were to implement the path a keystroke took until it reaches the application, I would do it like that:
Kernel translates Scancode into a Keycode by the Keyboard driver, which knows which scancode corresponds to which key for a specific keyboard hardware.
Kernel then translates the Keycode to a Keyvalue according to a specific keymap for the specific keyboard layout (one keyboard hardware may thus have multiple layouts).
X11 gets a Keycode and composes (if necessary) it into a Keysym, such as "é" or "ô" (composed) or "Esc", "k", "XF86Home".
The software can then either listen to keysyms or to keycodes, depending on what they want to do.
To my understanding the kernel part goes as I described it, but I don't understand by which logic X11 currently works. There seems to be a truckload of tables in X which translate keycodes back-and-forth without any apparent advantage of doing so.
There are /usr/include/X11 and /usr/share/X11/xkb, which again branch out into a million files which do all sorts of mapping. Not only am I not able to see any sense in this, but I can't even get it to work from which I can infer.
I tried to make scancode e02d be recognized as XF86Menu. For that, I found a thing like
Code: | /usr/share/X11/xkb/symbols/inet: key <I147> { [ XF86MenuKB ] }; |
and
Code: | /usr/share/X11/xkb/keycodes/evdev: <I147> = 147; // #define KEY_MENU |
So I ran "setkeycodes e02d 147" but then the key maps to XF86Xfer. Can anyone explain this? |
|
Back to top |
|
|
jrussia Tux's lil' helper
Joined: 29 Aug 2012 Posts: 89 Location: Chicago
|
Posted: Sun Oct 07, 2012 7:16 pm Post subject: |
|
|
In my /usr/share/X11/xkb/keycodes/evdev I have
<I147> = 147; // #define KEY_MENU 139
and
<I155> = 155; // #define KEY_XFER 147
so judging by your results, I would guess that the correct keycode for you would be 139. |
|
Back to top |
|
|
BillWho Veteran
Joined: 03 Mar 2012 Posts: 1600 Location: US
|
Posted: Sun Oct 07, 2012 11:52 pm Post subject: |
|
|
ManDay,
x11-apps/xev will display X events.
Code: | xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p' |
will display the key's scancode
Another application you might want to look into is x11-apps/xmodmap _________________ Good luck
Since installing gentoo, my life has become one long emerge |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|