vdr  2.0.2
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.2 2012/12/04 12:51:25 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,
30  kPlayPause, // combined Play/Pause key
57  // The following codes are used internally:
60  // The following flags are OR'd with the above codes:
61  k_Repeat = 0x8000,
62  k_Release = 0x4000,
64  };
65 
66 // This is in preparation for having more key codes:
67 #define kMarkToggle k0
68 #define kMarkMoveBack k4
69 #define kMarkMoveForward k6
70 #define kMarkJumpBack k7
71 #define kMarkJumpForward k9
72 #define kEditCut k2
73 #define kEditTest k8
74 
75 #define RAWKEY(k) (eKeys((k) & ~k_Flags))
76 #define ISRAWKEY(k) ((k) != kNone && ((k) & k_Flags) == 0)
77 #define NORMALKEY(k) (eKeys((k) & ~k_Repeat))
78 #define ISMODELESSKEY(k) (RAWKEY(k) > k9)
79 #define ISREALKEY(k) (k != kNone && k != k_Plugin)
80 
81 #define BASICKEY(k) (eKeys((k) & 0xFFFF))
82 #define KBDKEY(k) (eKeys(((k) << 16) | kKbd))
83 #define KEYKBD(k) (((k) >> 16) & 0xFFFF)
84 
85 struct tKey {
87  const char *name;
88  };
89 
90 class cKey : public cListObject {
91 private:
92  char *remote;
93  char *code;
95 public:
96  cKey(void);
97  cKey(const char *Remote, const char *Code, eKeys Key);
98  ~cKey();
99  const char *Remote(void) { return remote; }
100  const char *Code(void) { return code; }
101  eKeys Key(void) { return key; }
102  bool Parse(char *s);
103  bool Save(FILE *f);
104  static eKeys FromString(const char *Name);
105  static const char *ToString(eKeys Key, bool Translate = false);
106  };
107 
108 class cKeys : public cConfig<cKey> {
109 public:
110  bool KnowsRemote(const char *Remote);
111  eKeys Get(const char *Remote, const char *Code);
112  const char *GetSetup(const char *Remote);
113  void PutSetup(const char *Remote, const char *Setup);
114  };
115 
116 extern cKeys Keys;
117 
118 #define MAXKEYSINMACRO 16
119 
120 class cKeyMacro : public cListObject {
121 private:
123  int numKeys;
124  char *plugin;
125 public:
126  cKeyMacro(void);
127  ~cKeyMacro();
128  bool Parse(char *s);
129  int NumKeys(void) const { return numKeys; }
133  const eKeys *Macro(void) const { return macro; }
134  const char *Plugin(void) const { return plugin; }
135  };
136 
137 class cKeyMacros : public cConfig<cKeyMacro> {
138 public:
139  const cKeyMacro *Get(eKeys Key);
140  };
141 
142 extern cKeyMacros KeyMacros;
143 
144 #endif //__KEYS_H
145