vdr  1.7.31
keys.h
Go to the documentation of this file.
1 /*
2  * keys.h: Remote control Key handling
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: keys.h 2.1 2010/04/05 10:06:04 kls Exp $
8  */
9 
10 #ifndef __KEYS_H
11 #define __KEYS_H
12 
13 #include "config.h"
14 #include "tools.h"
15 
16 enum eKeys { // "Up" and "Down" must be the first two keys!
17  kUp,
20  kOk,
28  k0, k1, k2, k3, k4, k5, k6, k7, k8, k9,
56  // The following codes are used internally:
59  // The following flags are OR'd with the above codes:
60  k_Repeat = 0x8000,
61  k_Release = 0x4000,
63  };
64 
65 // This is in preparation for having more key codes:
66 #define kMarkToggle k0
67 #define kMarkMoveBack k4
68 #define kMarkMoveForward k6
69 #define kMarkJumpBack k7
70 #define kMarkJumpForward k9
71 #define kEditCut k2
72 #define kEditTest k8
73 
74 #define RAWKEY(k) (eKeys((k) & ~k_Flags))
75 #define ISRAWKEY(k) ((k) != kNone && ((k) & k_Flags) == 0)
76 #define NORMALKEY(k) (eKeys((k) & ~k_Repeat))
77 #define ISMODELESSKEY(k) (RAWKEY(k) > k9)
78 #define ISREALKEY(k) (k != kNone && k != k_Plugin)
79 
80 #define BASICKEY(k) (eKeys((k) & 0xFFFF))
81 #define KBDKEY(k) (eKeys(((k) << 16) | kKbd))
82 #define KEYKBD(k) (((k) >> 16) & 0xFFFF)
83 
84 struct tKey {
85  eKeys type;
86  const char *name;
87  };
88 
89 class cKey : public cListObject {
90 private:
91  char *remote;
92  char *code;
93  eKeys key;
94 public:
95  cKey(void);
96  cKey(const char *Remote, const char *Code, eKeys Key);
97  ~cKey();
98  const char *Remote(void) { return remote; }
99  const char *Code(void) { return code; }
100  eKeys Key(void) { return key; }
101  bool Parse(char *s);
102  bool Save(FILE *f);
103  static eKeys FromString(const char *Name);
104  static const char *ToString(eKeys Key, bool Translate = false);
105  };
106 
107 class cKeys : public cConfig<cKey> {
108 public:
109  bool KnowsRemote(const char *Remote);
110  eKeys Get(const char *Remote, const char *Code);
111  const char *GetSetup(const char *Remote);
112  void PutSetup(const char *Remote, const char *Setup);
113  };
114 
115 extern cKeys Keys;
116 
117 #define MAXKEYSINMACRO 16
118 
119 class cKeyMacro : public cListObject {
120 private:
122  int numKeys;
123  char *plugin;
124 public:
125  cKeyMacro(void);
126  ~cKeyMacro();
127  bool Parse(char *s);
128  int NumKeys(void) const { return numKeys; }
132  const eKeys *Macro(void) const { return macro; }
133  const char *Plugin(void) const { return plugin; }
134  };
135 
136 class cKeyMacros : public cConfig<cKeyMacro> {
137 public:
138  const cKeyMacro *Get(eKeys Key);
139  };
140 
141 extern cKeyMacros KeyMacros;
142 
143 #endif //__KEYS_H