Windows MCE remote in Ubuntu

This will go through configuring MythTV with a MCE Remote

Setup the key bindings

You can view the existing keys by using the xev command. However as GNOME might be stealing the command it is safer to do this in a console.

  • CTRL+ALT+F1 – 1st console
  • CTRL+ALT+F8 – Return to Gnome

Here we will press the STOP button on the remote. It gives the keycode of 174, and name of XF86AudioStop.
Note, we had to go into Keyboard Shortcuts in GNOME and disable (using the backspace key) the Audio Stop command

xev
...
KeyPress event, serial 34, synthetic NO, window 0x5a00001,
root 0x15a, subw 0x0, time 86872802, (182,70), root:(183,931),
state 0x10, keycode 174 (keysym 0x1008ff15, XF86AudioStop), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
...

To get the mouse buttons (information maps to right click) and the keys with CTRL+SHIFT to work we need to use xbindkeys. For the mouse to map a key press you need to use xte.

sudo apt-get install -y xbindkeys xautomation

To setup a sample xbindkeys config file (though you may need to comment out some commands)

xbindkeys --defaults > $HOME/.xbindkeysrc

Now setup the right click to map to “i” for information

sudo vi ~/.xbindkeysrc
# i_from_right_click
"xte 'keydown i' 'keyup i'"
b:3

Now you need to just start xbindkeys before starting myth, and kill it afterwards. To do this just write a custom script to launch mythtv

touch /mnt/apps/bin/mythtv_with_xbindkeys.sh
chmod +x /mnt/apps/bin/mythtv_with_xbindkeys.sh
vi /mnt/apps/bin/mythtv_with_xbindkeys.sh
#!/bin/bash
# mythtvstart.sh
# loads mouse support for mythtv.
killall mythfrontend
killall xbindkeys
xbindkeys
mythfrontend
sleep 5
killall xbindkeys
killall mythfrontend

Keys Mappings

Note that CTRL+SHIFT is the same as CTRL (the shift gets dropped)

Button Keycode Actual Key MythTV Command
Web 180 XF86HomePage Start MythTV
Sleep 150 XF86Sleep (Starts screensaver, configured in Ubuntu)
My TV 28 CTRL-SHIFT-T (F3 through xte) TV Recording Playback (SHIFT Ignored)
My Music 58 CTRL-M Play music
My Pictures 31 CTRL-I MythGallery
My Videos 26 CTRL-E Delete
Record TV 32 CTRL-O Manage Recordings
Guide 42 CTRL-G Program Guide
Live TV 28 CTRL-T Live TV
DVD Menu 58 CTRL-SHIFT-M (F4 through xte) Myth Video
Play 172 XF86AudioPlay Pause (Media Play)
Pause 172 XF86AudioPlay Pause (Media Play)
Reverse 56 CTRL-SHIFT-B Nothing, Something wierd is being sent for these
Forward 41 CTRL-SHIFT-F Nothing, Something wierd is being sent for these
Pre-track 173 XF86AudioPrev (Media Previous)
Next track 171 XF86AudioNext (Media Next)
Stop 174 XF86AudioStop Escape (Media Stop)
Record 27 CTRL-R TOGGLERECORD
Back 22 Backspace Backspace
Information Mouse Right click INFO (“i” through xbindkeys/xte)
Up 111 Up UP
Down 116 Down DOWN
Left 113 Left LEFT
Right 114 Right RIGHT
OK 36 Enter SELECT
Volume Up ??
Volume Down ??
Mute ??
Channel Up 112
Channel Down 117
Start 36
1 77 1 1
2 88 2 2
3 89 3 3
4 83 4 4
5 84 5 5
6 85 6 6
7 79 7 7
8 80 8 8
9 81 9 9
0 90 0 0
* 63 * *
# 84 # #
Close ??
Clear 9 Escape Escape
Enter 36 Enter SELECT