vdr/remote.h

103 lines
3.0 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.
*
2002-05-09 16:26:56 +02:00
* $Id: remote.h 1.16 2002/05/09 11:43:04 kls Exp $
2000-02-19 13:36:48 +01:00
*/
#ifndef __REMOTE_H
#define __REMOTE_H
#include <stdio.h>
#include <time.h>
2000-10-08 09:25:20 +02:00
#include "thread.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;
public:
enum { modeH = 'h', modeB = 'b', modeS = 's' };
2001-02-02 14:56:45 +01:00
cRcIoBase(void);
virtual ~cRcIoBase();
2000-07-15 12:39:20 +02:00
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; }
2000-10-08 09:25:20 +02:00
virtual void Flush(int WaitMs = 0) {}
2001-02-02 14:56:45 +01:00
virtual bool InputAvailable(void) { return false; }
virtual bool GetCommand(unsigned int *Command = NULL, bool *Repeat = NULL, bool *Release = NULL) { return false; }
2000-07-15 12:39:20 +02:00
};
#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-10-08 09:25:20 +02:00
virtual bool InputAvailable(void);
virtual bool GetCommand(unsigned int *Command = NULL, bool *Repeat = NULL, bool *Release = NULL);
2000-07-15 12:39:20 +02:00
};
#elif defined REMOTE_RCU
2000-10-08 09:25:20 +02:00
class cRcIoRCU : public cRcIoBase, private cThread {
2000-02-19 13:36:48 +01:00
private:
2000-10-08 09:25:20 +02:00
int f;
2000-02-19 13:36:48 +01:00
unsigned char dp, code, mode;
unsigned short address;
2000-10-08 09:25:20 +02:00
unsigned short receivedAddress;
unsigned int receivedCommand;
bool receivedData, receivedRepeat, receivedRelease;
int lastNumber;
2000-02-19 13:36:48 +01:00
bool SendCommand(unsigned char Cmd);
2000-10-08 09:25:20 +02:00
int ReceiveByte(int TimeoutMs = 0);
2000-02-19 13:36:48 +01:00
bool SendByteHandshake(unsigned char c);
bool SendByte(unsigned char c);
bool Digit(int n, int v);
2000-10-08 09:25:20 +02:00
virtual void Action(void);
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-10-08 09:25:20 +02:00
virtual bool InputAvailable(void) { return receivedData; }
virtual bool GetCommand(unsigned int *Command = NULL, bool *Repeat = NULL, bool *Release = NULL);
2000-07-15 12:39:20 +02:00
};
#elif defined REMOTE_LIRC
2000-10-08 09:25:20 +02:00
class cRcIoLIRC : public cRcIoBase, private cThread {
2000-07-15 12:39:20 +02:00
private:
enum { LIRC_KEY_BUF = 30, LIRC_BUFFER_SIZE = 128 };
2000-10-08 09:25:20 +02:00
int f;
2000-07-15 16:35:18 +02:00
char keyName[LIRC_KEY_BUF];
bool receivedData, receivedRepeat, receivedRelease;
2000-10-08 09:25:20 +02:00
virtual void Action(void);
2000-07-15 12:39:20 +02:00
public:
cRcIoLIRC(char *DeviceName);
virtual ~cRcIoLIRC();
2000-10-08 09:25:20 +02:00
virtual bool InputAvailable(void) { return receivedData; }
virtual bool GetCommand(unsigned int *Command = NULL, bool *Repeat = NULL, bool *Release = NULL);
2000-02-19 13:36:48 +01:00
};
2001-02-02 14:56:45 +01:00
#elif !defined REMOTE_NONE
2000-07-15 12:39:20 +02:00
2002-05-09 16:26:56 +02:00
// #error Please define a remote control mode!
2000-07-15 12:39:20 +02:00
#endif
2000-02-19 13:36:48 +01:00
#endif //__REMOTE_H