|
SASC-NG
DVBSoftCAM
|
00001 /* 00002 * remote.h: General Remote Control handling 00003 * 00004 * See the main source file 'vdr.c' for copyright information and 00005 * how to reach the author. 00006 * 00007 * $Id: remote.h 1.40 2007/04/30 12:37:37 kls Exp $ 00008 */ 00009 00010 #ifndef __REMOTE_H 00011 #define __REMOTE_H 00012 00013 #include <stdio.h> 00014 #include <termios.h> 00015 #include <time.h> 00016 #include "keys.h" 00017 #include "thread.h" 00018 #include "tools.h" 00019 00020 class cRemote : public cListObject { 00021 private: 00022 enum { MaxKeys = 2 * MAXKEYSINMACRO }; 00023 static eKeys keys[MaxKeys]; 00024 static int in; 00025 static int out; 00026 static cTimeMs repeatTimeout; 00027 static cRemote *learning; 00028 static char *unknownCode; 00029 static cMutex mutex; 00030 static cCondVar keyPressed; 00031 static time_t lastActivity; 00032 static const char *keyMacroPlugin; 00033 static const char *callPlugin; 00034 static bool enabled; 00035 char *name; 00036 protected: 00037 cRemote(const char *Name); 00038 const char *GetSetup(void); 00039 void PutSetup(const char *Setup); 00040 bool Put(uint64_t Code, bool Repeat = false, bool Release = false); 00041 bool Put(const char *Code, bool Repeat = false, bool Release = false); 00042 public: 00043 virtual ~cRemote(); 00044 virtual bool Ready(void) { return true; } 00045 virtual bool Initialize(void); 00046 const char *Name(void) { return name; } 00047 static void SetLearning(cRemote *Learning) { learning = Learning; } 00048 static bool IsLearning() { return learning != NULL; } 00049 static bool Enabled(void) { return enabled; } 00050 static void SetEnabled(bool Enabled) { enabled = Enabled; } 00051 static void Clear(void); 00052 static bool Put(eKeys Key, bool AtFront = false); 00053 static bool PutMacro(eKeys Key); 00054 static bool CallPlugin(const char *Plugin); 00062 static const char *GetPlugin(void); 00066 static bool HasKeys(void); 00067 static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL); 00068 static time_t LastActivity(void) { return lastActivity; } 00070 }; 00071 00072 class cRemotes : public cList<cRemote> {}; 00073 00074 extern cRemotes Remotes; 00075 00076 enum eKbdFunc { 00077 kfNone, 00078 kfF1 = 0x100, 00079 kfF2, 00080 kfF3, 00081 kfF4, 00082 kfF5, 00083 kfF6, 00084 kfF7, 00085 kfF8, 00086 kfF9, 00087 kfF10, 00088 kfF11, 00089 kfF12, 00090 kfUp, 00091 kfDown, 00092 kfLeft, 00093 kfRight, 00094 kfHome, 00095 kfEnd, 00096 kfPgUp, 00097 kfPgDown, 00098 kfIns, 00099 kfDel, 00100 }; 00101 00102 class cKbdRemote : public cRemote, private cThread { 00103 private: 00104 static bool kbdAvailable; 00105 static bool rawMode; 00106 struct termios savedTm; 00107 virtual void Action(void); 00108 int ReadKey(void); 00109 uint64_t ReadKeySequence(void); 00110 int MapCodeToFunc(uint64_t Code); 00111 public: 00112 cKbdRemote(void); 00113 virtual ~cKbdRemote(); 00114 static bool KbdAvailable(void) { return kbdAvailable; } 00115 static uint64_t MapFuncToCode(int Func); 00116 static void SetRawMode(bool RawMode); 00117 }; 00118 00119 #endif //__REMOTE_H