12 #define __STDC_FORMAT_MACROS // Required for format specifiers 14 #include <netinet/in.h> 16 #include <sys/types.h> 23 #define INITTIMEOUT 10000 // ms 24 #define REPEATTIMEOUT 1000 // ms 41 name = Name ? strdup(Name) : NULL;
66 if (Key !=
kNone || NewCode)
116 for (
int i = km->
NumKeys(); --i > 0; ) {
127 snprintf(buffer,
sizeof(buffer),
"%016" PRIX64, Code);
128 return Put(buffer, Repeat, Release);
221 {
kfF1, 0x0000001B5B31317EULL },
222 {
kfF2, 0x0000001B5B31327EULL },
223 {
kfF3, 0x0000001B5B31337EULL },
224 {
kfF4, 0x0000001B5B31347EULL },
225 {
kfF5, 0x0000001B5B31357EULL },
226 {
kfF6, 0x0000001B5B31377EULL },
227 {
kfF7, 0x0000001B5B31387EULL },
228 {
kfF8, 0x0000001B5B31397EULL },
229 {
kfF9, 0x0000001B5B32307EULL },
230 {
kfF10, 0x0000001B5B32317EULL },
231 {
kfF11, 0x0000001B5B32327EULL },
232 {
kfF12, 0x0000001B5B32337EULL },
233 {
kfUp, 0x00000000001B5B41ULL },
234 {
kfDown, 0x00000000001B5B42ULL },
235 {
kfLeft, 0x00000000001B5B44ULL },
236 {
kfRight, 0x00000000001B5B43ULL },
237 {
kfHome, 0x00000000001B5B48ULL },
238 {
kfEnd, 0x00000000001B5B46ULL },
239 {
kfPgUp, 0x000000001B5B357EULL },
240 {
kfPgDown, 0x000000001B5B367EULL },
241 {
kfIns, 0x000000001B5B327EULL },
242 {
kfDel, 0x000000001B5B337EULL },
243 {
kfNone, 0x0000000000000000ULL }
253 tcgetattr(STDIN_FILENO, &
savedTm);
255 if (tcgetattr(STDIN_FILENO, &tm) == 0) {
257 tm.c_lflag &= ~(ICANON | ECHO);
260 tcsetattr(STDIN_FILENO, TCSANOW, &tm);
271 tcsetattr(STDIN_FILENO, TCSANOW, &
savedTm);
285 return (Func <= 0xFF) ? Func : 0;
310 if (Poller.
Poll(50)) {
329 char bytes[4] = { 0 };
332 if ((key1 & 0xF0) == 0xF0)
334 else if ((key1 & 0xE0) == 0xE0)
336 for (
int i = 0; i < bytescount; i++) {
344 else if (key1 == 0x1B) {
368 }
while (key1 != 0x7E);
386 uint64_t FirstCommand = 0;
387 uint64_t LastCommand = 0;
388 bool Delayed =
false;
394 if (Command == LastCommand) {
407 else if (Command == FirstCommand) {
417 FirstCommand = Command;
423 PutKey(LastCommand,
false,
true);
426 else if (Delayed && FirstCommand) {
434 LastCommand = Command;
const char * GetSetup(void)
void Add(cListObject *Object, cListObject *After=NULL)
static void SetRawMode(bool RawMode)
uint64_t ReadKeySequence(void)
static const char * keyMacroPlugin
static const char * SystemCharacterTable(void)
virtual void Action(void)
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
static eKeys Get(int WaitMs=1000, char **UnknownCode=NULL)
void PutSetup(const char *Remote, const char *Setup)
bool Poll(int TimeoutMs=0)
static time_t lastActivity
void PutSetup(const char *Setup)
static bool PutMacro(eKeys Key)
void PutKey(uint64_t Code, bool Repeat=false, bool Release=false)
eKeys Get(const char *Remote, const char *Code)
bool TimedOut(void) const
const eKeys * Macro(void) const
static cCondVar keyPressed
const cKeyMacro * Get(eKeys Key)
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Put(uint64_t Code, bool Repeat=false, bool Release=false)
static bool HasKeys(void)
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
static const char * GetPlugin(void)
Returns the name of the plugin that was set with a previous call to PutMacro() or CallPlugin()...
bool TimedWait(cMutex &Mutex, int TimeoutMs)
static char * unknownCode
cRemote(const char *Name)
static cRemote * learning
static void TriggerLastActivity(void)
Simulates user activity, for instance to keep the current menu open even if no remote control key has...
virtual bool Initialize(void)
const char * Plugin(void) const
void Del(cListObject *Object, bool DeleteObject=true)
int NumKeys(void) const
Returns the number of keys in this macro.
static uint64_t MapFuncToCode(int Func)
static const char * callPlugin
static eKeys keys[MaxKeys]
static cTimeMs repeatTimeout
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
int MapCodeToFunc(uint64_t Code)
const char * GetSetup(const char *Remote)
uint64_t Elapsed(void) const
static bool CallPlugin(const char *Plugin)
Initiates calling the given plugin's main menu function.