Fix [#37077] User prefs > Input and Outliner Keymaps mismatch in representation.
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 15 Oct 2013 13:55:06 +0000 (13:55 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 15 Oct 2013 13:55:06 +0000 (13:55 +0000)
Remove KeyMap mode from outliner, was an old half-finished features redondant with user preferences settings...

Also moved key map item's "event type to map type" and map type defines at WM level, this is too much generic to be at RNA level.

Also added a check in versionning code to convert all outdated outliner modes to a valid one (seems old 'verse' ones were not handled as well).

Thanks to Brecht for reviews and advices!

source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/keyframing.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_wm.c
source/blender/windowmanager/WM_keymap.h
source/blender/windowmanager/intern/wm_keymap.c

index 23686986c7f0241055959b5e6c717437663f4b45..c4db8b188b2f428d487cc2d1c9d3357bf8ecb233 100644 (file)
@@ -9724,6 +9724,30 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                } FOREACH_NODETREE_END
        }
 
+       {
+               bScreen *sc;
+               ScrArea *sa;
+               SpaceLink *sl;
+
+               /* Update files using invalid (outdated) outlinevis Outliner values. */
+               for (sc = main->screen.first; sc; sc = sc->id.next) {
+                       for (sa = sc->areabase.first; sa; sa = sa->next) {
+                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                       if (sl->spacetype == SPACE_OUTLINER) {
+                                               SpaceOops *so = (SpaceOops *)sl;
+
+                                               if (!ELEM11(so->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_SELECTED, SO_ACTIVE,
+                                                                           SO_SAME_TYPE, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_DATABLOCKS,
+                                                                           SO_USERDEF))
+                                               {
+                                                       so->outlinevis = SO_ALL_SCENES;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init see do_versions_userdef() above! */
 
index 6b9200afb7585e4c94598f82b6dacdeb9ef45c7c..513085e9a64ab45810bd604ddc465d2fc58cbe7b 100644 (file)
@@ -1225,7 +1225,7 @@ static int modify_key_op_poll(bContext *C)
        
        /* if Outliner, don't allow in some views */
        if (so) {
-               if (ELEM5(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF, SO_KEYMAP)) {
+               if (ELEM4(so->outlinevis, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_USERDEF)) {
                        return 0;
                }
        }
index fe706ce23652b6cc794aaec8523deb00cb70294e..fda8c19d21b9d980228ff28189ea865090161c25 100644 (file)
@@ -765,286 +765,6 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
        uiBlockSetEmboss(block, UI_EMBOSS);
 }
 
-static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2)
-{
-       wmOperatorType *ot = arg2;
-       wmKeyMapItem *kmi = arg_kmi;
-       
-       if (ot)
-               BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME);
-}
-
-static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi),
-                               const char *str, uiSearchItems *items)
-{
-       GHashIterator *iter = WM_operatortype_iter();
-
-       for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) {
-               wmOperatorType *ot = BLI_ghashIterator_getValue(iter);
-               
-               if (BLI_strcasestr(ot->idname, str)) {
-                       char name[OP_MAX_TYPENAME];
-                       
-                       /* display name for menu */
-                       WM_operator_py_idname(name, ot->idname);
-                       
-                       if (false == uiSearchItemAdd(items, name, ot, 0))
-                               break;
-               }
-       }
-       BLI_ghashIterator_free(iter);
-}
-
-/* operator Search browse menu, open */
-static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi)
-{
-       static char search[OP_MAX_TYPENAME];
-       wmEvent event;
-       wmWindow *win = CTX_wm_window(C);
-       wmKeyMapItem *kmi = arg_kmi;
-       wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0);
-       uiBlock *block;
-       uiBut *but;
-       
-       /* clear initial search string, then all items show */
-       search[0] = 0;
-       
-       block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
-       uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
-       
-       /* fake button, it holds space for search items */
-       uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
-       
-       but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, "");
-       uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
-       
-       uiBoundsBlock(block, 6);
-       uiBlockSetDirection(block, UI_DOWN);
-       uiEndBlock(C, block);
-       
-       wm_event_init_from_window(win, &event);
-       event.type = EVT_BUT_OPEN;
-       event.val = KM_PRESS;
-       event.customdata = but;
-       event.customdatafree = FALSE;
-       wm_event_add(win, &event);
-       
-       return block;
-}
-
-#define OL_KM_KEYBOARD      0
-#define OL_KM_MOUSE         1
-#define OL_KM_TWEAK         2
-#define OL_KM_SPECIALS      3
-
-static short keymap_menu_type(short type)
-{
-       if (ISKEYBOARD(type)) return OL_KM_KEYBOARD;
-       if (ISTWEAK(type)) return OL_KM_TWEAK;
-       if (ISMOUSE(type)) return OL_KM_MOUSE;
-//     return OL_KM_SPECIALS;
-       return 0;
-}
-
-static const char *keymap_type_menu(void)
-{
-       static const char string[] =
-           "Event Type%t"
-           "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD)
-           "|Mouse%x" STRINGIFY(OL_KM_MOUSE)
-           "|Tweak%x" STRINGIFY(OL_KM_TWEAK)
-//     "|Specials%x" STRINGIFY(OL_KM_SPECIALS)
-       ;
-
-       return string;
-}
-
-static const char *keymap_mouse_menu(void)
-{
-       static const char string[] =
-           "Mouse Event%t"
-           "|Left Mouse%x" STRINGIFY(LEFTMOUSE)
-           "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE)
-           "|Right Mouse%x" STRINGIFY(RIGHTMOUSE)
-           "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE)
-           "|Right Mouse%x" STRINGIFY(RIGHTMOUSE)
-           "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE)
-           "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE)
-           "|Action Mouse%x" STRINGIFY(ACTIONMOUSE)
-           "|Select Mouse%x" STRINGIFY(SELECTMOUSE)
-           "|Mouse Move%x" STRINGIFY(MOUSEMOVE)
-           "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE)
-           "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE)
-           "|Wheel In%x" STRINGIFY(WHEELINMOUSE)
-           "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE)
-           "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN)
-           "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM)
-           "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE)
-       ;
-
-       return string;
-}
-
-static const char *keymap_tweak_menu(void)
-{
-       static const char string[] =
-           "Tweak Event%t"
-           "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L)
-           "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M)
-           "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R)
-           "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A)
-           "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S)
-       ;
-
-       return string;
-}
-
-static const char *keymap_tweak_dir_menu(void)
-{
-       static const char string[] =
-           "Tweak Direction%t"
-           "|Any%x" STRINGIFY(KM_ANY)
-           "|North%x" STRINGIFY(EVT_GESTURE_N)
-           "|North-East%x" STRINGIFY(EVT_GESTURE_NE)
-           "|East%x" STRINGIFY(EVT_GESTURE_E)
-           "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE)
-           "|South%x" STRINGIFY(EVT_GESTURE_S)
-           "|South-West%x" STRINGIFY(EVT_GESTURE_SW)
-           "|West%x" STRINGIFY(EVT_GESTURE_W)
-           "|North-West%x" STRINGIFY(EVT_GESTURE_NW)
-       ;
-
-       return string;
-}
-
-
-static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v))
-{
-       wmKeyMapItem *kmi = kmi_v;
-       short maptype = keymap_menu_type(kmi->type);
-       
-       if (maptype != kmi->maptype) {
-               switch (kmi->maptype) {
-                       case OL_KM_KEYBOARD:
-                               kmi->type = AKEY;
-                               kmi->val = KM_PRESS;
-                               break;
-                       case OL_KM_MOUSE:
-                               kmi->type = LEFTMOUSE;
-                               kmi->val = KM_PRESS;
-                               break;
-                       case OL_KM_TWEAK:
-                               kmi->type = EVT_TWEAK_L;
-                               kmi->val = KM_ANY;
-                               break;
-                       case OL_KM_SPECIALS:
-                               kmi->type = AKEY;
-                               kmi->val = KM_PRESS;
-                               break;
-               }
-               ED_region_tag_redraw(CTX_wm_region(C));
-       }
-}
-
-static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soops, ListBase *lb)
-{
-       TreeElement *te;
-       TreeStoreElem *tselem;
-       
-       uiBlockSetEmboss(block, UI_EMBOSST);
-       
-       for (te = lb->first; te; te = te->next) {
-               tselem = TREESTORE(te);
-               if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) {
-                       uiBut *but;
-                       const char *str;
-                       int xstart = 240;
-                       int butw1 = UI_UNIT_X; /* operator */
-                       int butw2 = 90; /* event type, menus */
-                       int butw3 = 43; /* modifiers */
-
-                       if (tselem->type == TSE_KEYMAP_ITEM) {
-                               wmKeyMapItem *kmi = te->directdata;
-                               
-                               /* modal map? */
-                               if (kmi->propvalue) {
-                                       /* pass */
-                               }
-                               else {
-                                       uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, te->ys + 1, butw1, UI_UNIT_Y - 1,
-                                                     TIP_("Assign new Operator"));
-                               }
-                               xstart += butw1 + 10;
-                               
-                               /* map type button */
-                               kmi->maptype = keymap_menu_type(kmi->type);
-                               
-                               str = keymap_type_menu();
-                               but = uiDefButS(block, MENU, 0, str,    xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype,
-                                               0, 0, 0, 0, TIP_("Event type"));
-                               uiButSetFunc(but, keymap_type_cb, kmi, NULL);
-                               xstart += butw2 + 5;
-                               
-                               /* edit actual event */
-                               switch (kmi->maptype) {
-                                       case OL_KM_KEYBOARD:
-                                               uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
-                                                               TIP_("Key code"));
-                                               xstart += butw2 + 5;
-                                               break;
-                                       case OL_KM_MOUSE:
-                                               str = keymap_mouse_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
-                                                         0, 0, 0, 0, TIP_("Mouse button"));
-                                               xstart += butw2 + 5;
-                                               break;
-                                       case OL_KM_TWEAK:
-                                               str = keymap_tweak_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type,
-                                                         0, 0, 0, 0, TIP_("Tweak gesture"));
-                                               xstart += butw2 + 5;
-                                               str = keymap_tweak_dir_menu();
-                                               uiDefButS(block, MENU, 0, str, xstart, te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val,
-                                                         0, 0, 0, 0, TIP_("Tweak gesture direction"));
-                                               xstart += butw2 + 5;
-                                               break;
-                               }
-                               
-                               /* modifiers */
-                               uiDefButS(block, OPTION, 0, IFACE_("Shift"), xstart, te->ys + 1, butw3 + 5, UI_UNIT_Y - 1,
-                                         &kmi->shift, 0, 0, 0, 0, TIP_("Modifier"));
-                               xstart += butw3 + 5;
-                               uiDefButS(block, OPTION, 0, IFACE_("Ctrl"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl,
-                                         0, 0, 0, 0, TIP_("Modifier"));
-                               xstart += butw3;
-                               uiDefButS(block, OPTION, 0, IFACE_("Alt"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt,
-                                         0, 0, 0, 0, TIP_("Modifier"));
-                               xstart += butw3;
-                               uiDefButS(block, OPTION, 0, IFACE_("OS"), xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey,
-                                         0, 0, 0, 0, TIP_("Modifier"));
-                               xstart += butw3 + 5;
-                               uiDefKeyevtButS(block, 0, "", xstart, te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier,
-                                               TIP_("Key Modifier code"));
-                               xstart += butw3 + 5;
-                               
-                               /* rna property */
-                               if (kmi->ptr && kmi->ptr->data) {
-                                       uiDefBut(block, LABEL, 0, IFACE_("(RNA property)"), xstart, te->ys + 1, butw2, UI_UNIT_Y - 1,
-                                                NULL, 0, 0, 0, 0, "");
-                                       xstart += butw2;
-                               }
-
-                               (void)xstart;
-                       }
-               }
-               
-               if (TSELEM_OPEN(tselem, soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree);
-       }
-
-       uiBlockSetEmboss(block, UI_EMBOSS);
-}
-
-
 static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, TreeElement *te)
 {
        uiBut *bt;
@@ -1864,7 +1584,7 @@ void draw_outliner(const bContext *C)
        /* get extents of data */
        outliner_height(soops, &soops->tree, &sizey);
 
-       if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) {
+       if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) {
                /* RNA has two columns:
                 *  - column 1 is (max_width + OL_RNA_COL_SPACEX) or
                 *                               (OL_RNA_COL_X), whichever is wider...
@@ -1878,11 +1598,7 @@ void draw_outliner(const bContext *C)
                sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX);
                
                /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */
-               if (soops->outlinevis == SO_KEYMAP)
-                       // XXX this is only really a quick hack to make this wide enough...
-                       sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50;
-               else
-                       sizex = sizex_rna + OL_RNA_COL_SIZEX + 50;
+               sizex = sizex_rna + OL_RNA_COL_SIZEX + 50;
        }
        else {
                /* width must take into account restriction columns (if visible) so that entries will still be visible */
@@ -1918,9 +1634,6 @@ void draw_outliner(const bContext *C)
                outliner_draw_rnacols(ar, sizex_rna);
                outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree);
        }
-       else if (soops->outlinevis == SO_KEYMAP) {
-               outliner_draw_keymapbuts(block, ar, soops, &soops->tree);
-       }
        else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) {
                /* draw restriction columns */
                outliner_draw_restrictcols(ar);
index 41ad75bb14fbaebd16e750af4be8a0996be5d722..d1d512409ee03cebb80e1a1b00f8d45e5e385695 100644 (file)
@@ -902,7 +902,7 @@ int outliner_item_do_activate(bContext *C, int x, int y, bool extend, bool recur
 
        UI_view2d_region_to_view(&ar->v2d, x, y, fmval, fmval + 1);
 
-       if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) &&
+       if (!ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF) &&
            !(soops->flag & SO_HIDE_RESTRICTCOLS) &&
            (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX))
        {
index a93ed2dc6b00dff81382d86a8c047396fc4660a5..036db3bae914352b5b64413e699624b5cf8c9fb1 100644 (file)
@@ -1676,14 +1676,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops)
                        tselem->flag &= ~TSE_CLOSED;
                }
        }
-       else if (soops->outlinevis == SO_KEYMAP) {
-               wmWindowManager *wm = mainvar->wm.first;
-               wmKeyMap *km;
-               
-               for (km = wm->defaultconf->keymaps.first; km; km = km->next) {
-                       /* ten = */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0);
-               }
-       }
        else {
                ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0);
                if (ten) ten->directdata = BASACT;
index 5befaa87e7f688ff06d48e82052c50f58a9fef4e..f71516af5e65e4c32d584beadb6b0ca15b4aafa1 100644 (file)
@@ -286,11 +286,11 @@ typedef enum eSpaceOutliner_Mode {
        SO_GROUPS = 6,
        SO_LIBRARIES = 7,
        /* SO_VERSE_SESSION = 8, */  /* deprecated! */
-       /* SO_VERSE_MS = 9, */       /* deprecated!*/
+       /* SO_VERSE_MS = 9, */       /* deprecated! */
        SO_SEQUENCE = 10,
        SO_DATABLOCKS = 11,
        SO_USERDEF = 12,
-       SO_KEYMAP = 13,
+       /* SO_KEYMAP = 13, */        /* deprecated! */
 } eSpaceOutliner_Mode;
 
 /* SpaceOops->storeflag */
index fd1b0c8ec2daafb8c48592458c7b4b2da4e79bad..ff43cc31b9aa162a5d0439e12f84ae6d591bf1c3 100644 (file)
@@ -263,6 +263,16 @@ enum {
        KMI_UPDATE         = (1 << 3),
 };
 
+/* wmKeyMapItem.maptype */
+enum {
+       KMI_TYPE_KEYBOARD   = 0,
+       KMI_TYPE_MOUSE      = 1,
+       KMI_TYPE_TWEAK      = 2,
+       KMI_TYPE_TEXTINPUT  = 3,
+       KMI_TYPE_TIMER      = 4,
+       KMI_TYPE_NDOF       = 5,
+};
+
 /* stored in WM, the actively used keymaps */
 typedef struct wmKeyMap {
        struct wmKeyMap *next, *prev;
index 41ea74ebb8cde7628c861e90838caabd16d2696a..77f5957641e701af52a7e14998bab3b217de37e0 100644 (file)
@@ -1490,7 +1490,6 @@ static void rna_def_space_outliner(BlenderRNA *brna)
                {SO_LIBRARIES, "LIBRARIES", 0, "Blender File", "Display data of current file and linked libraries"},
                {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", "Display all raw datablocks"},
                {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display the user preference datablocks"},
-               {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", "Display keymap datablocks"},
                {0, NULL, 0, NULL, NULL}
        };
        
index c6366745c55680c829f4c08991774f3e510af919..dd338713d3e1516f55747491ffea22e8a5b1f0ef 100644 (file)
@@ -442,13 +442,6 @@ EnumPropertyItem wm_report_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-#define KMI_TYPE_KEYBOARD   0
-#define KMI_TYPE_MOUSE      1
-#define KMI_TYPE_TWEAK      2
-#define KMI_TYPE_TEXTINPUT  3
-#define KMI_TYPE_TIMER      4
-#define KMI_TYPE_NDOF       5
-
 #ifdef RNA_RUNTIME
 
 #include <assert.h>
@@ -625,13 +618,7 @@ static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
 {
        wmKeyMapItem *kmi = ptr->data;
 
-       if (ISTIMER(kmi->type)) return KMI_TYPE_TIMER;
-       if (ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD;
-       if (ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK;
-       if (ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE;
-       if (ISNDOF(kmi->type)) return KMI_TYPE_NDOF;
-       if (kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT;
-       return KMI_TYPE_KEYBOARD;
+       return WM_keymap_map_type_get(kmi);
 }
 
 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
index eab27286709451268c5894f21feea63ff079c720..ce6481c89293aad5f38813f9802a7eeb943e8e9f 100644 (file)
@@ -91,6 +91,7 @@ void          WM_modalkeymap_assign(struct wmKeyMap *km, const char *opname);
 void           WM_keymap_restore_to_default(struct wmKeyMap *keymap, struct bContext *C);
 void           WM_keymap_properties_reset(struct wmKeyMapItem *kmi, struct IDProperty *properties);
 void           WM_keymap_restore_item_to_default(struct bContext *C, struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
+int                    WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
 
 /* Key Event */
 
index f6ba3a29344c1e974680484120e6d6a3ee2d7d2c..06719514483f2c7038faf2bcc4b8eae1f25d703b 100644 (file)
@@ -139,6 +139,29 @@ void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties
        wm_keymap_item_properties_set(kmi);
 }
 
+int WM_keymap_map_type_get(wmKeyMapItem *kmi) {
+       if (ISTIMER(kmi->type)) {
+               return KMI_TYPE_TIMER;
+       }
+       if (ISKEYBOARD(kmi->type)) {
+               return KMI_TYPE_KEYBOARD;
+       }
+       if (ISTWEAK(kmi->type)) {
+               return KMI_TYPE_TWEAK;
+       }
+       if (ISMOUSE(kmi->type)) {
+               return KMI_TYPE_MOUSE;
+       }
+       if (ISNDOF(kmi->type)) {
+               return KMI_TYPE_NDOF;
+       }
+       if (kmi->type == KM_TEXTINPUT) {
+               return KMI_TYPE_TEXTINPUT;
+       }
+       return KMI_TYPE_KEYBOARD;
+}
+
+
 /**************************** Keymap Diff Item *********************************
  * Item in a diff keymap, used for saving diff of keymaps in user preferences */