Categories
Linux

Kworld PC160-2T remote control on Ubuntu Linux 11.10

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 Ubuntu doesn't have a keymap for it. You can see in the dmesg output that it loads the default rc-empty keymap:

[ 31.058541] Registered IR keymap rc-empty
[ 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
[ 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
[ 31.058716] dvb-usb: schedule remote query interval to 500 msecs.

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 this list (see also this one). I saved my keymap 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).

frankster@mythtv:/etc/rc_keymaps$ sudo ir-keytable -c -p NEC -w kworld_pc160-2t
Read kworld_pc160-2t table
Old keytable cleared
Wrote 30 keycode(s) to driver
Protocols changed to NEC

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.

frankster@mythtv:/etc/rc_keymaps$ sudo ir-keytable -t
Testing events. Please, press CTRL-C to abort.
1329667198.608627: event MSC: scancode = 866b00
1329667198.608631: event key down: KEY_NUMERIC_1 (0x0201)
1329667198.608632: event sync
1329667198.859974: event key up: KEY_NUMERIC_1 (0x0201)
1329667198.859975: event sync

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:

af9015 * /etc/rc_keymaps/kworld_pc160-2t

ir-keytable could then load the appropriate keytable.

sudo ir-keytable -a /etc/rc_maps.cfg 

This is the keymap I am currently using, I expect I will do some more tweaking as time goes on.

# table kworld_pc160-2t, type: NEC

0x866b1d KEY_POWER
#0x866b0x kworld log button - not sure what this does
#0x866b16 button between kworld button and power button

0x866b0a KEY_NUMERIC_0
0x866b00 KEY_NUMERIC_1
0x866b01 KEY_NUMERIC_2
0x866b02 KEY_NUMERIC_3
0x866b03 KEY_NUMERIC_4
0x866b04 KEY_NUMERIC_5
0x866b05 KEY_NUMERIC_6
0x866b06 KEY_NUMERIC_7
0x866b07 KEY_NUMERIC_8
0x866b08 KEY_NUMERIC_9

#0x866b09 some kind of reload symbol
0x866b14 KEY_MUTE

#0x866b1e small rectangle and big rectangle
#0x866b17 fullscreen?
0x866b1f KEY_HOME
0x866b0e KEY_BACK

0x866b20 KEY_UP
0x866b21 KEY_DOWN
0x866b42 KEY_LEFT
0x866b43 KEY_RIGHT
0x866b0b KEY_ENTER

0x866b10 KEY_CHANNELUP
0x866b11 KEY_CHANNELDOWN
0x866b12 KEY_VOLUMEDOWN
0x866b13 KEY_VOLUMEUP

#0x866b19 scheduled recording?
0x866b1b KEY_RECORD
0x866b4b KEY_EPG

0x866b1a KEY_STOP
0x866b44 KEY_PLAYPAUSE
0x866b40 KEY_BACK
0x866b41 KEY_FORWARD

#0x866b22 Tx button

#0x866b15 looks like some kind of transmit or infrared symbol
#0x866b0f widescreen?
#0x866b1c screenshot?
0x866b4a KEY_SLEEP

By ff

Systems software engineer with interests in C/C++/Rust on Linux, electronic music and games.

4 replies on “Kworld PC160-2T remote control on Ubuntu Linux 11.10”

Hi thanks for this tutorial, I have a similar card (called a Peak but actually a K-World), I can get responses from the evtest but am still struggling to have them converted into keyboard - am not sure if its to do with my other tuner interferring, any idea how I can make lirc chose the k-world?

on your missing keys, I looked at the total keylist from here and found these as possiblities, they could then be assigned as keys in mythtv via edit keys:

# table kworld_pc160-2t, type: NEC
#0x866b0x kworld log button - not sure what this does KEY_MENU 0x008B to jump to menu or main menu
#0x866b16 button between kworld button and power button KEY_BOOKMARKS 0x009C to set a book mark
#0x866b09 some kind of reload symbol KEY_RESTART 0x0198 to restart playback or toggle repeat modes, could also use KEY_SHUFFLE to toggle modes
#0x866b1e small rectangle and big rectangle
#0x866b17 fullscreen? KEY_SCREEN 0x0177 assign to screen modes, similar to w
#0x866b19 scheduled recording?
#0x866b22 Tx button KEY_TEXT 0x0184 to switch on text or subtitle
#0x866b15 looks like some kind of transmit or infrared symbol KEY_AUDIO 0x0188 assign to an audio toggle of choice
#0x866b0f widescreen?
#0x866b1c screenshot? KEY_CAMERA 0x00D4

it might also be worthwhile just to assign letters to the keys to correspond to the functions you want to use, ie if your aspect ratio is W on the keyboard just assign the button 2nd row from bottom 2nd from left W with
KEY_W 0x0011

any ideas for my problem welcome

I'm not quite sure how far you are getting. Do you see just the scancode but no KEY_xxx? or do you see both?

1329667198.608627: event MSC: scancode = 866b00
1329667198.608631: event key down: KEY_NUMERIC_1 (0x0201)
1329667198.608632: event sync

Its good that you can see stuff in evtest as that means you are 95% of the way there (i.e. the kernel driver is working) so the rest is just configuration.

Are you using ubuntu 11.10 as well? If you are, I had to tell lirc which remote I was using via dpkg-reconfigure lirc and I selected "linux input layer" as the remote driver, then it allowed me to select the appropiate devinput device for the remote.

frankie

Hi Frankie,

evtest gives me

Testing ... (interrupt to exit)
Event: time 1334165679.258603, type 4 (Misc), code 4 (ScanCode), value 866b00
Event: time 1334165679.258610, type 1 (Key), code 513 (Numeric 1), value 1
Event: time 1334165679.258613, -------------- Report Sync ------------
Event: time 1334165679.508675, type 1 (Key), code 513 (Numeric 1), value 0
Event: time 1334165679.508679, -------------- Report Sync ------------
Event: time 1334165680.758582, type 4 (Misc), code 4 (ScanCode), value 866b01
Event: time 1334165680.758590, type 1 (Key), code 514 (Numeric 2), value 1
Event: time 1334165680.758593, -------------- Report Sync ------------
Event: time 1334165681.008674, type 1 (Key), code 514 (Numeric 2), value 0
Event: time 1334165681.008678, -------------- Report Sync ------------
Event: time 1334165681.257667, type 4 (Misc), code 4 (ScanCode), value 866b01
Event: time 1334165681.257674, type 1 (Key), code 514 (Numeric 2), value 1
Event: time 1334165681.257677, -------------- Report Sync ------------
Event: time 1334165681.508712, type 1 (Key), code 514 (Numeric 2), value 0
Event: time 1334165681.508715, -------------- Report Sync ------------
Event: time 1334165684.778597, type 4 (Misc), code 4 (ScanCode), value 866b02
Event: time 1334165684.778604, type 1 (Key), code 515 (Numeric 3), value 1
Event: time 1334165684.778607, -------------- Report Sync ------------
Event: time 1334165685.028677, type 1 (Key), code 515 (Numeric 3), value 0
Event: time 1334165685.028680, -------------- Report Sync ------------
Event: time 1334165685.277354, type 4 (Misc), code 4 (ScanCode), value 866b02
Event: time 1334165685.277362, type 1 (Key), code 515 (Numeric 3), value 1
Event: time 1334165685.277365, -------------- Report Sync ------------
Event: time 1334165685.528675, type 1 (Key), code 515 (Numeric 3), value 0
Event: time 1334165685.528679, -------------- Report Sync ------------

for the first few number keys but I am stuck after that.... will keep trying...
could you post your hardware.conf and lirc.conf as well ? or pastebin them?
thx

Leave a Reply to frankster Cancel reply

Your email address will not be published. Required fields are marked *