Using Emprex 3009URF III Vista MCE Remote with MythTV

I recently got my hands on a new Acer Aspire Revo R3610, the plan is to use this as a second MythTV frontend in the bedrooom (I’ve still got to find a suitable TV to hang it on the back of). To go with this I needed a new remote control so I don’t need to have a keyboard and mouse plugged in, I had a bit of a search round online and found the Emprex 3009URF on Amazon, it looked like it would be perfect for what I needed. As well as having all the buttons I wanted it also uses RF rather than IR so no need to have the USB dongle in line of sight.

When it arrived I plugged it in and it showed up as 2 separate keyboards, each with about half of the buttons. This wasn’t a major problem as both where seamlessly merged by the Linux HAL keyboard layer and I was planning on wrapping the input with LIRC anyway. What was a problem was that for a few of the buttons I was not getting any key events. The missing buttons where:

  • The Big Green Start Button
  • Most of the menu buttons (TV, DVD, Music, Photos …)
  • Teletex
  • Red, Green, Yellow & Blue

Kernel work

I could have lived with out most of these apart from the Teletext and the colour buttons as these are use by the DVB-T service here in the UK to access the interactive content.I started to have a bit of hunt round online and found that there was already code in the Linux Kernel to support similar remotes. I was just about to start writing my own extention to support this one when I came across a patch that had been submitted about 2 week earlier. Details of the patch can be found here. There is some discusion between the submitter (Wayne Thomas) and the maintainer of the HID code (Dmitry Torokhov) saying that Dmitry would like to remove all the code that provides support for these types of remote now it was possible to achive the same thing with configuration files and udev. I followed the link about how to set up udev, but was unable to get even the “unkown” responses when running the monitoring program.

Given that I could not get the alternative to work it looked like the quickest way to get full support for the remote was going to mean applying the patch. Since the HID code is built into the Kernel I couldn’t just build it as a module to load into an existing Fedora Kernel, I was going to have to rebuild the whole thing. Rather than mess about pulling a raw source tree I decided to let rpmbuild do the heavy lifting since this would mean I ended up with a kernel that was a close as possible to what I already had. I downloaded the src rpm with yumdownloader. Yumdownloader doesn’t actually install the src rpm package so you need to then actually install the package


# yumdownloader kernel
# rpm -ivh kernel-2.6.31.12-174.2.22.fc12.src.rpm

The install will create a rpmbuild directory tree. This is used to do the compiling and packaging when the rpm is built using the rpmbuild command. The tree looks like this:


	rpmbuild
	   |-BUILD
	   |-BUILDROOT
	   |-RPMS
	   |-SOURCES
	   |-SPECS
	   |-SRPMS

The source tar file and all the patch files end up in the SOURCE dir and the rpm spec file goes in the SPECS dir. Applying the patch is a 2 step process. Firstly we need to down load the patch file from patchwork site listed above,I saved that in to the SOURCE dir in a file called btc-remote.patch. Secondly we need to update the spec file to ensure
that the patch is applied. This requires adding 2 lines, one to identify the file with the patch and one to actually apply it.


...
Patch16570: futex-handle-user-space-corruption-gracefully.patch

Patch16580: partitions-use-sector-size-for-efi-gpt.patch

<span style="color: blue">Patch16590: btc-remote.patch</span>

%endif

BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
...
# enable IR receiver on Hauppauge HD PVR (v4l-dvb merge pending)
ApplyPatch hdpvr-ir-enable.patch
# tell usbhid to ignore all imon devices (sent upstream 2009.07.31)
ApplyPatch hid-ignore-all-recent-imon-devices.patch
<span style="color: blue">ApplyPatch btc-remote.patch</span>

# Add kernel KSM support
ApplyPatch linux-2.6-ksm.patch
ApplyPatch linux-2.6-ksm-updates.patch
...

I have created another patch to add these lines as I expect to have to apply this next time Fedora ships a new Kernel. I have submitted a Bugzilla to ask for this patch to be included in future releases. So with patch in the right place and the right bits in the spec file the rpms are built by executing the follow command from the rpmbuild dir


# rpmbuild -bb SPECS/kernel.spec

And remove the Fedora build package then install the new one with:


# yum erase kernel-2.6.31.12-174.2.22.fc12
# yum --nogpgcheck localinstall RPMS/kernel-2.6.31.12-174.2.22.fc12.i686.rpm

LIRC

After rebooting the system to the new Kernel all the buttons now work fine. Now rather than go throw all the applications mapping the keys to the required functions I chose to use LIRC to map the key presses to the functions. LIRC has a dev/input module that will take standard /dev/input/event devices as input. First we need to
stop the HAL layer from grabbing the devices and adding them to the normal keyboard inputs. Put the following in a file called 10-ignore-emprex in /etc/hal/fdi/preprobe


<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
<device>
 <match key="info.product" contains_ncase="'BTC USB MCE Cordless Remote">
    <merge key="info.ignore" type="bool">true</merge>
 </match>
</device>
</deviceinfo>

Now we need to make sure we can indentify the /dev/input/event entries that map to the remote even if the order changes on boot. To do this we can use the udev rules. Looking in /proc/bus/input/device for the “BTC USB MCE Cordless Remote”, there will 2 entries looking a bit like this:


I: Bus=0003 Vendor=046e Product=5578 Version=0111
N: Name="BTC USB MCE Cordless Remote Control."
P: Phys=usb-0000:00:04.0-6/input1
S: Sysfs=/devices/pci0000:00/0000:00:04.0/usb2/2-6/2-6:1.1/input/input7
U: Uniq=
H: Handlers=kbd event7
B: EV=1f
B: KEY=837fff 2ff2b7 bf004444 0 0 1 f84 8a37c000 667bfa d941dfed 9e0000 0 0 0
B: REL=40
B: ABS=1 0
B: MSC=10

From this we can see that currently one of the 2 event sources is bound to event7, using this information udevadm tool a signature for the device that can be used to map the event devices to unique names.


# udevadm info -a -p $(udevadm info -q path -n /dev/input/event7)
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:04.0/usb2/2-6/2-6:1.1/input/input7/event7':
    KERNEL=="event7"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:04.0/usb2/2-6/2-6:1.1/input/input7':
    KERNELS=="input7"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="BTC USB MCE Cordless Remote Control."
    ATTRS{phys}=="usb-0000:00:04.0-6/input1"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v046Ep5578e0111-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,
8A,8B,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B1,B2,B5,B6,CE,CF,D0,D1,D2,D5,
D9,DB,DF,E2,E7,E8,E9,EA,EB,100,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,
193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r6,a20,m4,lsfw"
...

Using this and the instructions from the How to write udev rules I built the following file /etc/udev/rules.d/99-emprex.rules


KERNEL=="event[0-9]*", ATTRS{name}=="BTC USB MCE C*", ATTRS{phys}=="usb-0000:00:04.0-6/input0", SYMLINK+="input/rfremote0"
KERNEL=="event[0-9]*", ATTRS{name}=="BTC USB MCE C*", ATTRS{phys}=="usb-0000:00:04.0-6/input1", SYMLINK+="input/rfremote1"

This adds 2 symlinks to the /dev/input directory called rfremote0 and rfremote1. Using these 2 instances of lircd can be started to read both sets of inputs and pass them to the applications. To bind the lircd instance you need to start one with –listen and one with –connect as follows:


# lircd --driver=dev/input --device=/dev/input/rfremote0  --pidfile=/var/run/lirc/lircd0.pid --listen
# lircd --driver=dev/input --device=/dev/input/rfremote1  --pidfile=/var/run/lirc/lircd1.pid  --connect=localhost:8765

Once these 2 instances are up and running irw can be used to test the input and also to build the .lircrc file


# Play
begin
prog = mythtv
button = KEY_PLAY
config = Return
end

# Stop
begin
prog = mythtv
button = KEY_STOPCD
config = I
end

# Escape/Exit/Back
begin
prog = mythtv
button = KEY_BACK
config = Esc
end
...
begin
prog = xine
button = KEY_PLAY
repeat = 3
config = Play
end

begin
prog = xine
button = KEY_STOPCD
repeat = 3
config = Stop
end

begin
prog = xine
button = KEY_BACK
repeat = 3
config = Quit
end

Now we are all good to go.

Resources

21 thoughts on “Using Emprex 3009URF III Vista MCE Remote with MythTV”

  1. Hi, I’m having the same issues with the Emprex 3009 using Ubuntu and XBMC. I don’t suppose those instructions are useable across distros are they?

  2. Great thread!

    I’ve bought the Aureal CiT W-01RN USB remote control and applied patch to fix the buttons. However, do you think its best to wrap using lirc, or use the HID layer directly? I still cant map some buttons to keys.

    Or should I just buy the Emprex 3009URF and use it as you have?

    Whats the simplest?

    1. To be honest I didn’t do much with the Aureal patch, I just needed to get 1 button working for the project I had at the time.

      The Emprex works flawlessly for me with LIRC and that allows me to map different functions for different applications easily. For instance I’ve mapped the big green media button to switch desktops away from MythTV to one where I have Firefox running.

  3. Well I’ve bought the Emprex, but under Ubuntu 10.10 I cant seem to inhibit the HAL layer from grabbing the devices and adding them to the normal keyboard inputs.

    I’ve got LIRC to work, but there seems to be a power struggle between it and the HAL. Also (same old story) not all of the buttons work….

    Any suggestions?

    1. I’ve not tried anything on Ubuntu with this, and the machine I’m using the remote with is still running Fedora 13 and as long as I rebuild the kernel with the patch it’s working fine.

  4. Got it working with Ubuntu 10.10 with your instructions.

    Many thanks!

    What command line/key combination did you use to swap between Mythtv and Firefox?

    1. I’m using irexec to run a little script that uses wmcrtl to switch between to desktop workspaces.

      The .lircrc entry looks like this:

      begin
      prog = irexec
      button = KEY_MEDIA
      config = /home/hardillb/bin/flipDesktop.sh
      end

      And flipDesktop.sh like this:

      #/bin/sh
      export DISPLAY=:0.0
      current=`wmctrl -d | grep * | awk ‘{ print $1 }’`
      if [ $current -eq 1 ]
      then
      if [ “$( ps -C mythfrontend | wc -l)” -eq 1 ] ; then
      nohup mythfrontend &
      fi
      wmctrl -s 0
      else
      wmctrl -s 1
      fi

      MythTV runs on Workspace 0 and Firefox on 1. The bit with the ps makes sure mythfrontend is running when I switch to workspace 0 and restarts it if needed.

      You need to make sure irexec is running in the background as well, so you can either set it up as a startup app in Gnome or run something like this

      nohup irexec &

  5. Just updated the box I’m using this remote with to Fedora 14 and without the patch all the buttons are working.

    A couple of buttons have changed their mappings but that’s easy enough to fix.

  6. Just applied the patch to my Ubuntu 10.04 machine, but it doesn’t seem to work. Udev generates the nodes /dev/input/event5 and event 6 when the usb dongle is plugged in, but when I cat these the keys that didn’t work before still do not generate any output. Is this the correct way to test? Anyone got any ideas what I might be doing wrong?

    1. Phil,

      Not sure, the only thing I can think of off the top of my head is may be you have a remote with some slightly different USB device id’s (I’ve seen them for sale called ARF not URF recently but not had one to try yet). Check with lsusb that the vendor id is 0x046e and the device id is 0x5578.

      It “just worked” for me out of the box. I did have to tweak the patch a little to get it to apply to some of the later Fedora 13 kernels but that was just because the line numbers didn’t line up anymore. And with the newer kernels in Fed 14 I haven’t needed the patch at all.

      Catting events should show you something (garbage chars most likely) if it’s working, but pointing LIRC at it and irw will give definitive answers as to what the kernel is seeing.

      1. Phil,

        I’ve just picked up an ARF version (product id 0x5577) and it’s behaving the same way before the patch even on my new Fedora 14 build.

        I know why the patch would not work for this on the old kernels as it does not include a mapping for the different product id which is an easy fix.

  7. All working now
    I went away after your first post and did a lsusb call and as you suggested the hardware id was 5577 not 5578 as in the patch. I edited the file and everything worked. I also needed to get the devinput lircd conf file from lirc.sourceforge.net/remotes/devinput/lircd.conf.devinput

    Thanks for your help.

    Have you considered putting a page on the MythTV wiki with these instructions for the emprex remote? If you don’t have time to do so then I’ll do it and put an link to your page.

    cheers

    Phil

    1. Phil,

      I got my new ARF (5577) working today as well by tweaking the patch, a bit of digging turned up that a patch for both versions has been included in the 2.6.38 kernel onward.

      As for lircd I’ve got a second lirc entry in /etc/init.d that uses a separate options file in /etc/sysconfig that set up the options I mentioned in the original post and also makes sure I start the one with “–listen” is stars first so the second can connect to it.

      I had to update both the udev and hal rules that map rfremote0 and rfremote1 and get Hal to ignore the device respectively as the name of the device changed from “BTC USB MCE Cordless Remote Control.” to “BTC USB Multimedia Cordless Keyboard”.

      I am getting some strange pauses in key presses sometimes with new remote, not sure how to debug it at the moment, but I’m planning a full Myth rig rebuild at some point so I’m tempted to leave it until I get the new set up working.

  8. That’s slightly annoying about the inclusion in the 2.6.38 kernel. I downloaded 2.6.39 source to apply the patch, however I already had 2.6.32 source in the same directory and must have unzipped the wrong tar file because I’ve just realized my new kernel is 2.6.32. Oh well!
    Not sure how to use config files with lircd. In the end I included the two lircd line from above in a bash script, removed sudo from the beginning of the lines, put it in /etc/init.d and added it to /etc/rc.local, this seems to work fine.
    Regarding your pauses, do they occur with the * and # keys? I noticed that these keys appear as shift 8 and shift 3 instead of being single keystrokes. Don’t know if the other version of the remote is the same.

    Thanks again for all the help. Again, If you don’t have time to add this tutorial the the mythtv wiki, I’ll happily do so and link your site.

    Phil

  9. I’ve got two installations of MythTV working with the Emprex via LIRC on Ubuntu 10.10 and get long pauses on one handset.

    I saw you were getting some strange pauses, I wondered if you have located/identified the problem? My configurations are practically identical.

    1. Check that both are the same model, I only had a problem with the ARF, the URF was fine.

      It looked like it was mainly a range/interference issue, I moved the receiver to the end of a USB extension cable so it was no longer hidden behind the TV an a bit closer to where I’m normally sat and it’s a lot better.

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=""> <s> <strike> <strong>