]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Prepare modifiers
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 26 Jul 2016 21:30:47 +0000 (23:30 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 26 Jul 2016 21:30:47 +0000 (23:30 +0200)
helpers/key.py
helpers/mapping.py

index 7ad0565045b9a8bbea8955318059c1e8a915a5e1..363e9ced7387577753113fda8a516b280abd9858 100644 (file)
@@ -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()
index 9c059725dcb54bd4beda9fc151298c051c531e3f..864afbef2eddf81c5fa791d64e1efea037a4afc4 100644 (file)
@@ -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])]