Ubuntu: How to remap key codes without '/usr/lib/keymap' (which is gone in Saucy, and in Trusty, …)?



Question:

X11 doesn’t see keycodes above 255, so how to remap those few keys into the gaps below 255?

/usr/lib/keymap existed in raring, which worked like this:

1. Keys identification:

sudo /lib/udev/keymap input/event3  > scan code: 0xC1021   key code: zoomreset => 100%  > scan code: 0xC101F   key code: zoomin => zoom -  > scan code: 0xC1020   key code: zoomout => zoom +  > scan code: 0xC0192   key code: calc => calculator  

2. Remap keys:

sudo /lib/udev/keymap input/event3 0xC1021 phone  sudo /lib/udev/keymap input/event3 0xC101F sport  sudo /lib/udev/keymap input/event3 0xC1020 shop  sudo /lib/udev/keymap input/event3 0xC0192 www  

It was great, simple and quick...

xmodmap works for keys < 255 like my calculator key (code 148)

sudo evtest /dev/input/event3   Input driver version is 1.0.1  Input device ID: bus 0x3 vendor 0x46d product 0xc517 version 0x110  Input device name: "Logitech USB Receiver"  ...  Testing ... (interrupt to exit)  > Event: time 1381940761.592647, type 1 (EV_KEY), code 140 (KEY_CALC), value 1 => calculator  > Event: time 1381940790.224658, type 1 (EV_KEY), code 420 (KEY_ZOOMRESET), value 1 => 100%  > Event: time 1381940810.928667, type 1 (EV_KEY), code 419 (KEY_ZOOMOUT), value 1 => Zoom -  > Event: time 1381940836.216678, type 1 (EV_KEY), code 418 (KEY_ZOOMIN), value 1 => Zoom +  

**EDIT : I have found the solution in this ubuntuforum post.


Solution:1

Keymappings are still done with udev in trusty (and saucy, I guess), but the mechanism changed.

To remap a key, only one ioctl(EVIOCSKEYCODE) is necessary, but no simple program doing that exists any more. â€" It is now internal to udev. So do this:

  1. tell udev the mappings
    1. create a file /etc/udev/hwdb.d/keyboard.hwdb
    2. write only the keyboard identifier in there and mappings you want to change (the format is like in /lib/udev/hwdb.d/60-keyboard.hwdb, where I also found those confusing identifiers for my keyboard); for example:
        keyboard:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*   KEYBOARD_KEY_00=msdos   KEYBOARD_KEY_09=prog3   KEYBOARD_KEY_0a=dashboard  
    3. udevadm hwdb --update
    4. check if you see your updates via udevadm hwdb --test='keyboard:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*' (change to your keyboard id)
    5. udevadm control --reload is needed even if the man-page says otherwise â€" I tried it.
  2. trigger their execution (or simply reboot)
    1. with a running udev monitor --property you can see the effect of the next step, the --property option will reveal the remappings
    2. for my keyboard I do a udevadm trigger --verbose --sysname-match=event6 --action=add The “add action” is important, because “change” events are ignored in the current keyboard rules.
    3. in your case a --sysname-match=event3 would do it, but you can play around with it via these three:
      • udevadm trigger --dry-run --verbose shows you all devices
      • inspire you fantasy for matcher building with udevadm info /sys/devices/platform/thinkpad_acpi/input/input12/event6 or whatever your device
      • udevadm trigger --help will give you hint how to reduce the next trigger dry-run

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »