Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-12-18 01:14:43 +0300
committerMartin Poirier <theeth@yahoo.com>2009-12-18 01:14:43 +0300
commit62639a55d90f1adc2e18f8d2b7d2556a761ef254 (patch)
treed1443e108af0755e9de81fcc98b7da7d26522394 /source/blender/windowmanager/intern/wm_keymap.c
parent66c3ae5c34015265466a303776644bff18076379 (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/intern/wm_keymap.c')
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c42
1 files changed, 42 insertions, 0 deletions
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)