diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-02 07:07:00 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-02 07:31:50 +0300 |
commit | 4986f718482b061082936f1f6aa13929741093a2 (patch) | |
tree | 21ea0b78e1182d35b44b4955ff308b8df1148b19 /source/blender/blenloader | |
parent | 426ff481a789017bd5810a2064ec06a298a6f2dc (diff) |
Event System: remove tweak events in favor of click-drag
Supporting two kinds of dragging is redundant, remove tweak events as
they only supported 3 mouse buttons and added complexity from using the
'value' to store directions.
Support only click-drag events (KM_CLICK_DRAG) which can be used with
any keyboard or mouse button.
Details:
- A "direction" member has been added to keymap items and events which
can be used when the event value is set to KM_CLICK_DRAG.
- Keymap items are version patched.
- Loading older key-maps are also updated.
- Currently the key-maps stored in ./release/scripts/presets/keyconfig/
still reference tweak events & need updating. For now they are updated
on load.
Note that in general this wont impact add-ons as modal operators don't
receive tweak events.
Reviewed By: brecht
Ref D14214
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 10160e9aadc..862e8a09166 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -33,6 +33,7 @@ #include "readfile.h" /* Own include. */ +#include "WM_types.h" #include "wm_event_types.h" /* Don't use translation strings in versioning! @@ -363,10 +364,12 @@ static void do_version_select_mouse(UserDef *userdef, wmKeyMapItem *kmi) kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE; break; case EVT_TWEAK_S: - kmi->type = (left) ? EVT_TWEAK_L : EVT_TWEAK_R; + kmi->type = (left) ? LEFTMOUSE : RIGHTMOUSE; + kmi->val = KM_CLICK_DRAG; break; case EVT_TWEAK_A: - kmi->type = (left) ? EVT_TWEAK_R : EVT_TWEAK_L; + kmi->type = (left) ? RIGHTMOUSE : LEFTMOUSE; + kmi->val = KM_CLICK_DRAG; break; default: break; @@ -385,6 +388,39 @@ static bool keymap_item_has_invalid_wm_context_data_path(wmKeyMapItem *kmi, return false; } +static bool keymap_item_update_tweak_event(wmKeyMapItem *kmi, void *UNUSED(user_data)) +{ + /* Tweak events for L M R mouse-buttons. */ + enum { + EVT_TWEAK_L = 0x5002, + EVT_TWEAK_M = 0x5003, + EVT_TWEAK_R = 0x5004, + }; + switch (kmi->type) { + case EVT_TWEAK_L: + kmi->type = LEFTMOUSE; + break; + case EVT_TWEAK_M: + kmi->type = MIDDLEMOUSE; + break; + case EVT_TWEAK_R: + kmi->type = RIGHTMOUSE; + break; + default: + kmi->direction = KM_ANY; + return false; + } + + if (kmi->val >= EVT_GESTURE_N && kmi->val <= EVT_GESTURE_NW) { + kmi->direction = kmi->val; + } + else { + kmi->direction = KM_ANY; + } + kmi->val = KM_CLICK_DRAG; + return false; +} + void blo_do_versions_userdef(UserDef *userdef) { /* #UserDef & #Main happen to have the same struct member. */ @@ -952,6 +988,16 @@ void blo_do_versions_userdef(UserDef *userdef) userdef->ndof_flag |= NDOF_CAMERA_PAN_ZOOM; } + if (!USER_VERSION_ATLEAST(302, 5)) { + BKE_keyconfig_pref_filter_items(userdef, + &((struct wmKeyConfigFilterItemParams){ + .check_item = true, + .check_diff_item_add = true, + }), + keymap_item_update_tweak_event, + NULL); + } + /** * Versioning code until next subversion bump goes here. * |