12#define __STDC_FORMAT_MACROS
14#include <netinet/in.h>
23#define INITTIMEOUT 10000
24#define REPEATTIMEOUT 1000
67 if (Key !=
kNone || NewCode)
122 for (
int i = km->
NumKeys(); --i > 0; ) {
133 snprintf(buffer,
sizeof(buffer),
"%016" PRIX64, Code);
134 return Put(buffer, Repeat, Release);
227 {
kfF1, 0x0000001B5B31317EULL },
228 {
kfF2, 0x0000001B5B31327EULL },
229 {
kfF3, 0x0000001B5B31337EULL },
230 {
kfF4, 0x0000001B5B31347EULL },
231 {
kfF5, 0x0000001B5B31357EULL },
232 {
kfF6, 0x0000001B5B31377EULL },
233 {
kfF7, 0x0000001B5B31387EULL },
234 {
kfF8, 0x0000001B5B31397EULL },
235 {
kfF9, 0x0000001B5B32307EULL },
236 {
kfF10, 0x0000001B5B32317EULL },
237 {
kfF11, 0x0000001B5B32327EULL },
238 {
kfF12, 0x0000001B5B32337EULL },
239 {
kfUp, 0x00000000001B5B41ULL },
240 {
kfDown, 0x00000000001B5B42ULL },
241 {
kfLeft, 0x00000000001B5B44ULL },
242 {
kfRight, 0x00000000001B5B43ULL },
243 {
kfHome, 0x00000000001B5B48ULL },
244 {
kfEnd, 0x00000000001B5B46ULL },
245 {
kfPgUp, 0x000000001B5B357EULL },
246 {
kfPgDown, 0x000000001B5B367EULL },
247 {
kfIns, 0x000000001B5B327EULL },
248 {
kfDel, 0x000000001B5B337EULL },
249 {
kfNone, 0x0000000000000000ULL }
259 tcgetattr(STDIN_FILENO, &
savedTm);
261 if (tcgetattr(STDIN_FILENO, &tm) == 0) {
263 tm.c_lflag &= ~(ICANON | ECHO);
266 tcsetattr(STDIN_FILENO, TCSANOW, &tm);
277 tcsetattr(STDIN_FILENO, TCSANOW, &
savedTm);
291 return (Func <= 0xFF) ? Func : 0;
316 if (Poller.
Poll(
Setup.RcRepeatDelta * 3 / 2)) {
335 char bytes[4] = { 0 };
338 if ((key1 & 0xF0) == 0xF0)
340 else if ((key1 & 0xE0) == 0xE0)
342 for (
int i = 0; i < bytescount; i++) {
350 else if (key1 == 0x1B) {
374 }
while (key1 != 0x7E);
392 uint64_t FirstCommand = 0;
393 uint64_t LastCommand = 0;
394 bool Delayed =
false;
400 if (Command == LastCommand) {
413 else if (Command == FirstCommand) {
423 FirstCommand = Command;
429 PutKey(LastCommand,
false,
true);
432 else if (Delayed && FirstCommand) {
440 else if (FirstCommand && FirstTime.
Elapsed() > (uint)
Setup.RcRepeatDelay) {
445 LastCommand = Command;
static const char * SystemCharacterTable(void)
uint64_t ReadKeySequence(void)
int MapCodeToFunc(uint64_t Code)
void PutKey(uint64_t Code, bool Repeat=false, bool Release=false)
virtual void Action(void) override
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
static uint64_t MapFuncToCode(int Func)
virtual ~cKbdRemote() override
static void SetRawMode(bool RawMode)
const eKeys * Macro(void) const
int NumKeys(void) const
Returns the number of keys in this macro.
const char * Plugin(void) const
bool Poll(int TimeoutMs=0)
static const char * GetPlugin(void)
Returns the name of the plugin that was set with a previous call to PutMacro() or CallPlugin().
static cRemote * learning
static const char * keyMacroPlugin
static time_t lastActivity
static eKeys Get(int WaitMs=1000, char **UnknownCode=NULL)
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
static cCondVar keyPressed
static char * unknownCode
static bool PutMacro(eKeys Key)
static cTimeMs repeatTimeout
static bool HasKeys(void)
static void TriggerLastActivity(void)
Simulates user activity, for instance to keep the current menu open even if no remote control key has...
const char * GetSetup(void)
static bool CallPlugin(const char *Plugin)
Initiates calling the given plugin's main menu function.
cRemote(const char *Name)
static const char * callPlugin
static eKeys keys[MaxKeys]
void PutSetup(const char *Setup)
virtual bool Initialize(void)
virtual ~cRemote() override
static bool IsLearning(void)
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
cThread(const char *Description=NULL, bool LowPriority=false)
Creates a new thread.
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
uint64_t Elapsed(void) const
Returns the number of milliseconds that have elapsed since the last call to Set().
void Set(int Ms=0)
Sets the timer.