From 64fd9c4a1b44b125c67455b5b1b45fedcec7e4da Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 27 Oct 2002 15:46:30 +0100 Subject: Implemented key macros --- HISTORY | 4 ++++ MANUAL | 3 +++ keymacros.conf | 11 +++++++++++ keys.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- keys.h | 21 ++++++++++++++++++++- remote.c | 18 +++++++++++++++++- remote.h | 5 +++-- vdr.5 | 16 +++++++++++++++- vdr.c | 9 ++++++++- 9 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 keymacros.conf diff --git a/HISTORY b/HISTORY index 81792ecd..f53d55ea 100644 --- a/HISTORY +++ b/HISTORY @@ -1663,3 +1663,7 @@ Video Disk Recorder Revision History control provides keys you want to assign these functions to, you can delete your 'remote.cof' file and restart VDR to go through the key learning procedure again in order to assign these new keys. See MANUAL for more information. +- The new configuration file 'keymacros.conf' can be used to assign macros to + the color buttons in normal viewing mode, as well as to up to 9 user defined + keys. See MANUAL and man vdr(5) for more information. The default 'keymacros.conf' + implements the functionality of the "color button patch". diff --git a/MANUAL b/MANUAL index d46e52cf..3c0504e7 100644 --- a/MANUAL +++ b/MANUAL @@ -49,6 +49,9 @@ Video Disk Recorder User's Manual Setup | Commands / + User1...9 additional user defined keys for macro functions + (defined in 'keymacros.conf') + (1) The "On/Off" button in the "Timers" menu only works if sorting the timers has been enabled in the "Setup" menu. Otherwise the Blue button is used to "mark" a timer for moving. diff --git a/keymacros.conf b/keymacros.conf new file mode 100644 index 00000000..767d49d3 --- /dev/null +++ b/keymacros.conf @@ -0,0 +1,11 @@ +# Remote control key macros for VDR +# +# Format: +# +# macrokey key1 key2 key3... +# +# See man vdr(5) + +Red Recordings +Green Schedule +Blue Timers diff --git a/keys.c b/keys.c index d3f323e0..4647f3ae 100644 --- a/keys.c +++ b/keys.c @@ -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; +} diff --git a/keys.h b/keys.h index 606772f0..ceb2d1c8 100644 --- a/keys.h +++ b/keys.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: keys.h 1.2 2002/10/27 13:58:55 kls Exp $ + * $Id: keys.h 1.3 2002/10/27 15:18:21 kls Exp $ */ #ifndef __KEYS_H @@ -44,6 +44,7 @@ enum eKeys { // "Up" and "Down" must be the first two keys! kRecordings, kSetup, kCommands, + kUser1, kUser2, kUser3, kUser4, kUser5, kUser6, kUser7, kUser8, kUser9, kNone, k_Setup, // The following flags are OR'd with the above codes: @@ -99,4 +100,22 @@ public: extern cKeys Keys; +#define MAXKEYSINMACRO 16 + +class cKeyMacro : public cListObject { +private: + eKeys macro[MAXKEYSINMACRO]; +public: + cKeyMacro(void); + bool Parse(char *s); + const eKeys *Macro(void) const { return macro; } + }; + +class cKeyMacros : public cConfig { +public: + const cKeyMacro *Get(eKeys Key); + }; + +extern cKeyMacros KeyMacros; + #endif //__KEYS_H diff --git a/remote.c b/remote.c index 05ce6063..6078c26b 100644 --- a/remote.c +++ b/remote.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remote.c 1.29 2002/10/12 15:22:08 kls Exp $ + * $Id: remote.c 1.30 2002/10/27 15:15:58 kls Exp $ */ #include "remote.h" @@ -84,6 +84,22 @@ bool cRemote::Put(eKeys Key) return true; // only a real key shall report an overflow! } +bool cRemote::PutMacro(eKeys Key) +{ + const cKeyMacro *km = KeyMacros.Get(Key); + if (km) { + for (int i = 1; i < MAXKEYSINMACRO; i++) { + if (km->Macro()[i] != kNone) { + if (!Put(km->Macro()[i])) + return false; + } + else + break; + } + } + return true; +} + bool cRemote::Put(uint64 Code, bool Repeat, bool Release) { char buffer[32]; diff --git a/remote.h b/remote.h index f715ade7..2bb9ea53 100644 --- a/remote.h +++ b/remote.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remote.h 1.17 2002/09/29 11:26:45 kls Exp $ + * $Id: remote.h 1.18 2002/10/27 15:16:50 kls Exp $ */ #ifndef __REMOTE_H @@ -20,7 +20,7 @@ typedef unsigned long long int uint64; class cRemote : public cListObject { private: - enum { MaxKeys = 16 }; + enum { MaxKeys = MAXKEYSINMACRO }; static eKeys keys[MaxKeys]; static int in; static int out; @@ -42,6 +42,7 @@ public: static void SetLearning(bool On) { learning = On; } static void Clear(void); static bool Put(eKeys Key); + static bool PutMacro(eKeys Key); static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL); }; diff --git a/vdr.5 b/vdr.5 index 44ecd6a2..2db8a7b6 100644 --- a/vdr.5 +++ b/vdr.5 @@ -8,7 +8,7 @@ .\" License as specified in the file COPYING that comes with the .\" vdr distribution. .\" -.\" $Id: vdr.5 1.10 2002/10/20 14:15:40 kls Exp $ +.\" $Id: vdr.5 1.11 2002/10/27 15:36:44 kls Exp $ .\" .TH vdr 5 "7 Oct 2002" "1.2.0" "Video Disk Recorder Files" .SH NAME @@ -323,6 +323,20 @@ PC keyboard, RCU for the home-built "Remote Control Unit", or LIRC for the "Linux Infrared Remote Control"), \fBkey\fR is the name of the key that is defined (like Up, Down, Menu etc.), and \fBcode\fR is a character string that this remote control delivers when the given key is pressed. +.SS KEY MACROS +The file \fIkeymacros.conf\fR contains user defined macros that will be executed +whenever the given key is pressed. The format is + +\fBmacrokey key1 key2 key3...\fR + +where \fBmacrokey\fR is the key that shall initiate execution of this macro +and can be one of \fIRed\fR, \fIGreen\fR, \fIYellow\fR, \fIBlue\fR or +\fIUser1\fR...\fIUser9\fR. The rest of the line consists of a set of +keys, which will be executed just as if they had been pressed in the given +sequence. Note that the color keys will only execute their macro function +in "normal viewing" mode (i.e. when no other menu or player is active). The +\fIUser1\fR...\fIUser9\fR keys will always execute their macro function. +There may be up to 15 keys in such a key sequence. .SS COMMANDS The file \fIcommands.conf\fR contains the definitions of commands that can be executed from the \fBvdr\fR main menu's "Commands" option. diff --git a/vdr.c b/vdr.c index ae83fd32..41d20477 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.129 2002/10/27 14:32:06 kls Exp $ + * $Id: vdr.c 1.130 2002/10/27 15:20:56 kls Exp $ */ #include @@ -324,6 +324,7 @@ int main(int argc, char *argv[]) SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true); CaDefinitions.Load(AddDirectory(ConfigDirectory, "ca.conf"), true); Keys.Load(AddDirectory(ConfigDirectory, "remote.conf")); + KeyMacros.Load(AddDirectory(ConfigDirectory, "keymacros.conf"), true); // DVB interfaces: @@ -468,6 +469,7 @@ int main(int argc, char *argv[]) case kRecordings: DirectMainFunction(osRecordings); break; case kSetup: DirectMainFunction(osSetup); break; case kCommands: DirectMainFunction(osCommands); break; + case kUser1 ... kUser9: cRemote::PutMacro(key); break; // Channel up/down: case kChanUp|k_Repeat: case kChanUp: @@ -591,6 +593,11 @@ int main(int argc, char *argv[]) else Interface->Error(tr("No free DVB device to record!")); break; + // Key macros: + case kRed: + case kGreen: + case kYellow: + case kBlue: cRemote::PutMacro(key); break; default: break; } } -- cgit v1.2.3