2011-11-07, 07:33
In this how-to, I will describe how I got an MCE remote to work without using LIRC. As you may know, many of the LIRC drivers have been migrated into the kernel. This how-to is based on a few others:
http://forum.xbmc.org/showthread.php?tid=99042
http://forum.xbmc.org/showthread.php?tid=101151
http://forum.xbmc.org/showthread.php?tid=104541
The IR kernel drivers look like a keyboard to XBMC, so the Lircmap.xml is not used and can not be this approach. All changes to key mapping of the remote must be done through keyboard.xml.
I have made this work on Ubuntu Natty and it will probably work on Maverik, but I am not sure. Definitely will not work on anything earlier due to the kernel version.
I have this working on a PC with a MCE USB receiver (built-in), as well as on a Asrock 330HT using the internal IR receiver with the kernel nuvoton driver.
There are a couple of problems that we must work around. First install the ubuntu ir-keytable package
Now there is a bug in that version that causes it to ignore key codes greater than 0x80000000. So do the following:
EDIT: Apparently ir-keytable is fixed in oneiric.
If your using an xbmcfreak version, then do the following
Comment echo none +lirc > /sys/class/rc/rc0/protocols in /etc/rc.local
Now we're going to temporarily disable lirc. So
If you feel comfortable, just go ahead and remove LIRC instead.
now reboot, then run ir-keytable, and you should see something like
The important thing is that the MCE receiver is recognized and that RC-6 is enabled. If this doesn't work, grep for mce in dmesg to see if there are errors loading the kernel driver.
Next run ir-keytable -t
press some keys on your remote and you should see things like
Now the next problem is that the kernel ir drivers generate keyboard scan codes greater than 255 for some keys. Xorg does not recognize these, in fact it ignores them. Until there is an overhaul of Xorg to fix this, we must work around it otherwise XBMC will never get the keys.
Create a new mapping file in /etc/rc_keymaps, call it rc6_mce
This is largely based on the default file.
Now run ir-keytable like this
Next re-run ir-keytable -t to make sure it still works.
Now we want our new mapping file to be loaded at startup, so create a file xbmc-ir-keytable.conf in /etc/init (note in init NOT init.d) as follows
Ok, now we need to remap the keys in xbmc to work. Need to add a keyboard.xml to .xbmc/userdata/keymaps. See next post for contents of my keyboard.xml
This is based on the default file and modified to my preferences. Note that there does seem to be an issue with the recent git of xbmc. You use to be able to look for the scancode of unmapped/unknown keys in the log and use something like <key id='65446'>, but the with recent overhauls, this seems to no longer work.
That should be it, it should work. The only thing that's a bit of a pain, is that if you press and hold a key, the repeat frequency seems very, very high. I haven't got around to tuning that yet.
http://forum.xbmc.org/showthread.php?tid=99042
http://forum.xbmc.org/showthread.php?tid=101151
http://forum.xbmc.org/showthread.php?tid=104541
The IR kernel drivers look like a keyboard to XBMC, so the Lircmap.xml is not used and can not be this approach. All changes to key mapping of the remote must be done through keyboard.xml.
I have made this work on Ubuntu Natty and it will probably work on Maverik, but I am not sure. Definitely will not work on anything earlier due to the kernel version.
I have this working on a PC with a MCE USB receiver (built-in), as well as on a Asrock 330HT using the internal IR receiver with the kernel nuvoton driver.
There are a couple of problems that we must work around. First install the ubuntu ir-keytable package
Code:
apt-get install ir-keytable
Now there is a bug in that version that causes it to ignore key codes greater than 0x80000000. So do the following:
Code:
git clone http://linuxtv.org/git/v4l-utils.git
apt-get install autoconf
apt-get install libjpeg62-dev g++
cd v4l-utils/utils/keytable
make
cp ./ir-keytable /usr/bin
EDIT: Apparently ir-keytable is fixed in oneiric.
If your using an xbmcfreak version, then do the following
Comment echo none +lirc > /sys/class/rc/rc0/protocols in /etc/rc.local
Now we're going to temporarily disable lirc. So
Code:
mv /etc/init.d/lirc /etc/init.d/lirc1
If you feel comfortable, just go ahead and remove LIRC instead.
now reboot, then run ir-keytable, and you should see something like
Quote:Found /sys/class/rc/rc0/ (/dev/input/event2) with:
Driver mceusb, table rc-rc6-mce
Supported protocols: NEC RC-5 RC-6 JVC SONY LIRC
Enabled protocols: RC-5 RC-6
Name: Media Center Ed. eHome Infrared
bus: 3, vendor/product: 0471:0815, version: 0x0000
Repeat delay = 500 ms, repeat period = 33 ms
The important thing is that the MCE receiver is recognized and that RC-6 is enabled. If this doesn't work, grep for mce in dmesg to see if there are errors loading the kernel driver.
Next run ir-keytable -t
press some keys on your remote and you should see things like
Quote:1320643260.849486: event MSC: scancode = 800f041e
1320643260.849498: event key down: KEY_UP (0x0067)
1320643260.849500: event sync
1320643260.968489: event MSC: scancode = 800f041e
1320643261.219926: event key up: KEY_UP (0x0067)
1320643261.219933: event sync
1320643261.682490: event MSC: scancode = 800f0421
1320643261.682502: event key down: KEY_RIGHT (0x006a)
1320643261.682504: event sync
1320643261.788502: event MSC: scancode = 800f0421
1320643262.039923: event key up: KEY_RIGHT (0x006a)
1320643262.039930: event sync
Now the next problem is that the kernel ir drivers generate keyboard scan codes greater than 255 for some keys. Xorg does not recognize these, in fact it ignores them. Until there is an overhaul of Xorg to fix this, we must work around it otherwise XBMC will never get the keys.
Create a new mapping file in /etc/rc_keymaps, call it rc6_mce
Code:
# table rc6_mce, type: RC-6
0x800f0400 KEY_KP0
0x800f0401 KEY_KP1
0x800f0402 KEY_KP2
0x800f0403 KEY_KP3
0x800f0404 KEY_KP4
0x800f0405 KEY_KP5
0x800f0406 KEY_KP6
0x800f0407 KEY_KP7
0x800f0408 KEY_KP8
0x800f0409 KEY_KP9
0x800f040a KEY_DELETE
0x800f040b KEY_ENTER
0x800f040c KEY_KPSLASH # Power
0x800f040d KEY_C # Left Meta, Start
0x800f040e KEY_MUTE
0x800f040f KEY_I # Info
0x800f0410 KEY_PAGEUP # Volume Up
0x800f0411 KEY_PAGEDOWN # Volume Down
0x800f0412 KEY_CHANNELUP
0x800f0413 KEY_CHANNELDOWN
0x800f0414 KEY_F # Fast forward
0x800f0415 KEY_R # Rewind
0x800f0416 KEY_PLAY
0x800f0417 KEY_RECORD
0x800f0418 KEY_PAUSE
0x800f046e KEY_PLAYPAUSE
0x800f0419 KEY_STOP
0x800f041a KEY_NEXTSONG # Skip Next
0x800f041b KEY_PREVIOUSSONG # Skip Previous
0x800f041c KEY_NUMERIC_POUND
0x800f041d KEY_NUMERIC_STAR
0x800f041e KEY_UP
0x800f041f KEY_DOWN
0x800f0420 KEY_LEFT
0x800f0421 KEY_RIGHT
0x800f0422 KEY_ENTER # Ok
0x800f0423 KEY_BACKSPACE # Back / Exit
0x800f0424 KEY_DVD
0x800f0425 KEY_TUNER
0x800f0426 KEY_EPG
0x800f0427 KEY_ZOOM
0x800f043a KEY_BRIGHTNESSUP
0x800f0446 KEY_TV
0x800f0447 KEY_AUDIO
0x800f0448 KEY_PVR
0x800f0449 KEY_CAMERA
0x800f044a KEY_VIDEO
0x800f044c KEY_LANGUAGE
0x800f044d KEY_TITLE
0x800f044e KEY_PRINT
0x800f0450 KEY_RADIO
0x800f045a KEY_SUBTITLE
0x800f045b KEY_RED
0x800f045c KEY_O # Green
0x800f045d KEY_YELLOW
0x800f045e KEY_Z # Blue
0x800f0465 KEY_POWER2
0x800f046e KEY_PLAYPAUSE
0x800f046f KEY_MEDIA
0x800f0480 KEY_BRIGHTNESSDOWN
0x800f0481 KEY_PLAYPAUSE
This is largely based on the default file.
Now run ir-keytable like this
Quote:ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce
Next re-run ir-keytable -t to make sure it still works.
Now we want our new mapping file to be loaded at startup, so create a file xbmc-ir-keytable.conf in /etc/init (note in init NOT init.d) as follows
Code:
#
description "xbmc-ir-keytable"
start on (filesystem and stopped udevtrigger)
pre-start script
end script
script
logger "Setting IR Keymap..."
/usr/bin/ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce
end script
pre-stop script
end script
Ok, now we need to remap the keys in xbmc to work. Need to add a keyboard.xml to .xbmc/userdata/keymaps. See next post for contents of my keyboard.xml
This is based on the default file and modified to my preferences. Note that there does seem to be an issue with the recent git of xbmc. You use to be able to look for the scancode of unmapped/unknown keys in the log and use something like <key id='65446'>, but the with recent overhauls, this seems to no longer work.
That should be it, it should work. The only thing that's a bit of a pain, is that if you press and hold a key, the repeat frequency seems very, very high. I haven't got around to tuning that yet.