diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2000-07-15 16:35:18 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2000-07-15 16:35:18 +0200 |
commit | c9e45322981dbe4c235ad7b9909138626184666f (patch) | |
tree | ee9a63907dc6bf1fff8b208e9ec46bb26589c61f | |
parent | 744849128df1318b70349223685d9fce8cf805c5 (diff) | |
download | vdr-c9e45322981dbe4c235ad7b9909138626184666f.tar.gz vdr-c9e45322981dbe4c235ad7b9909138626184666f.tar.bz2 |
Fixed/improved LIRC key handling
-rw-r--r-- | config.c | 10 | ||||
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | remote.c | 12 | ||||
-rw-r--r-- | remote.h | 6 | ||||
-rw-r--r-- | vdr.c | 6 |
5 files changed, 25 insertions, 12 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.8 2000/07/15 12:39:20 kls Exp $ + * $Id: config.c 1.9 2000/07/15 16:35:18 kls Exp $ */ #include "config.h" @@ -54,6 +54,12 @@ void cKeys::Clear(void) k->code = 0; } +void cKeys::SetDummyValues(void) +{ + for (tKey *k = keys; k->type != kNone; k++) + k->code = k->type + 1; // '+1' to avoid 0 +} + bool cKeys::Load(char *FileName) { isyslog(LOG_INFO, "loading %s", FileName); @@ -150,7 +156,7 @@ unsigned int cKeys::Encode(const char *Command) { if (Command != NULL) { const tKey *k = keys; - while ((k->type != kNone) && strncmp(k->name, Command, strlen(k->name)) != 0) // must use 'strncmp()' because LIRC delivers trailing characters! + while ((k->type != kNone) && strcmp(k->name, Command) != 0) k++; return k->code; } @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.7 2000/06/24 13:42:32 kls Exp $ + * $Id: config.h 1.8 2000/07/15 16:26:57 kls Exp $ */ #ifndef __CONFIG_H @@ -50,6 +50,7 @@ public: tKey *keys; cKeys(void); void Clear(void); + void SetDummyValues(void); bool Load(char *FileName = NULL); bool Save(void); unsigned int Encode(const char *Command); @@ -6,7 +6,7 @@ * * Ported to LIRC by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16. * - * $Id: remote.c 1.9 2000/07/15 12:19:50 kls Exp $ + * $Id: remote.c 1.10 2000/07/15 16:34:35 kls Exp $ */ #include "remote.h" @@ -365,17 +365,20 @@ cRcIoLIRC::~cRcIoLIRC() const char *cRcIoLIRC::ReceiveString(void) { + char buf[LIRC_BUFFER_SIZE]; + while (InputAvailable(true)) { if (read(f, buf, sizeof(buf)) > 21) { - const int repeat = 10 * (buf[17] - '0') + (buf[18] - '0'); const int now = time_ms(); + int repeat; + sscanf(buf, "%*s %x %7s", &repeat, keyName); // '7' in '%7s' is LIRC_KEY_BUF-1! if (repeat == 0) { firstTime = lastTime = now; - return buf + 20; + return keyName; } else if ((now > firstTime + REPEATDELAY) && (now > lastTime + REPEATLIMIT)) { lastTime = now; - return buf + 20; + return keyName; } } } @@ -384,6 +387,7 @@ const char *cRcIoLIRC::ReceiveString(void) void cRcIoLIRC::Flush(int WaitSeconds) { + char buf[LIRC_BUFFER_SIZE]; time_t t0 = time(NULL); for (;;) { @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remote.h 1.6 2000/06/24 15:52:56 kls Exp $ + * $Id: remote.h 1.7 2000/07/15 16:32:43 kls Exp $ */ #ifndef __REMOTE_H @@ -75,9 +75,9 @@ public: class cRcIoLIRC : public cRcIoBase { private: - enum { LIRC_BUFFER_SIZE = 128 }; + enum { LIRC_KEY_BUF = 8, LIRC_BUFFER_SIZE = 128 }; int f; - char buf[LIRC_BUFFER_SIZE]; + char keyName[LIRC_KEY_BUF]; const char *ReceiveString(void); public: cRcIoLIRC(char *DeviceName); @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.20 2000/07/15 11:45:05 kls Exp $ + * $Id: vdr.c 1.21 2000/07/15 16:26:57 kls Exp $ */ #include <signal.h> @@ -58,7 +58,9 @@ int main(int argc, char *argv[]) Channels.Load("channels.conf"); Timers.Load("timers.conf"); -#ifndef REMOTE_LIRC +#ifdef REMOTE_LIRC + Keys.SetDummyValues(); +#else if (!Keys.Load(KEYS_CONF)) Interface.LearnKeys(); #endif |