compile fix
[enigma2.git] / keymapparser.py
index 510a47a951c26e761861740d638c93a38a9e5de6..23cd5a86a536907c79e46325fbd9d2983e351225 100644 (file)
@@ -3,18 +3,25 @@ import enigma
 
 from keyids import KEYIDS;
 
+# these are only informational (for help)...
+from Tools.KeyBindings import addKeyBinding
+
 def readKeymap():
 
        p = enigma.eActionMapPtr()
        enigma.eActionMap.getInstance(p)
        assert p
        
-       filename = "keymap.xml"
-       
+       filename1 = "data/keymap.xml"
+       filename2 = "/usr/share/enigma2/keymap.xml"
+               
        try:
-               source = open(filename)
+               source = open(filename1)
+               filename = filename1
        except:
-               raise "couldn't open keymap.xml!"
+               source = open(filename2)
+               filename = filename2
+#              raise "couldn't open keymap.xml!"
        
        try:
                dom = xml.dom.minidom.parse(source)
@@ -38,11 +45,11 @@ def readKeymap():
                                id = x.getAttribute("id")
                                flags = x.getAttribute("flags")
                                
-                               flag_ascii_to_id = lambda x: {'m':1,'r':2,'b':4}[x]
+                               flag_ascii_to_id = lambda x: {'m':1,'b':2,'r':4}[x]
                                
 #                              try:
                                flags = sum(map(flag_ascii_to_id, flags))
-                               print "-> " + str(flags)
+#                              print "-> " + str(flags)
 #                              except:
 #                                      raise str("%s: illegal flags '%s' specificed in context %s, id '%s'" % (filename, flags, context, id))
                                
@@ -52,14 +59,22 @@ def readKeymap():
                                
                                if len(id) == 1:
                                        keyid = ord(id) | 0x8000
+                               elif id[0] == '\\':
+                                       if id[1] == 'x':
+                                               keyid = int(id[2:], 0x10) | 0x8000
+                                       elif id[1] == 'd':
+                                               keyid = int(id[2:]) | 0x8000
+                                       else:
+                                               raise "key id '" + str(id) + "' is neither hex nor dec"
                                else:
                                        try:
                                                keyid = KEYIDS[id]
                                        except:
                                                raise "key id '" + str(id) + "' is illegal"
 
-                               print context + "::" + mapto + " -> " + device + "." + hex(keyid)
-                               p.bindKey(device, keyid, 7, context, mapto)
+#                              print context + "::" + mapto + " -> " + device + "." + hex(keyid)
+                               p.bindKey(device, keyid, flags, context, mapto)
+                               addKeyBinding(keyid, context, mapto)
                
                parseKeys("generic", cmap)