Today’s challenge - getting this gizmo to work with MythTV. It turned out to be quite a pain so I am documenting it here in case I need to do it again in the future. Note that I am running Ubuntu 7.04 (Feisty Fawn). The procedure may be slightly different for other platforms.
STEP 1 - Locate the device node for the remote
This remote has a very nifty USB receiver which presents itself to the PC as a HID keyboard. It is mapped to a device in /dev/input but we need to figure out which one. Type this command:
cat /proc/bus/input/devices
Now look for the TwinHan keyboard device. Beware, it also creates a mouse device which you do not want. The entry will look like this:
I: Bus=0003 Vendor=6253 Product=0100 Version=0110
N: Name="Twinhan Tech Remote Control"
P: Phys=usb-0000:00:11.2-1/input0
S: Sysfs=/class/input/input3
H: Handlers=kbd event3
B: EV=120003
B: KEY=800000 0 e0b0ffdf 1cfffff ffffffff fffffffe
B: LED=1f
Note the Sysfs entry. We will need this for the next step…
STEP 2 - Create a symlink to the device node
Even though we saw the remote was on /class/input/input3, It is not guaranteed to stay there. Next time you reboot it may be a different device so we need to create some method of referring to it which will work every time. We can use UDEV for this. Type this command (replacing inputX with the appropriate event device of course):
udevinfo -a -p /class/input/inputX
You will get lots of output. We are interested in the first {modalias} line.
looking at parent device '/class/input/input3':
KERNELS=="input3"
SUBSYSTEMS=="input"
DRIVERS==""
ATTRS{modalias}==”input:b0003v6253p0100e0110-e0,1,11,14,k74,75,77,7D,7E,7F,B7,raml0,1,2,3,4,sfw”
ATTRS{uniq}==”1111111″
ATTRS{phys}==”usb-0000:00:11.2-1/input0″
ATTRS{name}==”Twinhan Tech Remote Control”
Create a new file /etc/udev/rules.d/10-local.rules and paste that line into it so it looks like this (this is supposed to be all on one line BTW):
KERNEL=="event*",ATTRS{modalias}=="input:b0003v6253p0100e0110-e0,1,11,14,
k74,75,77,7D,7E,7F,B7,raml0,1,2,3,4,sfw",SYMLINK="input/irremote"
Then simply unplug the USB device and plug it back in again. You should now see a new device called /dev/input/irremote. We can test it by typing the following. You should see data arrive whenever you press a button on the remote. Press Ctrl-C when you are done testing.
hexdump -C /dev/input/irremote
STEP 3 - Configure LIRC
You need to set up /etc/lirc/hardware.conf and lircd.conf. Both of these files are located in /etc/lirc. To save you the trouble of working out all the settings, I have posted mine here:
hardware.conf
lircd.conf
Once you have these files in place, restart the lirc daemon with this command:
/etc/init.d/lirc restart
You can test that it is working by typing this:
irw
Now every time you press a key, you should see it printed on the screen. Press Ctrl-C when you are done.
STEP 4 - Configure MythTV commands
We are getting closer now. The next step is to set up a file called /home/mythtv/.mythtv/lircrc which contains the mappings between the keys on the remote and the functions in MythTV. Once again, I have already prepared this file which you can download here:
lircrc-mythtv
Rename this file to lircrc and move it to /home/mythtv/.mythtv/. Once that is done, restart MythTV. Here are the key mappings you will end up with:
| Key |
Function |
| REC |
Record |
| TELETEXT |
OSD |
| RECALL |
MENU |
| PREVIEW |
INFO |
| REW/FFWD |
Forward/backward in MythMusic |
| CAPTURE |
Previous playlist item in MythMusic |
| RECORDLIST |
Next playlist item in MythMusic |
STEP 5 - Configure MPlayer
The final step is to configure the mapping between the remote and the commands in MPlayer. Since MPlayer is a separate program, it needs to be configured separately to MythTV. To configure it, we need another lircrc file but this time is has to be called /home/mythtv/.lircrc. Download it from here:
lircrc-mplayer
Rename it to .lircrc and put it in /home/mythtv and that should be that! Here are the key mappings for MPlayer:
| Key |
Function |
| MUTE |
Mute |
| VOL+/- |
Adjust volume |
| CH+/- |
Skip fwd/back 60 seconds |
| REW/FFWD |
Skip fwd/back 10 seconds |
| PREVIEW |
Show/hide subtitles |
| TELETEXT |
Show/hide OSD |
| TAB |
Cycle through audio tracks |
If you do not like the key mappings I have chosen, you may edit the lircrc files. The format should be fairly easy to follow.