vdr  1.7.27
remote.h
Go to the documentation of this file.
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 2.0 2008/02/23 14:38:47 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   static void TriggerLastActivity(void);
00073   };
00074 
00075 class cRemotes : public cList<cRemote> {};
00076 
00077 extern cRemotes Remotes;
00078 
00079 enum eKbdFunc {
00080   kfNone,
00081   kfF1 = 0x100,
00082   kfF2,
00083   kfF3,
00084   kfF4,
00085   kfF5,
00086   kfF6,
00087   kfF7,
00088   kfF8,
00089   kfF9,
00090   kfF10,
00091   kfF11,
00092   kfF12,
00093   kfUp,
00094   kfDown,
00095   kfLeft,
00096   kfRight,
00097   kfHome,
00098   kfEnd,
00099   kfPgUp,
00100   kfPgDown,
00101   kfIns,
00102   kfDel,
00103   };
00104 
00105 class cKbdRemote : public cRemote, private cThread {
00106 private:
00107   static bool kbdAvailable;
00108   static bool rawMode;
00109   struct termios savedTm;
00110   virtual void Action(void);
00111   int ReadKey(void);
00112   uint64_t ReadKeySequence(void);
00113   int MapCodeToFunc(uint64_t Code);
00114 public:
00115   cKbdRemote(void);
00116   virtual ~cKbdRemote();
00117   static bool KbdAvailable(void) { return kbdAvailable; }
00118   static uint64_t MapFuncToCode(int Func);
00119   static void SetRawMode(bool RawMode);
00120   };
00121 
00122 #endif //__REMOTE_H