summaryrefslogtreecommitdiff
path: root/remote.h
blob: 7b94ac782a1abfa236f9bc0d011d82092eb5d99e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
86
87
88
89
90
91
92
93
94
95
96
/*
 * remote.h: Interface to the Remote Control Unit
 *
 * See the main source file 'vdr.c' for copyright information and
 * how to reach the author.
 *
 * $Id: remote.h 1.7 2000/07/15 16:32:43 kls Exp $
 */

#ifndef __REMOTE_H
#define __REMOTE_H

#include <stdio.h>
#include <time.h>

class cRcIoBase {
protected:
  time_t t;
  int firstTime, lastTime;
  unsigned int lastCommand;
  cRcIoBase(void);
  virtual ~cRcIoBase();
public:
  enum { modeH = 'h', modeB = 'b', modeS = 's' };
  virtual bool SetCode(unsigned char Code, unsigned short Address) { return true; }
  virtual bool SetMode(unsigned char Mode) { return true; }
  virtual bool Number(int n, bool Hex = false) { return true; }
  virtual void SetPoints(unsigned char Dp, bool On) {}
  virtual bool String(char *s) { return true; }
  virtual bool DetectCode(unsigned char *Code, unsigned short *Address) { return true; }
  virtual void Flush(int WaitSeconds = 0) {}
  virtual bool InputAvailable(bool Wait = false) = 0;
  virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL) = 0;
  };

#if defined REMOTE_KBD

class cRcIoKBD : public cRcIoBase {
public:
  cRcIoKBD(void);
  virtual ~cRcIoKBD();
  virtual void Flush(int WaitSeconds = 0);
  virtual bool InputAvailable(bool Wait = false);
  virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL);
  };

#elif defined REMOTE_RCU

class cRcIoRCU : public cRcIoBase {
private:
  int f;
  unsigned char dp, code, mode;
  unsigned short address;
  int lastNumber;
  bool SendCommand(unsigned char Cmd);
  int ReceiveByte(bool Wait = true);
  bool SendByteHandshake(unsigned char c);
  bool SendByte(unsigned char c);
  bool Digit(int n, int v);
public:
  cRcIoRCU(char *DeviceName);
  virtual ~cRcIoRCU();
  virtual bool SetCode(unsigned char Code, unsigned short Address);
  virtual bool SetMode(unsigned char Mode);
  virtual bool Number(int n, bool Hex = false);
  virtual void SetPoints(unsigned char Dp, bool On);
  virtual bool String(char *s);
  virtual bool DetectCode(unsigned char *Code, unsigned short *Address);
  virtual void Flush(int WaitSeconds = 0);
  virtual bool InputAvailable(bool Wait = false);
  virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL);
  };

#elif defined REMOTE_LIRC

class cRcIoLIRC : public cRcIoBase {
private:
  enum { LIRC_KEY_BUF = 8, LIRC_BUFFER_SIZE = 128 };
  int f;
  char keyName[LIRC_KEY_BUF];
  const char *ReceiveString(void);
public:
  cRcIoLIRC(char *DeviceName);
  virtual ~cRcIoLIRC();
  virtual void Flush(int WaitSeconds = 0);
  virtual bool InputAvailable(bool Wait = false);
  virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL);
  };

#else

#error Please define a remote control mode!

#endif

#endif //__REMOTE_H