diff options
-rw-r--r-- | HISTORY | 4 | ||||
-rw-r--r-- | MANUAL | 3 | ||||
-rw-r--r-- | keymacros.conf | 11 | ||||
-rw-r--r-- | keys.c | 57 | ||||
-rw-r--r-- | keys.h | 21 | ||||
-rw-r--r-- | remote.c | 18 | ||||
-rw-r--r-- | remote.h | 5 | ||||
-rw-r--r-- | vdr.5 | 16 | ||||
-rw-r--r-- | vdr.c | 9 |
9 files changed, 137 insertions, 7 deletions
@@ -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". @@ -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 @@ -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; +} @@ -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<cKeyMacro> { +public: + const cKeyMacro *Get(eKeys Key); + }; + +extern cKeyMacros KeyMacros; + #endif //__KEYS_H @@ -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]; @@ -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); }; @@ -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. @@ -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 <getopt.h> @@ -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; } } |