[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: 33
Joined: Apr 2010
Reputation: 0
Post: #106
UsagiYojimbo Wrote:So "A+B" (that is A and B are pressed at the same time) is not likely needed, but "A B" (that is: A is pressed, after which B is pressed) is a possibility...Nerd

I would just say that for my usage case, dragging a scroll bar or highlighting text to copy and paste it (to navigate between something like myp2p.eu and sopcast) would probably require simultaneous key presses or else the drag would interrupt the mouse press to hold onto something.
find quote
UsagiYojimbo Offline
Member
Posts: 85
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #107
akr884 Wrote:I would just say that for my usage case, dragging a scroll bar or highlighting text to copy and paste it (to navigate between something like myp2p.eu and sopcast) would probably require simultaneous key presses or else the drag would interrupt the mouse press to hold onto something.

AFAIK uinput handles mouse movement and key-presses (as well as mouse button presses) differently. So I would say, a key/MB press would not interrupt the mouse movement.

Also for these "sophisticated maneuvers", i believe, it is easier to use a real mouse, like a wireless one...
(This post was last modified: 2011-03-07 17:22 by UsagiYojimbo.)
find quote
UsagiYojimbo Offline
Member
Posts: 85
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Post: #108
UsagiYojimbo Wrote:I found out:
The receiver always sends 6 bytes. If no button pressed for a given time, it sends zeros to fill up...

I made a debugging log (removed condition for learn mode to dump incoming bytes, and inserted printf's to output events):
Code:
00 00 00 00 00 00
00 00 00 00 00 00
43 41 54 00 ff a8
--> Key down event: 68
43 41 54 00 ff 77
--> Key up event: 68
--> Key repeat event: 68
00 00 00 00 00 00
--> Key up event: 68
00 00 00 00 00 00
43 41 54 00 ff 8a
--> Key down event: 67
43 41 54 00 ff 77
--> Key up event: 67
--> Key repeat event: 67
00 00 00 00 00 00
--> Key up event: 67
43 41 54 00 ff 8a
--> Key down event: 67
43 41 54 00 ff 77
--> Key up event: 67
--> Key repeat event: 67
00 00 00 00 00 00
--> Key up event: 67
00 00 00 00 00 00
00 00 00 00 00 00
Maybe this helps...

Some notes about key codes:
Those KEY_ identifiers are key positions on the US keyboards. So if Your keyboard has different mapping, You should check the key-codes on a console.
I just found out that my KEY_Y caused a "z", as well as KEY_0 (zero) caused a letter "รถ" on my Hungarian keyboard...
(This post was last modified: 2011-03-08 00:13 by UsagiYojimbo.)
find quote
UsagiYojimbo Offline
Member
Posts: 85
Joined: Feb 2010
Reputation: 1
Location: Debrecen, Hungary
Lightbulb   
Post: #109
UsagiYojimbo Wrote:The problem occurs, when something get between the key-down and the key-up events.
It also only affects XBMC, or at least it had not occurred in consoles...

I made a solution, by putting the key-up event behind the decoding block. Thus sending a key-up event after every key-down event, and not only on the next button-press...

This way everything is working fine, even repetition! Cool
find quote
coldsource Offline
Junior Member
Posts: 41
Joined: Dec 2010
Reputation: 0
Post: #110
UsagiYojimbo Wrote:I made a solution, by putting the key-up event behind the decoding block. Thus sending a key-up event after every key-down event, and not only on the next button-press...

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

The best thing to do would be to understand why remote is looping. I had a look at your trace but I can't understand why it would loop since every key down seems to be followed by the corresponding key up. Or did I missed something ?
find quote
UsagiYojimbo Offline
Member
Posts: 85
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: 85
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: 85
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: 85
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: 85
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