[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
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: 33
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
Psycho_Dad Offline
Junior Member
Posts: 6
Joined: Feb 2011
Reputation: 0
Post: #51
Hi coldsource!

I have the same remote as akr884 has and I've finally managed to capture its key codes with your mapper. I've tried to use the remote with LIRC before to no avail.

However I don't want to use XBMC at all and I would like to know if I can use the information (the key codes that the mapper lists for me when I'm clicking on my remote like there's no tomorrow :) somehow to control other applications.

I've just migrated from Windows to Ubuntu and I used my remote through EventGhost, but I couldn't find similar stuff for Linux (expect LIRC which did not worked). So what I want to do is to create key mapping profiles for different applications (like in EventGhost). Anyone done something similar? Any ideas?

Oh yes, the "remote blacklist in /usr/share/X11/xorg.conf.d" was just perfect, my remote has buttons which switch to and between virtual consoles. :D It was quite a headache!

Thanks in advance!
find quote
hoyanf Offline
Junior Member
Posts: 5
Joined: Nov 2010
Reputation: 0
Post: #52
Hi,

This is what I get when I run the command :-

Code:
sudo /usr/local/bin/hid_mapper --manufacturer '13ec' --product '0006' --map /etc/hid_mapper/zydacron-remote.map
Loaded map file /etc/hid_mapper/zydacron-remote.map
Unable to find specified HID device

System Info :-
Code:
uname -a
Linux XBMCLive 2.6.32-26-generic #48-Ubuntu SMP Wed Nov 24 09:00:03 UTC 2010 i686 GNU/Linux

lsmod | grep uinput
uinput                  6312  0

which hid_mapper
/usr/local/bin/hid_mapper

hid_mapper --list-devices --lookup-id
Found HID device at /dev/hidraw0
  Manufacturer : 04d9
  Product name : 0321

Found HID device at /dev/hidraw1
  Manufacturer : 04d9
  Product name : 0321

Found HID device at /dev/hidraw2
  Manufacturer : 13ec
  Product name : 0006

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 13ec:0006 Zydacron HID Remote Control
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 04d9:0321 Holtek Semiconductor, Inc.
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Btw just to correct that xorg.conf.d is at on "Dharma" :-
Code:
/usr/lib/X11/xorg.conf.d/
Is there anything else to do ?


Thanks

hoyanf
(This post was last modified: 2011-02-13 20:21 by hoyanf.)
find quote
hoyanf Offline
Junior Member
Posts: 5
Joined: Nov 2010
Reputation: 0
Post: #53
hoyanf Wrote:Hi,

This is what I get when I run the command :-

Code:
sudo /usr/local/bin/hid_mapper --manufacturer '13ec' --product '0006' --map /etc/hid_mapper/zydacron-remote.map
Loaded map file /etc/hid_mapper/zydacron-remote.map
Unable to find specified HID device

System Info :-
Code:
uname -a
Linux XBMCLive 2.6.32-26-generic #48-Ubuntu SMP Wed Nov 24 09:00:03 UTC 2010 i686 GNU/Linux

lsmod | grep uinput
uinput                  6312  0

which hid_mapper
/usr/local/bin/hid_mapper

hid_mapper --list-devices --lookup-id
Found HID device at /dev/hidraw0
  Manufacturer : 04d9
  Product name : 0321

Found HID device at /dev/hidraw1
  Manufacturer : 04d9
  Product name : 0321

Found HID device at /dev/hidraw2
  Manufacturer : 13ec
  Product name : 0006

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 13ec:0006 Zydacron HID Remote Control
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 04d9:0321 Holtek Semiconductor, Inc.
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Btw just to correct that xorg.conf.d is at on "Dharma" :-
Code:
/usr/lib/X11/xorg.conf.d/
Is there anything else to do ?


Thanks

hoyanf

Hi,

My current problem encountered :-

Code:
sudo hid_mapper --lookup-id --manufacturer '13ec' --product '0006' --map /etc/hid_mapper/zydacron.map
[sudo] password for mctr:
Loaded map file /etc/hid_mapper/zydacron.map
Found HID device
Opened HID interface on /dev/hidraw2
Unable to setup event device

Anything else to try ??

Thanks

hoyanf
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #54
Hi hoyanf,
You have to use --lookup-id to specify hexadecimal manufacturer and product name, but I think you finally found it.

For the error "Unable to setup event device" you might want to try :
Code:
sudo modprobe uinput
Then try re-launching hid_mapper it should work.

Psycho_Dad:
For the general questions about the mapper, it can be used with any application, not necessarily xbmc as it emulates real key presses. Changing profiles is not yet feasible but it should be quite easy to adapt with multiple mapping files. You would just have to determine which way you want to change of profile.
find quote
UsagiYojimbo Offline
Member
Posts: 85
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Question  Repetition
Post: #55
Every time I press a button on my remote it sends 2 key event to the HID device, E.G:
Code:
43415400FF7A
43415400FF77
The first selects the ENTER button, the second says it is pressed. I case of repetition only the latter one repeats.
Is it possible to map this? E.G to a "repeat-last-key" key-code? Confused

Another question:
Is it possible to put comments in the map-file? It could make map-files more human readable. Nerd
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #56
akr884 Wrote: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.

Hi akr884, I've finished the new beta version which should do what you need :
hid_mapper_beta.tar.gz

You can now affect multiple events to the same code and use wildcards in event definition. For your mouse, you should use something like this :
Quote:0000XX01:REL_X:4
0000XX02:REL_X:8
000001XX:REL_Y:4
000002XX:REL_Y:8

The first 2 lines map events ending by 01 or 02 on the X axis whatever the previous code is. The following 2 lines works the same way for the Y axis. So if your remote sends a code like 00000101 it will trigger 2 events for the X and Y axis et thus move the cursor by 4 pixels in diagonal.
So you should be able to keep your existing mapping and just add XX to hide unwanted codes.

I haven't yet mapped the BTN_CLICK as it is a little more tricky than keyboard when you use drag'n drop functions. It is not so easy to keep generic code and detect button up codes properly, but it should be possible. I'll let you test this first update and if everything works well, add buttons.

UsagiYojimbo Wrote:Is it possible to put comments in the map-file
I've added comment support in this release, you can use # to comment whole lines or to add comments at the end of a line.

UsagiYojimbo Wrote:I case of repetition only the latter one repeats.
Is it possible to map this? E.G to a "repeat-last-key" key-code?
Yes I'll add special mapping like CORE::REPEAT_LAST to do that. I'll release this with the mouse buttons as I said to akr884.
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #57
Thanks so much for this! I haven't tested it with my remote yet, but I played around using a spare trackball at work and it all worked perfectly.
find quote
UsagiYojimbo Offline
Member
Posts: 85
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #58
coldsource Wrote:I've added comment support in this release, you can use # to comment whole lines or to add comments at the end of a line.
Thanks for the hash mark, I put in some already, like buttons I still to be mapped...Nerd

However, currently uinput device is not really working with XBMC:
  • When I press buttons in a console (like 1, 2, 3...) the characters of the key-presses appear, correctly.Nod
  • In XBMC when I press a movement key, (E.G. Left,) the selection steps one to the left, and about a half seconds later it steps again, this time 2-10 steps...No

I do not know what causes this behavior. Maybe it is just for the movement keys... I will test that again!
find quote
ximon Offline
Member
Posts: 94
Joined: Jan 2009
Reputation: 2
Location: Nantes, France
Post: #59
Hello, I wonder if anyone can help me, I seem to be stuck fairly early on in the process - I can't seem to blacklist my remote (on xbmclive).

./hid_mapper --list-devices --lookup-id returns:
Code:
Found HID device at /dev/hidraw0
  Manufacturer : 1241
  Product name : e000

Found HID device at /dev/hidraw1
  Manufacturer : 1241
  Product name : e000

And my 50-remote.conf (in /usr/lib/X11/xorg.conf.d/) contains:
Code:
Section "InputClass"
Identifier "Remote blacklist"
MatchProduct "1241:e000"
Option "Ignore" "on"
EndSection

I have also tried '1241 e000' and 'e000' on the MatchProduct line, but every time my stupid remote keeps on working!

Any ideas how I can get Xorg to ignore my remote so I can continue to set up the HID mapper?

Thanks in advanceā€¦
find quote
UsagiYojimbo Offline
Member
Posts: 85
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #60
UsagiYojimbo Wrote:
  • In XBMC when I press a movement key, (E.G. Left,) the selection steps one to the left, and about a half seconds later it steps again, this time 2-10 steps...No
I do not know what causes this behavior. Maybe it is just for the movement keys... I will test that again!
I have looked in into your sources, and I found this:
In main.cpp from line 210 there is block that tries to find the end of the source event. However, my button press events are like this:
Code:
43415400FF7A
43415400FF77
As there is a zero byte inside the event, this code would find a wrong length, and in turn from line 230, no key-up-event is sent.
So I removed the first condition, and my remote works perfectly.Nerd
find quote
Post Reply