From d08073815d6d9132f7fb5cd9f82877967dc6b0e4 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 29 Sep 2002 18:00:00 +0200 Subject: Version 1.1.11 - Fixed an incomplete initialization of the filter parameters in eit.c (thanks to Jeremy Hall). - Fixed the 'newplugin' script for use with the NEWSTRUCT driver (thanks to Andreas Schultz for reporting this one). If you have already created a plugin directory and Makefile with 'newplugin', please apply the following patch to it: ------------------------------------------------------- --- Makefile 2002/06/10 16:24:06 1.4 +++ Makefile 2002/09/17 15:36:36 1.5 @@ -15,7 +15,12 @@ ### The directory environment: +ifdef NEWSTRUCT +DVBDIR = ../../../../DVB/include +DEFINES += -DNEWSTRUCT +else DVBDIR = ../../../../DVB/ost/include +endif VDRDIR = ../../.. VDRINC = $(VDRDIR)/include LIBDIR = ../../lib @@ -34,7 +39,7 @@ INCLUDES = -I$(VDRINC) -I$(DVBDIR) -DEFINES = -DPLUGIN_NAME_I18N='"$(PLUGIN)"' +DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): ------------------------------------------------------- This is the diff for the 'setup' example that comes with VDR, so your line numbers may be different. - Added a missing 'public' keyword in device.h (thanks to Martin Hammerschmid). - Fixed a race condition when starting 'Transfer Mode'. - Rearranged the remote control key handling to allow plugins to implement additional types of remote controls (see PLUGINS.html, section "Remote Control"). The previously used files 'keys.conf' and 'keys-pc.conf' have been replaced by the file 'remote.conf', which holds the key definitions of all remote controls. - The LIRC remote control keys are now handled just like the keyboard and RCU keys. This means that you can use the lircd.conf file as is for your remote control, without the need of editing it to make the key names the same as used in VDR. When first starting VDR it will go into the "Learning keys" mode and ask you to press the various keys. The resulting key assignment will be stored in the file 'remote.conf'. Since I have no way of testing the LIRC support, I hope I didn't break it in the process... - While learning the remote control keys it is now possible to press the 'Menu' key to skip the definition of keys that are not available on your particular RC unit. - Fixed handling DVD subtitles in the SPU decoder (thanks to Andreas Schultz). - Avoiding restarts due to 'panic level' when switching channels on the primary device during EPG scan. --- lirc.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 lirc.c (limited to 'lirc.c') diff --git a/lirc.c b/lirc.c new file mode 100644 index 0000000..f120743 --- /dev/null +++ b/lirc.c @@ -0,0 +1,84 @@ +/* + * lirc.c: LIRC remote control + * + * See the main source file 'vdr.c' for copyright information and + * how to reach the author. + * + * LIRC support added by Carsten Koch 2000-06-16. + * + * $Id: lirc.c 1.1 2002/09/29 13:16:33 kls Exp $ + */ + +#include "lirc.h" +#include +#include +#include + +#define REPEATLIMIT 20 // ms +#define REPEATDELAY 350 // ms + +cLircRemote::cLircRemote(char *DeviceName) +:cRemote("LIRC") +{ + struct sockaddr_un addr; + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, DeviceName); + if ((f = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) { + if (connect(f, (struct sockaddr *)&addr, sizeof(addr)) >= 0) { + Start(); + return; + } + LOG_ERROR_STR(DeviceName); + close(f); + } + else + LOG_ERROR_STR(DeviceName); + f = -1; +} + +cLircRemote::~cLircRemote() +{ + Cancel(); +} + +void cLircRemote::Action(void) +{ + dsyslog("LIRC remote control thread started (pid=%d)", getpid()); + + int FirstTime = 0; + int LastTime = 0; + char buf[LIRC_BUFFER_SIZE]; + char LastKeyName[LIRC_KEY_BUF] = ""; + bool repeat = false; + + for (; f >= 0;) { + + LOCK_THREAD; + + if (cFile::FileReady(f, REPEATLIMIT) && safe_read(f, buf, sizeof(buf)) > 21) { + int count; + char KeyName[LIRC_KEY_BUF]; + sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1! + int Now = time_ms(); + if (count == 0) { + strcpy(LastKeyName, KeyName); + repeat = false; + FirstTime = Now; + } + else { + if (Now - FirstTime < REPEATDELAY) + continue; // repeat function kicks in after a short delay + repeat = true; + } + LastTime = Now; + Put(KeyName, repeat); + } + else if (repeat) { // the last one was a repeat, so let's generate a release + if (time_ms() - LastTime > REPEATDELAY) { + Put(LastKeyName, false, true); + repeat = false; + *LastKeyName = 0; + } + } + } +} -- cgit v1.2.3