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()
try:
source = open(filename1)
+ filename = filename1
except:
source = open(filename2)
+ filename = filename2
# raise "couldn't open keymap.xml!"
try:
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")
# 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)