File: remote.h

package info (click to toggle)
vdr-plugin-remote 0.3.3-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 212 kB
  • ctags: 118
  • sloc: ansic: 1,337; makefile: 105; sh: 79
file content (113 lines) | stat: -rw-r--r-- 3,011 bytes parent folder | download | duplicates (2)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Remote Control plugin for the Video Disk Recorder
 *
 * remote.h: input/lirc/tty remote control
 *
 * See the README file for copyright information and how to reach the author.
 */


#ifndef __PLUGIN_REMOTE_H
#define __PLUGIN_REMOTE_H


#include <vdr/remote.h>
#include <vdr/thread.h>

//#define DEBUG

#ifdef DEBUG
#define DSYSLOG(x...)    dsyslog(x)
#else
#define DSYSLOG(x...)
#endif

#if VDRVERSNUM <= 10306
#define MSG_ERROR(x)	Interface->Error(x)
#define MSG_INFO(x)	Interface->Info(x)
#else
#define MSG_ERROR(x)	Skins.Message(mtError,x)
#define MSG_INFO(x)	Skins.Message(mtInfo,x)
#endif
				
// display error message with parameters on OSD
#define EOSD(fmt,parms...)     {  char msg[132]; \
                                  snprintf(msg, sizeof msg, fmt, parms); \
                                  MSG_ERROR(msg); \
                                  MSG_ERROR(msg); /* repeat once */ }



/*****************************************************************************/
class cRemoteGeneric : protected cRemote, protected cThread
/*****************************************************************************/
{
protected:
  static const uint64 INVALID_KEY = (uint64) -1;
  int fh;
  char *device;
  int polldelay;
  int repeatdelay;
  int repeatfreq;
  int repeattimeout;
  cRemoteGeneric(const char *name, int f, char *d);
  virtual ~cRemoteGeneric();
  virtual uint64 getKey(void) = 0;
  virtual bool keyPressed(uint64 code) = 0;
  virtual bool Put(uint64 Code, bool Repeat = false, bool Release = false);
  virtual void Action(void);
};



/*****************************************************************************/
class cRemoteDevInput : protected cRemoteGeneric
/*****************************************************************************/
{
private:
  bool testMode;
  uint64 testKey;
  bool loadKeymap(const char *devname, uint32_t options);
protected:
  virtual uint64 getKey(void);
  virtual bool keyPressed(uint64 code);
public:
  cRemoteDevInput(const char *name, int f, char *d);
  virtual bool Initialize(void);
};



#ifdef REMOTE_FEATURE_LIRCOLD
/*****************************************************************************/
class cRemoteDevLirc : protected cRemoteGeneric
/*****************************************************************************/
{
protected:
  virtual uint64 getKey(void);
  virtual bool keyPressed(uint64 code);
public:
  cRemoteDevLirc(const char *name, int f, char *d)
    :cRemoteGeneric(name, f, d) { Start(); }
};
#endif



/*****************************************************************************/
class cRemoteDevTty : protected cRemoteGeneric
/*****************************************************************************/
{
private:
  struct termios tm;
protected:
  virtual uint64 getKey(void);
  virtual bool keyPressed(uint64 code);
  virtual bool Put(uint64 Code, bool Repeat = false, bool Release = false);
public:
  cRemoteDevTty(const char *name, int f, char *d);
  virtual ~cRemoteDevTty(); 
};


#endif // __PLUGIN_REMOTE_H