add PicturePlayer plugin
[enigma2.git] / keymapparser.py
index 7b64ae04af3436979e1e014aa01a2f8f1c037ce1..1a6a378136500d7d6852be9bca8cccf3a78c6fde 100644 (file)
@@ -1,8 +1,12 @@
 import xml.dom.minidom
 import enigma
+from Tools.XMLTools import elementsWithTag
 
 from keyids import KEYIDS;
 
+# these are only informational (for help)...
+from Tools.KeyBindings import addKeyBinding
+
 def readKeymap():
 
        p = enigma.eActionMapPtr()
@@ -14,8 +18,10 @@ def readKeymap():
                
        try:
                source = open(filename1)
+               filename = filename1
        except:
                source = open(filename2)
+               filename = filename2
 #              raise "couldn't open keymap.xml!"
        
        try:
@@ -23,19 +29,16 @@ def readKeymap():
        except:
                raise "keymap not well-formed."
        
-       try:    
-               keymap = dom.getElementsByTagName("keymap")[0]
-       except:
-               raise "no keymap defined."
+       keymap = dom.childNodes[0]
        
-       maps = keymap.getElementsByTagName("map")
+       maps = elementsWithTag(keymap.childNodes, "map")
        
        for cmap in maps:
                context = str(cmap.getAttribute("context"))
                assert context != "", "map must have context"
        
                def parseKeys(device, keys):
-                       for x in keys.getElementsByTagName("key"):
+                       for x in elementsWithTag(keys.childNodes, "key"):
                                mapto = str(x.getAttribute("mapto"))
                                id = x.getAttribute("id")
                                flags = x.getAttribute("flags")
@@ -69,9 +72,10 @@ def readKeymap():
 
 #                              print context + "::" + mapto + " -> " + device + "." + hex(keyid)
                                p.bindKey(device, keyid, flags, context, mapto)
+                               addKeyBinding(keyid, context, mapto)
                
                parseKeys("generic", cmap)
                
-               for device in cmap.getElementsByTagName("device"):
+               for device in elementsWithTag(cmap.childNodes, "device"):
                        parseKeys(str(device.getAttribute("name")), device)