ir-keytable or: How I Learned to Stop Worrying about the LIRC Kernel - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111) +---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52) +---- Thread: ir-keytable or: How I Learned to Stop Worrying about the LIRC Kernel (/showthread.php?tid=101151) |
ir-keytable or: How I Learned to Stop Worrying about the LIRC Kernel - darkscout - 2011-05-10 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 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 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 The first line of the file, best I can figure, MUST look like this: Code: ==> rc6_mce <== 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 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 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 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 All 3 of my remotes work on reboot, and that's better than they used to. - darkscout - 2011-05-11 No bug here. Just me being special. Carry. on. - lukamus - 2011-06-09 Thank you! I've been scratching my head trying to understand how the change fom the external LIRC module to in-kernel LIRC driver works, and how I could get my remotes working without relying on LIRC. In my trials I found a couple of things. I think the in-kernel LIRC reads the standard hardware.conf, which specifies devinput as the driver amongst other things. It then turns the scancodes from the remote into keycodes using the ir-keytable mapping. I think these are passed as actual keystrokes so Lircmap.xml and remote.xml never factor into it and I keyboard.xml does the translation. I think this because none of the changes I was making to Lircmap.xml were having any effect. So I turned on key logging in XBMC, assigned a standard key (M) to a button on my remote using ir-keytable, then pressed it and the M key on my keyboadr. Both show up in the log just the same. The upshot is that you can assign any KEY_NAME to any button and as long as it's key code is less than 255 it'll work in XBMC. No more futzing around with xml files. I've now uninstalled Lirc and everything still works just fine. Caveat: I'm new to XBMC and LIRC, so my conclusions could be very wrong, but I don't think they are - darkscout - 2011-06-09 "In Kernel" LIRC reads nothing. It just "is" It's like a keyboard. hardware.conf tells the standalone lirc program that it should be looking at devinput instead of one of the normal kernel. And do you have a real deal MCE remote? Because it sounds like you have a fax knockoff where the remote actually does show up like a keyboard and just sends key presses. - lukamus - 2011-06-09 Fair enough. So I should be able to delete hardware.conf and lircd.conf? I've actually got two remotes. One's a Harmony 525 set to emulate an MCE remote, the other is a cheap knock off I bought for the receiver. It's branded HP but shows up as a Fintek (lsusb). Both remotes behave the same. Is there anyway to tell if the remote is being treated as a keyboard? - bsp134 - 2011-06-09 In xbmc_dharma_10 ( Ubuntu) in the xbmc.log was key id: Code: SDLKeyboard: scancode: 123, sym: 0, unicode: 0, modifier: 0 Code: SDLKeyboard: scancode: 1a, sym: 0065, unicode: 0005, modifier: 40 How do I edit keyboard.xml in xbmc_eden on key id? I was looking for an answer here https://github.com/xbmc/xbmc/tree/master/xbmc/input, but did not find - lupick - 2011-06-09 Are you able to have lirc working if you suspend the pc and resume it? thnak you L. - darkscout - 2011-06-09 lupick: yep, problems after resume. I just tested it. Tried dumping the kernel modules and reloading them, everything. Probably just another bug from the merge. bsp134: They're just dumped in hex now. Why they didn't prefix it with 0x you'll have to ask the devs. - lukamus - 2011-06-10 lupick: My remotes work after suspend/resume using the in kernel LIRC. - tomolac - 2011-08-10 Code: ir-keytable its the xbox DVD remote btw, I hate that every single update of ubuntu breaks everything just to add some new stuff that's not needed but what ya gonu do :/ - darkscout - 2011-08-10 What does lsusb do? Because right now it doesn't think it has an RC remote connected. - tomolac - 2011-08-10 well I reconfigured the ati module with "#undef LIRC_HAVE_KFIFO" to get it working, I tried running lsusb before but it crashed and I didn't try it again. but now its showing; Code: Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub - colinjones - 2011-08-13 I'm stuck on programming the keycodes... I have copied the file to /etc/rc_keymaps/rc6_mce, used ir-keytable -r to see the existing keycodes, -c to clear them, -r to confirm they are now cleared. Then the -p command to program the new codes from the file above. It says "wrote 61 keycode(s) to driver... protocols changed to RC-6" and so on, but now when I use -r the only entry in the table is: scancode 0x7fffff = KEY_PLAYPAUSE (0xa4) And that isn't even in the file! But judging by the hex value, it just isn't working in the first place.... Any thoughts? I've tried it multiple times with the same result. Reboot gives me back the original keycode table, then I go through the process again, with the same result. I have tried using the original file without modifications, and with the # table rc6_mce, type: RC6 line at the top... same deal... UPDATE: hmmm I use the -v verbose option when updating the keycode table and this results. Initially it looks as though it is parsing it correctly, then at the end it appears to be writing all the codes to the same scancode, which is presumably why I'm only left with a single entry! Any thoughts? UPDATE2: it seems that the maximum scancode it accepts is 7fffff! When I set a pair manually using the -k option, below 80000000 it works fine... but the standard codes for rc6 are all well over 80000000 ... now I'm really confused! UPDATE3: OK, ir-keymaps has a bug in it - build new version from these instructions http://2cheeseburgers.blogspot.com/2010/11/imon-with-mce-remote-under-maverick.html then it allows codes higher than 7ffffff ... Code: xbmc@xbmc:~$ sudo ir-keytable -v -p RC6 -w /etc/rc_keymaps/rc6_mce - colinjones - 2011-08-13 ...ok next problem! I've got through all the config up to testing using irw - but none of the keys do anything when I run irw. ir-keytable -t shows me the scan codes and the correctly mapped keycodes. as soon as I start lirc, ir-keytables stops reporting anything. Lirc starts fine it seems, but then irw doesn't report anything at all when I press buttons on the remote. As soon as I stop lirc, ir-keytable starts working again. I have the devinput settings in both the lirc config files. if I cat /dev/input/by-id .... it generates junk characters whilst lirc isn't running, and nothing when it is running... for some reason it seems that lirc just isn't connected to that device properly, but enough to cut off anything else from using it! I'm not clear on whether I am using the built in lirc stuff new to Natty or not... I just apt-get installed lirc Can anyone help? - colinjones - 2011-08-15 bump! Can anyone help me?? (mum and dad want their media centre back ) |