Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How does a keystroke reach the (X) software?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
ManDay
Apprentice
Apprentice


Joined: 22 Jan 2008
Posts: 218

PostPosted: Sun Oct 07, 2012 8:44 am    Post subject: How does a keystroke reach the (X) software? Reply with quote

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
View user's profile Send private message
jrussia
Tux's lil' helper
Tux's lil' helper


Joined: 29 Aug 2012
Posts: 89
Location: Chicago

PostPosted: Sun Oct 07, 2012 7:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Sun Oct 07, 2012 11:52 pm    Post subject: Reply with quote

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 :wink:
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
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