From 4b6d1836f3cc6e063bca3f4011ce5d17f733baa6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 26 Jul 2016 23:30:47 +0200 Subject: [PATCH] Prepare modifiers --- helpers/key.py | 2 +- helpers/mapping.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/helpers/key.py b/helpers/key.py index 7ad0565..363e9ce 100644 --- a/helpers/key.py +++ b/helpers/key.py @@ -156,7 +156,7 @@ class Key(ButtonBehavior, Widget): else: self.no_actions() - def on_enter_loaded_running(self): + def on_enter_loaded_running(self, modifiers): self.parent.parent.ids['KeyList'].append(self.key_sym) debug_print("running actions for {}".format(self.key_sym)) start_time = time.time() 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): def on_keyboard_down(self, keyboard, keycode, text, modifiers): key = self.find_by_key_code(keycode) - if len(modifiers) == 0 and key is not None: - threading.Thread(name="MSKeyAction", target=key.run).start() + if self.allowed_modifiers(modifiers) and key is not None: + modifiers.sort() + threading.Thread(name="MSKeyAction", target=key.run, + args=['-'.join(modifiers)]).start() elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'): self.stop_all_running() for thread in threading.enumerate(): @@ -112,6 +114,11 @@ class Mapping(RelativeLayout): sys.exit() return True + # Helpers + def allowed_modifiers(self, modifiers): + allowed = [] + return len([a for a in modifiers if a not in allowed]) == 0 + def find_by_key_code(self, key_code): if "Key_" + str(key_code[0]) in self.ids: return self.ids["Key_" + str(key_code[0])] -- 2.41.0