lib/dvb/dvb.cpp: allow non relative seeking even without valid decoding demux here
[enigma2.git] / lib / driver / rcinput.cpp
index a5b1c719818c76dff0ed2211767bb864dabd3c02..2bfeefa1992e53c2a07d55b346f30f91670e15c1 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);
+
+       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,27 @@ void eRCDeviceInputDev::handleCode(int rccode)
        }
 }
 
-eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver): eRCDevice(driver->getDeviceName(), driver)
+eRCDeviceInputDev::eRCDeviceInputDev(eRCInputEventDriver *driver)
+       :eRCDevice(driver->getDeviceName(), driver), iskeyboard(false)
+{
+       int len=id.length();
+       int idx=0;
+       while(idx <= len-8)
+       {
+               if (!strncasecmp(&id[idx++], "KEYBOARD", 8))
+               {
+                       iskeyboard=true;
+                       break;
+               }
+       }
+       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