1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00
vdr/remote.h

101 lines
2.8 KiB
C
Raw Normal View History

2000-02-19 13:36:48 +01:00
/*
* remote.h: Interface to the Remote Control Unit
*
2000-04-24 09:46:05 +02:00
* See the main source file 'vdr.c' for copyright information and
2000-02-19 13:36:48 +01:00
* how to reach the author.
*
* $Id: remote.h 1.10 2000/10/03 10:45:35 kls Exp $
2000-02-19 13:36:48 +01:00
*/
#ifndef __REMOTE_H
#define __REMOTE_H
#include <stdio.h>
#include <time.h>
#include "tools.h"
2000-02-19 13:36:48 +01:00
2000-07-15 12:39:20 +02:00
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 WaitMs = 0) = 0;
2000-07-15 12:39:20 +02:00
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 {
private:
cFile f;
2000-07-15 12:39:20 +02:00
public:
cRcIoKBD(void);
virtual ~cRcIoKBD();
2000-09-19 17:48:42 +02:00
virtual void Flush(int WaitMs = 0);
2000-07-15 12:39:20 +02:00
virtual bool InputAvailable(bool Wait = false);
virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL);
};
#elif defined REMOTE_RCU
class cRcIoRCU : public cRcIoBase {
2000-02-19 13:36:48 +01:00
private:
cFile f;
2000-02-19 13:36:48 +01:00
unsigned char dp, code, mode;
unsigned short address;
int lastNumber;
2000-02-19 13:36:48 +01:00
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);
2000-02-19 13:36:48 +01:00
public:
2000-07-15 12:39:20 +02:00
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);
2000-09-19 17:48:42 +02:00
virtual void Flush(int WaitMs = 0);
2000-07-15 12:39:20 +02:00
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:
2000-07-15 16:35:18 +02:00
enum { LIRC_KEY_BUF = 8, LIRC_BUFFER_SIZE = 128 };
cFile f;
2000-07-15 16:35:18 +02:00
char keyName[LIRC_KEY_BUF];
int repeat;
2000-07-15 12:39:20 +02:00
const char *ReceiveString(void);
public:
cRcIoLIRC(char *DeviceName);
virtual ~cRcIoLIRC();
2000-09-19 17:48:42 +02:00
virtual void Flush(int WaitMs = 0);
2000-07-15 12:39:20 +02:00
virtual bool InputAvailable(bool Wait = false);
virtual bool GetCommand(unsigned int *Command, unsigned short *Address = NULL);
2000-02-19 13:36:48 +01:00
};
2000-07-15 12:39:20 +02:00
#else
#error Please define a remote control mode!
#endif
2000-02-19 13:36:48 +01:00
#endif //__REMOTE_H