remote.h 2.28 KB
Newer Older
1
/*
Klaus Schmidinger's avatar
Klaus Schmidinger committed
2
 * remote.h: General Remote Control handling
3
 *
Klaus Schmidinger's avatar
Klaus Schmidinger committed
4
 * See the main source file 'vdr.c' for copyright information and
5 6
 * how to reach the author.
 *
Klaus Schmidinger's avatar
Klaus Schmidinger committed
7
 * $Id: remote.h 1.31 2005/09/03 12:28:42 kls Exp $
8 9 10 11 12 13
 */

#ifndef __REMOTE_H
#define __REMOTE_H

#include <stdio.h>
Klaus Schmidinger's avatar
Klaus Schmidinger committed
14
#include <termios.h>
15
#include <time.h>
Klaus Schmidinger's avatar
Klaus Schmidinger committed
16
#include "keys.h"
Klaus Schmidinger's avatar
Klaus Schmidinger committed
17
#include "thread.h"
Klaus Schmidinger's avatar
Klaus Schmidinger committed
18
#include "tools.h"
19

Klaus Schmidinger's avatar
Klaus Schmidinger committed
20
class cRemote : public cListObject {
Klaus Schmidinger's avatar
Klaus Schmidinger committed
21
private:
Klaus Schmidinger's avatar
Klaus Schmidinger committed
22
  enum { MaxKeys = MAXKEYSINMACRO };
Klaus Schmidinger's avatar
Klaus Schmidinger committed
23 24 25
  static eKeys keys[MaxKeys];
  static int in;
  static int out;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
26
  static cRemote *learning;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
27 28 29
  static char *unknownCode;
  static cMutex mutex;
  static cCondVar keyPressed;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
30
  static const char *plugin;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
31 32 33 34 35 36 37
  char *name;
protected:
  cRemote(const char *Name);
  const char *GetSetup(void);
  void PutSetup(const char *Setup);
  bool Put(uint64 Code, bool Repeat = false, bool Release = false);
  bool Put(const char *Code, bool Repeat = false, bool Release = false);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
38
public:
Klaus Schmidinger's avatar
Klaus Schmidinger committed
39
  virtual ~cRemote();
Klaus Schmidinger's avatar
Klaus Schmidinger committed
40
  virtual bool Ready(void) { return true; }
Klaus Schmidinger's avatar
Klaus Schmidinger committed
41
  virtual bool Initialize(void);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
42
  const char *Name(void) { return name; }
Klaus Schmidinger's avatar
Klaus Schmidinger committed
43
  static void SetLearning(cRemote *Learning) { learning = Learning; }
Klaus Schmidinger's avatar
Klaus Schmidinger committed
44
  static void Clear(void);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
45
  static bool Put(eKeys Key, bool AtFront = false);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
46
  static bool PutMacro(eKeys Key);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
47 48 49 50
  static void CallPlugin(const char *Plugin);
      ///< Initiates calling the given plugin's main menu function.
      ///< The Plugin parameter is the name of the plugin, and must be
      ///< a static string.
Klaus Schmidinger's avatar
Klaus Schmidinger committed
51
  static const char *GetPlugin(void) { return plugin; }
Klaus Schmidinger's avatar
Klaus Schmidinger committed
52
  static bool HasKeys(void);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
53
  static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
54 55
  };

Klaus Schmidinger's avatar
Klaus Schmidinger committed
56
class cRemotes : public cList<cRemote> {};
Klaus Schmidinger's avatar
Klaus Schmidinger committed
57

Klaus Schmidinger's avatar
Klaus Schmidinger committed
58
extern cRemotes Remotes;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
59

Klaus Schmidinger's avatar
Klaus Schmidinger committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
enum eKbdFunc {
  kfNone,
  kfF1 = 0x100,
  kfF2,
  kfF3,
  kfF4,
  kfF5,
  kfF6,
  kfF7,
  kfF8,
  kfF9,
  kfF10,
  kfF11,
  kfF12,
  kfUp,
  kfDown,
  kfLeft,
  kfRight,
  kfHome,
  kfEnd,
  kfPgUp,
  kfPgDown,
  kfIns,
  kfDel,
  };

Klaus Schmidinger's avatar
Klaus Schmidinger committed
86
class cKbdRemote : public cRemote, private cThread {
Klaus Schmidinger's avatar
Klaus Schmidinger committed
87
private:
Klaus Schmidinger's avatar
Klaus Schmidinger committed
88 89
  static bool kbdAvailable;
  static bool rawMode;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
90
  struct termios savedTm;
Klaus Schmidinger's avatar
Klaus Schmidinger committed
91
  virtual void Action(void);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
92
  int MapCodeToFunc(uint64 Code);
Klaus Schmidinger's avatar
Klaus Schmidinger committed
93
public:
Klaus Schmidinger's avatar
Klaus Schmidinger committed
94 95
  cKbdRemote(void);
  virtual ~cKbdRemote();
Klaus Schmidinger's avatar
Klaus Schmidinger committed
96 97 98
  static bool KbdAvailable(void) { return kbdAvailable; }
  static uint64 MapFuncToCode(int Func);
  static void SetRawMode(bool RawMode);
99 100 101
  };

#endif //__REMOTE_H