vdr/remote.c
Klaus Schmidinger 1a8a081629 Version 1.1.15
- Completely switched to the new CVS HEAD version of the linux-dvb driver.
  The NEWSTRUCT compile time switch is now obsolete. The required driver is now
  the CVS HEAD version dated 2002-11-01 or later.
- Adjusted the INSTALL file to the 1.1.x version.
- Only accepting key presses from the current remote control when learning (thanks to
  Oliver Endriss).
- Fixed the EPG scanner, which broke 'Transfer Mode' as soon as it kicked in
  (thanks to Oliver Endriss for reporting this one).
- Fixed handling audio tracks in cDvbDevice.
- Updated channels.conf.terr (thanks to Uwe Scheffler).
- Fixed displaying the group separators in the channel display (thanks to Martin
  Hammerschmid for pointing out this one).
- The Makefile now includes the file Make.config (if present in the VDR source
  directory), which allows the user to overwrite several settings with individual
  values (suggested by Andreas Schultz). The VDR distribution archive does not
  contain this file in order to not overwrite a user defined file. There is a
  Make.config.template which contains the default values of the macros the user
  can overwrite.
- Since there have been changes to the 'newplugin' script authors of plugins
  may want to newly create their plugins' Makefiles with the new version of this
  script, and adapt them to their individual needs (make sure you don't overwrite
  your existing plugin directory - make a backup copy first!).
- Fixed reading EPG data via the SVDRP command PUTE (it changed the current
  service ID).
- Fixed closing all dup'ed file descriptors in cPipe.
- Implemented a plugin interface for additional audio processing (see PLUGINS.html
  under "Dolby Digital").
  The functionality of the '-a' command line option has been reactivated.
  Since the author doesn't have any Dolby Digital equipment this may or may not
  work as expected. There may still be some places where a call to cAudios::Clear()
  or cAudios::Mute() is necessary. Those with Dolby Digital equipment should please
  take a look at this and maybe send patches.
  Replaying Dolby Digital in ways other than through VDR's '-a' option will have to
  be implemented as plugins. Those who have written patches for VDR version 1.0.x
  should convert their work into the proper plugins for version 1.1.x.
  Note to authors of cPlayer derived plugins: please read the modified comments
  in device.h regarding the member functions cDevice::Clear(), cDevice::Mute() and
  cDevice::PlayAudio(). Derived classes must call these base class member functions
  to make sure all registered cAudio objects are properly handled. Also note that
  the return type of cDevice::PlayAudio() has been changed to 'void', since this
  function always has to accept the entire data block immediately and there is
  nothing that could be reasonably done in case an error occurs in one of the
  cAudio objects.
- Now checking the driver's DVB_API_VERSION in dvbdevice.h. Since VDR now requires
  a driver dated 2002-11-01 or later the MIN_DVB_DRIVER_VERSION_FOR_TIMESHIFT and
  DVB_DRIVER_VERSION stuff has been replaced with DO_REC_AND_PLAY_ON_PRIMARY_DEVICE,
  which can be used to disable simultaneous recording and replaying on the primary
  DVB device in case there are problems with this.
2002-11-03 18:00:00 +01:00

183 lines
3.6 KiB
C

/*
* remote.c: General Remote Control handling
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: remote.c 1.31 2002/11/01 10:50:13 kls Exp $
*/
#include "remote.h"
#include <fcntl.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <termios.h>
#include <unistd.h>
#if defined REMOTE_KBD
#include <ncurses.h>
#endif
#include "tools.h"
// --- cRemote ---------------------------------------------------------------
eKeys cRemote::keys[MaxKeys];
int cRemote::in = 0;
int cRemote::out = 0;
cRemote *cRemote::learning = NULL;
char *cRemote::unknownCode = NULL;
cMutex cRemote::mutex;
cCondVar cRemote::keyPressed;
cRemote::cRemote(const char *Name)
{
name = Name ? strdup(Name) : NULL;
Remotes.Add(this);
}
cRemote::~cRemote()
{
free(name);
}
const char *cRemote::GetSetup(void)
{
return Keys.GetSetup(Name());
}
void cRemote::PutSetup(const char *Setup)
{
Keys.PutSetup(Name(), Setup);
}
void cRemote::Clear(void)
{
cMutexLock MutexLock(&mutex);
in = out = 0;
if (learning) {
free(unknownCode);
unknownCode = NULL;
}
}
bool cRemote::Put(eKeys Key)
{
if (Key != kNone) {
cMutexLock MutexLock(&mutex);
if ((Key & k_Release) != 0)
Clear();
int d = out - in;
if (d <= 0)
d = MaxKeys + d;
if (d - 1 > 0) {
keys[in] = Key;
if (++in >= MaxKeys)
in = 0;
keyPressed.Broadcast();
return true;
}
return false;
}
return true; // only a real key shall report an overflow!
}
bool cRemote::PutMacro(eKeys Key)
{
const cKeyMacro *km = KeyMacros.Get(Key);
if (km) {
for (int i = 1; i < MAXKEYSINMACRO; i++) {
if (km->Macro()[i] != kNone) {
if (!Put(km->Macro()[i]))
return false;
}
else
break;
}
}
return true;
}
bool cRemote::Put(uint64 Code, bool Repeat, bool Release)
{
char buffer[32];
snprintf(buffer, sizeof(buffer), "%016LX", Code);
return Put(buffer, Repeat, Release);
}
bool cRemote::Put(const char *Code, bool Repeat, bool Release)
{
if (learning && this != learning)
return false;
eKeys Key = Keys.Get(Name(), Code);
if (Key != kNone) {
if (Repeat)
Key = eKeys(Key | k_Repeat);
if (Release)
Key = eKeys(Key | k_Release);
return Put(Key);
}
if (learning) {
free(unknownCode);
unknownCode = strdup(Code);
keyPressed.Broadcast();
}
return false;
}
eKeys cRemote::Get(int WaitMs, char **UnknownCode)
{
for (;;) {
cMutexLock MutexLock(&mutex);
if (in != out) {
eKeys k = keys[out];
if (++out >= MaxKeys)
out = 0;
return k;
}
else if (!WaitMs || !keyPressed.TimedWait(mutex, WaitMs)) {
if (learning && UnknownCode) {
*UnknownCode = unknownCode;
unknownCode = NULL;
}
return kNone;
}
}
}
// --- cRemotes --------------------------------------------------------------
cRemotes Remotes;
// --- cKbdRemote ------------------------------------------------------------
#if defined REMOTE_KBD
cKbdRemote::cKbdRemote(void)
:cRemote("KBD")
{
Start();
}
cKbdRemote::~cKbdRemote()
{
Cancel();
}
void cKbdRemote::Action(void)
{
dsyslog("KBD remote control thread started (pid=%d)", getpid());
cPoller Poller(STDIN_FILENO);
for (;;) {//XXX
int Command = getch();
if (Command != EOF)
Put(Command);
Poller.Poll(100);
}
dsyslog("KBD remote control thread ended (pid=%d)", getpid());
}
#endif