{"id":105,"date":"2012-02-19T23:01:13","date_gmt":"2012-02-19T23:01:13","guid":{"rendered":"http:\/\/francisfisher.me.uk\/problem\/?p=105"},"modified":"2012-07-30T17:18:38","modified_gmt":"2012-07-30T17:18:38","slug":"kworld-pc160-2t-remote-control-on-ubuntu-linux-11-10-2","status":"publish","type":"post","link":"https:\/\/francisfisher.me.uk\/problem\/2012\/kworld-pc160-2t-remote-control-on-ubuntu-linux-11-10-2\/","title":{"rendered":"Kworld PC160-2T remote control on Ubuntu Linux 11.10"},"content":{"rendered":"<p>I recently bought a dual tuner card for my Mythtv box (and I discussed getting it working with mythtv <a title=\"Using the KWorld PC160-2T with mythtv on Ubuntu Linux 11.10\" href=\"http:\/\/francisfisher.me.uk\/problem\/2012\/using-the-kworld-pc160-2t-with-mythtv-on-ubuntu-linux-11-10\/\">here<\/a>). The good news is that the IR receiver on the card is detected by the driver, however the bad news is that the remote does not work out of the box with Ubuntu 11.10 because Ubuntu doesn't have a keymap for it. You can see in the dmesg output that it loads the default rc-empty keymap:<\/p>\n<pre>[ 31.058541] Registered IR keymap rc-empty\r\n[ 31.058604] input: IR-receiver inside an USB DVB receiver as \/devices\/pci0000:00\/0000:00:1e.0\/0000:05:01.2\/usb3\/3-1\/rc\/rc0\/input4\r\n[ 31.058713] rc0: IR-receiver inside an USB DVB receiver as \/devices\/pci0000:00\/0000:00:1e.0\/0000:05:01.2\/usb3\/3-1\/rc\/rc0\r\n[ 31.058716] dvb-usb: schedule remote query interval to 500 msecs.<\/pre>\n<p>So I sorted it out by creating my own keymap - its still a bit of a work in progress as I have no idea what functions some of the pictures on the buttons represent! To create the keymap, I used the programme evtest to capture the scancodes generated by the remote. I then added the scancode to a file and mapped it to a sensible looking event which I chose from <a href=\"http:\/\/linuxtv.org\/wiki\/index.php\/Remote_Controllers\">this list<\/a> (see also <a href=\"http:\/\/xbmc.exstatic.org\/ir_keys.txt\">this one<\/a>). I saved <a href=\"http:\/\/francisfisher.me.uk\/problem\/wp-content\/uploads\/2012\/02\/kworld_pc160-2t.txt\">my keymap<\/a> in the \/etc\/rc_keymaps directory and inserted it (I first closed mythtv and switched out of X to a terminal with ctrl-alt-F2 to ensure that no application had the event device open).<\/p>\n<pre>frankster@mythtv:\/etc\/rc_keymaps$ sudo ir-keytable -c -p NEC -w kworld_pc160-2t\r\nRead kworld_pc160-2t table\r\nOld keytable cleared\r\nWrote 30 keycode(s) to driver\r\nProtocols changed to NEC\r\n<\/pre>\n<p>I then verified my keymap was working with ir-keytable. Now we receive as well as the scancode, a key up and down event every time a button is pressed.<\/p>\n<pre>frankster@mythtv:\/etc\/rc_keymaps$ sudo ir-keytable -t\r\nTesting events. Please, press CTRL-C to abort.\r\n1329667198.608627: event MSC: scancode = 866b00\r\n1329667198.608631: event key down: KEY_NUMERIC_1 (0x0201)\r\n1329667198.608632: event sync\r\n1329667198.859974: event key up: KEY_NUMERIC_1 (0x0201)\r\n1329667198.859975: event sync\r\n<\/pre>\n<p>Its all very well being able to manually install the keymap, but we need to make this a bit more permanent. I am currently preparing a kernel patch so that this remote control can be handled automatically, but for now we can achieve the same effect in userspace. I added to \/etc\/rc_maps.cfg the following line:<\/p>\n<pre>af9015 * \/etc\/rc_keymaps\/kworld_pc160-2t<\/pre>\n<p>ir-keytable could then load the appropriate keytable.<\/p>\n<pre>sudo ir-keytable -a \/etc\/rc_maps.cfg <\/pre>\n<p><a href=\"http:\/\/francisfisher.me.uk\/problem\/wp-content\/uploads\/2012\/02\/kworld_pc160-2t.txt\">This is the keymap I am currently using<\/a>, I expect I will do some more tweaking as time goes on.<\/p>\n<pre># table kworld_pc160-2t, type: NEC\r\n\r\n0x866b1d KEY_POWER\r\n#0x866b0x kworld log button - not sure what this does\r\n#0x866b16 button between kworld button and power button\r\n\r\n0x866b0a KEY_NUMERIC_0\r\n0x866b00 KEY_NUMERIC_1\r\n0x866b01 KEY_NUMERIC_2\r\n0x866b02 KEY_NUMERIC_3\r\n0x866b03 KEY_NUMERIC_4\r\n0x866b04 KEY_NUMERIC_5\r\n0x866b05 KEY_NUMERIC_6\r\n0x866b06 KEY_NUMERIC_7\r\n0x866b07 KEY_NUMERIC_8\r\n0x866b08 KEY_NUMERIC_9\r\n\r\n#0x866b09 some kind of reload symbol\r\n0x866b14 KEY_MUTE\r\n\r\n#0x866b1e small rectangle and big rectangle\r\n#0x866b17 fullscreen?\r\n0x866b1f KEY_HOME\r\n0x866b0e KEY_BACK\r\n\r\n0x866b20 KEY_UP\r\n0x866b21 KEY_DOWN\r\n0x866b42 KEY_LEFT\r\n0x866b43 KEY_RIGHT\r\n0x866b0b KEY_ENTER\r\n\r\n0x866b10 KEY_CHANNELUP\r\n0x866b11 KEY_CHANNELDOWN\r\n0x866b12 KEY_VOLUMEDOWN\r\n0x866b13 KEY_VOLUMEUP\r\n\r\n#0x866b19 scheduled recording?\r\n0x866b1b KEY_RECORD\r\n0x866b4b KEY_EPG\r\n\r\n0x866b1a KEY_STOP\r\n0x866b44 KEY_PLAYPAUSE\r\n0x866b40 KEY_BACK\r\n0x866b41 KEY_FORWARD\r\n\r\n#0x866b22 Tx button\r\n\r\n#0x866b15 looks like some kind of transmit or infrared symbol\r\n#0x866b0f widescreen?\r\n#0x866b1c screenshot?\r\n0x866b4a KEY_SLEEP\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I recently bought a dual tuner card for my Mythtv box (and I discussed getting it working with mythtv here). The good news is that the IR receiver on the card is detected by the driver, however the bad news is that the remote does not work out of the box with Ubuntu 11.10 because [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts\/105"}],"collection":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/comments?post=105"}],"version-history":[{"count":15,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts\/105\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts\/105\/revisions\/124"}],"wp:attachment":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/media?parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/categories?post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/tags?post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}