summaryrefslogtreecommitdiff
path: root/lirc.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-12-19 18:08:09 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2004-12-19 18:08:09 +0100
commitc49253824a46a45dac86d2a0404b9d5c6e1a92a4 (patch)
treec81bb3537cd4670d6eddc062d0f0f92a43ade8d2 /lirc.c
parentce8369251cf64919a7f1a8333201d87f92fb2f14 (diff)
downloadvdr-c49253824a46a45dac86d2a0404b9d5c6e1a92a4.tar.gz
vdr-c49253824a46a45dac86d2a0404b9d5c6e1a92a4.tar.bz2
Replaced time_ms() with a threadsafe and non-overflowing cTimeMs
Diffstat (limited to 'lirc.c')
-rw-r--r--lirc.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lirc.c b/lirc.c
index ae905fdc..8fe585ab 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 1.8 2004/12/18 13:25:11 kls Exp $
+ * $Id: lirc.c 1.9 2004/12/19 18:05:13 kls Exp $
*/
#include "lirc.h"
@@ -52,8 +52,8 @@ bool cLircRemote::Ready(void)
void cLircRemote::Action(void)
{
- int FirstTime = 0;
- int LastTime = 0;
+ cTimeMs FirstTime;
+ cTimeMs LastTime;
char buf[LIRC_BUFFER_SIZE];
char LastKeyName[LIRC_KEY_BUF] = "";
bool repeat = false;
@@ -75,28 +75,27 @@ void cLircRemote::Action(void)
int count;
char KeyName[LIRC_KEY_BUF];
sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1!
- int Now = time_ms();
if (count == 0) {
- if (strcmp(KeyName, LastKeyName) == 0 && Now - FirstTime < KEYPRESSDELAY)
+ if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < KEYPRESSDELAY)
continue; // skip keys coming in too fast
if (repeat)
Put(LastKeyName, false, true);
strcpy(LastKeyName, KeyName);
repeat = false;
- FirstTime = Now;
+ FirstTime.Set();
timeout = -1;
}
else {
- if (Now - FirstTime < REPEATDELAY)
+ if (FirstTime.Elapsed() < REPEATDELAY)
continue; // repeat function kicks in after a short delay
repeat = true;
timeout = REPEATDELAY;
}
- LastTime = Now;
+ LastTime.Set();
Put(KeyName, repeat);
}
else if (repeat) { // the last one was a repeat, so let's generate a release
- if (time_ms() - LastTime >= REPEATDELAY) {
+ if (LastTime.Elapsed() >= REPEATDELAY) {
Put(LastKeyName, false, true);
repeat = false;
*LastKeyName = 0;