mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
- 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.
166 lines
3.2 KiB
C
166 lines
3.2 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.28 2002/09/29 12:51:26 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;
|
|
bool cRemote::learning = false;
|
|
char *cRemote::unknownCode = NULL;
|
|
cMutex cRemote::mutex;
|
|
cCondVar cRemote::keyPressed;
|
|
|
|
cRemote::cRemote(const char *Name)
|
|
{
|
|
if (Name)
|
|
name = strdup(Name);
|
|
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::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)
|
|
{
|
|
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
|