vdr  2.4.1
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 4.0 2013/12/25 12:32:44 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;
27  static cRemote *learning;
28  static char *unknownCode;
29  static cMutex mutex;
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;
110  struct termios savedTm;
111  virtual void Action(void);
112  int ReadKey(void);
113  uint64_t ReadKeySequence(void);
114  int MapCodeToFunc(uint64_t Code);
115  void PutKey(uint64_t Code, bool Repeat = false, bool Release = false);
116 public:
117  cKbdRemote(void);
118  virtual ~cKbdRemote();
119  static bool KbdAvailable(void) { return kbdAvailable; }
120  static uint64_t MapFuncToCode(int Func);
121  static void SetRawMode(bool RawMode);
122  };
123 
124 #endif //__REMOTE_H
kfLeft
@ kfLeft
Definition: remote.h:95
cRemote::MaxKeys
@ MaxKeys
Definition: remote.h:22
kfDown
@ kfDown
Definition: remote.h:94
kfF5
@ kfF5
Definition: remote.h:85
kfF8
@ kfF8
Definition: remote.h:88
cRemote::PutMacro
static bool PutMacro(eKeys Key)
Definition: remote.c:110
kfNone
@ kfNone
Definition: remote.h:80
kfPgDown
@ kfPgDown
Definition: remote.h:100
cRemote::unknownCode
static char * unknownCode
Definition: remote.h:28
keys.h
cCondVar
Definition: thread.h:44
cKbdRemote::KbdAvailable
static bool KbdAvailable(void)
Definition: remote.h:119
cRemote::keyPressed
static cCondVar keyPressed
Definition: remote.h:30
cRemote::keyMacroPlugin
static const char * keyMacroPlugin
Definition: remote.h:32
cRemote::keys
static eKeys keys[MaxKeys]
Definition: remote.h:23
cRemote::LastActivity
static time_t LastActivity(void)
Absolute time when last key was delivered by Get().
Definition: remote.h:68
cKbdRemote::MapFuncToCode
static uint64_t MapFuncToCode(int Func)
Definition: remote.c:279
eKeys
eKeys
Definition: keys.h:16
cRemote::Ready
virtual bool Ready(void)
Definition: remote.h:44
cRemote::Put
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
Definition: remote.c:124
Remotes
cRemotes Remotes
Definition: remote.c:211
kfF11
@ kfF11
Definition: remote.h:91
kfF1
@ kfF1
Definition: remote.h:81
kfEnd
@ kfEnd
Definition: remote.h:98
Setup
cSetup Setup
Definition: config.c:372
cRemote::Name
const char * Name(void)
Definition: remote.h:46
kfPgUp
@ kfPgUp
Definition: remote.h:99
kfF7
@ kfF7
Definition: remote.h:87
kfHome
@ kfHome
Definition: remote.h:97
cRemote::Get
static eKeys Get(int WaitMs=1000, char **UnknownCode=NULL)
Definition: remote.c:181
cRemote::PutSetup
void PutSetup(const char *Setup)
Definition: remote.c:56
MAXKEYSINMACRO
#define MAXKEYSINMACRO
Definition: keys.h:120
cRemote::Initialize
virtual bool Initialize(void)
Definition: remote.c:61
cRemote::Enabled
static bool Enabled(void)
Definition: remote.h:49
cKbdRemote::kbdAvailable
static bool kbdAvailable
Definition: remote.h:107
cMutex
Definition: thread.h:67
cRemote::out
static int out
Definition: remote.h:25
cKbdRemote::savedTm
struct termios savedTm
Definition: remote.h:110
cRemote::~cRemote
virtual ~cRemote()
Definition: remote.c:45
kfF12
@ kfF12
Definition: remote.h:92
cListObject
Definition: tools.h:493
cRemote::HasKeys
static bool HasKeys(void)
Definition: remote.c:175
kfF10
@ kfF10
Definition: remote.h:90
kfF2
@ kfF2
Definition: remote.h:82
cTimeMs
Definition: tools.h:369
cRemote::TriggerLastActivity
static void TriggerLastActivity(void)
Simulates user activity, for instance to keep the current menu open even if no remote control key has...
Definition: remote.c:204
cRemote::name
char * name
Definition: remote.h:35
cKbdRemote::Action
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
Definition: remote.c:382
cRemote
Definition: remote.h:20
kfF4
@ kfF4
Definition: remote.h:84
cList
Definition: tools.h:594
cKbdRemote::MapCodeToFunc
int MapCodeToFunc(uint64_t Code)
Definition: remote.c:288
kfF6
@ kfF6
Definition: remote.h:86
kfIns
@ kfIns
Definition: remote.h:101
cKbdRemote::SetRawMode
static void SetRawMode(bool RawMode)
Definition: remote.c:274
cKbdRemote::ReadKey
int ReadKey(void)
Definition: remote.c:307
cRemote::learning
static cRemote * learning
Definition: remote.h:27
cRemote::Clear
static void Clear(void)
Definition: remote.c:72
kfF3
@ kfF3
Definition: remote.h:83
cRemote::GetSetup
const char * GetSetup(void)
Definition: remote.c:51
cRemote::enabled
static bool enabled
Definition: remote.h:34
cKbdRemote
Definition: remote.h:105
cKbdRemote::~cKbdRemote
virtual ~cKbdRemote()
Definition: remote.c:267
cKbdRemote::ReadKeySequence
uint64_t ReadKeySequence(void)
Definition: remote.c:321
cRemote::CallPlugin
static bool CallPlugin(const char *Plugin)
Initiates calling the given plugin's main menu function.
Definition: remote.c:151
cKbdRemote::rawMode
static bool rawMode
Definition: remote.h:108
cKbdRemote::systemIsUtf8
bool systemIsUtf8
Definition: remote.h:109
kfF9
@ kfF9
Definition: remote.h:89
cRemote::GetPlugin
static const char * GetPlugin(void)
Returns the name of the plugin that was set with a previous call to PutMacro() or CallPlugin().
Definition: remote.c:162
cThread
Definition: thread.h:79
cRemote::cRemote
cRemote(const char *Name)
Definition: remote.c:39
cKbdRemote::cKbdRemote
cKbdRemote(void)
Definition: remote.c:249
kfUp
@ kfUp
Definition: remote.h:93
kfDel
@ kfDel
Definition: remote.h:102
cRemote::SetEnabled
static void SetEnabled(bool Enabled)
Definition: remote.h:50
cRemote::lastActivity
static time_t lastActivity
Definition: remote.h:31
eKbdFunc
eKbdFunc
Definition: remote.h:79
tools.h
cRemote::IsLearning
static bool IsLearning()
Definition: remote.h:48
cRemote::SetLearning
static void SetLearning(cRemote *Learning)
Definition: remote.h:47
thread.h
cRemotes
Definition: remote.h:75
cRemote::in
static int in
Definition: remote.h:24
kfRight
@ kfRight
Definition: remote.h:96
cRemote::mutex
static cMutex mutex
Definition: remote.h:29
cKbdRemote::PutKey
void PutKey(uint64_t Code, bool Repeat=false, bool Release=false)
Definition: remote.c:299
cRemote::repeatTimeout
static cTimeMs repeatTimeout
Definition: remote.h:26
cRemote::callPlugin
static const char * callPlugin
Definition: remote.h:33