vdr/lirc.c
Klaus Schmidinger 4c5de28883 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).
- Modified the description of cDevice::Poll() to avoid misunderstandings.
- Updated Croatian language texts (thanks to Drazen Dupor).
- cDvbPlayer::Goto() now appends a Sequence End Code to get the image shown
  immediately with softdevices (thanks to Reinhard Nissl).
- Reactivated cVideoRepacker in remux.c after some fixes (thanks to Reinhard Nissl).
- Removed the fix for handling VPS timers, so that they only record if the event
  they are assigned to actually has the given VPS time. This has caused repeating
  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).
- Now checking whether timers or channels are currently being edited via the menu
  before making changes through SVDRP (thanks to Andreas Brugger for reporting a
  problem with this).
- Files and directories are now created with rights according to the shell's
  umask settings (thanks to Andreas Brachold).
- Fixed the cChannel copy constructor (thanks to Marcel Wiesweg for pointing out
  a problem with it).
- Fixed an out-of-bounds memory access with audio language ids (thanks to
  Matthias Lenk for reporting, and Udo Richter for suggesting a fix).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
- Added missing storing of the MenuScrollPage parameter (thanks to Frank Krömmelbein).
- Added cRemux::SetTimeouts() for better use of cRemux in a single thread (thanks
  to Udo Richter for reporting a problem with this).
- Modified cEITScanner::Process() so that it uses the primary device if it is
  replaying and is the only device that provides the given transponder, and that
  a forced EPG scan works even if EPG scan timeout is set to 0 (thanks to
  Bernhard Stegmaier for reporting a problem with this).
- Fixed cDvbSpuBitmap::putPixel() (thanks to Reinhard Nissl).
- Fixed setting system time to avoid time jumps in case of faulty data (thanks
  to Andreas Böttger).
- Fixed a memory leak in the SVDRP command LSTE (thanks to Stefan Huelswitt).
2005-08-07 18:00:00 +02:00

109 lines
2.6 KiB
C

/*
* 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 <Carsten.Koch@icem.de> 2000-06-16.
*
* $Id: lirc.c 1.11 2005/07/31 10:18:09 kls Exp $
*/
#include "lirc.h"
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/un.h>
#define REPEATLIMIT 20 // ms
#define REPEATDELAY 350 // ms
#define KEYPRESSDELAY 150 // ms
cLircRemote::cLircRemote(const char *DeviceName)
:cRemote("LIRC")
,cThread("LIRC remote control")
{
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()
{
int fh = f;
f = -1;
Cancel();
if (fh >= 0)
close(fh);
}
bool cLircRemote::Ready(void)
{
return f >= 0;
}
void cLircRemote::Action(void)
{
cTimeMs FirstTime;
cTimeMs LastTime;
char buf[LIRC_BUFFER_SIZE];
char LastKeyName[LIRC_KEY_BUF] = "";
bool repeat = false;
int timeout = -1;
for (; f >= 0;) {
bool ready = cFile::FileReady(f, timeout);
int ret = ready ? safe_read(f, buf, sizeof(buf)) : -1;
if (ready && ret <= 0 ) {
esyslog("ERROR: lircd connection lost");
close(f);
f = -1;
break;
}
if (ready && ret > 21) {
int count;
char KeyName[LIRC_KEY_BUF];
sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1!
if (count == 0) {
if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < KEYPRESSDELAY)
continue; // skip keys coming in too fast
if (repeat)
Put(LastKeyName, false, true);
strcpy(LastKeyName, KeyName);
repeat = false;
FirstTime.Set();
timeout = -1;
}
else {
if (FirstTime.Elapsed() < REPEATDELAY)
continue; // repeat function kicks in after a short delay
repeat = true;
timeout = REPEATDELAY;
}
LastTime.Set();
Put(KeyName, repeat);
}
else if (repeat) { // the last one was a repeat, so let's generate a release
if (LastTime.Elapsed() >= REPEATDELAY) {
Put(LastKeyName, false, true);
repeat = false;
*LastKeyName = 0;
timeout = -1;
}
}
}
}