[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
UsagiYojimbo Offline
Member
Posts: 83
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #111
coldsource Wrote:Hi UsagiYojimbo and thanks for debugging this. The problem with this solution is that in normal operation mode on a keyboard, you only send a key down event, wait for some time and then send the key up event. The repetition is generated by your underlying system (Xorg) as it sees the key stay pressed. So if you send the key up directly after the key down, most remote won't work because they won't send key down again (until you release the button).

I think, this could be the cause of my problems, as you code send key-up event before the next key-down event, which may be a few seconds away...

Anyhow, my remote sends select-press-press-... codes. That is for a single button-press it gives a select code, and a single press code, while for repetition it would give a select code, and multiple press codes.
So the select code being mapped to a key-dovn event, and the press codes mapped to key repetition, (skipping the first one,) it works.

I was thinking about to send you a patched version for testing...
find quote
MrFX Offline
Junior Member
Posts: 14
Joined: Dec 2010
Reputation: 0
Post: #112
Hi,

i have a similar problem with endless repeating once a key is pressed...

Here are two sample remote codes:

01071400220000:KEY_UP
01071400230000:KEY_DOWN

I've build this USB IR Receiver: http://www.mikrocontroller.net/articles/...e_Receiver , which provides a raw HID device and forwards the received codes from any remote.

The codes (from a universal remote with RC5 enabled) above are well recogniced by the mapper, but with the created map file the codes "running" endless.

What can i do to prevent this behavior?

Thanks,
MrFX
find quote
UsagiYojimbo Offline
Member
Posts: 83
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #113
MrFX Wrote:i have a similar problem with endless repeating once a key is pressed...

First try it on a console, with buttons mapped to letters or numbers.
find quote
UsagiYojimbo Offline
Member
Posts: 83
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Lightbulb    Post: #114
UsagiYojimbo Wrote:I was thinking about to send you a patched version for testing...

Here is a diff (without the logging):
Code:
236c236,242
< //            else
---
>             if(last_key_down!=0)
>             {
>                 send_key_up_event(uinput_fd,last_key_down);
>                 last_key_code = last_key_down;
>                 last_key_down = 0;
>             }
>             else
272,277d277
<             if(last_key_down!=0)
<             {
<                 send_key_up_event(uinput_fd,last_key_down);
<                 last_key_code = last_key_down;
<                 last_key_down = 0;
<             }
find quote
MrFX Offline
Junior Member
Posts: 14
Joined: Dec 2010
Reputation: 0
Post: #115
Hi,

UsagiYojimbo Wrote:First try it on a console, with buttons mapped to letters or numbers.

i've tried it in xterm, but the keys are running endless...
Within the normal console (where i started the mapper) there is no such a behaviour.

Best regards,
MrFX
find quote
UsagiYojimbo Offline
Member
Posts: 83
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #116
MrFX Wrote:i've tried it in xterm, but the keys are running endless...
Within the normal console (where i started the mapper) there is no such a behaviour.

I believe my change would solve Your problem, too. But let us let coldsource test it... Nerd
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #117
Hi everyone and thanks for the feedback.

I've made a new beta version based on your remarks to correct the endless key repetition :
hid_mapper_beta.tar.gz

I've added the --disable-repetition switch to disable key repetition from hid_mapper. So when setting this switch, it is the responsability of the remote to send repeted key codes, thus making repetition working.

Setting this flag do not mean that key repetition won't work, it just tells hid_mapper to not worry about it. I'm forced to make it via a command line switch because some remote don't send key repetition, and so won't work anymore with this behavior.

Please let me know if it works for you UsagiYojimbo and MrFX.
find quote
MrFX Offline
Junior Member
Posts: 14
Joined: Dec 2010
Reputation: 0
Post: #118
Hi coldsource,

thanks for this release... now it works for me with the option above.
I've added to my map file also the ":CORE::LAST_KEY" option for some keys, because the code is slightly different (last digit is 1 instead of 0), if i long press the buttons:

01071400220000:KEY_UP
01071400230000:KEY_DOWN
01071400220001:CORE::LAST_KEY #(up-repetition)
01071400230001:CORE::LAST_KEY #(down-repetition)

I will now write a complete map file for all the keys and make a link to this thread in the mikrocontroller board

Have a nice day,
MrFX
find quote
UsagiYojimbo Offline
Member
Posts: 83
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Lightbulb    Post: #119
MrFX Wrote:01071400220000:KEY_UP
01071400230000:KEY_DOWN
01071400220001:CORE::LAST_KEY #(up-repetition)
01071400230001:CORE::LAST_KEY #(down-repetition)

I do not know whether it is working in the key mapping, or just in the mouse mapping, but try to use XXs in the repetition line. Like this:
' Wrote:01071400220000:KEY_UP
01071400230000:KEY_DOWN
01071400XX0001:CORE::LAST_KEY

BTW this is the diff of the final version I made for my remote:
(Well, it is for the last version before the current, as I see...)
Code:
217d216
<     int counter = 0;
237c236,242
< //            else
---
>             if(last_key_down!=0)
>             {
>                 send_key_up_event(uinput_fd,last_key_down);
>                 last_key_code = last_key_down;
>                 last_key_down = 0;
>             }
>             else
248d252
<                             counter = 0;
263c267
<                                     if(!last_key_code || !counter++)
---
>                                     if(!last_key_code)
274,279d277
<             if(last_key_down!=0)
<             {
<                 send_key_up_event(uinput_fd,last_key_down);
<                 last_key_code = last_key_down;
<                 last_key_down = 0;
<             }
I only added a counter that gets zeroed on every key press event, and incremented by the repetition events, thus the first repetition could be skipped.
(This post was last modified: 2011-03-14 18:48 by UsagiYojimbo.)
find quote
MrFX Offline
Junior Member
Posts: 14
Joined: Dec 2010
Reputation: 0
Post: #120
Hi,
thanks for the hint, but my map with the entries above is working well.

Best regards,
MrFX
find quote
Post Reply