Commit: 90526e1606c337440a1846c968276a24945ae853
Author: Campbell Barton
Date:   Fri Mar 1 16:46:10 2019 +1100
Branches: master
https://developer.blender.org/rB90526e1606c337440a1846c968276a24945ae853

WM: improve support for binding actions to modifier keys

Previously a modifier key-map type only worked when the same key was
enabled as a modifier as well.

This allows for users to assign an action to double-tap-shift for eg.

===================================================================

M       source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index ebf09af825c..139e1a5127a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1886,24 +1886,33 @@ static bool wm_eventmatch(const wmEvent *winevent, 
const wmKeyMapItem *kmi)
                }
        }
 
-       /* modifiers also check bits, so it allows modifier order */
+       /* Modifiers also check bits, so it allows modifier order.
+        * Account for rare case of when these keys are used as the 'type' not 
as modifiers. */
        if (kmi->shift != KM_ANY) {
-               if (winevent->shift != kmi->shift && !(winevent->shift & 
kmi->shift)) {
+               if ((winevent->shift != kmi->shift) && !(winevent->shift & 
kmi->shift) &&
+                   !ELEM(winevent->type, LEFTSHIFTKEY, RIGHTSHIFTKEY))
+               {
                        return false;
                }
        }
        if (kmi->ctrl != KM_ANY) {
-               if (winevent->ctrl != kmi->ctrl && !(winevent->ctrl & 
kmi->ctrl)) {
+               if (winevent->ctrl != kmi->ctrl && !(winevent->ctrl & 
kmi->ctrl) &&
+                   !ELEM(winevent->type, LEFTCTRLKEY, RIGHTCTRLKEY))
+               {
                        return false;
                }
        }
        if (kmi->alt != KM_ANY) {
-               if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt)) {
+               if (winevent->alt != kmi->alt && !(winevent->alt & kmi->alt) &&
+                   !ELEM(winevent->type, LEFTALTKEY, RIGHTALTKEY))
+               {
                        return false;
                }
        }
        if (kmi->oskey != KM_ANY) {
-               if (winevent->oskey != kmi->oskey && !(winevent->oskey & 
kmi->oskey)) {
+               if (winevent->oskey != kmi->oskey && !(winevent->oskey & 
kmi->oskey) &&
+                   (winevent->type != OSKEY))
+               {
                        return false;
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to