diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-12-18 01:14:43 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-12-18 01:14:43 +0300 |
commit | 62639a55d90f1adc2e18f8d2b7d2556a761ef254 (patch) | |
tree | d1443e108af0755e9de81fcc98b7da7d26522394 /source/blender/windowmanager | |
parent | 66c3ae5c34015265466a303776644bff18076379 (diff) |
Keymap conflict detection operator.
Takes into account the hierarchical structures of keymaps as well as wildcards (KM_ANY) in event definitions, user remaps (emulate numpad, action/select mouse buttons, ...) and event values that overlap (click, press and release)
For now, doesn't do anything other than print conflicts in the console.
As a result, I cleaned up a lot of keymaps that had double definitions, moved some keymap items in more appropriate places, fixed wrong definitions and removed kmi that were added for testing a long long time ago.
Out of all the remaining conflicts, after removing obvious non-issues, here's what remains: http://www.pasteall.org/9898
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 42 |
3 files changed, 46 insertions, 2 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index c4270fbc8b0..1702149cf8b 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -115,6 +115,8 @@ wmKeyMap *WM_keymap_copy_to_user(struct wmKeyMap *keymap); void WM_keymap_restore_to_default(struct wmKeyMap *keymap); void WM_keymap_properties_reset(struct wmKeyMapItem *kmi); void WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi); +int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2); +int WM_userdef_event_map(int kmitype); wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, struct EnumPropertyItem *items); wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, char *idname); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index ccc020827c5..ac4c2709688 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -709,7 +709,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) } /* do userdef mappings */ -static int wm_userdef_event_map(int kmitype) +int WM_userdef_event_map(int kmitype) { switch(kmitype) { case SELECTMOUSE: @@ -754,7 +754,7 @@ static int wm_userdef_event_map(int kmitype) static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) { - int kmitype= wm_userdef_event_map(kmi->type); + int kmitype= WM_userdef_event_map(kmi->type); if(kmi->flag & KMI_INACTIVE) return 0; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index e1f812ee45f..116bc263d71 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -453,6 +453,48 @@ char *WM_key_event_operator_string(const bContext *C, const char *opname, int op return NULL; } +int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) +{ + int k1type, k2type; + + if (k1->flag & KMI_INACTIVE || k2->flag & KMI_INACTIVE) + return 0; + + /* take event mapping into account */ + k1type = WM_userdef_event_map(k1->type); + k2type = WM_userdef_event_map(k2->type); + + if(k1type != KM_ANY && k2type != KM_ANY && k1type != k2type) + return 0; + + if(k1->val != KM_ANY && k2->val != KM_ANY) { + /* take click, press, release conflict into account */ + if (k1->val == KM_CLICK && ELEM3(k2->val, KM_PRESS, KM_RELEASE, KM_CLICK) == 0) + return 0; + if (k2->val == KM_CLICK && ELEM3(k1->val, KM_PRESS, KM_RELEASE, KM_CLICK) == 0) + return 0; + if (k1->val != k2->val) + return 0; + } + + if(k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift) + return 0; + + if(k1->ctrl != KM_ANY && k2->ctrl != KM_ANY && k1->ctrl != k2->ctrl) + return 0; + + if(k1->alt != KM_ANY && k2->alt != KM_ANY && k1->alt != k2->alt) + return 0; + + if(k1->oskey != KM_ANY && k2->oskey != KM_ANY && k1->oskey != k2->oskey) + return 0; + + if(k1->keymodifier != k2->keymodifier) + return 0; + + return 1; +} + /* ***************** user preferences ******************* */ int WM_keymap_user_init(wmWindowManager *wm, wmKeyMap *keymap) |