From 6a88cbc2bfa43b2a18eb896b3d635622da7e9d0a Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 20 May 2005 19:34:23 +0000 Subject: [PATCH] - add keyboard mode support (like in enigma1) --- lib/driver/rc.cpp | 1 + lib/driver/rc.h | 25 +++++++++++++++++++++++++ lib/driver/rcconsole.cpp | 18 +++++++++--------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lib/driver/rc.cpp b/lib/driver/rc.cpp index f1df5493..ca0d62bc 100644 --- a/lib/driver/rc.cpp +++ b/lib/driver/rc.cpp @@ -177,6 +177,7 @@ eRCInput::eRCInput() instance=this; handle = -1; locked = 0; + keyboardMode = kmNone; } eRCInput::~eRCInput() diff --git a/lib/driver/rc.h b/lib/driver/rc.h index 7b735962..1ce13c72 100644 --- a/lib/driver/rc.h +++ b/lib/driver/rc.h @@ -166,6 +166,7 @@ class eRCInput: public Object int locked; int handle; static eRCInput *instance; + int keyboardMode; public: struct lstr @@ -190,6 +191,30 @@ public: void setFile(int handle); + /* This is only relevant for "keyboard"-styled input devices, + i.e. not plain remote controls. It's up to the input device + driver to decide wheter an input device is a keyboard or + not. + + kmNone will ignore all Ascii Characters sent from the + keyboard/console driver, only give normal keycodes to the + application. + + kmAscii will filter out all keys which produce ascii characters, + and send them instead. Note that Modifiers like shift will still + be send. Control keys which produce escape codes are send using + normal keycodes. + + kmAll will ignore all keycodes, and send everything as ascii, + including escape codes. Pretty much useless, since you should + lock the console and pass this as the console fd for making the + tc* stuff working. + */ + + enum { kmNone, kmAscii, kmAll }; + void setKeyboardMode(int mode) { keyboardMode = mode; } + int getKeyboardMode() { return keyboardMode; } + void keyPressed(const eRCKey &key) { /*emit*/ keyEvent(key); diff --git a/lib/driver/rcconsole.cpp b/lib/driver/rcconsole.cpp index 98ebed4f..eae3a7a5 100644 --- a/lib/driver/rcconsole.cpp +++ b/lib/driver/rcconsole.cpp @@ -42,30 +42,30 @@ void eRCConsoleDriver::keyPressed(int) char *d = data; int num = read(handle, data, 16); int code; -#if 0 + int km = input->getKeyboardMode(); if (km == eRCInput::kmNone) return; -#endif + while (num--) { -#if 0 if (km == eRCInput::kmAll) -#endif code = *d++; -#if 0 else { if (*d == 27) // escape code { - while (num) + /* skip all this stuff */ + return; + +/* while (num) { num--; if (*++d != '[') break; } - code = -1; + code = -1; */ } else code = *d; ++d; @@ -75,7 +75,7 @@ void eRCConsoleDriver::keyPressed(int) if (code == 0x7F) /* delete */ code = -1; } -#endif + if (code != -1) for (std::list::iterator i(listeners.begin()); i!=listeners.end(); ++i) (*i)->handleCode(code | 0x8000); @@ -104,7 +104,7 @@ const char *eRCConsole::getKeyDescription(const eRCKey &key) const int eRCConsole::getKeyCompatibleCode(const eRCKey &key) const { - return key.code; // | KEY_ASCII; + return key.code; } class eRCConsoleInit -- 2.30.2