Implemented key macros

This commit is contained in:
Klaus Schmidinger
2002-10-27 15:46:30 +01:00
parent 74c74fb5d2
commit 64fd9c4a1b
9 changed files with 137 additions and 7 deletions

57
keys.c
View File

@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: keys.c 1.2 2002/10/27 14:00:49 kls Exp $
* $Id: keys.c 1.3 2002/10/27 15:19:40 kls Exp $
*/
#include "keys.h"
@@ -49,6 +49,15 @@ static tKey keyTable[] = { // "Up" and "Down" must be the first two keys!
{ 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 },
@@ -166,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;
}