e758213314e11a1217354358d9abafe834638c7d
[openblackhole/openblackhole-enigma2.git] / lib / python / Tools / KeyBindings.py
1
2 keyBindings = { }
3
4 from keyids import KEYIDS
5
6 keyDescriptions = {
7                 KEYIDS["KEY_RED"]: "red",
8                 KEYIDS["KEY_BLUE"]: "blue",
9                 KEYIDS["KEY_GREEN"]: "green",
10                 KEYIDS["KEY_MENU"]: "menu",
11                 KEYIDS["KEY_LEFT"]: "left",
12                 KEYIDS["KEY_RIGHT"]: "right",
13                 KEYIDS["KEY_VIDEO"]: "video",
14                 KEYIDS["KEY_INFO"]: "info",
15                 KEYIDS["KEY_AUDIO"]: "audio",
16                 KEYIDS["KEY_RADIO"]: "radio"
17         }
18
19 def addKeyBinding(key, context, action):
20         if (context, action) in keyBindings:
21                 keyBindings[(context, action)].append(key)
22         else:
23                 keyBindings[(context, action)] = [key]
24
25 def queryKeyBinding(context, action):
26         if (context, action) in keyBindings:
27                 return keyBindings[(context, action)]
28         else:
29                 return [ ]
30
31 def getKeyDescription(key):
32         if key in keyDescriptions:
33                 return keyDescriptions[key]
34         return "key_%0x" % key