ir-keytable or: How I Learned to Stop Worrying about the LIRC Kernel
#1
This is for kernel's 2.6.35+ and LIRC 0.9.0 and above.

Foreword: I've put off upgrading from Lucid because of the cluster that was LIRC in Kernel (and have not been shy about it). After Natty... I'm not happy about Natty, I'm going back to what every thing else in my house runs. A good proper Debian system. I've finally bit the bullet and started to figure out how to deal with LIRC in the Kernel, because it's not going away. Turns out, its just a little bit of awesome (and a whole lot of work.)

First you're going to need ir-keytable. It's available in natty (not maverick) and Sid & Testing.
apt-get install ir-keytable. ir-keytable turns ... I'm not really sure what ir-keytable really does. But it turns remote presses into LIRC stuff.

This is the flow chart of fun. I'll try and work on this in order.
lirc kernel -> ir-keytable mapping -> LIRC devinput -> lircmap.xml -> remote.xml.

Do not install LIRC yet. Un-install it if you have it. Right now we're going to be futzing without it.

Running ir-keytable by itself will dump out what IR receiver it recognizes in addition to what protocols it supports. I have a real HP receiver & Remote (ID 045e:006d Microsoft Corp. eHome Remote Control Keyboard keys)
Code:
ir-keytable
Found /sys/class/rc/rc0/ (/dev/input/event0) with:
    Driver mceusb, table rc-rc6-mce
    Supported protocols: NEC RC-5 RC-6 JVC SONY LIRC
    Enabled protocols: NEC RC-5 RC-6 JVC SONY LIRC
    Repeat delay = 500 ms, repeat period = 33 ms

RC5/6 are the IR protocols defined by Philips.
NEC aka "Japanese Format" are by NEC. This is the bread and butter protocol as most remotes use this. (At least in my house hold my Yamaha receiver and Samsung TV both use it.)
Sony. Sony ALWAYS does their own thing... I don't have anything in my house that uses this.
JVC. JVC has their own too.
--
First, You're going to be making a hex -> LIRC button name file for each of your remotes. I have 3. MCE Remote, Yamaha Receiver Remote & TV Remote.

The MCE Remote should already be mostly mapped, but if you try to standardize something as non-standard as remotes, you're bound to get a few wrong. Inside of /lib/udev/rc_keymaps/, there should be an rc6_mce. Copy that to /etc/rc_keymaps/, we're going to be editing that instead of creating a brand new file.
Code:
cp /lib/udev/rc_keymaps/rc6_mce /etc/rc_keymaps/

1) Open up my dump of valid LIRC keys: http://xbmc.exstatic.org/ir_keys.txt. You can use your own, but these are "standard". These are the names we'll be working
2) I'm opening text files on my laptop for each remote then scping them over. You can edit directly in nano. You can export the /etc/rc_keymaps/. You can use butterflies if you like
3) Run "ir-keytable -c" to clear out the old table. Fire up "ir-keytable -t". If you'd like to think of this as the new "irw", you can. (If you're running LIRC, you didn't follow the directions and you have to at least stop it before running ir-keytable.)

"ir-keytable -t/--test" shows you what is being pressed. This is where the slight bit of awesome comes in. irrecord would NOT record some buttons for me, TV up down. This literally shows me something every time I press the remote. Even weird keys like +10. All of my TV commands, etc.

4) First we're going to go through our rc6 remote and 'correct' any keys that are funky. For example the "Start" key on my remote is KEY_PROG1, I want to change it to KEY_HOME.
Code:
nano /etc/rc_keymaps/rc6_mce

5) Repeat this for every remote you want to program. For my Yamaha remote "XBMC" is going to be the DVD button. When I press it on remote the receiver swaps to the correct HDMI and SPDIF in. So when I press the DVD button, it'll now control my XBMC.

Down, Up, Left, Right, Select, Keys 1-0.
Code:
ir-keytable -t
Testing events. Please, press CTRL-C to abort.
1304995824.617619: event MSC: scancode = 7cb3
1304995825.030592: event MSC: scancode = 7cb4
1304995825.380603: event MSC: scancode = 7cb5
...

I'm personally doing this in TextMate and then just copying it to ssh. The scan codes are in hex. So right now it looks like this:
Code:
0x7cb3 KEY_DOWN
0x7cb4 KEY_UP
0x7cb5 KEY_LEFT
0x7cb6 KEY_RIGHT
0x7cb8 KEY_OK

0x7c93 KEY_NUMERIC_0
0x7c94 KEY_NUMERIC_1
...

The first line of the file, best I can figure, MUST look like this:
Code:
==> rc6_mce <==
# table rc6_mce, type: RC6

==> samsung_stb <==
# table samsung, type: NEC

==> yamaha_dvd <==
# table yamaha, type: NEC

Again, it's not really documented. But if it didn't look like this, it threw a fit.

6) Edit /etc/rc_maps.cfg ... To what. I really don't know right now. I have no @#)(* clue how it works or what it does.

Right now I'm loading each of the files individually.
Code:
/usr/bin/ir-keytable -c
/usr/bin/ir-keytable -p NEC,RC6 -w /etc/rc_keymaps/rc6_mce
/usr/bin/ir-keytable -p NEC,RC6 -w /etc/rc_keymaps/yamaha_dvd
/usr/bin/ir-keytable -p NEC,RC6 -w /etc/rc_keymaps/samsung_stb

Now when you run 'ir-keytable -t' you should see each of the buttons mapped.
You need to specify the protocol otherwise it'll drop one of them based on the rc_keymaps.

7) NOW you can install LIRC. Edit /etc/lirc/hardware.conf so that
Code:
LOAD_MODULES=true
DRIVER="devinput"
DEVICE="/dev/input/by-id/**YOUR DEVICE HERE***"

To determine where the input device is mapped just do an 'ls' of /dev/input/by-id/. It should be fairly obvious which one it is. If it's not obvious, unplug everything else until your receiver is the only thing left.

Edit /etc/lirc/lircd.conf so that it looks like this:
Code:
include "/usr/share/lirc/remotes/devinput/lircd.conf.devinput"

Fire up lirc. Now when you run irw, you should see the output of each of your remotes, except they're all channeled as devinput.

Code:
/etc/rc_keymaps# irw
0000000080010069 00 KEY_LEFT devinput
0000000080010069 01 KEY_LEFT devinput
0000000080010069 00 KEY_LEFT devinput
000000008001006a 00 KEY_RIGHT devinput
000000008001006a 01 KEY_RIGHT devinput
0000000080010067 00 KEY_UP devinput
000000008001006c 00 KEY_DOWN devinput
0000000080010160 00 KEY_OK devinput
0000000080010160 00 KEY_OK devinput

8-n) From here on out, you're on your own. Read up on LIRC and lircmap.xml

Problems as of now: I literally have no clue WTF rc_maps.cfg does or how to use it. For some crazy reason if LIRC starts in init.d like it should, it won't work. I always have to restart it. So right now, my rc.local looks like this:
Code:
/etc/init.d/lirc stop
/usr/bin/ir-keytable -c
/usr/bin/ir-keytable -p NEC,RC6 -w /etc/rc_keymaps/rc6_mce
/usr/bin/ir-keytable -p NEC,RC6 -w /etc/rc_keymaps/yamaha_dvd
/usr/bin/ir-keytable -p NEC,RC6 -w /etc/rc_keymaps/samsung_stb
/etc/init.d/lirc start

All 3 of my remotes work on reboot, and that's better than they used to.
Code:
GRANT ALL PRIVILEGES ON `xbmc_%`.* TO 'xbmc'@'%';
IF you have a mysql problem, find one of the 4 dozen threads already open.
Reply


Messages In This Thread
ir-keytable or: How I Learned to Stop Worrying about the LIRC Kernel - by darkscout - 2011-05-10, 07:28
[No subject] - by darkscout - 2011-05-11, 02:37
[No subject] - by lukamus - 2011-06-09, 02:23
[No subject] - by darkscout - 2011-06-09, 04:22
[No subject] - by lukamus - 2011-06-09, 07:27
[No subject] - by bsp134 - 2011-06-09, 09:31
[No subject] - by lupick - 2011-06-09, 18:18
[No subject] - by darkscout - 2011-06-09, 18:36
[No subject] - by lukamus - 2011-06-10, 02:42
[No subject] - by tomolac - 2011-08-10, 19:39
[No subject] - by darkscout - 2011-08-10, 22:48
[No subject] - by tomolac - 2011-08-10, 22:53
[No subject] - by colinjones - 2011-08-13, 06:45
[No subject] - by colinjones - 2011-08-13, 08:50
[No subject] - by colinjones - 2011-08-15, 11:29
[No subject] - by colinjones - 2011-08-16, 05:13
[No subject] - by darkscout - 2011-08-16, 08:00
[No subject] - by colinjones - 2011-08-16, 08:05
[No subject] - by illumilore - 2011-11-09, 00:39
Logout Mark Read Team Forum Stats Members Help
ir-keytable or: How I Learned to Stop Worrying about the LIRC Kernel0