Kodi Community Forum
[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: Help and Support (/forumdisplay.php?fid=33)
+--- Forum: Kodi 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


- Diego2002 - 2011-01-27 23:48

Hi Coldsource!

I tried this x11/xorg blacklisting, but in /usr/share/x11 there isn't such folder xorg.conf.d.

The situation anyway isn't changed, my custom map isn't recognized.

Slowly I give up, because I have only two buttons (Power off, and Win key), which aren't working on my remote, I try to live without these. Frown


- coldsource - 2011-01-28 11:50

Cucurbitace Wrote:Every key that use a value above 9 (A to E) is not recognized by the program.

My fault it was a bug in the code. I have updated the beta version to correct this. Try redownloading the archive to see if it works.


Still not detecting these keys - akr884 - 2011-01-28 12:47

coldsource Wrote:My fault it was a bug in the code. I have updated the beta version to correct this. Try redownloading the archive to see if it works.

First of all, thanks a lot for these drivers.
I just downloaded the beta version again and it has the same issue with not detecting keypresses that have letters (for me a - f).

edit: Updating the beta driver on my laptop didn't work (I use it for testing) but installing the beta cleanly on my Media Center PC worked.


- Cucurbitace - 2011-01-29 11:22

Hi,

Congratulations coldsource, the new beta is doing really good. Smile

Here is my map:
Code:
0100000000520000:KEY_UP
0100000000510000:KEY_DOWN
0100000000500000:KEY_LEFT
01000000004F0000:KEY_RIGHT
0100000000280000:KEY_ENTER
01000000002A0000:KEY_BACKSPACE
0400040000000000:KEY_C
0500200000000000:KEY_PREVIOUSSONG
0500010000000000:KEY_PLAYPAUSE
0500100000000000:KEY_NEXTSONG
0500080000000000:KEY_R
0500400000000000:KEY_STOP
0500040000000000:KEY_F
0501000000000000:KEY_KPPLUS
0502000000000000:KEY_KPMINUS
0401000000000000:KEY_HOME
0508000000000000:KEY_PAGEUP
0510000000000000:KEY_PAGEDOWN
0504000000000000:KEY_MUTE
0500020000000000:KEY_TAB
01000000001E0000:KEY_1
01000000001F0000:KEY_2
0100000000200000:KEY_3
0100000000210000:KEY_4
0100000000220000:KEY_5
0100000000230000:KEY_6
0100000000240000:KEY_7
0100000000250000:KEY_8
0100000000260000:KEY_9
0100000000270000:KEY_0
0602000000000000:KEY_S
0402000000000000:KEY_F11
0400200000000000:KEY_V
0408000000000000:KEY_F9
0410000000000000:KEY_F8
0420000000000000:KEY_F10
0480000000000000:KEY_F12

I add to edit keyboard.xml config from XBMC too in order to have all the keys working the way I wanted. Here are the changes:
Code:
<f12>XBMC.ActivateWindow(VideoLibrary,MovieTitles)</f12>
<f11>XBMC.ActivateWindow(VideoLibrary,TvShowTitles</f11>
<f10>XBMC.ActivateWindow(VideoLibrary,Plugins)</f10>
<f9>XBMC.ActivateWindow(MyMusic)</f9>
<f8>XBMC.ActivateWindow(Pictures)</f8>

At the moment I still run it manually, as soon as you think it's not a beta anymore, I'll install it properly.

Thanks again for the great work.


Buttons Sticking - akr884 - 2011-01-30 21:55

I've got a generic USB HID mce remote: 073a:2230 that has a mouse input pad.

The button presses that it sends is something like this for the mouse pad
020000xx

with the xx starting off as one thing and changing maybe 7 times before it sticks definitively (if I hold the button down).

Each direction has a unique pattern, but no matter which number I choose in the sequence as the Action capture to define the button in my .map file, the button sticks until I push another button.

It's not a deal-breaker, but I was wondering if there is a possible fix for this.

I tried to block out only the keyboard and not the mouse input in xorg, but I couldn't get that to work either.

It shows up as /dev/input/by-id/xxx/mouse
and
/dev/input/by-id/xxx/mouse-event-server - but this one is the only one that shows up on the event input query using cat.


- Grez - 2011-01-31 22:59

This is brilliant, thank you so much Coldsource, this driver/app has solved all my Remote niggles with my Jetway Mini-TOP.

The jetway has a built in IR that shows up as:

Found HID device at /dev/hidraw3
Manufacturer : Cy se̪http://www.ir
Product name : http://www.irfmedia.com UIR

Here's my map, I basically remapped most of the more useless buttons on the bundled remote into keys to do useful things in XBMC as follows:

Standby = L (next sub)
Close = Q (add to queue)
Magnifier = A (audio delay)
www = T (toggle subs)
Full Screen = Z (aspect ratio)
Desktop = O (codec info)
Mic OSD = C (context menu)
WindowToggle = I (info)

Code:
0000500000000000:KEY_LEFT
0000520000000000:KEY_UP
00004f0000000000:KEY_RIGHT
0000510000000000:KEY_DOWN
0000290000000000:KEY_BACKSPACE
0000280000000000:KEY_ENTER
02b4000000:KEY_R
02cd000000:KEY_P
02b3000000:KEY_F
02b6000000:KEY_COMMA
02b7000000:KEY_X
02b5000000:KEY_DOT
00004b0000000000:KEY_PAGEUP
00004e0000000000:KEY_PAGEDOWN
02e9000000:KEY_VOLUMEUP
02ea000000:KEY_VOLUMEDOWN
02e2000000:KEY_MUTE
04002b0000000000:KEY_I
0700310000000000:KEY_C
0224020000:KEY_BACK
0225020000:KEY_FORWARD
0400280000000000:KEY_Z
0800070000000000:KEY_O
0223020000:KEY_T
08002e0000000000:KEY_A
0382000000:KEY_L
04003d0000000000:KEY_Q
00004c0000000000:KEY_DELETEFILE
0100100000000000:KEY_AUDIO
0100080000000000:KEY_VIDEO
0c00280000000000:KEY_ESC

I then made my Harmony remote learn all these, mapped them to the right buttons on the Harmony and I can shove the useless bundled remote into a drawer. Big Grin


- coldsource - 2011-02-01 12:49

Hi everyone and thanks for the feedback.

Based on your results and on the tests I have made I think the beta version is now stable enough, so I have placed it as stable.

I'll post a startup script using upstart for those using ubuntu so you can cleanly start the mapper at boot time.


akr884 :
Some devices simulate multiple interfaces (for mouse and keyboard for example).
When you start the mapper, do you see multiple :
Quote:Opened HID interface on ...
And if it is the case could you post the output at startup.
If I understand your problem, the mapping works but the key repetition doesn't. Is it right? I'm not sure to understand what you would like to do.

Could you also post the exact model of your remote ?

Thanks everyone


- Shayan - 2011-02-02 01:58

Thanks for putting this together, it works great. It got me to register just to say thanks for putting this together.

However, there was one bug I ran into. When I do a ./hid_mapper --list-devices, I have 6 devices attached to my machine, the last 3 of them have the Manufacturer as unknown. So in this block of code

Code:
            if(get_file_contents(filename,buf,256)<0)
            {
                if(manufacturer==0)
                    printf("  Manufacturer : Unknown\n");
                else
                {
                    closedir(dh);
                    return -1;
                }

Even though it found my HID device earlier in its loop, the code still exits out with a -1 causing the program to say the HID device was not found.

I did a quick hack, which works for me. If it found some devices earlier, return 0 instead of -1, but I didn't go and check if that works if the valid HID device is after devices with an unknown manufacturer.

Here's my updated block of code

Code:
            if(get_file_contents(filename,buf,256)<0)
            {
                if(manufacturer==0)
                    printf("  Manufacturer : Unknown\n");
                else if(hid_device->num_interfaces>0) {
                    closedir(dh);
                    return 0;
                }
                else {
                    closedir(dh);
                    return -1;
                }
            }

Hope this helps.


- coldsource - 2011-02-02 10:42

Hi Shayan,

Shayan Wrote:However, there was one bug I ran into. When I do a ./hid_mapper --list-devices, I have 6 devices attached to my machine, the last 3 of them have the Manufacturer as unknown.

I think you could use the --lookup-id if some devices have unknown manufacturer or product name, it should do the trick.

Quote:./hid_mapper --list-devices --lookup-id



- UsagiYojimbo - 2011-02-02 13:29

Thanks for this driver!
It works with the IR receiver in my ModeCom FEEL 607 MediaCenter case. I will post the mappings for my remotes (i have 2 of them). Nerd


- akr884 - 2011-02-05 19:16

Quote:If I understand your problem, the mapping works but the key repetition doesn't. Is it right? I'm not sure to understand what you would like to do.

From the hid lookup

Quote:aaron@aaron:~/Desktop/hid_mapper_beta$ ./hid_mapper --list-devices --lookup-id
Found HID device at /dev/hidraw0
Manufacturer : 073a
Product name : 2230

This is holding the 'mouse' up arrow for a few seconds
Quote:Opened HID interface on /dev/hidraw0
02 00 00 fc
02 00 00 fa
02 00 00 f8
02 00 00 f6
02 00 00 f4
02 00 00 f2
02 00 00 f0
02 00 00 ee
02 00 00 ec
02 00 00 ea
02 00 00 e8
02 00 00 e6
02 00 00 e6
02 00 00 e6
02 00 00 e6

No matter which code I choose as the action button among those, the key press sticks until I push another button. My guess is that the 'mouse' buttons just have a key press that isn't followed by a key release, so the button just 'sticks' and repeats until I press something else. My solution was to route the 'keyboard' through hid_mapper and let X control the 'mouse' but I can't get X.org to only ignore one of the two inputs and if I use hid_mapper, the 'mouse' is useless because all the button presses stick (hid_mapper works well for me, it would just be nice to be able to get these buttons working too)

The remote is a cheap MCE remote from amazon.co.uk

http://www.amazon.co.uk/gp/product/B003TKJE9G/ref=oss_product

I think it's this one, but I couldn't get it to work with lirc in ubuntu 10.10; nothing would show up using irw after successfully programming the remote.

http://wiki.xbmc.org/index.php?title=Remote_Control_Reviews#Unbranded_MCE_remote


- coldsource - 2011-02-09 01:25

Hi and sorry for the late reply.
Here is the upstart script to place in /etc/init/remote_mapper.conf :
Code:
description     "HID Remote mapper"
author          "Thibault Kummer"

start on started udev

stop on runlevel [016]

script
    exec /root/hid_mapper/hid_mapper --manufacturer '...' --product '...' --map /root/hid_mapper/asus-spinel.map
end script

Be careful to use full paths and not relative ones as you can't know the working directory of upstart.
Also note that this is an upstart script, it will work for ubuntu only. For other distributions you can use /etc/rc.local or the standard init scripts.

akr884:
I confirm that there is no key up notification or at least that hid_mapper won't detect it as it expects an all 0 code. Did you also release the key in your previous example ? Because even if the 'Key up' code was '02 00 00 e6' (the last event from your dump), it sounds strange that it is emitted multiple times.

Could you try with several key and try to guess what is the key up code ? If it is fixed I could add a command line option to specify it and all should be working well.


- akr884 - 2011-02-09 21:09

Coldsource:
The remote emits all those numbers in sequence (not all at once) when I hold the 'mouse' up key for maybe a second-and-a-half. I can choose any one of those key codes and use it as the hook in my .map file and it works (of course, if I choose a code that's further down, there's a delay between holding the 'mouse' up and getting a button response though).

If I just tap the button, then the only output is

02 00 00 fc

A longer press gives

02 00 00 fc
02 00 00 fa

etc...

However, regardless of which button press I use as the key code in the .map file, the button 'sticks', meaning even a quick press causes continuous upward scrolling (if it's programmed as the 'up' button) until I hit another key. I think that, because they're 'mouse' presses, the remote sends key presses without indicating a key release like it does with all the other buttons (which work fine).

I think that the button sequence changes as I hold it down to create accelerated mouse scrolling, but again that's just a best guess.


- coldsource - 2011-02-09 23:05

akr884 Wrote:I think that the button sequence changes as I hold it down to create accelerated mouse scrolling, but again that's just a best guess.

I also think so. These keys must me programmed for mouse movement so of course there is no key release. I'll write a new beta version with a specific map file for mouse events. This will be used to map key codes to movements (e.g. up by 4 pixels). This way you'll be able to setup these buttons with acceleration setting, that is :
Quote:02 00 00 fa = Up 1 pixel
02 00 00 f8 = Up 2 pixels
02 00 00 f6 = Up 4 pixels
02 00 00 f4 = Up 6 pixels

I think this is the only way to setup these buttons correctly.

I'll post here as soon as the new beta version is ready.

Thanks for the new informations.


upstart script - Shayan - 2011-02-10 05:38

coldsource Wrote:Hi and sorry for the late reply.
Here is the upstart script to place in /etc/init/remote_mapper.conf :
Code:
description     "HID Remote mapper"
author          "Thibault Kummer"

start on started udev

stop on runlevel [016]

script
    exec /root/hid_mapper/hid_mapper --manufacturer '...' --product '...' --map /root/hid_mapper/asus-spinel.map
end script

Be careful to use full paths and not relative ones as you can't know the working directory of upstart.
Also note that this is an upstart script, it will work for ubuntu only. For other distributions you can use /etc/rc.local or the standard init scripts.

akr884:
I confirm that there is no key up notification or at least that hid_mapper won't detect it as it expects an all 0 code. Did you also release the key in your previous example ? Because even if the 'Key up' code was '02 00 00 e6' (the last event from your dump), it sounds strange that it is emitted multiple times.

Could you try with several key and try to guess what is the key up code ? If it is fixed I could add a command line option to specify it and all should be working well.

This is my first time messing around with upstart, and it doesn't seem to work for me. I placed the remote_mapper.conf file in the /etc/init directory. However, it doesn't seem to start the service at bootup. I'm not sure if there is anything extra that I need to do.

Right now once the system boots up, if I do a status remote_mapper it says the service is stopped. If I do a start remote_mapper, there is an error and the service doesn't start. However, if I do a sudo start remote_mapper, the service starts fine.

Is there something that needs to be configured for upstart to start remote_mapper at boot time?