I’ve got a cheap USB remote that acts as a HID keyboard, with the key presses all hard coded to MCE suitable settings. Unfortunately these don’t all work well with Linux and mythtv in particular.
I found a replacement HID driver for remotes here: http://rtr.ca/sapphire_remote/
I had to modify it to recognise my remote instead, and also figured out how to automatically attach the driver rather than the normal hid one when plugging the remote in / boot.
My remote has completely different keycodes to the sapphire one, so I modified the driver to print the keycodes to syslog of any button press that’s not recognised. In this way I can have the driver attached and running, but pressing buttons will simply print the codes. I can then modify a copy of the driver to add the codes to the lookup table, every now and again recompiling the driver to check that they’re working. I haven’t actually mapped all the keys on my remote, just the ones I want to use.
I also added the HOLTEK’s vid/pid to the driver to recognise my remote.
The makefile automatically handles reinstalling the driver and resetting the remote, so every time you run ‘make install’, if the remotes already attached to the driver, it gets the updated compiled driver.
Driver Attach Script
This is a modified version of the original one that searches for any HID device with HOLTEK as it’s name and detaches the hid driver. It then modprobes the hid_sapphire driver which will automatically attach the the remote.
I couldn’t find a way to directly override the driver to use when the USB remote was installed, but I can get it to automatically run a script on insertion, so I get it to run the above driver attach script. It appears to work flawlessly, both on random unplug/replug of the usb, as well as aleep/wake and reboots!