[LINUX] Generic HID Remote Driver for XBMC (Drivers for XBMC on Linux and XBMC Live) - Printable Version
+- Kodi Community Forum (http://forum.kodi.tv)
+-- Forum: Support (/forumdisplay.php?fid=33)
+--- Forum: General Support (/forumdisplay.php?fid=111)
+---- Forum: Linux and Live support (/forumdisplay.php?fid=52)
+---- Thread: [LINUX] Generic HID Remote Driver for XBMC (Drivers for XBMC on Linux and XBMC Live) (/showthread.php?tid=88560)
[LINUX] Generic HID Remote Driver for XBMC (Drivers for XBMC on Linux and XBMC Live) - coldsource - 2010-12-25 13:43
I have bought an ASUS motherboard which was supplied with an IR remote control.
Here is a picture of the remote :
The receptor is an HID receptor that is not supported by LIRC, nor fully supported by evdev so only half of the keys are working.
I have developped a generic HID mapper which can convert any HID signal to a key event that can easly be used in XBMC.
Here is the driver :
And a step by step guide for how to use it :
First we have to build the hid_mapper. Untar the archive and CD to hid_mapper. Then type 'make' to build the driver.
Type ./hid_mapper --list-devices to see if your device if recognized here. For example I have :
Quote:Found HID device at /dev/hidraw0
It is then necessary to blacklist the device in Xorg so it does not conflict with the mapper. Create a new file in /usr/share/X11/xorg.conf.d/. I have named it 50-remote.conf and it contains :
Quote:Section "InputClass"Match id done on the manufacturer and the product name. Restart Xorg and you're done. At this point the remote is not recognized anymore.
Next you have to use hid_mapper in learn mode to capture HID events :
./hid_mapper --learn --manufacturer 'PHILIPS' --product 'MCE USB IR Receiver- Spinel plusf0r ASUS' --map ''
If i press "OK" key of the remote I get
Quote:Found HID device at /dev/hidraw0
The first event is the "key down" event, containing the key code. This is what we need. Capture all the events you need to write a map file. This my map file for the asus remote :
The list of the keys can be found in /usr/include/linux/input.h.
Last step is to run the mapper :
Quote:./hid_mapper --manufacturer 'PHILIPS' --product 'MCE USB IR Receiver- Spinel plusf0r ASUS' --map 'asus-spinel.map'
At this point the remote should work and emit the keys specified in the map file.
Since the hidraw driver is generic, this mapper should work with any HID receiver, even if it is not a remote. HID is used for keyboard, mouses, joysticks...
I hope this can help someone.
- 2ami - 2010-12-25 19:29
hi Bob, first of all i would llike to thank you for writing this driver, i believe so many waiting for this solution on hid based receiver, as i also have 2 cheap MCE clone remote
but after i type "make" (before i got g++ command not found then i sudo apt-get update g++)
g++ main.o uinput_device.o hid.o signals.o keys_definition.o EventMapping.o Keys.o Exception.o MapReader.o -o hid_mapper
/usr/bin/ld: i386:x86-64 architecture of input file `main.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `uinput_device.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `hid.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `signals.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `keys_definition.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `EventMapping.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `Keys.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `Exception.o' is incompatible with i386 output....
...MapReader.cpp.text+0x8e): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
make: *** [all] Error 1
i'm a complete newbie in linux, is it because of my machine running i386 version of linux?
or do i miss something
[email protected] ~/Downloads/hid_mapper $ uname -a
Linux amiami-Aspire-4710 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686 GNU/Linux
- jakeluck1 - 2010-12-25 20:02
thank you, Bob! will try it out here soon.
FYI, a related discussion from our own ph77
- jakeluck1 - 2010-12-25 20:04
- coldsource - 2010-12-25 20:45
Sorry it's my fault I let object files in archive.
Try using :
It should work. I'll upload a new archive.
EDIT : Done the new archive is online.
- coldsource - 2010-12-25 21:09
jakeluck1 Wrote:thank you, Bob! will try it out here soon.
Thank you for posting these links. However the approach is not the same. My driver works in userland so there is no need to compile kernel modules. Furthermore the HID mapper is generic, so it can be used with any HID remote, not only ASUS remotes. I only posted ASUS remote as an example since it is the remote I use.
If you have any suggestions or improvement ideas on the driver I'll we glad to develop it.
- 2ami - 2010-12-26 16:58
coldsource Wrote:2ami :
Thanks again bob... it's working now and created map file for my own, but wonder some key such as volume up/down only show 0000000000000 when pressed, but i confirm its working under win 7
one more question, is it possible to use this usb hid receiver with another remote?
- coldsource - 2010-12-26 17:37
Hi 2ami :
HID receivers can generally only be used with the original remote. However as far as I know some universal remotes can work with it
Concerning volume up/down keys I don't know why it doesn't work. The code you get is a key up code, that is when you release the key. It can happen when pressing multiple keys at the same time when learning codes.
Edit : 2ami I sent you a PM I may know what is wrong with these buttons of your remote.
- 2ami - 2010-12-27 11:20
coldsource Wrote:Hi 2ami :
Thanks again bob, i have tried several method to use this remote on linux especially on xbmc, I think your driver and method is the most suitable for my remote and it's hid receiver, because somehow the button up, down, left, right navigation can not work on linux. now its working with your driver. This should be sticky so we have alternative way to manipulate remote based hid receiver.
i dont have - nor plan to buy - universal remote, i though we can use your driver to manage this hid receiver so it can act like lirc.
i will play around with another logitech mouse/keyboard wireless hid dongle later. thanks so much
- jpmayo - 2011-01-01 22:40
I was actually trying to set up xbmc as an add on to Fedora 14 with a very generic HID remote and this works! Thank you!
However, when I do a reboot of the computer, I have to reapply the keymap for the remote to work.
I tried adding a script that ran on startup, but it needs superuser priviledge to apply the keymap.
Is there a way to apply the keymap without supperuser priviledge or get it to work on startup?
This is probably more of a Fedora than an xbmc question, but you obviously know what you are talking about with the remote, so I figured I might as well ask.
- coldsource - 2011-01-02 15:44
The driver works as a daemon, so it is normal that you have to run it on each boot for the mapping to work. Also is it normal to run it as root, because of the default properties of the HID files in /dev (only readable by root).
I think the simplest would be to but something in /etc/rc.local, like :
Quote:hid_mapper --manufacturer '...' --product '...' --map '...' &
Put it before the exit statement. It should be enough to make it work.
Hope this helps
- jpmayo - 2011-01-15 06:55
I tried that, but it dosen't seem to work. I can only get it to work if I got to terminal and type
Quote:sudo /./hid_mapper --manufacturer 'Cy se' --product 'W-01RN USB_V3.1' --map '/s$
- Diego2002 - 2011-01-18 00:13
I try to compile the source, but I get this error to make:
[email protected]:/home/xxx/hid_mapper/hid_mapper# make
g++ -c -Iinclude main.cpp
gcc -c -Iinclude uinput_device.c
gcc -c -Iinclude hid.c
gcc -c -Iinclude signals.c
g++ -c -Iinclude keys_definition.cpp
keys_definition.cpp:458: error: âKEY_CAMERA_FOCUSâ was not declared in this scope
keys_definition.cpp:705: error: âKEY_RFKILLâ was not declared in this scope
keys_definition.cpp:777: error: âKEY_WPS_BUTTONâ was not declared in this scope
make: *** [keys_definition.o] Error 1
I had deal with c++ a long time ago, so I can not really find the problem. I checked those lines, but nothing interesting. It's even else...
Can you help plz?
- coldsource - 2011-01-21 12:17
What it your Linux distribution ?
This file does mapping between text description of keys and standard constants. I have generated the file based on ubuntu 10.10 so it is possible that you do not have all the keys defined.
One solution could be to delete the entries that are not recognized from the file, it should be harmless. Just be careful to remove entries from both arrays (keys_char and keys_int : one have quotes around values and the other not). Then recompile and it should be ok.
- Cucurbitace - 2011-01-22 12:29
I feel this might just be the solution I'm looking for quit a few time! The program compiled fine, but when I use the command:
I get this:
The last one is my remote, but as you can see, there is no manufacturer nor product name.
Any idea what I may try?