take device string into account
[enigma2.git] / lib / actions / action.cpp
index 0fa52361c888f2299f0e77c50350c6be3f0c5bd0..8b298eadac48c183c44b88523be943832c5092f1 100644 (file)
@@ -105,7 +105,7 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st
                {
                                // we found a native action.
                        eNativeKeyBinding bind;
-                       bind.m_device = 0;
+                       bind.m_device = device;
                        bind.m_key = key;
                        bind.m_flags = flags;
                        bind.m_action = actions[i].m_id;
@@ -117,7 +117,7 @@ void eActionMap::bindKey(const std::string &device, int key, int flags, const st
                // we didn't find the action, so it must be a pythonAction
        ePythonKeyBinding bind;
 
-       bind.m_device = 0;
+       bind.m_device = device;
        bind.m_key = key;
        bind.m_flags = flags;
        bind.m_action = action;
@@ -128,12 +128,12 @@ struct call_entry
 {
        PyObject *m_fnc, *m_arg;
        eWidget *m_widget;
-       void *m_widget_arg;
-       call_entry(PyObject *fnc, PyObject *arg): m_fnc(fnc), m_arg(arg) { }
-       call_entry(eWidget *widget, void *arg): m_widget(widget), m_widget_arg(arg) { }
+       void *m_widget_arg, *m_widget_arg2;
+       call_entry(PyObject *fnc, PyObject *arg): m_fnc(fnc), m_arg(arg), m_widget(0), m_widget_arg(0) { }
+       call_entry(eWidget *widget, void *arg, void *arg2): m_fnc(0), m_arg(0), m_widget(widget), m_widget_arg(arg), m_widget_arg2(arg2) { }
 };
 
-void eActionMap::keyPressed(int device, int key, int flags)
+void eActionMap::keyPressed(const std::string &device, int key, int flags)
 {
        std::list<call_entry> call_list;
        
@@ -155,10 +155,11 @@ void eActionMap::keyPressed(int device, int key, int flags)
                                for (; k != e; ++k)
                                {
                                        if (
-                                               // (k->second.m_device == m_device) &&
                                                        (k->second.m_key == key) &&
-                                                       (k->second.m_flags & (1<<flags)))
-                                               call_list.push_back(call_entry(i->second.m_widget, (void*)k->second.m_action));
+                                                       (k->second.m_flags & (1<<flags)) &&
+                                                 ((k->second.m_device == device) || (k->second.m_device == "generic"))
+                                                 )
+                                               call_list.push_back(call_entry(i->second.m_widget, (void*)i->second.m_id, (void*)k->second.m_action));
                                }
                        } else
                        {
@@ -177,13 +178,14 @@ void eActionMap::keyPressed(int device, int key, int flags)
                                for (; k != e;)
                                {
                                        if (
-                                               // (k->second.m_device == m_device) &&
                                                (k->second.m_key == key) &&
-                                               (k->second.m_flags & (1<<flags)))
+                                               (k->second.m_flags & (1<<flags)) &&
+                                               ((k->second.m_device == device) || (k->second.m_device == "generic"))
+                                               )
                                        {
                                                PyObject *pArgs = PyTuple_New(2);
-                                               PyTuple_SetItem(pArgs, 0, PyString_FromString(k->first.c_str()));
-                                               PyTuple_SetItem(pArgs, 1, PyString_FromString(k->second.m_action.c_str()));
+                                               PyTuple_SET_ITEM(pArgs, 0, PyString_FromString(k->first.c_str()));
+                                               PyTuple_SET_ITEM(pArgs, 1, PyString_FromString(k->second.m_action.c_str()));
                                                ++k;
                                                Py_INCREF(i->second.m_fnc);
                                                call_list.push_back(call_entry(i->second.m_fnc, pArgs));
@@ -192,9 +194,10 @@ void eActionMap::keyPressed(int device, int key, int flags)
                                }
                        } else
                        {
+                               eDebug("wildcard.");
                                PyObject *pArgs = PyTuple_New(2);
-                               PyTuple_SetItem(pArgs, 0, PyInt_FromLong(key));
-                               PyTuple_SetItem(pArgs, 1, PyInt_FromLong(flags));
+                               PyTuple_SET_ITEM(pArgs, 0, PyInt_FromLong(key));
+                               PyTuple_SET_ITEM(pArgs, 1, PyInt_FromLong(flags));
                                Py_INCREF(i->second.m_fnc);
                                call_list.push_back(call_entry(i->second.m_fnc, pArgs));
                        }
@@ -214,7 +217,7 @@ void eActionMap::keyPressed(int device, int key, int flags)
                } else if (i->m_widget)
                {
                        if (!res)
-                               res = i->m_widget->event(eWidget::evtAction, 0, (void*)i->m_widget_arg);
+                               res = i->m_widget->event(eWidget::evtAction, (void*)i->m_widget_arg, (void*)i->m_widget_arg2 );
                }
        }
 }