summaryrefslogtreecommitdiff
path: root/lirc.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-01-31 12:13:39 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2013-01-31 12:13:39 +0100
commit250419d2c9fce77bdd4714d0d7a0debbd893db51 (patch)
tree383521f7519176686c4b5be2ee1d6f578728ef00 /lirc.c
parentd95804fec37c778db08b724d409665eabf20138a (diff)
downloadvdr-250419d2c9fce77bdd4714d0d7a0debbd893db51.tar.gz
vdr-250419d2c9fce77bdd4714d0d7a0debbd893db51.tar.bz2
Improved LIRC timing for repeat function (cont'd)
Diffstat (limited to 'lirc.c')
-rw-r--r--lirc.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/lirc.c b/lirc.c
index 67b955c5..d9bcd66b 100644
--- a/lirc.c
+++ b/lirc.c
@@ -6,7 +6,7 @@
*
* LIRC support added by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
*
- * $Id: lirc.c 2.2 2013/01/30 11:56:38 kls Exp $
+ * $Id: lirc.c 2.3 2013/01/31 12:13:39 kls Exp $
*/
#include "lirc.h"
@@ -15,7 +15,6 @@
#define REPEATDELAY 300 // ms
#define REPEATFREQ 100 // ms
-#define REPEATTIMEOUT 150 // ms
#define RECONNECTDELAY 3000 // ms
cLircRemote::cLircRemote(const char *DeviceName)
@@ -63,8 +62,10 @@ void cLircRemote::Action(void)
{
cTimeMs FirstTime;
cTimeMs LastTime;
+ cTimeMs ThisTime;
char buf[LIRC_BUFFER_SIZE];
char LastKeyName[LIRC_KEY_BUF] = "";
+ bool pressed = false;
bool repeat = false;
int timeout = -1;
@@ -94,12 +95,15 @@ void cLircRemote::Action(void)
esyslog("ERROR: unparseable lirc command: %s", buf);
continue;
}
+ int Delta = ThisTime.Elapsed(); // the time between two subsequent LIRC events
+ ThisTime.Set();
if (count == 0) {
if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < REPEATDELAY)
continue; // skip keys coming in too fast
if (repeat)
Put(LastKeyName, false, true);
strcpy(LastKeyName, KeyName);
+ pressed = true;
repeat = false;
FirstTime.Set();
timeout = -1;
@@ -110,18 +114,24 @@ void cLircRemote::Action(void)
continue; // skip same keys coming in too fast
else {
repeat = true;
- timeout = REPEATTIMEOUT;
+ timeout = Delta * 10 / 9;
}
- LastTime.Set();
- Put(KeyName, repeat);
+ if (pressed)
+ LastTime.Set();
+ Put(KeyName, repeat);
}
- else if (repeat) { // the last one was a repeat, so let's generate a release
- if (LastTime.Elapsed() >= REPEATTIMEOUT) {
- Put(LastKeyName, false, true);
- repeat = false;
- *LastKeyName = 0;
- timeout = -1;
- }
+ else if (pressed && repeat) { // the last one was a repeat, so let's generate a release
+ Put(LastKeyName, false, true);
+ pressed = false;
+ repeat = false;
+ *LastKeyName = 0;
+ timeout = -1;
+ }
+ else {
+ pressed = false;
+ repeat = false;
+ *LastKeyName = 0;
+ timeout = -1;
}
}
}