lirc improvement suggestion

Message ID 1148760266.5182.27.camel@localhost.localdomain
State New
Headers

Commit Message

Ville Skyttä May 27, 2006, 8:04 p.m. UTC
  On Sat, 2006-05-27 at 19:27 +0200, Joerg Riechardt wrote:
> I used to use the usbremote plugin, now I switched to lirc, because I
> wanted to play with irexec. Since then vdr didn´t react to my remote
> control as I was used to any more. I had sometimes double reactions on
> one keypress as other people have described and the speed of the
> reactions was weird. After investigating I found following solution,
> which makes me 100% happy. Maybe other people like it too?

I like it.  The patch you posted had some whitespace/linewrap issues
though, which are hopefully fixed by the attached one (no other changes
in it).
  

Comments

Darren Salt June 6, 2006, 4:12 p.m. UTC | #1
I demand that Ville Skyttä may or may not have written...

> --- vdr-1.4.0/lirc.c~	2006-01-27 17:59:47.000000000 +0200
> +++ vdr-1.4.0/lirc.c	2006-05-27 22:04:19.000000000 +0300
> @@ -13,9 +13,9 @@
>  #include <netinet/in.h>
>  #include <sys/socket.h>

> -#define REPEATLIMIT  20 // ms
>  #define REPEATDELAY 350 // ms
> -#define KEYPRESSDELAY 150 // ms
> +#define REPEATFREQ 100 // ms

No. You want at least 114 (for RC5).

[snip]
  
Joerg Riechardt June 6, 2006, 5:51 p.m. UTC | #2
Darren Salt schrieb:
> I demand that Ville Skyttä may or may not have written...
> 
>> --- vdr-1.4.0/lirc.c~	2006-01-27 17:59:47.000000000 +0200
>> +++ vdr-1.4.0/lirc.c	2006-05-27 22:04:19.000000000 +0300
>> @@ -13,9 +13,9 @@
>>  #include <netinet/in.h>
>>  #include <sys/socket.h>
> 
>> -#define REPEATLIMIT  20 // ms
>>  #define REPEATDELAY 350 // ms
>> -#define KEYPRESSDELAY 150 // ms
>> +#define REPEATFREQ 100 // ms
> 
> No. You want at least 114 (for RC5).
> 
> [snip]

Do you mean REPEATFREQ? It works well here with RC5 and 100.
Doesn´t it work for you??
Jörg
  
Darren Salt June 6, 2006, 6:52 p.m. UTC | #3
I demand that Joerg Riechardt may or may not have written...

> Darren Salt schrieb:
>> I demand that Ville Skyttä may or may not have written...
[snip]
>>> -#define REPEATLIMIT  20 // ms
>>>  #define REPEATDELAY 350 // ms
>>> -#define KEYPRESSDELAY 150 // ms
>>> +#define REPEATFREQ 100 // ms
>> No. You want at least 114 (for RC5).
>> [snip]

> Do you mean REPEATFREQ? It works well here with RC5 and 100.

(Actually, it's also misnamed: that's a repeat interval.)

The RC5 repeat interval is (IIRC) 113.4ms. Any soft repeat handler needs to
have an interval which is no less than this else sometimes you'll be unable
to avoid an extra repeat.

> Doesn't it work for you??

Not checked; I'm using LIRC via gxine and irexec.
  
Joerg Riechardt June 6, 2006, 8:04 p.m. UTC | #4
Darren Salt schrieb:
> I demand that Joerg Riechardt may or may not have written...
> 
>> Darren Salt schrieb:
>>> I demand that Ville Skyttä may or may not have written...
> [snip]
>>>> -#define REPEATLIMIT  20 // ms
>>>>  #define REPEATDELAY 350 // ms
>>>> -#define KEYPRESSDELAY 150 // ms
>>>> +#define REPEATFREQ 100 // ms
>>> No. You want at least 114 (for RC5).
>>> [snip]
> 
>> Do you mean REPEATFREQ? It works well here with RC5 and 100.
> 
> (Actually, it's also misnamed: that's a repeat interval.)
> 
> The RC5 repeat interval is (IIRC) 113.4ms. Any soft repeat handler needs to
> have an interval which is no less than this else sometimes you'll be unable
> to avoid an extra repeat.

If you look at how the code works, you will find that that´s not true.
And the repeat interval (incoming keys) depends on the lirc driver. With 
different drivers there are different intervals for the same remote. And 
I am not writing from theory, i checked it.
Jörg

> 
>> Doesn't it work for you??
> 
> Not checked; I'm using LIRC via gxine and irexec.
>
  

Patch

--- vdr-1.4.0/lirc.c~	2006-01-27 17:59:47.000000000 +0200
+++ vdr-1.4.0/lirc.c	2006-05-27 22:04:19.000000000 +0300
@@ -13,9 +13,9 @@ 
 #include <netinet/in.h>
 #include <sys/socket.h>
 
-#define REPEATLIMIT  20 // ms
 #define REPEATDELAY 350 // ms
-#define KEYPRESSDELAY 150 // ms
+#define REPEATFREQ 100 // ms
+#define REPEATTIMEOUT 500 // ms
 #define RECONNECTDELAY 3000 // ms
 
 cLircRemote::cLircRemote(const char *DeviceName)
@@ -94,7 +94,7 @@ 
               continue;
               }
            if (count == 0) {
-              if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < KEYPRESSDELAY)
+              if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < REPEATDELAY)
                  continue; // skip keys coming in too fast
               if (repeat)
                  Put(LastKeyName, false, true);
@@ -104,8 +104,10 @@ 
               timeout = -1;
               }
            else {
+              if (LastTime.Elapsed() < REPEATFREQ)
+                 continue; // repeat function kicks in after a short delay (after last key instead of first key)
               if (FirstTime.Elapsed() < REPEATDELAY)
-                 continue; // repeat function kicks in after a short delay
+                 continue; // skip keys coming in too fast (for count != 0 as well)
               repeat = true;
               timeout = REPEATDELAY;
               }
@@ -113,7 +115,7 @@ 
            Put(KeyName, repeat);
            }
         else if (repeat) { // the last one was a repeat, so let's generate a release
-           if (LastTime.Elapsed() >= REPEATDELAY) {
+           if (LastTime.Elapsed() >= REPEATTIMEOUT) {
               Put(LastKeyName, false, true);
               repeat = false;
               *LastKeyName = 0;