From d6b8a2832973d7bf767039a91905059bc7800452 Mon Sep 17 00:00:00 2001
From: Klaus Schmidinger <vdr@tvdr.de>
Date: Sun, 31 Jul 2005 11:38:40 +0200
Subject: Added the command line options '--lirc', '--rcu' and '--no-kbd'

---
 CONTRIBUTORS         |  2 ++
 HISTORY              |  4 +++-
 INSTALL              | 16 +++++++++++-----
 Make.config.template |  7 ++++++-
 Makefile             | 10 ++++++++--
 lirc.c               |  4 ++--
 lirc.h               |  4 ++--
 rcu.c                |  4 ++--
 rcu.h                |  4 ++--
 vdr.1                | 15 +++++++++++++--
 vdr.c                | 47 ++++++++++++++++++++++++++++++++++++++---------
 11 files changed, 89 insertions(+), 28 deletions(-)

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 2eeb9e3a..ab14f41d 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -1292,6 +1292,8 @@ Olaf Titz <olaf@bigred.inka.de>
 Darren Salt <linux@youmustbejoking.demon.co.uk>
  for pointing out that the '-' and '�' characters need to be escaped in the man
  pages
+ for a patch that was used to add the command line options '--lirc', '--rcu' and
+ '--no-kbd'
 
 Sean Carlos <seanc@libero.it>
  for translating OSD texts to the Italian language
diff --git a/HISTORY b/HISTORY
index 43dfbe31..0c94ed0c 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3634,7 +3634,7 @@ Video Disk Recorder Revision History
   replaced with the new one instead of adding the new entries (thanks to Andreas
   Regel).
 
-2005-07-30: Version 1.3.28
+2005-07-31: Version 1.3.28
 
 - Added a sleep in cDvbPlayer::Action() in case there is no data to send to the
   device, which avoids a busy loop on very fast machines (thanks to Martin Wache).
@@ -3648,3 +3648,5 @@ Video Disk Recorder Revision History
   VPS timers to stop recording prematurely.
 - Avoiding duplicate components in EPG events when reading epg.data or in the
   PUTE SVDRP command (thanks to Olaf Titz for reporting this one).
+- Added the command line options '--lirc', '--rcu' and '--no-kbd' to allow setting
+  the remote control at runtime (based on a patch by Darren Salt).
diff --git a/INSTALL b/INSTALL
index 581a5d91..778dd6c1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -45,17 +45,23 @@ installed.
 IMPORTANT: See "Configuration files" below for information on how
 =========  to set up the configuration files at the proper location!
 
-By default the 'vdr' program can be controlled via the PC keyboard. If you have
-an infrared remote control unit you can define the REMOTE macro to one of the
-following values in the 'make' call to activate the respective control mode:
+By default the 'vdr' program can be controlled via the PC keyboard.
+If you want to disable control via the keyboard, you can add NO_KBD=1
+to the 'make' call, or use the '--no-kbd' option at runtime.
+
+If you have an infrared remote control unit you can define the REMOTE macro
+to one of the following values in the 'make' call to make the respective control
+the default:
 
   REMOTE=RCU    control via the "Remote Control Unit" receiver
                 (see http://www.cadsoft.de/vdr/remote.htm)
   REMOTE=LIRC   control via the "Linux Infrared Remote Control"
                 (see http://www.lirc.org)
 
-If you want to disable control via the PC keyboard, you can add NO_KBD=1
-to the 'make' call.
+Alternatively you can use the '--rcu' or '--lirc' options at runtime.
+These options accept an optional path to the remote control device,
+which's defaults can be set via the RCU_DEVICE and LIRC_DEVICE macros,
+respectively.
 
 If your video directory will be on a VFAT partition, add the compile
 time switch
diff --git a/Make.config.template b/Make.config.template
index 3c429e77..149ce986 100644
--- a/Make.config.template
+++ b/Make.config.template
@@ -6,7 +6,7 @@
 # See the main source file 'vdr.c' for copyright information and
 # how to reach the author.
 #
-# $Id: Make.config.template 1.4 2005/05/14 10:32:33 kls Exp $
+# $Id: Make.config.template 1.5 2005/07/31 11:35:28 kls Exp $
 
 ### The C compiler and options:
 
@@ -25,3 +25,8 @@ BINDIR   = /usr/local/bin
 PLUGINDIR= ./PLUGINS
 PLUGINLIBDIR= $(PLUGINDIR)/lib
 VIDEODIR = /video
+
+### The remote control:
+
+LIRC_DEVICE = /dev/lircd
+RCU_DEVICE  = /dev/ttyS1
diff --git a/Makefile b/Makefile
index 7bc8a57d..12142390 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
 # See the main source file 'vdr.c' for copyright information and
 # how to reach the author.
 #
-# $Id: Makefile 1.75 2005/05/14 10:32:13 kls Exp $
+# $Id: Makefile 1.76 2005/07/31 11:20:20 kls Exp $
 
 .DELETE_ON_ERROR:
 
@@ -65,8 +65,14 @@ SMLFONT_ISO8859_15 = -adobe-helvetica-medium-r-normal--18-*-100-100-p-*-iso8859-
 ifndef NO_KBD
 DEFINES += -DREMOTE_KBD
 endif
-
+ifdef REMOTE
 DEFINES += -DREMOTE_$(REMOTE)
+endif
+
+LIRC_DEVICE ?= /dev/lircd
+RCU_DEVICE  ?= /dev/ttyS1
+
+DEFINES += -DLIRC_DEVICE=\"$(LIRC_DEVICE)\" -DRCU_DEVICE=\"$(RCU_DEVICE)\"
 
 DEFINES += -D_GNU_SOURCE
 
diff --git a/lirc.c b/lirc.c
index dbda75c2..0714049b 100644
--- a/lirc.c
+++ b/lirc.c
@@ -6,7 +6,7 @@
  *
  * LIRC support added by Carsten Koch <Carsten.Koch@icem.de>  2000-06-16.
  *
- * $Id: lirc.c 1.10 2005/01/14 14:18:42 kls Exp $
+ * $Id: lirc.c 1.11 2005/07/31 10:18:09 kls Exp $
  */
 
 #include "lirc.h"
@@ -18,7 +18,7 @@
 #define REPEATDELAY 350 // ms
 #define KEYPRESSDELAY 150 // ms
 
-cLircRemote::cLircRemote(char *DeviceName)
+cLircRemote::cLircRemote(const char *DeviceName)
 :cRemote("LIRC")
 ,cThread("LIRC remote control")
 {
diff --git a/lirc.h b/lirc.h
index cd3c780d..25b743fe 100644
--- a/lirc.h
+++ b/lirc.h
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: lirc.h 1.2 2003/04/12 14:15:20 kls Exp $
+ * $Id: lirc.h 1.3 2005/07/31 10:18:15 kls Exp $
  */
 
 #ifndef __LIRC_H
@@ -19,7 +19,7 @@ private:
   int f;
   virtual void Action(void);
 public:
-  cLircRemote(char *DeviceName);
+  cLircRemote(const char *DeviceName);
   virtual ~cLircRemote();
   virtual bool Ready(void);
   };
diff --git a/rcu.c b/rcu.c
index 4ea80d9e..fea31ec3 100644
--- a/rcu.c
+++ b/rcu.c
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: rcu.c 1.8 2004/12/19 18:06:00 kls Exp $
+ * $Id: rcu.c 1.9 2005/07/31 10:17:45 kls Exp $
  */
 
 #include "rcu.h"
@@ -16,7 +16,7 @@
 #define REPEATLIMIT  20 // ms
 #define REPEATDELAY 350 // ms
 
-cRcuRemote::cRcuRemote(char *DeviceName)
+cRcuRemote::cRcuRemote(const char *DeviceName)
 :cRemote("RCU")
 ,cThread("RCU remote control")
 {
diff --git a/rcu.h b/rcu.h
index 534ca3da..be5c64af 100644
--- a/rcu.h
+++ b/rcu.h
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: rcu.h 1.3 2003/04/12 14:36:09 kls Exp $
+ * $Id: rcu.h 1.4 2005/07/31 10:18:00 kls Exp $
  */
 
 #ifndef __RCU_H
@@ -37,7 +37,7 @@ private:
   virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber);
   virtual void Recording(const cDevice *Device, const char *Name);
 public:
-  cRcuRemote(char *DeviceName);
+  cRcuRemote(const char *DeviceName);
   virtual ~cRcuRemote();
   virtual bool Ready(void);
   virtual bool Initialize(void);
diff --git a/vdr.1 b/vdr.1
index a6783969..af8ce127 100644
--- a/vdr.1
+++ b/vdr.1
@@ -8,7 +8,7 @@
 .\" License as specified in the file COPYING that comes with the
 .\" vdr distribution.
 .\"
-.\" $Id: vdr.1 1.13 2004/12/19 09:36:25 kls Exp $
+.\" $Id: vdr.1 1.14 2005/07/31 10:49:35 kls Exp $
 .\"
 .TH vdr 1 "19 Dec 2004" "1.3.18" "Video Disk Recorder"
 .SH NAME
@@ -46,7 +46,7 @@ Read config files from directory \fIdir\fR
 (default is to read them from the video directory).
 .TP
 .B \-d, \-\-daemon
-Run in daemon mode.
+Run in daemon mode (implies \-\-no\-kbd).
 .TP
 .BI \-D\  num ,\ \-\-device= num
 Use only the given DVB device (\fInum\fR = 0, 1, 2...).
@@ -75,9 +75,16 @@ Search for plugins in directory \fIdir\fR (default is ./PLUGINS/lib).
 There can be several \fB\-L\fR options with different \fIdir\fR values.
 Each of them will apply to the \fB\-P\fR options following it.
 .TP
+.BI \-\-lirc[= path ]
+Use a LIRC remote control device.
+If \fIpath\fR is omitted, vdr uses \fI/dev/lircd\fR.
+.TP
 .B \-m, \-\-mute
 Mute audio of the primary DVB device at startup.
 .TP
+.B \-\-no\-kbd
+Don't use the keyboard as an input device.
+.TP
 .BI \-p\  port ,\ \-\-port= port
 Use \fIport\fR for SVDRP. A value of \fB0\fR turns off SVDRP.
 The default SVDRP port is \fB2001\fR.
@@ -101,6 +108,10 @@ particular options) you can use
 
 (note the quotes around the asterisk to prevent wildcard expansion).
 .TP
+.BI \-\-rcu[= path ]
+Use a serial port remote control device.
+If \fIpath\fR is omitted, vdr uses \fI/dev/ttyS1\fR.
+.TP
 .BI \-r\  cmd ,\ \-\-record= cmd
 Call \fIcmd\fR before and after a recording.
 .TP
diff --git a/vdr.c b/vdr.c
index bd9de2fd..f58d02bf 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
  *
  * The project's page is at http://www.cadsoft.de/vdr
  *
- * $Id: vdr.c 1.208 2005/06/18 11:19:07 kls Exp $
+ * $Id: vdr.c 1.209 2005/07/31 11:25:16 kls Exp $
  */
 
 #include <getopt.h>
@@ -115,6 +115,19 @@ int main(int argc, char *argv[])
   int WatchdogTimeout = DEFAULTWATCHDOG;
   const char *Terminal = NULL;
   const char *Shutdown = NULL;
+
+  bool UseKbd = true;
+  const char *LircDevice = NULL;
+  const char *RcuDevice = NULL;
+#if !defined(REMOTE_KBD)
+  UseKbd = false;
+#endif
+#if defined(REMOTE_LIRC)
+  LircDevice = LIRC_DEVICE;
+#elif defined(REMOTE_RCU)
+  RcuDevice = RCU_DEVICE;
+#endif
+
   cPluginManager PluginManager(DEFAULTPLUGINDIR);
   int ExitCode = 0;
 
@@ -126,10 +139,13 @@ int main(int argc, char *argv[])
       { "epgfile",  required_argument, NULL, 'E' },
       { "help",     no_argument,       NULL, 'h' },
       { "lib",      required_argument, NULL, 'L' },
+      { "lirc",     optional_argument, NULL, 'l' | 0x100 },
       { "log",      required_argument, NULL, 'l' },
       { "mute",     no_argument,       NULL, 'm' },
+      { "no-kbd",   no_argument,       NULL, 'n' | 0x100 },
       { "plugin",   required_argument, NULL, 'P' },
       { "port",     required_argument, NULL, 'p' },
+      { "rcu",      optional_argument, NULL, 'r' | 0x100 },
       { "record",   required_argument, NULL, 'r' },
       { "shutdown", required_argument, NULL, 's' },
       { "terminal", required_argument, NULL, 't' },
@@ -194,8 +210,14 @@ int main(int argc, char *argv[])
                        return 2;
                        }
                     break;
+          case 'l' | 0x100:
+                    LircDevice = optarg ? : LIRC_DEVICE;
+                    break;
           case 'm': MuteAudio = true;
                     break;
+          case 'n' | 0x100:
+                    UseKbd = false;
+                    break;
           case 'p': if (isnumber(optarg))
                        SVDRPport = atoi(optarg);
                     else {
@@ -205,6 +227,9 @@ int main(int argc, char *argv[])
                     break;
           case 'P': PluginManager.AddPlugin(optarg);
                     break;
+          case 'r' | 0x100:
+                    RcuDevice = optarg ? : RCU_DEVICE;
+                    break;
           case 'r': cRecordingUserCommand::SetCommand(optarg);
                     break;
           case 's': Shutdown = optarg;
@@ -261,10 +286,15 @@ int main(int argc, char *argv[])
                "                           if logging should be done to LOG_LOCALn instead of\n"
                "                           LOG_USER, add '.n' to LEVEL, as in 3.7 (n=0..7)\n"
                "  -L DIR,   --lib=DIR      search for plugins in DIR (default is %s)\n"
+               "            --lirc[=PATH]  use a LIRC remote control device, attached to PATH\n"
+               "                           (default: %s)\n"
                "  -m,       --mute         mute audio of the primary DVB device at startup\n"
+               "            --no-kbd       don't use the keyboard as an input device\n"
                "  -p PORT,  --port=PORT    use PORT for SVDRP (default: %d)\n"
                "                           0 turns off SVDRP\n"
                "  -P OPT,   --plugin=OPT   load a plugin defined by the given options\n"
+               "            --rcu[=PATH]   use a remote control device, attached to PATH\n"
+               "                           (default: %s)\n"
                "  -r CMD,   --record=CMD   call CMD before and after a recording\n"
                "  -s CMD,   --shutdown=CMD call CMD to shutdown the computer\n"
                "  -t TTY,   --terminal=TTY controlling tty\n"
@@ -275,7 +305,9 @@ int main(int argc, char *argv[])
                "\n",
                DEFAULTEPGDATAFILENAME,
                DEFAULTPLUGINDIR,
+               LIRC_DEVICE,
                DEFAULTSVDRPPORT,
+               RCU_DEVICE,
                VideoDirectory,
                DEFAULTWATCHDOG
                );
@@ -470,15 +502,12 @@ int main(int argc, char *argv[])
   cThemes::Load(Skins.Current()->Name(), Setup.OSDTheme, Skins.Current()->Theme());
 
   // Remote Controls:
-#if defined(REMOTE_RCU)
-  new cRcuRemote("/dev/ttyS1");
-#elif defined(REMOTE_LIRC)
-  new cLircRemote("/dev/lircd");
-#endif
-#if defined(REMOTE_KBD)
-  if (!DaemonMode && HasStdin)
+  if (RcuDevice)
+     new cRcuRemote(RcuDevice);
+  if (LircDevice)
+     new cLircRemote(LircDevice);
+  if (!DaemonMode && HasStdin && UseKbd)
      new cKbdRemote;
-#endif
   Interface->LearnKeys();
 
   // External audio:
-- 
cgit v1.2.3