[LINUX] Generic HID Remote Driver for XBMC (Drivers for XBMC on Linux and XBMC Live)

  Thread Rating:
  • 7 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
akr884 Offline
Junior Member
Posts: 34
Joined: Apr 2010
Reputation: 0
Post: #41
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/B003T...ss_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=Rem...MCE_remote
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #42
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.
find quote
akr884 Offline
Junior Member
Posts: 34
Joined: Apr 2010
Reputation: 0
Post: #43
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.
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #44
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.
find quote
Shayan Offline
Junior Member
Posts: 4
Joined: Feb 2011
Reputation: 0
Post: #45
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?
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #46
Hi Shayan,

You shouldn't have anything else to do as upstart read it's configuration at each boot.
You can try to check if the service is started at by the following way, after booting up try :
Code:
ps aux | grep hid_mapper
And see if hid_mapper is started. Be careful cause this command will also show your grep, so you should see 2 lines, grep and the hid_mapper if it is started.

If it is not started, then your problem might come from the condition :
Code:
start on started udev

This means that remote mapper should be started once udev is started. Depending on your distribution it might not work. Could you tell me what distribution you are using ?

You could also try to get the condition of another script that runs after udev, for example gdm or kdm. Edit /etc/init/kdm.conf (for example) et copy the "start on" stanza. On ubuntu 10.10 it is :
Code:
start on (filesystem
          and started dbus
          and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
               or stopped udevtrigger))

Then replace start on started udev in your current remote_mapper.conf by the standza you juste copied.
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #47
Hi akr884,

I've finished the first stage of the new version and the beta is now ready. You can find it at :
hid_mapper_beta.tar.gz

You will have to create 2 distinct map files, one for the keyboard actions (you can keep your existing one) and the other for mouse actions. The format is the following :
Quote:00004f0000000000:REL_X:5
0000500000000000:REL_X:-5
0000510000000000:REL_Y:5
0000520000000000:REL_Y:-5
This file maps 4 keys to the 4 different directions of the cursor (right, left, up and down) and the cursor will move by 5 pixels in each case.

You can affect multiple key codes to the same direction but with different movement step, e.g. :
Quote:00004f0000000000:REL_X:5
00004e0000000000:REL_X:10
00004d0000000000:REL_X:15
This will be useful in your case to manage cursor acceleration.

Once your map file is ready, start hid_mapper with the following :
Code:
./hid_mapper --manufacturer '...' --product '...' --map keyboard.map --map-mouse mouse.map

This will load both map files and it should do the trick.

Let me know if it works !
find quote
Shayan Offline
Junior Member
Posts: 4
Joined: Feb 2011
Reputation: 0
Post: #48
coldsource Wrote:Hi Shayan,

You shouldn't have anything else to do as upstart read it's configuration at each boot.
You can try to check if the service is started at by the following way, after booting up try :
Code:
ps aux | grep hid_mapper
And see if hid_mapper is started. Be careful cause this command will also show your grep, so you should see 2 lines, grep and the hid_mapper if it is started.

If it is not started, then your problem might come from the condition :
Code:
start on started udev

This means that remote mapper should be started once udev is started. Depending on your distribution it might not work. Could you tell me what distribution you are using ?

You could also try to get the condition of another script that runs after udev, for example gdm or kdm. Edit /etc/init/kdm.conf (for example) et copy the "start on" stanza. On ubuntu 10.10 it is :
Code:
start on (filesystem
          and started dbus
          and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1
               or stopped udevtrigger))

Then replace start on started udev in your current remote_mapper.conf by the standza you juste copied.

Yeah, I had checked the running processes earlier and had no such luck. Upstart was telling me it wasn't running either when I did a status on the process.

It seems as though it was the start on started udev that was the problem for me. I replaced it with the start on stanza from gdm.conf and now the process starts up great for me. Thanks for your help.

I'm running Ubuntu 10.10
find quote
akr884 Offline
Junior Member
Posts: 34
Joined: Apr 2010
Reputation: 0
Post: #49
Quote:You can affect multiple key codes to the same direction but with different movement step

Coldsource, everything works really well including the acceleration (using 2,4,6... for the pixel movements)

However, my remote sends the presses like this

02 00 xx yy

where 02 00 defines it as a mouse press and xx is movement along the x-axis and yy is movement along the y-axis - so that there are actually 8 classes of mouse movements including diagonals.

I tried to string :REL_X:2:REL_Y:2 and got the message that the 'movement is too long'. I'm sure it's a trivial fix but it makes me wonder why not allow stringed definitions throughout the keymaps? For a keymap, it might be useful to map a button the xxxxxx:KEY_ALT:KEY_F2 for example to launch GnomeDo or something along those lines as just one example.

Edit:
I could probably define
02 00 x1 y1
as a vertical movement 0200x1y1:REL_X:2
then define the same press as a horizontal movement 0200x1y1:REL_Y:2
to get a diagonal movement but that seems like an inelegant hack, so I'll wait for your response coldsource

Also in /usr/include/linux/inputid.h
there's a map for BTN_LEFT and BTN_RIGHT (Mouse Clicks), but HID_MAPPER says it doesn't recognize them - If I add keys to keys_definition.cpp in the top and bottom section - will they work? I'll try it and see
(This post was last modified: 2011-02-14 13:25 by akr884.)
find quote
Shayan Offline
Junior Member
Posts: 4
Joined: Feb 2011
Reputation: 0
Post: #50
Another question regarding the hid_mapper. Has anyone gotten the shutdown command to work with the remote? I can select shutdown from the menu in xbmc and it sends my box into hibernate. But if there was some way i could shut the box down by pressing the power button on my remote, that would be great. Is there a keyboard shortcut that maps directly to shutdown?
find quote
Post Reply