DreamInfoHandler.py: strip data. refs #578
[enigma2.git] / lib / driver / rcconsole.cpp
index eaeeb58654c3c1427df1f4ae4e98da1973b9bcfd..eb5aee3db7187cc99cc1c0108fee87f0fb657c38 100644 (file)
@@ -14,9 +14,8 @@ eRCConsoleDriver::eRCConsoleDriver(const char *filename): eRCDriver(eRCInput::ge
                sn=0;
        } else
        {
-               sn=new eSocketNotifier(eApp, handle, eSocketNotifier::Read);
+               sn=eSocketNotifier::create(eApp, handle, eSocketNotifier::Read);
                CONNECT(sn->activated, eRCConsoleDriver::keyPressed);
-               eRCInput::getInstance()->setFile(handle);
        }
        
                /* set console mode */
@@ -32,59 +31,64 @@ eRCConsoleDriver::~eRCConsoleDriver()
        tcsetattr(handle,TCSANOW, &ot);
        if (handle>=0)
                close(handle);
-       if (sn)
-               delete sn;
 }
 
 void eRCConsoleDriver::keyPressed(int)
 {
-       char data[16];
-       char *d = data;
+       unsigned char data[16];
+       unsigned char *d = data;
        int num = read(handle, data, 16);
-       int code;
+       int code=-1;
        
        int km = input->getKeyboardMode();
 
+       if (km == eRCInput::kmNone)
+               return;
+
        while (num--)
        {
+//             eDebug("console code %08x\n", *d);
                if (km == eRCInput::kmAll)
                        code = *d++;
                else
                {
                        if (*d == 27) // escape code
                        {
-                                       /* skip all this stuff */
-                               return;
-
-/*                             while (num)
+                               while (num)
                                {
                                        num--;
                                        if (*++d != '[')
                                                break;
                                }
-                               code = -1; */
+                               code = -1;
                        } else
                                code = *d;
                        ++d;
-                       
+
                        if (code < 32)                  /* control characters */
                                code = -1;
-                       if (code == 0x7F)               /* delete */
-                               code = -1;
+                       else switch(code)
+                       {
+                       case 0x7E:  // mute, einfg, entf
+                       case 0x7F:  // backspace
+                       code = -1;
+                       default:
+                               break;
+                       }
                }
 
                if (code != -1)
                        for (std::list<eRCDevice*>::iterator i(listeners.begin()); i!=listeners.end(); ++i)
                        {
-                               eDebug("ascii %08x", code);
-                               (*i)->handleCode(code | 0x8000);
+//                             eDebug("ascii %08x", code);
+                               (*i)->handleCode(code);
                        }
        }
 }
 
-void eRCConsole::handleCode(int code)
+void eRCConsole::handleCode(long code)
 {
-       input->keyPressed(eRCKey(this, code, 0));
+       input->keyPressed(eRCKey(this, code, eRCKey::flagAscii));
 }
 
 eRCConsole::eRCConsole(eRCDriver *driver)
@@ -112,7 +116,7 @@ class eRCConsoleInit
        eRCConsoleDriver driver;
        eRCConsole device;
 public:
-       eRCConsoleInit(): driver("/dev/stdin"), device(&driver)
+       eRCConsoleInit(): driver("/dev/vc/0"), device(&driver)
        {
        }
 };