aboutsummaryrefslogtreecommitdiff
path: root/helpers/mapping.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/mapping.py')
-rw-r--r--helpers/mapping.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/helpers/mapping.py b/helpers/mapping.py
index 9c05972..864afbe 100644
--- a/helpers/mapping.py
+++ b/helpers/mapping.py
@@ -100,8 +100,10 @@ class Mapping(RelativeLayout):
100 100
101 def on_keyboard_down(self, keyboard, keycode, text, modifiers): 101 def on_keyboard_down(self, keyboard, keycode, text, modifiers):
102 key = self.find_by_key_code(keycode) 102 key = self.find_by_key_code(keycode)
103 if len(modifiers) == 0 and key is not None: 103 if self.allowed_modifiers(modifiers) and key is not None:
104 threading.Thread(name="MSKeyAction", target=key.run).start() 104 modifiers.sort()
105 threading.Thread(name="MSKeyAction", target=key.run,
106 args=['-'.join(modifiers)]).start()
105 elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'): 107 elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'):
106 self.stop_all_running() 108 self.stop_all_running()
107 for thread in threading.enumerate(): 109 for thread in threading.enumerate():
@@ -112,6 +114,11 @@ class Mapping(RelativeLayout):
112 sys.exit() 114 sys.exit()
113 return True 115 return True
114 116
117 # Helpers
118 def allowed_modifiers(self, modifiers):
119 allowed = []
120 return len([a for a in modifiers if a not in allowed]) == 0
121
115 def find_by_key_code(self, key_code): 122 def find_by_key_code(self, key_code):
116 if "Key_" + str(key_code[0]) in self.ids: 123 if "Key_" + str(key_code[0]) in self.ids:
117 return self.ids["Key_" + str(key_code[0])] 124 return self.ids["Key_" + str(key_code[0])]