diff options
Diffstat (limited to 'keys.c')
-rw-r--r-- | keys.c | 127 |
1 files changed, 98 insertions, 29 deletions
@@ -4,40 +4,63 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: keys.c 1.1 2002/09/29 09:56:51 kls Exp $ + * $Id: keys.c 1.3 2002/10/27 15:19:40 kls Exp $ */ #include "keys.h" static tKey keyTable[] = { // "Up" and "Down" must be the first two keys! - { kUp, "Up" }, - { kDown, "Down" }, - { kMenu, "Menu" }, - { kOk, "Ok" }, - { kBack, "Back" }, - { kLeft, "Left" }, - { kRight, "Right" }, - { kRed, "Red" }, - { kGreen, "Green" }, - { kYellow, "Yellow" }, - { kBlue, "Blue" }, - { k0, "0" }, - { k1, "1" }, - { k2, "2" }, - { k3, "3" }, - { k4, "4" }, - { k5, "5" }, - { k6, "6" }, - { k7, "7" }, - { k8, "8" }, - { k9, "9" }, - { kPower, "Power" }, - { kVolUp, "Volume+" }, - { kVolDn, "Volume-" }, - { kMute, "Mute" }, - { kNone, "" }, - { k_Setup, "_Setup" }, - { kNone, NULL }, + { kUp, "Up" }, + { kDown, "Down" }, + { kMenu, "Menu" }, + { kOk, "Ok" }, + { kBack, "Back" }, + { kLeft, "Left" }, + { kRight, "Right" }, + { kRed, "Red" }, + { kGreen, "Green" }, + { kYellow, "Yellow" }, + { kBlue, "Blue" }, + { k0, "0" }, + { k1, "1" }, + { k2, "2" }, + { k3, "3" }, + { k4, "4" }, + { k5, "5" }, + { k6, "6" }, + { k7, "7" }, + { k8, "8" }, + { k9, "9" }, + { kPlay, "Play" }, + { kPause, "Pause" }, + { kStop, "Stop" }, + { kRecord, "Record" }, + { kFastFwd, "FastFwd" }, + { kFastRew, "FastRew" }, + { kPower, "Power" }, + { kChanUp, "Channel+" }, + { kChanDn, "Channel-" }, + { kVolUp, "Volume+" }, + { kVolDn, "Volume-" }, + { kMute, "Mute" }, + { kSchedule, "Schedule" }, + { kChannels, "Channels" }, + { kTimers, "Timers" }, + { kRecordings, "Recordings" }, + { kSetup, "Setup" }, + { kCommands, "Commands" }, + { kUser1, "User1" }, + { kUser2, "User2" }, + { kUser3, "User3" }, + { kUser4, "User4" }, + { kUser5, "User5" }, + { kUser6, "User6" }, + { kUser7, "User7" }, + { kUser8, "User8" }, + { kUser9, "User9" }, + { kNone, "" }, + { k_Setup, "_Setup" }, + { kNone, NULL }, }; // -- cKey ------------------------------------------------------------------- @@ -152,3 +175,49 @@ void cKeys::PutSetup(const char *Remote, const char *Setup) else esyslog("ERROR: called PutSetup() for %s, but setup has already been defined!", Remote); } + +// -- cKeyMacro -------------------------------------------------------------- + +cKeyMacro::cKeyMacro(void) +{ + for (int i = 0; i < MAXKEYSINMACRO; i++) + macro[i] = kNone; +} + +bool cKeyMacro::Parse(char *s) +{ + int n = 0; + char *p; + while ((p = strtok(s, " \t")) != NULL) { + if (n < MAXKEYSINMACRO) { + macro[n] = cKey::FromString(p); + if (macro[n] == kNone) { + esyslog("ERROR: unknown key '%s'", p); + return false; + } + n++; + s = NULL; + } + else { + esyslog("ERROR: key macro too long"); + return false; + } + } + if (n < 2) { + esyslog("ERROR: empty key macro"); + } + return true; +} + +// -- cKeyMacros ------------------------------------------------------------- + +cKeyMacros KeyMacros; + +const cKeyMacro *cKeyMacros::Get(eKeys Key) +{ + for (cKeyMacro *k = First(); k; k = Next(k)) { + if (*k->Macro() == Key) + return k; + } + return NULL; +} |