vdr 2.6.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 3.1 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
20class cRemote : public cListObject {
21private:
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;
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;
36protected:
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);
42public:
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
75class cRemotes : public cList<cRemote> {};
76
77extern cRemotes Remotes;
78
81 kfF1 = 0x100,
103 };
104
105class cKbdRemote : public cRemote, private cThread {
106private:
107 static bool kbdAvailable;
108 static bool rawMode;
109 bool systemIsUtf8;
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);
116public:
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
static bool rawMode
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
static bool KbdAvailable(void)
Definition: remote.h:119
uint64_t ReadKeySequence(void)
int ReadKey(void)
int MapCodeToFunc(uint64_t Code)
cKbdRemote(void)
static bool kbdAvailable
void PutKey(uint64_t Code, bool Repeat=false, bool Release=false)
static void SetRawMode(bool RawMode)
struct termios savedTm
static uint64_t MapFuncToCode(int Func)
virtual ~cKbdRemote()
static cTimeMs repeatTimeout
static bool Put(eKeys Key, bool AtFront=false)
const char * Name(void)
static bool IsLearning()
Definition: remote.h:48
static const char * callPlugin
static void SetLearning(cRemote *Learning)
Definition: remote.h:47
bool Put(const char *Code, bool Repeat=false, bool Release=false)
static bool enabled
static eKeys keys[MaxKeys]
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
static bool PutMacro(eKeys Key)
virtual ~cRemote()
static const char * keyMacroPlugin
static void TriggerLastActivity(void)
Simulates user activity, for instance to keep the current menu open even if no remote control key has...
static bool Enabled(void)
Definition: remote.h:49
const char * GetSetup(void)
static cRemote * learning
static cCondVar keyPressed
static void Clear(void)
static int in
static bool CallPlugin(const char *Plugin)
Initiates calling the given plugin's main menu function.
cRemote(const char *Name)
static time_t LastActivity(void)
Absolute time when last key was delivered by Get().
Definition: remote.h:68
static bool HasKeys(void)
static const char * GetPlugin(void)
Returns the name of the plugin that was set with a previous call to PutMacro() or CallPlugin().
virtual bool Initialize(void)
static char * unknownCode
virtual bool Ready(void)
Definition: remote.h:44
static void SetEnabled(bool Enabled)
Definition: remote.h:50
void PutSetup(const char *Setup)
static time_t lastActivity
static eKeys Get(int WaitMs=1000, char **UnknownCode=NULL)
static cMutex mutex
static int out
cSetup Setup
Definition: config.c:372
#define MAXKEYSINMACRO
cRemotes Remotes
Definition: remote.c:211
@ kfNone
Definition: remote.h:80
@ kfF10
Definition: remote.h:90
@ kfF11
Definition: remote.h:91
@ kfF7
Definition: remote.h:87
@ kfUp
Definition: remote.h:93
@ kfF9
Definition: remote.h:89
@ kfDown
Definition: remote.h:94
@ kfF3
Definition: remote.h:83
@ kfRight
Definition: remote.h:96
@ kfF2
Definition: remote.h:82
@ kfF4
Definition: remote.h:84
@ kfPgUp
Definition: remote.h:99
@ kfF8
Definition: remote.h:88
@ kfLeft
Definition: remote.h:95
@ kfF6
Definition: remote.h:86
@ kfIns
Definition: remote.h:101
@ kfDel
Definition: remote.h:102
@ kfF12
Definition: remote.h:92
@ kfEnd
Definition: remote.h:98
@ kfF1
Definition: remote.h:81
@ kfF5
Definition: remote.h:85
@ kfHome
Definition: remote.h:97
@ kfPgDown
Definition: remote.h:100