3

I am trying to map a function key combination to an XF86 key symbol. The key combination is Fn+F1, which I was able to use showkey to get the raw keycode for.

jason@io ~ $ showkey
kb mode was RAW
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]

press any key (program terminates 10s after last keypress)...
keycode  28 release
keycode 466 press
keycode 466 release
keycode 113 press
keycode 113 release
keycode 114 press
keycode 114 release

Adding 8 to the showkey keycode, as mentioned in another question, gives an X keycode of 474. Although, running xev doesn't seem to catch the key press or release. It does catch the next two function key combinations though (Fn+F2, Fn+F3).

jason@io ~ $ xev -root

FocusIn event, serial 18, synthetic NO, window 0x71,
    mode NotifyGrab, detail NotifyInferior

KeymapNotify event, serial 18, synthetic NO, window 0x0,
    keys:  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   2
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

FocusOut event, serial 18, synthetic NO, window 0x71,
    mode NotifyUngrab, detail NotifyInferior

FocusIn event, serial 18, synthetic NO, window 0x71,
    mode NotifyGrab, detail NotifyInferior

KeymapNotify event, serial 18, synthetic NO, window 0x0,
    keys:  1   0   0   0   0   0   0   0   0   0   0   0   0   0   0   4
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0

FocusOut event, serial 18, synthetic NO, window 0x71,
    mode NotifyUngrab, detail NotifyInferior

I'm trying to handle the key combination in the window manager, where I have number of other working bindings, including Fn+F2 and Fn+F3. However, it seems like either X isn't receiving the key press, or maybe .Xmodmap isn't binding the keycode correctly.

Am I not doing something right? Is there a another way to do this?

3

After researching, I found out that this is a fundamental limitation of the X11 protocol. Specifically, the data type used to represent a keycode is a byte, which limits values to between 8 to 255 (+8 bias). It's an issue that's intended to be resolved in the X12 protocol (see Resource Limits).

One workaround is to remap the keycode into the valid range using a patched evdev in xorg.conf.

Section "InputDevice"
    Identifier     "keyboard"
    Driver         "evdev"
    Option         "event_key_remap" "474=247"
EndSection

The keycode can also be remapped in the kernel.

jason@io ~ $ sudo setkeycodes e0xx 266

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.