2000-02-19 13:36:48 +01:00
|
|
|
/*
|
2002-09-29 13:40:45 +02:00
|
|
|
* remote.h: General Remote Control handling
|
2000-02-19 13:36:48 +01:00
|
|
|
*
|
2000-04-24 09:46:05 +02:00
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
2000-02-19 13:36:48 +01:00
|
|
|
* how to reach the author.
|
|
|
|
*
|
2007-04-30 12:53:35 +02:00
|
|
|
* $Id: remote.h 1.40 2007/04/30 12:37:37 kls Exp $
|
2000-02-19 13:36:48 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __REMOTE_H
|
|
|
|
#define __REMOTE_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2002-12-08 14:30:32 +01:00
|
|
|
#include <termios.h>
|
2000-02-19 13:36:48 +01:00
|
|
|
#include <time.h>
|
2002-09-29 13:40:45 +02:00
|
|
|
#include "keys.h"
|
2000-10-08 09:25:20 +02:00
|
|
|
#include "thread.h"
|
2000-09-17 08:23:46 +02:00
|
|
|
#include "tools.h"
|
2000-02-19 13:36:48 +01:00
|
|
|
|
2002-09-29 13:40:45 +02:00
|
|
|
class cRemote : public cListObject {
|
2000-09-17 08:23:46 +02:00
|
|
|
private:
|
2006-10-14 11:47:32 +02:00
|
|
|
enum { MaxKeys = 2 * MAXKEYSINMACRO };
|
2002-09-29 13:40:45 +02:00
|
|
|
static eKeys keys[MaxKeys];
|
|
|
|
static int in;
|
|
|
|
static int out;
|
2006-01-29 12:39:04 +01:00
|
|
|
static cTimeMs repeatTimeout;
|
2002-11-01 10:53:07 +01:00
|
|
|
static cRemote *learning;
|
2002-09-29 13:40:45 +02:00
|
|
|
static char *unknownCode;
|
|
|
|
static cMutex mutex;
|
|
|
|
static cCondVar keyPressed;
|
2007-02-25 10:56:29 +01:00
|
|
|
static time_t lastActivity;
|
2006-10-14 11:09:01 +02:00
|
|
|
static const char *keyMacroPlugin;
|
|
|
|
static const char *callPlugin;
|
2007-04-30 12:53:35 +02:00
|
|
|
static bool enabled;
|
2002-09-29 13:40:45 +02:00
|
|
|
char *name;
|
|
|
|
protected:
|
|
|
|
cRemote(const char *Name);
|
|
|
|
const char *GetSetup(void);
|
|
|
|
void PutSetup(const char *Setup);
|
2006-12-02 11:30:19 +01:00
|
|
|
bool Put(uint64_t Code, bool Repeat = false, bool Release = false);
|
2002-09-29 13:40:45 +02:00
|
|
|
bool Put(const char *Code, bool Repeat = false, bool Release = false);
|
2000-07-15 12:39:20 +02:00
|
|
|
public:
|
2002-09-29 13:40:45 +02:00
|
|
|
virtual ~cRemote();
|
2003-04-12 14:37:57 +02:00
|
|
|
virtual bool Ready(void) { return true; }
|
2004-05-28 14:28:36 +02:00
|
|
|
virtual bool Initialize(void);
|
2002-09-29 13:40:45 +02:00
|
|
|
const char *Name(void) { return name; }
|
2002-11-01 10:53:07 +01:00
|
|
|
static void SetLearning(cRemote *Learning) { learning = Learning; }
|
2006-03-31 14:24:58 +02:00
|
|
|
static bool IsLearning() { return learning != NULL; }
|
2007-04-30 12:53:35 +02:00
|
|
|
static bool Enabled(void) { return enabled; }
|
|
|
|
static void SetEnabled(bool Enabled) { enabled = Enabled; }
|
2002-09-29 13:40:45 +02:00
|
|
|
static void Clear(void);
|
2003-05-02 10:54:00 +02:00
|
|
|
static bool Put(eKeys Key, bool AtFront = false);
|
2002-10-27 15:46:30 +01:00
|
|
|
static bool PutMacro(eKeys Key);
|
2006-04-17 09:10:39 +02:00
|
|
|
static bool CallPlugin(const char *Plugin);
|
2005-09-03 12:36:51 +02:00
|
|
|
///< Initiates calling the given plugin's main menu function.
|
|
|
|
///< The Plugin parameter is the name of the plugin, and must be
|
2006-04-17 09:10:39 +02:00
|
|
|
///< a static string. Returns true if the plugin call was successfully
|
|
|
|
///< initiated (the actual call to the plugin's main menu function
|
|
|
|
///< will take place some time later, during the next execution
|
|
|
|
///< of VDR's main loop). If there is already a plugin call pending
|
|
|
|
///< false will be returned and the caller should try again later.
|
|
|
|
static const char *GetPlugin(void);
|
|
|
|
///< Returns the name of the plugin that was set with a previous
|
2006-10-14 11:09:01 +02:00
|
|
|
///< call to PutMacro() or CallPlugin(). The internally stored pointer to the
|
2006-04-17 09:10:39 +02:00
|
|
|
///< plugin name will be reset to NULL by this call.
|
2003-05-01 14:48:54 +02:00
|
|
|
static bool HasKeys(void);
|
2002-09-29 13:40:45 +02:00
|
|
|
static eKeys Get(int WaitMs = 1000, char **UnknownCode = NULL);
|
2007-02-25 10:56:29 +01:00
|
|
|
static time_t LastActivity(void) { return lastActivity; }
|
|
|
|
///< Absolute time when last key was delivered by Get().
|
2000-07-15 12:39:20 +02:00
|
|
|
};
|
|
|
|
|
2002-09-29 13:40:45 +02:00
|
|
|
class cRemotes : public cList<cRemote> {};
|
2000-07-15 12:39:20 +02:00
|
|
|
|
2002-09-29 13:40:45 +02:00
|
|
|
extern cRemotes Remotes;
|
2000-07-15 12:39:20 +02:00
|
|
|
|
2002-12-15 10:58:00 +01:00
|
|
|
enum eKbdFunc {
|
|
|
|
kfNone,
|
|
|
|
kfF1 = 0x100,
|
|
|
|
kfF2,
|
|
|
|
kfF3,
|
|
|
|
kfF4,
|
|
|
|
kfF5,
|
|
|
|
kfF6,
|
|
|
|
kfF7,
|
|
|
|
kfF8,
|
|
|
|
kfF9,
|
|
|
|
kfF10,
|
|
|
|
kfF11,
|
|
|
|
kfF12,
|
|
|
|
kfUp,
|
|
|
|
kfDown,
|
|
|
|
kfLeft,
|
|
|
|
kfRight,
|
|
|
|
kfHome,
|
|
|
|
kfEnd,
|
|
|
|
kfPgUp,
|
|
|
|
kfPgDown,
|
|
|
|
kfIns,
|
|
|
|
kfDel,
|
|
|
|
};
|
|
|
|
|
2002-09-29 13:40:45 +02:00
|
|
|
class cKbdRemote : public cRemote, private cThread {
|
2000-07-15 12:39:20 +02:00
|
|
|
private:
|
2002-12-15 15:58:59 +01:00
|
|
|
static bool kbdAvailable;
|
2002-12-15 10:58:00 +01:00
|
|
|
static bool rawMode;
|
2002-12-08 14:30:32 +01:00
|
|
|
struct termios savedTm;
|
2000-10-08 09:25:20 +02:00
|
|
|
virtual void Action(void);
|
2006-01-01 14:28:47 +01:00
|
|
|
int ReadKey(void);
|
2006-12-02 11:30:19 +01:00
|
|
|
uint64_t ReadKeySequence(void);
|
|
|
|
int MapCodeToFunc(uint64_t Code);
|
2000-07-15 12:39:20 +02:00
|
|
|
public:
|
2002-09-29 13:40:45 +02:00
|
|
|
cKbdRemote(void);
|
|
|
|
virtual ~cKbdRemote();
|
2002-12-15 15:58:59 +01:00
|
|
|
static bool KbdAvailable(void) { return kbdAvailable; }
|
2006-12-02 11:30:19 +01:00
|
|
|
static uint64_t MapFuncToCode(int Func);
|
2002-12-15 10:58:00 +01:00
|
|
|
static void SetRawMode(bool RawMode);
|
2000-02-19 13:36:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__REMOTE_H
|