Making MythTV work with MCE Remote Mouse Emulation

After a long series of unsuccessful attempts to make XBox 360 play all the videos we had without resorting to a Windows VM, I decided to connect my existing home server running Ubuntu to the TV and install mythbuntu-desktop.

Everything went quite well, I added the startup of mythfrontend to autostart and purchased a cheap USB HID remote (detected as 073a:2230 Chaplet Systems, Inc. infrared dongle for remote, here’s the MythTV Wiki page on these) without looking closely at the design of the device itself.

The receiver emulates a USB HID keyboard with media keys and in order for MythTV to receive these keys one needs to do the following:

  • Disable xfce4-volumed — copy the /etc/xdg/autostart/xfce4-volumed.desktop to ~/.config/autostart and add Hidden=true to the section. That way the XF86AudioLowerVolume, XF86AudioRaiseVolume and XF86AudioMute events can reach the application. Alternatively, you can just uninstall xfce4-volumed package
  • Disable multimedia plugin of gnome-settings-daemon — it will also capture the media key presses and also prevent the application from receiving XF86Audio{Next,Prev,Pause}events:
  • $ gsettings set org.gnome.settings-daemon.plugins.media-keys active false
  • Configure the keys in MythTV interface.

The remote I purchased features a large “Mouse” directional pad while the regular keyboard keys actually used in MythTV were inconveniently located at the bottom of the remote. It was not comfortable to navigate through the menu so I decided to make this mouse-emulating “joystick” send regular keyboard events.

The receiver feeds USB HID data to the system and it does not look like it can give raw data for lirc. So I took python-xlib, googled for various parts I did not know about and came up with the following script: mythtv-mouse2kbd.py, which monitors the active window and performs the mouse movements into key presses translation if “MythTV Frontend” is the active window. Also left mouse button emits “Return” key and the right one emits “Escape”.

So now I can navigate around MythTV using this large joystick as if it was originally designed to be used this way.

The only issue the script has is that grabbing the pointer for some reason prevents Alt+Tab from working but once you exit MythTV (or switch to another workspace) the pointer will be released, so that looks like a minor issue.

12 thoughts on “Making MythTV work with MCE Remote Mouse Emulation

  1. MarkC

    A bit late to help you now, but I’ve had most success with MythTV using a “Flirc” IR-to-USB dongle (http://www.flirc.tv) with any old spare remote that happens to be kicking around and has a suitable combination of buttons. I’ve spent years wrestling with lirc, which has worked for me on-and-off, requiring work to get it going after some updates and rebuilds. Flirc, on the other hand, stores the configuration on the dongle itself (so isn’t affected by upgrades or rebuilds of the MythTV box) and appears to the computer as a USB keyboard (no drivers needed).

    Reply
  2. Roman Yepishev Post author

    I had an IrDA dongle (which is can not be made complatible with regular remotes) so this time I decided to use something that provides me all with a simple USB HID device out of the box. The whole point of the post was to tell about the script that can translate mouse movements to actual keyboard keys, as requested multiple times and worked around too.

    Reply
  3. MarkC

    I understood the point of the post, and wasn’t trying to suggest it’s not useful information to have online. I just thought it might be worth mentioning Flirc as an alternative for those people that stumble across your post before they’ve made an investment in a particular remote.

    Just to clarify, Flirc isn’t an IrDA dongle and *is* compatible with regular remotes. It also appears to the PC as a regular USB HID out of the box, though you do need to teach it what keypress it should fake for each button on the remote. The software for doing so is very user-friendly, and cross-platform. Because the configuration is stored on the dongle itself, you can program it on one machine then just unplug it and use it on another.

    Note: I’m not affiliated with the Flirc people in any way, other than being a very satisfied customer whose years of lirc woes have now become a thing of the past.

    Reply
    1. Roman Yepishev Post author

      Oh, I totally missed the point when I originally replied. It looks like a perfect solution when there is a spare remote. Thank you for sharing!

      Reply
  4. chemstar

    hi roman,

    is it possible to use the remote while choosing os’es inside of grub bootloader ?

    Reply
    1. Roman Yepishev Post author

      Yes, the remote emulates USB keyboard so it will work in grub too.

      No, it presents itself as a mouse and will not work in BIOS or GRUB, sorry for the false hopes :(.

      Reply
      1. chemstar

        finally i get one and against all expectations i can’t get it working with grub. inside bios i can see it, registered as additional mouse, and use it as a mouse but not as keyboard. have no idea how to change it …

        Reply
        1. Roman Yepishev Post author

          Chemstar, I have to apologize for my advice above.

          I dig further and found that the device is indeed a HID keyboard, but it is a HID Mouse first (and for some reason a joystick).

          kernel:
          hid-generic 0003:073A:2230.0001: input,hidraw0: USB HID v1.10 Keyboard [HID 073a:2230] on usb-0000:00:1a.0-1.3/input0
          
          Xorg:
          [    23.293] (II) config/udev: Adding input device HID 073a:2230 (/dev/input/js0)
          
          /proc/bus/input/devices:
          H: Handlers=sysrq kbd mouse0 event3 js0 
          

          I checked whether enabling USB Legacy support works but BIOS still sees it as a mouse only

          I am sincerely sorry about this.

          Reply
  5. Mark Preston

    Please pardon my lack of nerdy-knowledge but where you say: “I took python-xlib, googled for various parts I did not know about and came up with the following script: mythtv-mouse2kbd.py, ”

    once I have the file in gedit, what do I do with it? Where does it go and do I have to execute it or something?

    Reply
    1. Roman Yepishev Post author

      You can start the script in the terminal:

      $ python mythtv-mouse2kbd.py
      Initializing...
      Xlib.protocol.request.QueryExtension
      Ready to process events
      

      After this you can start MythTV. If this works you can add a new startup application in XFCE interface in Applications/Settings/Session and Startup and add new application to Application Autostart specifying the path to the script you have downloaded. Please make sure the script is marked as executable (chmod +x /path/to/mythtv-mouse2kbd.py).

      Reply
      1. Mark Preston

        mark@Lexington-19:~$ python mythtv-mouse2kbd.py
        Traceback (most recent call last):
        File “mythtv-mouse2kbd.py”, line 8, in
        from Xlib import display, X, XK
        ImportError: No module named Xlib

        sorry to bother you about this. Maybe after I get mine working I will try to write up a “how to” and post it at various Ubuntu formums, and Amazon/eBay. thanks.

        Reply
        1. Roman Yepishev Post author

          I should have specified this more clearly in the blog post. You will need to install python-xlib package:

          $ sudo apt-get install python-xlib
          
          Reply

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>