summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2000-07-15 18:00:00 +0200
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2000-07-15 18:00:00 +0200
commit3b78ec8374aac8daa560fa0cd06260fca6eb1500 (patch)
treee753b7fb9304a47651926ce1db67f83127b510fb
parent9599a8fd8a6724e55ec4ad2ba2c975c0850073d9 (diff)
downloadvdr-patch-lnbsharing-vdr-0.06.tar.gz
vdr-patch-lnbsharing-vdr-0.06.tar.bz2
Version 0.06vdr-0.06
- Added support for LIRC remote control (thanks to Carsten Koch!). There are now three different remote control modes: KBD (PC-Keyboard), RCU and LIRC. See the INSTALL file for information on how to enable either of these modes. The default mode is now KBD, not RCU as before (to make it work immediately even if there is no actual remote control).
-rw-r--r--CONTRIBUTORS5
-rw-r--r--HISTORY9
-rw-r--r--INSTALL30
-rw-r--r--Makefile8
-rw-r--r--channels.conf6
-rw-r--r--config.c13
-rw-r--r--config.h3
-rw-r--r--dvbapi.c6
-rw-r--r--dvbapi.h4
-rw-r--r--interface.c28
-rw-r--r--remote.c250
-rw-r--r--remote.h85
-rw-r--r--timers.conf14
-rw-r--r--tools.c21
-rw-r--r--tools.h4
-rw-r--r--vdr.c6
16 files changed, 360 insertions, 132 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
new file mode 100644
index 0000000..fbf6e86
--- /dev/null
+++ b/CONTRIBUTORS
@@ -0,0 +1,5 @@
+Thanks go to the following people for patches and contributions:
+
+Carsten Koch <Carsten.Koch@icem.de>
+ for adding LIRC support
+
diff --git a/HISTORY b/HISTORY
index 9767c3f..40150c6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -55,3 +55,12 @@ Video Disk Recorder Revision History
- Reduced the number of remote control keys. Modified the key assignments for
the PC keyboard to better resemble the "up-down-left-right-ok" layout on
menu controlling remote control units.
+
+2000-07-15: Version 0.06
+
+- Added support for LIRC remote control (thanks to Carsten Koch!).
+ There are now three different remote control modes: KBD (PC-Keyboard), RCU
+ and LIRC. See the INSTALL file for information on how to enable either of
+ these modes. The default mode is now KBD, not RCU as before (to make it
+ work immediately even if there is no actual remote control).
+
diff --git a/INSTALL b/INSTALL
index bc619d7..1a6442d 100644
--- a/INSTALL
+++ b/INSTALL
@@ -20,10 +20,16 @@ and type 'make'. This should produce an executable file
named 'vdr', which can be run after the DVB driver has been
installed.
-There are two macros you can use to customize the 'vdr' program
-at compile time. Adding "DEBUG_REMOTE=1" to the 'make' call
-will use the PC's keyboard as input device instead of the "Remote
-Control Unit" (see http://www.cadsoft.de/people/kls/vdr/remote.htm).
+The 'vdr' program can be controlled via the PC keyboard or
+an infrared remote control unit. Define the REMOTE macro to one of the
+following values 'make' call to activate the respective control mode:
+
+ REMOTE=KBD control via the PC keyboard (default)
+ REMOTE=RCU control via the "Remote Control Unit" receiver
+ (see http://www.cadsoft.de/people/kls/vdr/remote.htm)
+ REMOTE=LIRC control via the "Linux Infrared Remote Control"
+ (see http://fsinfo.cs.uni-sb.de/~columbus/lirc)
+
Adding "DEBUG_OSD=1" will use the PC screen (or current window)
to display texts instead of the DVB card's on-screen display
interface. These modes are useful when testing new menus if you
@@ -65,7 +71,7 @@ Learning the remote control keys:
---------------------------------
There is no default 'keys.conf' file, so if you compile the program
-without 'DEBUG_REMOTE=1' you will have to go through a "teach-in"
+with 'REMOTE=RCU' you will have to go through a "teach-in"
session that allows the program to learn your remote control codes.
It will first attempt to determine the basic data transfer mode and
timing of your remote control unit, and then will ask you to press one
@@ -76,9 +82,9 @@ you define, the more you will be able to navigate through the menus and
control recording/replaying. The program uses only a very small number
of keys which have multiple meanings in the various modes (see MANUAL
for a detailed description).
-If the program has been built with "DEBUG_REMOTE=1", it will use the
+If the program has been built with "REMOTE=KBD", it will use the
key configuration file 'keys-pc.conf', so that you won't loose data
-when switching between normal and debug mode.
+when switching between remote control and keyboard mode.
The default PC key assignments are:
@@ -89,6 +95,12 @@ The default PC key assignments are:
Red, Green, Yellow, Blue 'F1'..'F4'
0..9 '0'..'9' in top row
-If you prefer different key assignments, simply delete the file
-'keys-pc.conf' and restart 'vdr' to get into learning mode.
+If you prefer different key assignments, or if the default doesn't work for
+your keyboard, simply delete the file 'keys-pc.conf' and restart 'vdr' to get
+into learning mode.
+
+If the program has been compiled with 'REMOTE=LIRC', no 'keys.conf' file
+will be used. Instead, the key names as listed in the source file 'config.c'
+must be used when setting up LIRC. See http://www2.arnes.si/~mthale1 for
+more about LIRC.
diff --git a/Makefile b/Makefile
index 0ed17ca..cfa7ef7 100644
--- a/Makefile
+++ b/Makefile
@@ -4,14 +4,16 @@
# See the main source file 'vdr.c' for copyright information and
# how to reach the author.
#
-# $Id: Makefile 1.3 2000/04/24 09:44:10 kls Exp $
+# $Id: Makefile 1.4 2000/06/24 15:09:30 kls Exp $
OBJS = config.o dvbapi.o interface.o menu.o osd.o recording.o remote.o tools.o vdr.o
-ifdef DEBUG_REMOTE
-DEFINES += -DDEBUG_REMOTE
+ifndef REMOTE
+REMOTE = KBD
endif
+DEFINES += -DREMOTE_$(REMOTE)
+
ifdef DEBUG_OSD
DEFINES += -DDEBUG_OSD
endif
diff --git a/channels.conf b/channels.conf
index 5edd778..d59b83b 100644
--- a/channels.conf
+++ b/channels.conf
@@ -1,5 +1,5 @@
RTL:12188:h:1:27500:163:104:0:0
-Sat.1:12552:v:1:22000:163:104:0:0
+Sat.1:12480:v:1:27500:1791:1792:0:0
Pro-7:12480:v:1:27500:255:256:0:0
RTL2:12188:h:1:27500:166:128:0:0
ARD:11837:h:1:27500:101:102:0:0
@@ -41,8 +41,8 @@ ORB:12722:h:1:22000:501:502:0:0
B1:12722:h:1:22000:601:602:0:0
ARD Online-Kanal:12722:h:1:22000:8191:701:0:0
Premiere World Promo:11798:h:1:27500:255:256:0:0
-Premiere:11798:h:1:27500:511:512:1:10
-Star Kino:11798:h:1:27500:767:768:1:9
+Premiere:11798:h:1:27500:511:512:2:10
+Star Kino:11798:h:1:27500:767:768:2:9
Cine Action:11798:h:1:27500:1023:1024:1:20
Cine Comedy:11798:h:1:27500:1279:1280:1:29
Sci Fantasy:11798:h:1:27500:1535:1536:1:41
diff --git a/config.c b/config.c
index 7e02c91..ca43ff0 100644
--- a/config.c
+++ b/config.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.c 1.7 2000/05/27 14:44:15 kls Exp $
+ * $Id: config.c 1.8 2000/06/24 13:43:14 kls Exp $
*/
#include "config.h"
@@ -146,6 +146,17 @@ eKeys cKeys::Get(unsigned int Code)
return kNone;
}
+unsigned int cKeys::Encode(const char *Command)
+{
+ if (Command != NULL) {
+ const tKey *k = keys;
+ while ((k->type != kNone) && strncmp(k->name, Command, strlen(k->name)) != 0) //XXX why 'strncmp()'???
+ k++;
+ return k->code;
+ }
+ return 0;
+}
+
void cKeys::Set(eKeys Key, unsigned int Code)
{
for (tKey *k = keys; k->type != kNone; k++) {
diff --git a/config.h b/config.h
index 1e22b88..22099b9 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.h 1.6 2000/05/27 14:43:46 kls Exp $
+ * $Id: config.h 1.7 2000/06/24 13:42:32 kls Exp $
*/
#ifndef __CONFIG_H
@@ -52,6 +52,7 @@ public:
void Clear(void);
bool Load(char *FileName = NULL);
bool Save(void);
+ unsigned int Encode(const char *Command);
eKeys Get(unsigned int Code);
void Set(eKeys Key, unsigned int Code);
};
diff --git a/dvbapi.c b/dvbapi.c
index e652d99..58b2d74 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbapi.c 1.10 2000/05/27 14:07:17 kls Exp $
+ * $Id: dvbapi.c 1.11 2000/06/24 14:03:19 kls Exp $
*/
#include "dvbapi.h"
@@ -1054,7 +1054,7 @@ cDvbApi::cDvbApi(const char *FileName)
if (videoDev < 0)
LOG_ERROR;
cols = rows = 0;
-#if defined(DEBUG_OSD) || defined(DEBUG_REMOTE)
+#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
initscr();
keypad(stdscr, TRUE);
nonl();
@@ -1080,7 +1080,7 @@ cDvbApi::~cDvbApi()
StopRecord();
close(videoDev);
}
-#if defined(DEBUG_REMOTE) || defined(DEBUG_OSD)
+#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
endwin();
#endif
delete replayTitle;
diff --git a/dvbapi.h b/dvbapi.h
index e0c74b0..a43ba0e 100644
--- a/dvbapi.h
+++ b/dvbapi.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbapi.h 1.10 2000/05/20 14:50:43 kls Exp $
+ * $Id: dvbapi.h 1.11 2000/06/24 14:03:57 kls Exp $
*/
#ifndef __DVBAPI_H
@@ -15,7 +15,7 @@ typedef unsigned int __u32;
typedef unsigned short __u16;
typedef unsigned char __u8;
-#if defined(DEBUG_OSD) || defined(DEBUG_REMOTE)
+#if defined(DEBUG_OSD) || defined(REMOTE_KBD)
#include <ncurses.h>
#endif
#include <stdio.h>
diff --git a/interface.c b/interface.c
index 82f955d..244488a 100644
--- a/interface.c
+++ b/interface.c
@@ -4,15 +4,19 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: interface.c 1.9 2000/05/07 09:28:39 kls Exp $
+ * $Id: interface.c 1.10 2000/07/15 12:39:20 kls Exp $
*/
#include "interface.h"
#include <unistd.h>
#include "remote.h"
-#ifndef DEBUG_REMOTE
-cRcIo RcIo("/dev/ttyS1");
+#if defined(REMOTE_RCU)
+cRcIoRCU RcIo("/dev/ttyS1");
+#elif defined(REMOTE_LIRC)
+cRcIoLIRC RcIo("/dev/lircd");
+#else
+cRcIoKBD RcIo;
#endif
cInterface Interface;
@@ -26,9 +30,7 @@ cInterface::cInterface(void)
void cInterface::Init(void)
{
-#ifndef DEBUG_REMOTE
RcIo.SetCode(Keys.code, Keys.address);
-#endif
}
void cInterface::Open(int NumCols, int NumLines)
@@ -47,21 +49,15 @@ void cInterface::Close(void)
unsigned int cInterface::GetCh(bool Wait)
{
-#ifdef DEBUG_REMOTE
- timeout(Wait ? 1000 :10);
- int c = getch();
- return (c > 0) ? c : 0;
-#else
#ifdef DEBUG_OSD
timeout(0);
getch(); // just to make 'ncurses' display the window:
#endif
- if (Wait || RcIo.InputAvailable()) {
+ if (RcIo.InputAvailable(Wait)) {
unsigned int Command;
return RcIo.GetCommand(&Command, NULL) ? Command : 0;
}
return 0;
-#endif
}
eKeys cInterface::GetKey(bool Wait)
@@ -215,12 +211,12 @@ void cInterface::QueryKeys(void)
WriteText(1, 1, "Learning Remote Control Keys");
WriteText(1, 3, "Phase 1: Detecting RC code type");
WriteText(1, 5, "Press any key on the RC unit");
-#ifndef DEBUG_REMOTE
+#ifndef REMOTE_KBD
unsigned char Code = 0;
unsigned short Address;
#endif
for (;;) {
-#ifdef DEBUG_REMOTE
+#ifdef REMOTE_KBD
if (GetCh())
break;
#else
@@ -318,9 +314,7 @@ void cInterface::LearnKeys(void)
void cInterface::DisplayChannel(int Number, const char *Name)
{
-#ifndef DEBUG_REMOTE
RcIo.Number(Number);
-#endif
if (Name && !Recording()) {
Open(MenuColumns, 1);
char buffer[MenuColumns + 1];
@@ -338,9 +332,7 @@ void cInterface::DisplayChannel(int Number, const char *Name)
void cInterface::DisplayRecording(int Index, bool On)
{
-#ifndef DEBUG_REMOTE
RcIo.SetPoints(1 << Index, On);
-#endif
}
bool cInterface::Recording(void)
diff --git a/remote.c b/remote.c
index eb495e1..e3786c5 100644
--- a/remote.c
+++ b/remote.c
@@ -4,7 +4,9 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: remote.c 1.7 2000/05/07 09:28:18 kls Exp $
+ * Ported to LIRC by Carsten Koch <Carsten.Koch@icem.de> 2000-06-16.
+ *
+ * $Id: remote.c 1.9 2000/07/15 12:19:50 kls Exp $
*/
#include "remote.h"
@@ -15,20 +17,82 @@
#include <sys/time.h>
#include <termios.h>
#include <unistd.h>
+
+#if defined REMOTE_LIRC
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/un.h>
+#endif
+
+#include "config.h"
#include "tools.h"
#define REPEATLIMIT 100 // ms
#define REPEATDELAY 250 // ms
-cRcIo::cRcIo(char *DeviceName)
+// --- cRcIoBase -------------------------------------------------------------
+
+cRcIoBase::cRcIoBase(void)
+{
+ t = 0;
+ firstTime = lastTime = 0;
+ lastCommand = 0;
+}
+
+cRcIoBase::~cRcIoBase()
+{
+}
+
+// --- cRcIoKBD --------------------------------------------------------------
+
+#if defined REMOTE_KBD
+
+cRcIoKBD::cRcIoKBD(void)
+{
+}
+
+cRcIoKBD::~cRcIoKBD()
+{
+}
+
+void cRcIoKBD::Flush(int WaitSeconds)
+{
+ time_t t0 = time(NULL);
+
+ timeout(10);
+ for (;;) {
+ while (getch() > 0)
+ t0 = time(NULL);
+ if (time(NULL) - t0 >= WaitSeconds)
+ break;
+ }
+}
+
+bool cRcIoKBD::InputAvailable(bool Wait)
+{
+ timeout(Wait ? 1000 : 10);
+ return true;//XXX
+}
+
+bool cRcIoKBD::GetCommand(unsigned int *Command, unsigned short *)
+{
+ if (Command) {
+ *Command = getch();
+ return *Command > 0;
+ }
+ return false;
+}
+
+// --- cRcIoRCU --------------------------------------------------------------
+
+#elif defined REMOTE_RCU
+
+cRcIoRCU::cRcIoRCU(char *DeviceName)
{
dp = 0;
mode = modeB;
code = 0;
address = 0xFFFF;
- t = 0;
- firstTime = lastTime = 0;
- lastCommand = 0;
lastNumber = 0;
if ((f = open(DeviceName, O_RDWR | O_NONBLOCK)) >= 0) {
struct termios t;
@@ -46,59 +110,50 @@ cRcIo::cRcIo(char *DeviceName)
f = -1;
}
-cRcIo::~cRcIo()
+cRcIoRCU::~cRcIoRCU()
{
if (f >= 0)
close(f);
}
-bool cRcIo::InputAvailable(bool Wait)
-{
- if (f >= 0) {
- fd_set set;
- struct timeval timeout;
- timeout.tv_sec = Wait ? 1 : 0;
- timeout.tv_usec = Wait ? 0 : 10000;
- FD_ZERO(&set);
- FD_SET(f, &set);
- if (select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0)
- return FD_ISSET(f, &set);
- }
- return false;
-}
-
-int cRcIo::ReceiveByte(bool Wait)
+int cRcIoRCU::ReceiveByte(bool Wait)
{
// Returns the byte if one was received within a timeout, -1 otherwise
if (InputAvailable(Wait)) {
unsigned char b;
if (read(f, &b, 1) == 1)
return b;
+ else
+ LOG_ERROR;
}
return -1;
}
-bool cRcIo::SendByteHandshake(unsigned char c)
+bool cRcIoRCU::SendByteHandshake(unsigned char c)
{
- if (f >= 0 && write(f, &c, 1) == 1) {
- for (int reply = ReceiveByte(); reply >= 0;) {
- if (reply == c)
- return true;
- else if (reply == 'X') {
- // skip any incoming RC code - it will come again
- for (int i = 6; i--;) {
- if (ReceiveByte(false) < 0)
- return false;
- }
+ if (f >= 0) {
+ int w = write(f, &c, 1);
+ if (w == 1) {
+ for (int reply = ReceiveByte(); reply >= 0;) {
+ if (reply == c)
+ return true;
+ else if (reply == 'X') {
+ // skip any incoming RC code - it will come again
+ for (int i = 6; i--;) {
+ if (ReceiveByte(false) < 0)
+ return false;
+ }
+ }
+ else
+ return false;
}
- else
- return false;
- }
+ }
+ LOG_ERROR;
}
return false;
}
-bool cRcIo::SendByte(unsigned char c)
+bool cRcIoRCU::SendByte(unsigned char c)
{
for (int retry = 5; retry--;) {
if (SendByteHandshake(c))
@@ -107,7 +162,20 @@ bool cRcIo::SendByte(unsigned char c)
return false;
}
-void cRcIo::Flush(int WaitSeconds)
+bool cRcIoRCU::SetCode(unsigned char Code, unsigned short Address)
+{
+ code = Code;
+ address = Address;
+ return SendCommand(code);
+}
+
+bool cRcIoRCU::SetMode(unsigned char Mode)
+{
+ mode = Mode;
+ return SendCommand(mode);
+}
+
+void cRcIoRCU::Flush(int WaitSeconds)
{
time_t t0 = time(NULL);
@@ -119,20 +187,12 @@ void cRcIo::Flush(int WaitSeconds)
}
}
-bool cRcIo::SetCode(unsigned char Code, unsigned short Address)
+bool cRcIoRCU::InputAvailable(bool Wait)
{
- code = Code;
- address = Address;
- return SendCommand(code);
+ return DataAvailable(f, Wait);
}
-bool cRcIo::SetMode(unsigned char Mode)
-{
- mode = Mode;
- return SendCommand(mode);
-}
-
-bool cRcIo::GetCommand(unsigned int *Command, unsigned short *Address)
+bool cRcIoRCU::GetCommand(unsigned int *Command, unsigned short *Address)
{
#pragma pack(1)
union {
@@ -185,17 +245,17 @@ bool cRcIo::GetCommand(unsigned int *Command, unsigned short *Address)
return false;
}
-bool cRcIo::SendCommand(unsigned char Cmd)
+bool cRcIoRCU::SendCommand(unsigned char Cmd)
{
return SendByte(Cmd | 0x80);
}
-bool cRcIo::Digit(int n, int v)
+bool cRcIoRCU::Digit(int n, int v)
{
return SendByte(((n & 0x03) << 5) | (v & 0x0F) | (((dp >> n) & 0x01) << 4));
}
-bool cRcIo::Number(int n, bool Hex)
+bool cRcIoRCU::Number(int n, bool Hex)
{
if (!Hex) {
char buf[8];
@@ -216,7 +276,7 @@ bool cRcIo::Number(int n, bool Hex)
return SendCommand(mode);
}
-bool cRcIo::String(char *s)
+bool cRcIoRCU::String(char *s)
{
const char *chars = mode == modeH ? "0123456789ABCDEF" : "0123456789-EHLP ";
int n = 0;
@@ -233,7 +293,7 @@ bool cRcIo::String(char *s)
return Number(n, true);
}
-void cRcIo::SetPoints(unsigned char Dp, bool On)
+void cRcIoRCU::SetPoints(unsigned char Dp, bool On)
{
if (On)
dp |= Dp;
@@ -242,7 +302,7 @@ void cRcIo::SetPoints(unsigned char Dp, bool On)
Number(lastNumber, true);
}
-bool cRcIo::DetectCode(unsigned char *Code, unsigned short *Address)
+bool cRcIoRCU::DetectCode(unsigned char *Code, unsigned short *Address)
{
// Caller should initialize 'Code' to 0 and call DetectCode()
// until it returns true. Whenever DetectCode() returns false
@@ -276,3 +336,83 @@ bool cRcIo::DetectCode(unsigned char *Code, unsigned short *Address)
return false;
}
+// --- cRcIoLIRC -------------------------------------------------------------
+
+#elif defined REMOTE_LIRC
+
+cRcIoLIRC::cRcIoLIRC(char *DeviceName)
+{
+ struct sockaddr_un addr;
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, DeviceName);
+ f = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (f >= 0) {
+ if (connect(f, (struct sockaddr *)&addr, sizeof(addr)) >= 0)
+ return;
+ LOG_ERROR_STR(DeviceName);
+ close(f);
+ }
+ else
+ LOG_ERROR_STR(DeviceName);
+ f = -1;
+}
+
+cRcIoLIRC::~cRcIoLIRC()
+{
+ if (f >= 0)
+ close(f);
+}
+
+const char *cRcIoLIRC::ReceiveString(void)
+{
+ while (InputAvailable(true)) {
+ if (read(f, buf, sizeof(buf)) > 21) {
+ const int repeat = 10 * (buf[17] - '0') + (buf[18] - '0');
+ const int now = time_ms();
+ if (repeat == 0) {
+ firstTime = lastTime = now;
+ return buf + 20;
+ }
+ else if ((now > firstTime + REPEATDELAY) && (now > lastTime + REPEATLIMIT)) {
+ lastTime = now;
+ return buf + 20;
+ }
+ }
+ }
+ return NULL;
+}
+
+void cRcIoLIRC::Flush(int WaitSeconds)
+{
+ time_t t0 = time(NULL);
+
+ for (;;) {
+ while (InputAvailable(false)) {
+ read(f, buf, sizeof(buf));
+ t0 = time(NULL);
+ }
+ if (time(NULL) - t0 >= WaitSeconds)
+ break;
+ }
+}
+
+bool cRcIoLIRC::InputAvailable(bool Wait)
+{
+ return DataAvailable(f, Wait);
+}
+
+bool cRcIoLIRC::GetCommand(unsigned int *Command, unsigned short *)
+{
+ Flush();
+ if (Command) {
+ const char *cmd = ReceiveString();
+ if (cmd) {
+ *Command = Keys.Encode(cmd);
+ return true;
+ }
+ }
+ return false;
+}
+
+#endif
+
diff --git a/remote.h b/remote.h
index 1d0a1cc..38961b9 100644
--- a/remote.h
+++ b/remote.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: remote.h 1.5 2000/05/07 09:27:54 kls Exp $
+ * $Id: remote.h 1.6 2000/06/24 15:52:56 kls Exp $
*/
#ifndef __REMOTE_H
@@ -13,14 +13,44 @@
#include <stdio.h>
#include <time.h>
-class cRcIo {
+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;
- time_t t;
- int firstTime, lastTime;
- unsigned int lastCommand;
int lastNumber;
bool SendCommand(unsigned char Cmd);
int ReceiveByte(bool Wait = true);
@@ -28,18 +58,39 @@ private:
bool SendByte(unsigned char c);
bool Digit(int n, int v);
public:
- enum { modeH = 'h', modeB = 'b', modeS = 's' };
- cRcIo(char *DeviceName);
- ~cRcIo();
- bool InputAvailable(bool Wait = false);
- void Flush(int WaitSeconds = 0);
- bool SetCode(unsigned char Code, unsigned short Address);
- bool SetMode(unsigned char Mode);
- bool GetCommand(unsigned int *Command, unsigned short *Address = NULL);
- bool Number(int n, bool Hex = false);
- void SetPoints(unsigned char Dp, bool On);
- bool String(char *s);
- bool DetectCode(unsigned char *Code, unsigned short *Address);
+ 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_BUFFER_SIZE = 128 };
+ int f;
+ char buf[LIRC_BUFFER_SIZE];
+ 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
diff --git a/timers.conf b/timers.conf
index 1f9fae0..a5dcb9a 100644
--- a/timers.conf
+++ b/timers.conf
@@ -1,10 +1,10 @@
1:15:MTWTF--:1828:1901:10:5:nano
-1:3:M------:2110:2230:99:10:SevenDays
1:10:-T-----:2058:2202:99:10:Quarks
-1:3:---T---:2158:2300:99:10:Switch
-1:1:----F--:2210:2325:99:10:7Tage7Koepfe
+1:5:-T-----:2100:2205:99:10:RudisSuchmaschine
+0:3:---T---:2211:2300:99:10:Switch
1:15:-----S-:1358:1435:99:7:Neues
-1:1:-----S-:1445:1600:99:10:Hammerman
-1:2:-----S-:2150:2320:99:10:Wochenshow
-1:14:------S:2155:2245:99:10:AprilHailer
-1:2:--W----:2110:2325:99:99:BulleVonToelz
+1:1:-----S-:1445:1600:99:30:Hammerman
+1:2:-----S-:2200:2350:99:30:Wochenshow
+1:11:------S:2058:2120:99:10:Centauri
+1:14:20:1920:2035:99:30:SamtUndSeide
+1:10:---T---:2158:2250:99:99:DiePlaneten
diff --git a/tools.c b/tools.c
index eb0a14a..c0eb2ec 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.7 2000/04/24 15:01:35 kls Exp $
+ * $Id: tools.c 1.8 2000/06/24 15:26:15 kls Exp $
*/
#define _GNU_SOURCE
@@ -22,15 +22,18 @@
int SysLogLevel = 3;
-bool DataAvailable(int filedes)
+bool DataAvailable(int filedes, bool wait)
{
- fd_set set;
- FD_ZERO(&set);
- FD_SET(filedes, &set);
- struct timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 10000;
- return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(filedes, &set);
+ if (filedes >= 0) {
+ fd_set set;
+ FD_ZERO(&set);
+ FD_SET(filedes, &set);
+ struct timeval timeout;
+ timeout.tv_sec = wait ? 1 : 0;
+ timeout.tv_usec = wait ? 0 : 10000;
+ return select(FD_SETSIZE, &set, NULL, NULL, &timeout) > 0 && FD_ISSET(filedes, &set);
+ }
+ return false;
}
void writechar(int filedes, char c)
diff --git a/tools.h b/tools.h
index 57b2065..db55983 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.h 1.7 2000/04/24 15:01:49 kls Exp $
+ * $Id: tools.h 1.8 2000/06/24 15:25:00 kls Exp $
*/
#ifndef __TOOLS_H
@@ -30,7 +30,7 @@ extern int SysLogLevel;
#define DELETENULL(p) (delete (p), p = NULL)
-bool DataAvailable(int filedes);
+bool DataAvailable(int filedes, bool wait = false);
void writechar(int filedes, char c);
void writeint(int filedes, int n);
char readchar(int filedes);
diff --git a/vdr.c b/vdr.c
index bcda471..4c1dce0 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/people/kls/vdr
*
- * $Id: vdr.c 1.19 2000/05/27 15:38:35 kls Exp $
+ * $Id: vdr.c 1.20 2000/07/15 11:45:05 kls Exp $
*/
#include <signal.h>
@@ -33,7 +33,7 @@
#include "recording.h"
#include "tools.h"
-#ifdef DEBUG_REMOTE
+#ifdef REMOTE_KBD
#define KEYS_CONF "keys-pc.conf"
#else
#define KEYS_CONF "keys.conf"
@@ -58,8 +58,10 @@ int main(int argc, char *argv[])
Channels.Load("channels.conf");
Timers.Load("timers.conf");
+#ifndef REMOTE_LIRC
if (!Keys.Load(KEYS_CONF))
Interface.LearnKeys();
+#endif
Interface.Init();
cChannel::SwitchTo(CurrentChannel);