vdr  1.7.31
remote.h
Go to the documentation of this file.
1 /*
2  * remote.h: General Remote Control handling
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: remote.h 2.0 2008/02/23 14:38:47 kls Exp $
8  */
9 
10 #ifndef __REMOTE_H
11 #define __REMOTE_H
12 
13 #include <stdio.h>
14 #include <termios.h>
15 #include <time.h>
16 #include "keys.h"
17 #include "thread.h"
18 #include "tools.h"
19 
20 class cRemote : public cListObject {
21 private:
22  enum { MaxKeys = 2 * MAXKEYSINMACRO };
23  static eKeys keys[MaxKeys];
24  static int in;
25  static int out;
26  static cTimeMs repeatTimeout;
27  static cRemote *learning;
28  static char *unknownCode;
29  static cMutex mutex;
30  static cCondVar keyPressed;
31  static time_t lastActivity;
32  static const char *keyMacroPlugin;
33  static const char *callPlugin;
34  static bool enabled;
35  char *name;
36 protected:
37  cRemote(const char *Name);
38  const char *GetSetup(void);
39  void PutSetup(const char *Setup);
40  bool Put(uint64_t Code, bool Repeat = false, bool Release = false);
41  bool Put(const char *Code, bool Repeat = false, bool Release = false);
42 public:
43  virtual ~cRemote();
44  virtual bool Ready(void) { return true; }
45  virtual bool Initialize(void);
46  const char *Name(void) { return name; }
47  static void SetLearning(cRemote *Learning) { learning = Learning; }
48  static bool IsLearning() { return learning != NULL; }
49  static bool Enabled(void) { return enabled; }
50  static void SetEnabled(bool Enabled) { enabled = Enabled; }
51  static void Clear(void);
52  static bool Put(eKeys Key, bool AtFront = false);
53  static bool PutMacro(eKeys Key);
54  static bool CallPlugin(const char *Plugin);
62  static const char *GetPlugin(void);
66  static bool HasKeys(void);
67  static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL);
68  static time_t LastActivity(void) { return lastActivity; }
70  static void TriggerLastActivity(void);
73  };
74 
75 class cRemotes : public cList<cRemote> {};
76 
77 extern cRemotes Remotes;
78 
79 enum eKbdFunc {
81  kfF1 = 0x100,
103  };
104 
105 class cKbdRemote : public cRemote, private cThread {
106 private:
107  static bool kbdAvailable;
108  static bool rawMode;
109  struct termios savedTm;
110  virtual void Action(void);
111  int ReadKey(void);
112  uint64_t ReadKeySequence(void);
113  int MapCodeToFunc(uint64_t Code);
114 public:
115  cKbdRemote(void);
116  virtual ~cKbdRemote();
117  static bool KbdAvailable(void) { return kbdAvailable; }
118  static uint64_t MapFuncToCode(int Func);
119  static void SetRawMode(bool RawMode);
120  };
121 
122 #endif //__REMOTE_H