Merge branch 'bug_538_ignore_global_actions_in_standby'
[enigma2.git] / lib / driver / rcinput.cpp
index ad2d3f6..f30ba8c 100644 (file)
 #include <lib/base/init_num.h>
 #include <lib/driver/input_fake.h>
 
-void eRCDeviceInputDev::handleCode(int rccode)
+void eRCDeviceInputDev::handleCode(long rccode)
 {
        struct input_event *ev = (struct input_event *)rccode;
        if (ev->type!=EV_KEY)
                return;
-       eDebug("%x %x %x", ev->value, ev->code, ev->type);
+
+//     eDebug("%x %x %x", ev->value, ev->code, ev->type);
+
+       if (ev->type!=EV_KEY)
+               return;
+
+       int km = iskeyboard ? input->getKeyboardMode() : eRCInput::kmNone;
+
+//     eDebug("keyboard mode %d", km);
+       
+       if (km == eRCInput::kmAll)
+               return;
+
+       if (km == eRCInput::kmAscii)
+       {
+//             eDebug("filtering.. %d", ev->code);
+               bool filtered = ( ev->code > 0 && ev->code < 61 );
+               switch (ev->code)
+               {
+                       case KEY_RESERVED:
+                       case KEY_ESC:
+                       case KEY_TAB:
+                       case KEY_BACKSPACE:
+                       case KEY_ENTER:
+                       case KEY_LEFTCTRL:
+                       case KEY_RIGHTSHIFT:
+                       case KEY_LEFTALT:
+                       case KEY_CAPSLOCK:
+                       case KEY_INSERT:
+                       case KEY_DELETE:
+                       case KEY_MUTE:
+                               filtered=false;
+                       default:
+                               break;
+               }
+               if (filtered)
+                       return;
+//             eDebug("passed!");
+       }
+
        switch (ev->value)
        {
        case 0:
@@ -31,8 +70,19 @@ void eRCDeviceInputDev::handleCode(int rccode)
        }
 }
 
-eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver): eRCDevice(driver->getDeviceName(), driver)
+eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver)
+       :eRCDevice(driver->getDeviceName(), driver), iskeyboard(false)
+{
+       if (strcasestr(id.c_str(), "keyboard") != NULL)
+               iskeyboard = true;
+       setExclusive(true);
+       eDebug("Input device \"%s\" is %sa keyboard.", id.c_str(), iskeyboard ? "" : "not ");
+}
+
+void eRCDeviceInputDev::setExclusive(bool b)
 {
+       if (!iskeyboard)
+               driver->setExclusive(b);
 }
 
 const char *eRCDeviceInputDev::getDescription() const