diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-09-16 16:20:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-09-17 09:52:33 +0300 |
commit | 06ac655b8dda53aa2122844d487ed68510211395 (patch) | |
tree | 6fcd428f6482f83023e75348303ed27592203838 /source/blender/windowmanager/intern/wm_keymap.c | |
parent | 6dca61b91c3178a22e8d6e9cdaaeaa12554ffb73 (diff) |
WM: expose the "any" state of KeyMapItem modifiers
Change KeyMapItem.alt/ctrl/shift/oskey to integer types,
where -1 is used to ignore the modifier when matching key-map items.
It was only possible to set all modifiers to -1 at once from RNA
using the 'any' property.
Afterwards individual modifiers could be set back to true/false.
Although these key-map items could not be exported/imported.
Exposing the values directly avoids the need for cumbersome workarounds.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index bcd21fd7ac3..f955abaed53 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -484,10 +484,20 @@ static void keymap_event_set( kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY; } else { - kmi->shift = (modifier & KM_SHIFT) ? KM_MOD_HELD : KM_NOTHING; - kmi->ctrl = (modifier & KM_CTRL) ? KM_MOD_HELD : KM_NOTHING; - kmi->alt = (modifier & KM_ALT) ? KM_MOD_HELD : KM_NOTHING; - kmi->oskey = (modifier & KM_OSKEY) ? KM_MOD_HELD : KM_NOTHING; + /* Only one of the flags should be set. */ + BLI_assert(((modifier & (KM_SHIFT | KM_SHIFT_ANY)) != (KM_SHIFT | KM_SHIFT_ANY)) && + ((modifier & (KM_CTRL | KM_CTRL_ANY)) != (KM_CTRL | KM_CTRL_ANY)) && + ((modifier & (KM_ALT | KM_ALT_ANY)) != (KM_ALT | KM_ALT_ANY)) && + ((modifier & (KM_OSKEY | KM_OSKEY_ANY)) != (KM_OSKEY | KM_OSKEY_ANY))); + + kmi->shift = ((modifier & KM_SHIFT) ? KM_MOD_HELD : + ((modifier & KM_SHIFT_ANY) ? KM_ANY : KM_NOTHING)); + kmi->ctrl = ((modifier & KM_CTRL) ? KM_MOD_HELD : + ((modifier & KM_CTRL_ANY) ? KM_ANY : KM_NOTHING)); + kmi->alt = ((modifier & KM_ALT) ? KM_MOD_HELD : + ((modifier & KM_ALT_ANY) ? KM_ANY : KM_NOTHING)); + kmi->oskey = ((modifier & KM_OSKEY) ? KM_MOD_HELD : + ((modifier & KM_OSKEY_ANY) ? KM_ANY : KM_NOTHING)); } } |