ATI Remote Wonder II
One common remote used for controlling MythTV is the ATI Remote Wonder II. Highly popular for Windows and MacOS machines, the RWII is also supported under linux by the ati_remote2 kernel module or by using the LIRC project. Here is a short guide for getting it configured with MythTV.
MythTV, ATI Remote Wonder II and Kernel Keymap Modification
Starting with Linux 2.6.28 the ati_remote2 v0.3 kernel module supports kernel scancode-to-keycode mapping modification. This functionality allows the keycodes generated by the ati_remote2 kernel module for a given button on the remote control to be modified. This is useful because by default a number of the keycodes generated by the ati_remote2 kernel module have values greater than 255, which when combined with the limitation of the X windows system being unable to handle keycodes with such values, results in the offending buttons on the remote being unusable within MythTV.
Modifying the kernel scancode-to-keycode mapping for any buttons with keycode values greater than 255 to give them values less than 255 makes these buttons usable within X and consequently within MythTV.
The simplest way to modify the kernel scancode-to-keycode mapping is to use the "setkeycodes" program. This program accepts pairs of command line parameters consisting of a scancode, in hexadecimal, and a keycode, in decimal. The scancode is the code generated by the hardware, the keycode is the code generated in software by the kernel module in response and sent to the rest of the system. A table of scancodes for the ATI Remote Wonder II can be obtained from Appendix C. A table of keycodes can be obtained from Appendix D.
The ATI Remote Wonder II can operate in one of five modes, AUX1, AUX2, AUX3, AUX4, and PC. Each button generates a different scancode for each of the five modes. Therefore, each button can be configured to generate a different keycode for each of the five modes if so desired. The scancodes consist of two bytes, the upper byte is the index of the mode, the lower byte is the button's code.
So, for example, if we wished to map the "OK" button (0x5C) in PC mode (0x04), which has a default keycode of KEY_OK (352), to be KEY_ENTER (28) we would use:
setkeycodes 0x045C 28
If we didn't want to worry about which mode (AUX1 (0x00), AUX2 (0x01), AUX3 (0x02), AUX4 (0x03), or PC (0x04)) the remote was in when we used it, we could use:
setkeycodes 0x005C 28 0x015C 28 0x025C 28 0x035C 28 0x045C 28
MythTV, ATI Remote Wonder II and xmodmap
Update 23rd Jan 2007: By way of the module ati_remote2 the ATI Remote Wonder is now natively supported under newer linux kernels (I'm using 2.6.17). So by using modprobe ati_remote2 and then using the command xev and xmodmap LIRC is no longer needed in order to use the RWII.
Refer this page for help to configure ATI Remote Wonder II to watch MythTV Frontend using xmodmap.
LIRC, MythTV, and the ATI Remote Wonder II
Please note that this is not highly-detailed, may contain mistakes, and assumes little knowledge of your particular linux distro. The differences should be minor, if any, but for frame of reference I am using Slack10. If you spot mistakes or think you can make this guide more clear, please feel free to edit it.
Note: I have found the RWII receiver to be somewhat temperamental. If you plug it in after the computer has booted and then push a button, the internal LED ceases to flash and receive input. Unplug and re-plug it in, push buttons on your remote again, and the LED should flash normally. If the receiver is plugged in at boot it doesn't seem to be a problem.
Before we even install lirc, we're going to get a config file for MythTV to use your remote properly. This will aid you later if you need to generate a new configuration file. See Appendix A for a configuration file based on the one available here. Feel free to modify it to suit your needs once it's working. The text goes in
~/.mythtv/lircrc, with ~ being the home directory of the user that starts mythfrontend (probably your user or the mythtv user). If you have a different remote then you might want to see if there are any /Lircrc Files for it.
Note: The buttons are set up as I thought they make sense. If you would like to change it, find the button you want next to a "button" line, and change the key under "config" below. Another note, the mouse on it (big circular direction pad) can be finnicky. If it is too slow, or too fast, adjust the "repeat" setting under the locations "mouse_cursor_left", "mouse_cursor_right", and so on. A higher repeat will cause lirc to ignore more repeats, and a lower repeat number will let more repeats through (lirc will pass on one key press per however many repeats are specified).
Next, you'll need to install LIRC. The latest official release of LIRC as of this writing is 0.70 and I don't believe it will work properly with all models of the RWII. If there is a later official release, get it, or get the latest from CVS. You can do this via CVS snapshots or straight from CVS.
Follow the instructions in the INSTALL document, which should be something like
./configure make sudo make install
You may wish to do
./configure --help first to see what options are available. The defaults should be ok. After it's installed, modprobe the ATI driver to load it with
modprobe lirc_atiusb (remember you'll need to be root). You can make sure LIRC detected the USB receiver by searching
dmesg for lines similar to (
dmesg | grep lirc):
lirc_dev: IR Remote Control driver registered, at major 61 lirc_atiusb: USB remote driver for LIRC v0.4 lirc_atiusb: Paul Miller <firstname.lastname@example.org> usb.c: registered new driver lirc_atiusb lirc_dev: lirc_register_plugin:sample_rate: 0 lirc_atiusb: on usb2:5
ls -l /dev/ | grep lirc and see if the devices have been created. If nothing displays or
dmesg doesn't indicate LIRC loaded, try rebooting. If /dev/lirc displays (among others) but /dev/lirc0 does not, I recommend you create a link called lirc0 to lirc as I seemed to have problems before doing this. However, I could be off-base on that one. You can create the link with
ln -s /dev/lirc /dev/lirc0 .
Next, you can either try using the RWII LIRC config files that come with LIRC, use the one provided below, or create your own. The one below should work, and can save you the trouble of naming all your buttons. I had to create my own but your milage may vary. To find out if we need to create one, do the following:
Start the LIRC daemon by issuing the following command (as root):
lircd -d /dev/lirc0 /path/to/config.conf
Optionally you may pass --debug after the config file path if it doesn't seem to be starting right. Normal output will be:
lircd 0.7.1-CVS: started server socket lircd 0.7.1-CVS: parsing remote lircd 0.7.1-CVS: parsing /root/ati2_full.conf remote lircd 0.7.1-CVS: config file read
Note the "parsing ..." line will output the name of the read configuration name, not the physical file path! Also, if the daemon has an error reading your configuration file, it will start anyway and you'll need to kill it before you can restart it with a correct config file.
irw and start pushing buttons. If nothing displays, you'll need to generate a new configuration file. If you get an error about being unable to connect to socket, your daemon didn't start or isn't started properly (possibly an invalid device or configuration path).
Note if you use the config files below, make sure the button names are the same in both files.
Creating a New Configuration File
To create a new configuration file, you'll probably want to kill the daemon first although I don't think it's required. As root,
killall lircd . Then run irrecord with a path to the new configuration file as the parameter, like:
Follow the instructions and note that when naming the control buttons, you'll want to name them to match up with what MythTV needs to process. These button names are located in the
~/.mythtv/lircrc file we created at the very beginning. For each "begin...end" entry, the "button" line is what MythTV is looking for from LIRC. For example, name your stop button "stop", channel up/down "ch+" and "ch-". You can always edit either of the config files to match, so don't feel pressure to get it exact right now. In fact, irrecord will time-out if you don't give it input in 10 seconds, so it's best to get the config file created first and then match up button names later.
Now that your new configuration file is created load the daemon again as you did above, this time with the config path pointing to the new one. Load irw and push buttons. You should see output now. If you don't see output here, go back and try to find the problem as continuing through this guide will not help you. See For Additional Help if you get stuck.
Building LIRC Support into MythTV
If that's working well, only one more step is required for full MythTV integration. If you didn't already compile MythTV will LIRC support, you'll need to do so now.
For Additional Help
For additional help, check the MythTV documentation, the LIRC documentation, the #mythtv-users IRC channel on irc.freenode.net, and the LIRC dev mailing list.
Starting LIRC Daemon on Boot
Optionally, to start the LIRC daemon on boot, I have the following line in my rc.local file:
/usr/local/sbin/lircd -d /dev/lirc0 /etc/ati2_full.conf ;
That's it! Good luck!
Appendix A - MythTV lircrc
# config file for # the ATI-Wonder Remote # using lirc_atiusb driver # begin prog = mythtv button = a config = E repeat = 5 end begin prog = mythtv button = b config = O repeat = 5 end begin prog = mythtv button = tv config = Key Alt-T [[Current Window]] repeat = 5 end begin prog = mythtv button = stop config = Esc repeat = 5 end begin prog = mythtv button = fastforward config = Right repeat = 5 end begin prog = mythtv button = rewind config = Left repeat = 5 end begin prog = mythtv button = pip config = V repeat = 5 end begin prog = mythtv button = pause config = P repeat = 5 end begin prog = mythtv button = play config = P repeat = 5 end begin prog = mythtv button = mute config = | repeat = 5 end begin prog = mythtv button = vol_down config = F10 repeat = 5 end begin prog = mythtv button = vol_up config = F11 repeat = 5 end begin prog = mythtv button = f config = [[Pg Down]] repeat = 5 end begin prog = mythtv button = d config = [[Pg Up]] repeat = 5 end begin prog = mythtv button = c config = F4 repeat = 5 end begin prog = mythtv button = e config = Esc repeat = 5 end begin prog = mythtv button = arrow_right config = Right repeat = 5 end begin prog = mythtv button = mouse_cursor_right config = Right repeat = 10 end begin prog = mythtv button = arrow_left config = Left repeat = 5 end begin prog = mythtv button = mouse_cursor_left config = Left repeat = 10 end begin prog = mythtv button = arrow_up config = Up repeat = 5 end begin prog = mythtv button = mouse_cursor_up config = Up repeat = 10 end begin prog = mythtv button = arrow_down config = Down repeat = 5 end begin prog = mythtv button = mouse_cursor_down config = Down repeat = 10 end begin prog = mythtv button = ch_up config = Up repeat = 5 end begin prog = mythtv button = ch_down config = Down repeat = 5 end begin prog = mythtv button = rewind config = Left repeat = 5 end begin prog = mythtv button = ok config = Return repeat = 5 end begin prog = mythtv button = 1 config = 1 repeat = 5 end begin prog = mythtv button = 2 config = 2 repeat = 5 end begin prog = mythtv button = 3 config = 3 repeat = 5 end begin prog = mythtv button = 4 config = 4 repeat = 5 end begin prog = mythtv button = 5 config = 5 repeat = 5 end begin prog = mythtv button = 6 config = 6 repeat = 5 end begin prog = mythtv button = 7 config = 7 repeat = 5 end begin prog = mythtv button = 8 config = 8 repeat = 5 end begin prog = mythtv button = 9 config = 9 repeat = 5 end begin prog = mythtv button = 0 config = 0 repeat = 5 end begin prog = mythtv button = info config = I repeat = 5 end begin prog = mythtv button = rec config = R repeat = 5 end begin prog = mythtv button = check config = Enter repeat = 5 end begin prog = mythtv button = mouse_left_btn config = Enter repeat = 5 end begin prog = mythtv button = mouse_right_btn config = Esc repeat = 5 end begin prog = mythtv button = list config = M repeat = 5 end begin prog = mythtv button = info config = I repeat = 5 end begin prog = mythtv button = power config = Esc repeat = 5 end begin prog = mythtv button = resize config = W repeat = 5 end
Appendix B - A Sample remote configuration file. /etc/lircd.conf
# this config file was automatically generated # using lirc-0.7.0(atiusb) on Sat Feb 12 13:22:29 2005 # # contributed by Steffen # # brand: ATI Sapphire Remote Bob II USB # model no. of remote control: 5000024400 # devices being controlled by this remote: MythTV # begin remote name 5000024400 bits 16 eps 30 aeps 100 one 0 0 zero 0 0 pre_data_bits 8 pre_data 0x0 post_data_bits 16 post_data 0x0 gap 299851 toggle_bit 0 begin codes aux1 0x023F aux2 0x023F aux3 0x023F aux4 0x023F mouse_left_btn 0x02A9 mouse_right_btn 0x02AA a 0x0278 b 0x0279 power 0x020C dvd 0x0238 tv 0x0239 help 0x02BE pc 0x023F resize 0x02D5 hand 0x02D0 ati 0x028E vol_up 0x0210 vol_down 0x0211 mute 0x020D ch_up 0x0220 ch_down 0x0221 mouse_cursor_up 0x01FF mouse_cursor_down 0x02FF mouse_cursor_left 0x20FF mouse_cursor_right 0x10FF mouse_cursor_upleft 0x21FF mouse_cursor_upright 0x11FF mouse_cursor_downleft 0x22FF mouse_cursor_downright 0x12FF 1 0x0201 2 0x0202 3 0x0203 4 0x0204 5 0x0205 6 0x0206 7 0x0207 8 0x0208 9 0x0209 0 0x0200 list 0x0254 check 0x0282 info 0x02F9 timer 0x0296 arrow_up 0x0258 arrow_left 0x025A arrow_right 0x025B arrow_down 0x0259 ok 0x025C c 0x027A d 0x027B play 0x022C e 0x027C f 0x027D rewind 0x0229 rec 0x0237 stop 0x0231 pause 0x0230 ffwd 0x0228 end codes end remote
Appendix C - ati_remote2 scancodes
From Linux kernel sources "drivers/input/misc/ati_remote2.c"
|Scancode upper byte||Remote mode|
|Scancode lower byte||Keycode (decimal value)|
Appendix D - keycodes < 255
From Linux kernel sources "include/linux/input.h"
|Keycode (decimal value)|
Appendix E - ati_remote2 keycode configuration
Settings for modifying the key actions for the ati_remote2 kernel driver to common MythTV frontend keys. The remote has 4 modes, and the below configuration sets the keys identically for all 4 modes.
# ATI Key -> F11; Ubuntu's keyboard settings allow a keycode to be mapped to an executable. # I mapped F11 to a shell script to start mfe. setkeycodes 0x008e 87 0x018e 87 0x028e 87 0x038e 87 0x048e 87 # OK -> Enter setkeycodes 0x005C 28 0x015C 28 0x025C 28 0x035C 28 0x045C 28 # i (info) -> i setkeycodes 0x00f9 23 0x01f9 23 0x02f9 23 0x03f9 23 0x04f9 23 # clock (coffee) -> Escape setkeycodes 0x0096 1 0x0196 1 0x0296 1 0x0396 1 0x0496 1 # Pause -> p setkeycodes 0x0030 25 0x0130 25 0x0230 25 0x0330 25 0x0430 25 # Play -> p setkeycodes 0x002c 25 0x012c 25 0x022c 25 0x032c 25 0x042c 25 # Stop -> Space setkeycodes 0x0031 57 0x0131 57 0x0231 57 0x0331 57 0x0431 57 # Menu -> m setkeycodes 0x0054 50 0x0154 50 0x0254 50 0x0354 50 0x0454 50 # Check (Enter?) -> i setkeycodes 0x0082 23 0x0182 23 0x0282 23 0x0382 23 0x0482 23 # FF -> RightArrow setkeycodes 0x0028 106 0x0128 106 0x0228 106 0x0328 106 0x0428 106 # REW -> LeftArrow setkeycodes 0x0029 105 0x0129 105 0x0229 105 0x0329 105 0x0429 105 # Rec -> r setkeycodes 0x0037 19 0x0137 19 0x0237 19 0x0337 19 0x0437 19