Myth TV remote control working

I’ve had an ATI Remote Wonder for years. Bought it whilst at Uni’ for my computer because I couldn’t be bothered to walk the three feet to the computer! I’ve known this has had a linux driver since I compiled the original before it was wound in to the kernel. I had it kicking about the house so wanted to get it working. I’ve read a lot about lirc and using that to set up the Remote Wonder. One drawback to using lirc that I think is unique to the Remote Wonder is that you can’t use the mouse functionality.

The Remote Wonder has a direction wheel and a left and right mouse button on the control. I want this because I may want to use catch up TV, which means running a web browser as well as Myth TV, and typing something in the search box, clicking on a ‘full screen’ button for the video means I need a pointer, and the Remote Wonder gives me that. What I’m then missing would be a keyboard. Happily, there is a Firefox plug in that does just that. I’ve managed to get them all configured and working, so below is how I did it. The only slight downer is the known issue around the TV, DVD, OK and Channel up/down buttons that do not work on Linux because the key codes are greater than 255. There is a patch to fix this I’ve not applied yet to evdev, I’ll update this blog when I’ve done that.

The ATI Remote Wonder is a USB based RF (radio) remote control. Plug it in and the ati_remote kernel module will be automagically loaded. Here’s how to figure out what’s working and get it configured.

Run the following in a terminal to get the right driver for X loaded, and so we can test what devices we have:-

sudo apt-get install evdev evtest

evdev will likely already be there. evtest allows you to see what devices you have attached, so go attach the USB bit now (you don’t need the control to have batteries just yet). Now run this to see if the remote wonder is detected:-

adam@theatre:~$ sudo evtest
[sudo] password for user: 
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Power Button
/dev/input/event1:      Power Button
/dev/input/event10:     HDA Intel Rear Mic
/dev/input/event11:     HDA Intel Front Headphone
/dev/input/event12:     HDA Intel Line-Out
/dev/input/event13:     HDA NVidia HDMI/DP,pcm=9
/dev/input/event14:     HDA NVidia HDMI/DP,pcm=8
/dev/input/event15:     HDA NVidia HDMI/DP,pcm=7
/dev/input/event16:     HDA NVidia HDMI/DP,pcm=3
/dev/input/event2:      X10 Wireless Technology Inc USB Receiver
/dev/input/event3:      X10 Wireless Technology Inc USB Receiver mouse
/dev/input/event4:      Microsoft  Microsoft Basic Optical Mouse v2.0 
/dev/input/event5:      em28xx IR (em28xx #0)
/dev/input/event6:      Lite-On Technology USB Productivity Option Keyboard( has the hub in # 1 )
/dev/input/event7:      Lite-On Technology USB Productivity Option Keyboard( has the hub in # 1 )
/dev/input/event8:      HDA Intel Line
/dev/input/event9:      HDA Intel Front Mic
Select the device event number [0-16]:

(Hit Ctrl+c to close the app at this point).

As you can see from the above the Remote Wonder is device /dev/input/event2 . We could configure X to use this but the problem is these event numbers tend to change on reboot, so you have to do something a little unique. Here’s my xorg.conf:-

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
#    InputDevice "Remote0" "SendCoreEvents"
    Option         "Xinerama" "0"

Section "Files"

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"

Section "InputClass"
    Identifier     "Remote0"
MatchProduct "X10 Wireless Techology Inc USB Receiver"
MatchDevicePath "/dev/input/event*"
    Driver         "evdev"
    Option         "event_key_remap" "402=112 403=117 377=156 389=157 352=36"

Section "InputClass"
   Identifier  "RemoteMouse0"
MatchProduct "X10 Wireless Techology Inc USB Receiver mouse"
MatchDevicePath "/dev/input/event*"
   Driver      "mouse"
   Option       "Protocol" "PS/2"
   Option       "SendCoreEvents"

... other stuff about monitors after this...

I’ve used InputClass instead of InputDevice. This means you don’t link to them in the ServerLayout, hence the commented out InputDevice highlighted above in that section. Using InputClass allows you to match by the device product name reported by evtest, and match anything in /dev/input starting with event, which means no matter what event number it gets loaded as this declaration will work.

I have the mouse declared too as a PS/2 mouse. I haven’t customised the mouse Options to simulate a three button mouse, and thus allow autoscrolling in Firefox, but I’ve not tested that yet. I’ll post back when I’ve tried it. For now though the above works great.

The Option event_key_remap line for the keyboard part of the remote is for the future, as yet untested by me, evdev alteration that allows remapping of key codes above 255 to lower key codes so that the X server can handle it.

Once the above is done you need to edit your ~/.Xmodmap so that the relevant keys are mapped to their Myth TV equivalents:-

keycode 164 = S
keycode 123 = F11
keycode 122 = F10
keycode 121 = F9
keycode 147 = M
keycode 104 = I
keycode 160 = F8
keycode 140 = W
keycode 176 = Left
keycode 208 = P
keycode 167 = Right
keycode 175 = R
keycode 136 = Escape
keycode 127 = P

I saved these files, rebooted the machine (sudo reboot) and lo the remote worked fine. Had a few typos originally which caused X not to load. I basically ran the following and you get some useful output to diagnose issues:-

tail -n 50 /var/log/Xorg.0.log

It should give you a line saying there’s an error on line 43 (or similar). From this it should be pretty clear what’s wrong. The error reporting is pretty good.

I then installed a plugin for Firefox called FxKeyboard. I then increased the default font size to 26 and used my normal mouse and keyboard (I’m lazy like that) to add all the catch up TV services, Lovefilm and Netflix sites as tabs to Firefox and pinned them as App Tabs. Then configured Firefox to open up previous tabs on startup. All these are simple options to find and configure in Edit > Preferences in Firefox.

Further information:-

Xorg mouse driver options (for 3 button emulation, etc.) –

evdev modified driver home – – WARNING: Use the following instead of git pull (you may need 2.7.0 for newest Ubuntu or X versions): git checkout -b code-remap-2.6.0 origin/code-remap-2.6.0

Home tech update…

Decided to take some time to revamp our HTPC (Home Theatre PC). Had Ubuntu 10.04 with XBMC on it. XBMC is a great idea but, like so many other things in free software these days, often doesn’t work out of the box. Updated Ubuntu and actually put a 64 bit build on the box (weirdly used a 32 bit image before – I think because I used the XBMC live CD to install) Decided not to bother with XBMC at all this time. We tend to use our TV and PC to either watch live TV or catch up TV, with the occassional Netflix/Lovefilm streamed movie. As it turns out XBMCs browser support sucks too. Decided to opt for just Myth TV on an Ubuntu box.

Myth TV is a great user interface, probably one of the best EPGs I’ve seen on any TV. I bought a PCTVSystems NanoStick DVB-T2 290e USB Freeview HD device which works out of the box with the latest Linux Kernel. This comes with a great mini antenna of its own, but also a normal aerial adapter. I was quite impressed with the reception of the antenna. Myth TV worked great with the backend (that records and received TV programmes) and the frontend (with the user interface and playback) on the same machine.

I hit a few annoying issues when running the frontend on a different machine. This is quite surprising when you think about it – a lot of the time these days you have multiple PCs and TVs in the house and if you don’t like being forced to sit through Coronation street it’s handy to relegate the missus to a different room! You would think Myth TV would support having remote Frontends out of the box. Unfortunately even though it configures 99% of the MySQL database backend it neglects the ability for the mythtv database account to connect remotely. Also, surprisingly, the mythtv db account fails locally when used from a transcoding perl script. This means logging in to MySQL as root and adding a ‘mythtv’@’*’ account and granting it all permissions on the mythconverg database. Plenty of websites with this on, just search for ‘MythTV database permission denied’.

Once those teething issues were sorted it worked well. Quite possibly the sexiest feature of Myth TV, and one that’s quite undersold in my opinion, is the ability for an Android phone to use the Mythmote application to act as a Myth TV specific remote control for a front end! Most people have their phones connected to their wifi at home, so this remote control app is a brilliant idea. It uses the local network rather than infrared to control a Myth Frontend. It also supports saving multiple front end locations, so the same app can control the living room (HTPC) frontend, my laptop frontend, or my mac mini front end. Great idea!

Also decided to set up the Myth Frontend for Mac. This was a massive, massive let down. Turns out the playback on Myth Frontend 0.25 on the mac has had hardware accelerated graphics disabled, meaning its nigh on impossible to watch any HD channels or HD recordings. This was done because the method Myth TV uses on the mac (DVADecoder) causes a kernel panic on interlaced playback. I logged a bug/feature request for them to use Qtkit instead for HD playback. This was immediately closed as invalid which bemused me. Their argument was that Qtkit wouldn’t give them a ‘Myth style playback’ i.e. pause/resume on live TV. My position is that HD playback without pause is better than no HD playback at all! They disagree. I managed to find a 32 bit build with DVA decoding enabled (at the moment even if you select it in the frontend, it will fallback to opengl!). This 32 bit build works great. A bit of an overreaction disabling all playback via DVA if sometimes it doesn’t work – you can always select a different playback option (and indeed DVA isn’t turned on by default anyway!) so their decision to do this is a bit bizarre.

I suspect a lot of the problem in linux born opensource projects is that the Mac is a second class citizen. A classic example of this is the way the bug closer responded to my bug. He said I should either install linux instead of Mac OS X or upgrade my hardware! Given I said I had a Macbook Pro and I use OS X because I don’t want to use Ubuntu (I use laptop for video editing), I found his reply utterly ridiculous. I’d expect better from a Windoze developer to be honest. It seems there is little appetite to work on Mac ports of mainstream software. If it ‘works on my machine’ they don’t particularly care about anyone else.

Managed to resurrect my Mac mini. This had a hard disk issue. Now got it set up with a new disc and Snow Leopard. I’ll use this to power the spare HD flat panel upstairs. I’m going to mount this on the wall between my two windows. I have a great view of the Peak District from the top floor here in my home office. I’ve often wondered if one very long window would be better, so am going to use the TV when not in use to displa the best HD photos of the peak district, and ones of myself and my fiancee climbing locally, so I always have a good weather picture to motivate me during the day.

Also looking at creating a live data feed set up for this screen. I’d like a mix of local (system, tv, network) and remote (stocks, news, email) alerts to show on it. Looking at using a web browser as the client. This would mean I can follow up on any news items from whichever computer I’m working on rather than be forced to use the mac. I want to keep the server side stuff to a minimum so am looking at node.js. Need to see if I can use that to access local system info, and mythtv (so mysql), as well as remote news feeds. Didn’t want to use a mix of programming languages as this would have meant at some point a complex mish mash of server side communication. Hopefully node.js has modules to do a lot of these facilities on the backend. I don’t need anything complicated really, just the ability to execute local commands (I can always write a script to do something) or fetch a remote URL.