summaryrefslogtreecommitdiff
path: root/keys.h
blob: cb2b2eb08aba76c31375b65a511bc15d17ee0232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * keys.h: Remote control Key handling
 *
 * See the main source file 'vdr.c' for copyright information and
 * how to reach the author.
 *
 * $Id: keys.h 1.14 2007/08/26 12:34:50 kls Exp $
 */

#ifndef __KEYS_H
#define __KEYS_H

#include "config.h"
#include "tools.h"

enum eKeys { // "Up" and "Down" must be the first two keys!
             kUp,
             kDown,
             kMenu,
             kOk,
             kBack,
             kLeft,
             kRight,
             kRed,
             kGreen,
             kYellow,
             kBlue,
             k0, k1, k2, k3, k4, k5, k6, k7, k8, k9,
             kInfo,
             kPlay,
             kPause,
             kStop,
             kRecord,
             kFastFwd,
             kFastRew,
             kNext,
             kPrev,
             kPower,
             kChanUp,
             kChanDn,
             kChanPrev,
             kVolUp,
             kVolDn,
             kMute,
             kAudio,
             kSubtitles,
             kSchedule,
             kChannels,
             kTimers,
             kRecordings,
             kSetup,
             kCommands,
             kUser1, kUser2, kUser3, kUser4, kUser5, kUser6, kUser7, kUser8, kUser9,
             kNone,
             kKbd,
             // The following codes are used internally:
             k_Plugin,
             k_Setup,
             // The following flags are OR'd with the above codes:
             k_Repeat  = 0x8000,
             k_Release = 0x4000,
             k_Flags   = k_Repeat | k_Release,
           };

// This is in preparation for having more key codes:
#define kMarkToggle      k0
#define kMarkMoveBack    k4
#define kMarkMoveForward k6
#define kMarkJumpBack    k7
#define kMarkJumpForward k9
#define kEditCut         k2
#define kEditTest        k8

#define RAWKEY(k)        (eKeys((k) & ~k_Flags))
#define ISRAWKEY(k)      ((k) != kNone && ((k) & k_Flags) == 0)
#define NORMALKEY(k)     (eKeys((k) & ~k_Repeat))
#define ISMODELESSKEY(k) (RAWKEY(k) > k9)
#define ISREALKEY(k)     (k != kNone && k != k_Plugin)

#define BASICKEY(k)      (eKeys((k) & 0xFFFF))
#define KBDKEY(k)        (eKeys(((k) << 16) | kKbd))
#define KEYKBD(k)        (((k) >> 16) & 0xFFFF)

struct tKey {
  eKeys type;
  const char *name;
  };

class cKey : public cListObject {
private:
  char *remote;
  char *code;
  eKeys key;
public:
  cKey(void);
  cKey(const char *Remote, const char *Code, eKeys Key);
  ~cKey();
  const char *Remote(void) { return remote; }
  const char *Code(void) { return code; }
  eKeys Key(void) { return key; }
  bool Parse(char *s);
  bool Save(FILE *f);
  static eKeys FromString(const char *Name);
  static const char *ToString(eKeys Key, bool Translate = false);
  };

class cKeys : public cConfig<cKey> {
public:
  bool KnowsRemote(const char *Remote);
  eKeys Get(const char *Remote, const char *Code);
  const char *GetSetup(const char *Remote);
  void PutSetup(const char *Remote, const char *Setup);
  };

extern cKeys Keys;

#define MAXKEYSINMACRO 16

class cKeyMacro : public cListObject {
private:
  eKeys macro[MAXKEYSINMACRO];
  int numKeys;
  char *plugin;
public:
  cKeyMacro(void);
  ~cKeyMacro();
  bool Parse(char *s);
  int NumKeys(void) const { return numKeys; }
      ///< Returns the number of keys in this macro. The first key (with
      ///< index 0) is the macro code. The actual macro expansion codes
      ///< start at index 1 and go to NumKeys() - 1.
  const eKeys *Macro(void) const { return macro; }
  const char *Plugin(void) const { return plugin; }
  };

class cKeyMacros : public cConfig<cKeyMacro> {
public:
  const cKeyMacro *Get(eKeys Key);
  };

extern cKeyMacros KeyMacros;

#endif //__KEYS_H