XBMC Community Forum
[LINUX] Generic HID Remote Driver for XBMC (Drivers for XBMC on Linux and XBMC Live) - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Help and Support (/forumdisplay.php?fid=33)
+--- Forum: XBMC General Help and 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)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12


[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 :
[Image: Asus-Bravo220-remote.jpg]

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 :
hid_mapper.tar.gz

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
Manufacturer : PHILIPS
Product name : MCE USB IR Receiver- Spinel plusf0r ASUS

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"
Identifier "Remote blacklist"
MatchProduct "PHILIPS MCE USB IR Receiver- Spinel plusf0r ASUS"
Option "Ignore" "on"
EndSection
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
01 00 00 28 00 00 00 00 00
01 00 00 00 00 00 00 00 00

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 :
Quote:010000520000000000:KEY_UP
010000510000000000:KEY_DOWN
010000500000000000:KEY_LEFT
0100004f0000000000:KEY_RIGHT
010000280000000000:KEY_ENTER
030000000000020000:KEY_KP1
030000000000040000:KEY_KP2
030000000020000000:KEY_C
030000000000008000:KEY_TAB
030010000000000000:KEY_KP3
02004000:KEY_ESC
02040000:KEY_KPMINUS
02020000:KEY_KPPLUS
02000002:KEY_PLAY
02000800:KEY_STOP
02000100:KEY_R
02800000:KEY_F
02010000:KEY_MUTE
02400000:KEY_PREVIOUSSONG
02200000:KEY_NEXTSONG

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.

Bob


- 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.cppSad.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

uname -a
amiami@amiami-Aspire-4710 ~/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

regard


- jakeluck1 - 2010-12-25 20:02

thank you, Bob! will try it out here soon.

FYI, a related discussion from our own ph77

http://forum.xbmc.org/showpost.php?p=536174&postcount=67

[url] http://ubuntuforums.org/showthread.php?t=1458300&page=2[/url]


- jakeluck1 - 2010-12-25 20:04

x


- coldsource - 2010-12-25 20:45

2ami :
Sorry it's my fault I let object files in archive.

Try using :
Quote:make clean
make

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.

FYI, a related discussion from our own ph77

http://forum.xbmc.org/showpost.php?p=536174&postcount=67

[url] http://ubuntuforums.org/showthread.php?t=1458300&page=2[/url]

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 :
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.

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

.
Quote:/hid_mapper --list-devices
Found HID device at /dev/hidraw0
Manufacturer : ATWF@83-W001
Product name : P-05R UIR_V2A

Code:
sudo ./hid_mapper --learn --manufacturer 'ATWF@83-W001' --product 'P-05R UIR_V2A' --map ''

sudo ./hid_mapper --manufacturer 'ATWF@83-W001' --product 'P-05R UIR_V2A' --map 'aureal.map'

Code:
aureal.map
0000520000000000:KEY_UP
0000510000000000:KEY_DOWN
0000500000000000:KEY_LEFT
00004f0000000000:KEY_RIGHT
0100080000000000:KEY_VIDEO
0100040000000000:KEY_RADIO
01000c0000000000:KEY_1
0100100000000000:KEY_2
0100170000000000:KEY_TV
04003d0000000000:KEY_CLOSE
00004b0000000000:KEY_VOLUMEDOWN
00004e0000000000:KEY_VOLUMEUP
00004e0000000000:KEY_MUTE
04002b0000000000:KEY_PLAYPAUSE
8000070000000000:KEY_NEXTSONG
0300050000000000:KEY_PREVIOUSSONG
0c00280000000000:KEY_FASTFORWARD
0000280000000000:KEY_ENTER
00002a0000000000:KEY_ENTER
0000290000000000:KEY_ESC
0000650000000000:KEY_BACKSPACE

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 :

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.


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. Laugh 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. Blush

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

Hi jpmayo.
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

Hello coldsource!

I try to compile the source, but I get this error to make:

root@XBMCLive:/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?

Thx
Diego


- 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

Hi,

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:

hif_mapper --list-devices

I get this:
Code:
Found HID device at /dev/hidraw0
  Manufacturer : Microsoft
  Product name : Basic Optical Mouse

Found HID device at /dev/hidraw1
  Manufacturer : NOVATEK
  Product name : USB Keyboard

Found HID device at /dev/hidraw3

The last one is my remote, but as you can see, there is no manufacturer nor product name.

Any idea what I may try?

Thanks