Merge branch 'obi/master-20110329' into experimental
authorAndreas Oberritter <obi@opendreambox.org>
Thu, 31 Mar 2011 23:42:14 +0000 (01:42 +0200)
committerAndreas Oberritter <obi@opendreambox.org>
Thu, 31 Mar 2011 23:42:14 +0000 (01:42 +0200)
lib/driver/rcsdl.cpp
lib/python/Screens/InputBox.py
lib/python/Screens/Screen.py
lib/python/connections.h
mytest.py

index 145b23c..0705cb0 100644 (file)
@@ -1,3 +1,4 @@
+#include <lib/base/etrace.h>
 #include <lib/driver/rcsdl.h>
 //#include <lib/actions/action.h>
 #include <lib/base/init.h>
@@ -18,6 +19,8 @@ eSDLInputDevice::~eSDLInputDevice()
 
 void eSDLInputDevice::handleCode(long arg)
 {
+       D_ENTER();
+
        const SDL_KeyboardEvent *event = (const SDL_KeyboardEvent *)arg;
        const SDL_keysym *key = &event->keysym;
        int km = input->getKeyboardMode();
@@ -32,48 +35,43 @@ void eSDLInputDevice::handleCode(long arg)
 
        if (km == eRCInput::kmNone) {
                code = translateKey(key->sym);
+               D_PRINT("translated code: %d", code);
        } else {
-               // ASCII keys should only generate key press events
-               if (flags == eRCKey::flagBreak)
-                       return;
-
-               eDebug("unicode=%04x scancode=%02x", m_unicode, key->scancode);
-               if (m_unicode & 0xff80) {
-                       eDebug("SDL: skipping unicode character");
-                       return;
-               }
-               code = m_unicode & ~0xff80;
-               // unicode not set...!? use key symbol
-               if (code == 0) {
-                       // keysym is ascii
-                       if (key->sym >= 128) {
-                               eDebug("SDL: cannot emulate ASCII");
-                               return;
-                       }
-                       eDebug("SDL: emulate ASCII");
+               code = m_unicode;
+               D_PRINT("native virtual code: %d / sym: %d", code, key->sym);
+               if ((code == 0) && (key->sym < 128)) {
                        code = key->sym;
+                       D_PRINT("ASCII code: %u", code);
                }
-               if (km == eRCInput::kmAscii) {
-                       // skip ESC c or ESC '[' c
-                       if (m_escape) {
-                               if (code != '[')
-                                       m_escape = false;
-                               return;
-                       }
 
-                       if (code == SDLK_ESCAPE)
-                               m_escape = true;
+               if ((km == eRCInput::kmAscii) &&
+                   ((code < SDLK_SPACE) ||
+                    (code == 0x7e) ||
+                    (code == SDLK_DELETE) ||
+                    (code > 255))) {
+                       code = translateKey(key->sym);
+               } else {
+                       // ASCII keys should only generate key press events
+                       if (flags == eRCKey::flagBreak)
+                               D_RETURN();
 
-                       if ((code < SDLK_SPACE) ||
-                           (code == 0x7e) ||   // really?
-                           (code == SDLK_DELETE))
-                               return;
+                       if (km == eRCInput::kmAscii) {
+                               // skip ESC c or ESC '[' c
+                               if (m_escape) {
+                                       if (code != '[')
+                                               m_escape = false;
+                                       D_RETURN();
+                               }
+                               if (code == SDLK_ESCAPE)
+                                       m_escape = true;
+                       }
+                       flags |= eRCKey::flagAscii;
                }
-               flags |= eRCKey::flagAscii;
        }
 
-       eDebug("SDL code=%d flags=%d", code, flags);
+       D_PRINT("code=%d (%#x) flags=%d (%#x)", code, code, flags, flags);
        input->keyPressed(eRCKey(this, code, flags));
+       D_RETURN();
 }
 
 const char *eSDLInputDevice::getDescription() const
index 1379768..7dd7b12 100644 (file)
@@ -43,9 +43,9 @@ class InputBox(Screen):
                }, -1)
 
                if self["input"].type == Input.TEXT:
-                       self.onShow.append(self.setKeyboardModeAscii)
+                       self.onExecBegin.append(self.setKeyboardModeAscii)
                else:
-                       self.onShow.append(self.setKeyboardModeNone)
+                       self.onExecBegin.append(self.setKeyboardModeNone)
 
        def gotAsciiCode(self):
                self["input"].handleAscii(getPrevAsciiCode())
index 3210186..4a0accd 100644 (file)
@@ -48,9 +48,6 @@ class Screen(dict, GUISkin):
                # stand alone screens (for example web screens)
                # don't care about having or not having focus.
                self.stand_alone = False
-
-               self.onShow.append(self.saveKeyboardMode)
-               self.onHide.append(self.restoreKeyboardMode)
                self.keyboardMode = None
 
        def saveKeyboardMode(self):
index b4cd1c7..374749a 100644 (file)
@@ -80,4 +80,23 @@ public:
        }
 };
 
+template <class R, class V0, class V1, class V2>
+class PSignal3: public PSignal, public Signal3<R,V0,V1,V2>
+{
+public:
+       R operator()(V0 a0, V1 a1, V2 a2)
+       {
+               if (m_list)
+               {
+                       PyObject *pArgs = PyTuple_New(3);
+                       PyTuple_SET_ITEM(pArgs, 0, PyFrom(a0));
+                       PyTuple_SET_ITEM(pArgs, 1, PyFrom(a1));
+                       PyTuple_SET_ITEM(pArgs, 2, PyFrom(a2));
+                       callPython(pArgs);
+                       Org_Py_DECREF(pArgs);
+               }
+               return Signal3<R,V0,V1,V2>::operator()(a0, a1, a2);
+       }
+};
+
 #endif
index 7a8d7b7..99695e0 100755 (executable)
--- a/mytest.py
+++ b/mytest.py
@@ -214,6 +214,7 @@ class Session:
                        self.summary.show()
                        c.addSummary(self.summary)
 
+               c.saveKeyboardMode()
                c.execBegin()
 
                # when execBegin opened a new dialog, don't bother showing the old one.
@@ -225,6 +226,7 @@ class Session:
                self.in_exec = False
 
                self.current_dialog.execEnd()
+               self.current_dialog.restoreKeyboardMode()
                self.current_dialog.hide()
 
                if last: