štvrtok 11. marca 2010

Keys mapping

Not all the keys on my TV card remote work with XBMC. I needed to map some of them to achieve certain behavior, e.g. I needed to use the backspace key which was not mapped to the remote.

The solution is very simple. First run the "xev" program. This program prints out the content of X events, such as key presses. Then press a key on the remote and make sure you see this in the "xev"-s output, such as:

KeyPress event, serial 31, synthetic NO, window 0x400001,
root 0x157, subw 0x0, time 69418336, (567,307), root:(620,340),
state 0x0, keycode 182 (keysym 0x1008ff56, XF86Close), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False


This is the output for the "Back" key on my remote. There's another event for KeyRelease, which does not interest us at this point. The important information is the "keycode", which is 182 in my case.

Next we need to map the keycode 182 to the particular keyboard key, in my case it is the Backspace key. Since I am using gdm, I put the mapping to the /etc/gdm/PostLogin/Default file. The mapping is:

xmodmap -e "keycode 182 = BackSpace"


And that's it.

Update 20120124: Now that Ubuntu switched to lightdm, the key mapping can be made permanent by adding the xmodmap commands to separate shell script and add this shell script to /etc/lightdm/lightdm.conf under "greeter-setup-script".

6 komentárov:

  1. Tento komentár bol odstránený autorom.

    OdpovedaťOdstrániť
  2. Thanks a million !!

    xmodmap -e "keycode 182 = BackSpace" worked!!

    Some of my buttons are not mapped at all i.e. the red, yellow, green, blue is ok.

    xev does nothing..

    Anyway to get it working?

    And thanks again for the very detailed post!!

    OdpovedaťOdstrániť
    Odpovede
    1. So you got it working at last?
      This reminds me I might need to update the post, since Ubuntu now switched to Lightdm and my backspace button does not work anymore.

      Odstrániť
  3. I found this:
    http://deneb.homedns.org/things/?p=81&replytocom=24
    how can i use the codes from input-kbd 6 > keyMapIR.txt to make a new mycinema.conf file?

    So ALL the buttons work..

    Thanks

    OdpovedaťOdstrániť
  4. OK...
    Fully fixed it:

    http://ubuntuforums.org/showthread.php?p=11590929#post11590929

    Cheers

    OdpovedaťOdstrániť