Difference between revisions of "Remapping remote control key codes greater than 255"
(Remapping remote control buttons using event_key_remap - initial version)
m (moved Event key remap to Remapping remote control key codes greater than 255: Provide a better title for use with the HOWTO category.)
Revision as of 19:10, 12 June 2010
- 1 Key mapping using event_key_remap
- 2 Building the xf86-input-evdev driver
- 3 Determining the codes generated by your remote control
Key mapping using event_key_remap
Version 11 of the X protocol only supports single-byte key codes - so key codes above 255 are ignored. Unfortunately, buttons on many keyboards and remote controls, particularly those intended for "multi-media" purposes, generate key codes higher than 255 for many of their buttons. These codes are simply ignored by X and will not work.
This issue has been raised as a bug at bugs.freedesktop.org and support for more key codes is on the wish list for version 12 of X.
Until version 12 is released, however, Gianni Ceccarelli has created a patched version of the 'xf86-input-evdev' driver which allows key codes to be remapped from one value another. Details are on his page here.
Building the xf86-input-evdev driver
The instructions below are based on Mythbuntu 10.04 and may need to be varied slightly for your distribution.
If you do not have git installed, the following command will install it for you:
sudo apt-get install git-core
Downloading the patched driver
These commands assume that you are starting off in your 'home' directory:
git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-input-evdev git pull git://www.thenautilus.net/xf86-input-evdev code_remap
Building the driver
cd xf86-input-evdev ./autogen.sh ./configure make sudo make install
Instructing X to use the patched driver
By default, the 'make install' script above copies the new driver into /usr/local/lib/xorg/modules, though this can be overridden if you want to. For the default case, this path needs to be added to the ModulePath for X:
Section "Files" ModulePath "/usr/local/lib/xorg/modules,/usr/lib/xorg/extra-modules,/usr/lib/xorg/modules" EndSection
Now restart X by whaterver means you can (eg rebooting the machine, restarting gdm etc) and check that the new module is being used:
grep evdev_drv /var/log/Xorg.0.log
and you should see a line such as:
(II) Loading /usr/local/lib/xorg/modules/input/evdev_drv.so
which shows that the evdev driver was loaded from /usr/local/lib, and not /usr/lib.
Gianni describes how to use event_key_remap with HAL configuration on his web page; an alternative method is to add the following entries to your xorg.conf file:
Section "ServerLayout" Identifier "your-layout-name" ... add the following line to the existing lines in this section ... InputDevice "RF remote" "SendCoreEvents" EndSection Section "InputDevice" Identifier "RF remote" Driver "evdev" Option "Name" "your-remote-name" Option "event_key_remap" "402=111 403=116" Option "xkb_rules" "xorg" Option "xkb_model" "evdev" Option "Device" "your-device-id" Option "Protocol" "evdev" EndSection
The magic line is the 'event_key_remap' option which has been added to the 'evdev' driver by the patches. In the example above, codes 402 and 403 (which are ignored by X since they are above 255) from the remote control are respectively mapped to codes 111 and 116 (which will be handled properly by X).
You will need to modify the 'event_key_remap' line with all the various codes that you need for your own remote control handset.