1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

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

View File

@ -1663,3 +1663,7 @@ Video Disk Recorder Revision History
control provides keys you want to assign these functions to, you can delete 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 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. 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".

3
MANUAL
View File

@ -49,6 +49,9 @@ Video Disk Recorder User's Manual
Setup | Setup |
Commands / 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 (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 has been enabled in the "Setup" menu. Otherwise the Blue button is used
to "mark" a timer for moving. to "mark" a timer for moving.

11
keymacros.conf Normal file
View File

@ -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

57
keys.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "keys.h"
@ -49,6 +49,15 @@ static tKey keyTable[] = { // "Up" and "Down" must be the first two keys!
{ kRecordings, "Recordings" }, { kRecordings, "Recordings" },
{ kSetup, "Setup" }, { kSetup, "Setup" },
{ kCommands, "Commands" }, { kCommands, "Commands" },
{ kUser1, "User1" },
{ kUser2, "User2" },
{ kUser3, "User3" },
{ kUser4, "User4" },
{ kUser5, "User5" },
{ kUser6, "User6" },
{ kUser7, "User7" },
{ kUser8, "User8" },
{ kUser9, "User9" },
{ kNone, "" }, { kNone, "" },
{ k_Setup, "_Setup" }, { k_Setup, "_Setup" },
{ kNone, NULL }, { kNone, NULL },
@ -166,3 +175,49 @@ void cKeys::PutSetup(const char *Remote, const char *Setup)
else else
esyslog("ERROR: called PutSetup() for %s, but setup has already been defined!", Remote); 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;
}

21
keys.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __KEYS_H
@ -44,6 +44,7 @@ enum eKeys { // "Up" and "Down" must be the first two keys!
kRecordings, kRecordings,
kSetup, kSetup,
kCommands, kCommands,
kUser1, kUser2, kUser3, kUser4, kUser5, kUser6, kUser7, kUser8, kUser9,
kNone, kNone,
k_Setup, k_Setup,
// The following flags are OR'd with the above codes: // The following flags are OR'd with the above codes:
@ -99,4 +100,22 @@ public:
extern cKeys Keys; 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 #endif //__KEYS_H

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "remote.h"
@ -84,6 +84,22 @@ bool cRemote::Put(eKeys Key)
return true; // only a real key shall report an overflow! 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) bool cRemote::Put(uint64 Code, bool Repeat, bool Release)
{ {
char buffer[32]; char buffer[32];

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __REMOTE_H
@ -20,7 +20,7 @@ typedef unsigned long long int uint64;
class cRemote : public cListObject { class cRemote : public cListObject {
private: private:
enum { MaxKeys = 16 }; enum { MaxKeys = MAXKEYSINMACRO };
static eKeys keys[MaxKeys]; static eKeys keys[MaxKeys];
static int in; static int in;
static int out; static int out;
@ -42,6 +42,7 @@ public:
static void SetLearning(bool On) { learning = On; } static void SetLearning(bool On) { learning = On; }
static void Clear(void); static void Clear(void);
static bool Put(eKeys Key); static bool Put(eKeys Key);
static bool PutMacro(eKeys Key);
static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL); static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL);
}; };

16
vdr.5
View File

@ -8,7 +8,7 @@
.\" License as specified in the file COPYING that comes with the .\" License as specified in the file COPYING that comes with the
.\" vdr distribution. .\" 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" .TH vdr 5 "7 Oct 2002" "1.2.0" "Video Disk Recorder Files"
.SH NAME .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 "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 defined (like Up, Down, Menu etc.), and \fBcode\fR is a character string that
this remote control delivers when the given key is pressed. 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 .SS COMMANDS
The file \fIcommands.conf\fR contains the definitions of commands that can The file \fIcommands.conf\fR contains the definitions of commands that can
be executed from the \fBvdr\fR main menu's "Commands" option. be executed from the \fBvdr\fR main menu's "Commands" option.

9
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * 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> #include <getopt.h>
@ -324,6 +324,7 @@ int main(int argc, char *argv[])
SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true); SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true);
CaDefinitions.Load(AddDirectory(ConfigDirectory, "ca.conf"), true); CaDefinitions.Load(AddDirectory(ConfigDirectory, "ca.conf"), true);
Keys.Load(AddDirectory(ConfigDirectory, "remote.conf")); Keys.Load(AddDirectory(ConfigDirectory, "remote.conf"));
KeyMacros.Load(AddDirectory(ConfigDirectory, "keymacros.conf"), true);
// DVB interfaces: // DVB interfaces:
@ -468,6 +469,7 @@ int main(int argc, char *argv[])
case kRecordings: DirectMainFunction(osRecordings); break; case kRecordings: DirectMainFunction(osRecordings); break;
case kSetup: DirectMainFunction(osSetup); break; case kSetup: DirectMainFunction(osSetup); break;
case kCommands: DirectMainFunction(osCommands); break; case kCommands: DirectMainFunction(osCommands); break;
case kUser1 ... kUser9: cRemote::PutMacro(key); break;
// Channel up/down: // Channel up/down:
case kChanUp|k_Repeat: case kChanUp|k_Repeat:
case kChanUp: case kChanUp:
@ -591,6 +593,11 @@ int main(int argc, char *argv[])
else else
Interface->Error(tr("No free DVB device to record!")); Interface->Error(tr("No free DVB device to record!"));
break; break;
// Key macros:
case kRed:
case kGreen:
case kYellow:
case kBlue: cRemote::PutMacro(key); break;
default: break; default: break;
} }
} }