From 9b3b98f88f3b29c4df704fa321bb882aaa7207c1 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 28 May 2006 08:49:52 +0200 Subject: Improved the repeat function for LIRC remote controls --- lirc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lirc.c') diff --git a/lirc.c b/lirc.c index 9bb83287..c4838b16 100644 --- a/lirc.c +++ b/lirc.c @@ -6,16 +6,16 @@ * * LIRC support added by Carsten Koch 2000-06-16. * - * $Id: lirc.c 1.14 2006/01/27 15:59:47 kls Exp $ + * $Id: lirc.c 1.15 2006/05/28 08:48:13 kls Exp $ */ #include "lirc.h" #include #include -#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 @@ void cLircRemote::Action(void) 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 @@ void cLircRemote::Action(void) 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 @@ void cLircRemote::Action(void) 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; -- cgit v1.2.3