SASC-NG
DVBSoftCAM

keys.h

Go to the documentation of this file.
00001 /*
00002  * keys.h: Remote control Key handling
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: keys.h 1.11 2007/02/25 10:49:35 kls Exp $
00008  */
00009 
00010 #ifndef __KEYS_H
00011 #define __KEYS_H
00012 
00013 #include "config.h"
00014 #include "tools.h"
00015 
00016 enum eKeys { // "Up" and "Down" must be the first two keys!
00017              kUp,
00018              kDown,
00019              kMenu,
00020              kOk,
00021              kBack,
00022              kLeft,
00023              kRight,
00024              kRed,
00025              kGreen,
00026              kYellow,
00027              kBlue,
00028              k0, k1, k2, k3, k4, k5, k6, k7, k8, k9,
00029              kInfo,
00030              kPlay,
00031              kPause,
00032              kStop,
00033              kRecord,
00034              kFastFwd,
00035              kFastRew,
00036              kNext,
00037              kPrev,
00038              kPower,
00039              kChanUp,
00040              kChanDn,
00041              kChanPrev,
00042              kVolUp,
00043              kVolDn,
00044              kMute,
00045              kAudio,
00046              kSchedule,
00047              kChannels,
00048              kTimers,
00049              kRecordings,
00050              kSetup,
00051              kCommands,
00052              kUser1, kUser2, kUser3, kUser4, kUser5, kUser6, kUser7, kUser8, kUser9,
00053              kNone,
00054              kKbd,
00055              // The following codes are used internally:
00056              k_Plugin,
00057              k_Setup,
00058              // The following flags are OR'd with the above codes:
00059              k_Repeat  = 0x8000,
00060              k_Release = 0x4000,
00061              k_Flags   = k_Repeat | k_Release,
00062            };
00063 
00064 // This is in preparation for having more key codes:
00065 #define kMarkToggle      k0
00066 #define kMarkMoveBack    k4
00067 #define kMarkMoveForward k6
00068 #define kMarkJumpBack    k7
00069 #define kMarkJumpForward k9
00070 #define kEditCut         k2
00071 #define kEditTest        k8
00072 
00073 #define RAWKEY(k)        (eKeys((k) & ~k_Flags))
00074 #define ISRAWKEY(k)      ((k) != kNone && ((k) & k_Flags) == 0)
00075 #define NORMALKEY(k)     (eKeys((k) & ~k_Repeat))
00076 #define ISMODELESSKEY(k) (RAWKEY(k) > k9)
00077 #define ISREALKEY(k)     (k != kNone && k != k_Plugin)
00078 
00079 #define BASICKEY(k)      (eKeys((k) & 0xFFFF))
00080 #define KBDKEY(k)        (eKeys(((k) << 16) | kKbd))
00081 #define KEYKBD(k)        (((k) >> 16) & 0xFFFF)
00082 
00083 struct tKey {
00084   eKeys type;
00085   char *name;
00086   };
00087 
00088 class cKey : public cListObject {
00089 private:
00090   char *remote;
00091   char *code;
00092   eKeys key;
00093 public:
00094   cKey(void);
00095   cKey(const char *Remote, const char *Code, eKeys Key);
00096   ~cKey();
00097   const char *Remote(void) { return remote; }
00098   const char *Code(void) { return code; }
00099   eKeys Key(void) { return key; }
00100   bool Parse(char *s);
00101   bool Save(FILE *f);
00102   static eKeys FromString(const char *Name);
00103   static const char *ToString(eKeys Key);
00104   };
00105 
00106 class cKeys : public cConfig<cKey> {
00107 public:
00108   bool KnowsRemote(const char *Remote);
00109   eKeys Get(const char *Remote, const char *Code);
00110   const char *GetSetup(const char *Remote);
00111   void PutSetup(const char *Remote, const char *Setup);
00112   };
00113 
00114 extern cKeys Keys;
00115 
00116 #define MAXKEYSINMACRO 16
00117 
00118 class cKeyMacro : public cListObject {
00119 private:
00120   eKeys macro[MAXKEYSINMACRO];
00121   int numKeys;
00122   char *plugin;
00123 public:
00124   cKeyMacro(void);
00125   ~cKeyMacro();
00126   bool Parse(char *s);
00127   int NumKeys(void) const { return numKeys; }
00131   const eKeys *Macro(void) const { return macro; }
00132   const char *Plugin(void) const { return plugin; }
00133   };
00134 
00135 class cKeyMacros : public cConfig<cKeyMacro> {
00136 public:
00137   const cKeyMacro *Get(eKeys Key);
00138   };
00139 
00140 extern cKeyMacros KeyMacros;
00141 
00142 #endif //__KEYS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines