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:
-rw-r--r--source/blender/editors/armature/pose_lib.c2
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/editors/interface/interface_layout.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c2
-rw-r--r--source/blender/editors/transform/transform.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm.c220
-rw-r--r--source/blender/windowmanager/WM_keymap.h13
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c160
10 files changed, 257 insertions, 153 deletions
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index d571fb374d9..3ced37dcfb2 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -1196,7 +1196,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
/* only accept 'press' event, and ignore 'release', so that we don't get double actions */
if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) {
- //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type), event->val);
+ //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val);
return ret;
}
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index b5e1b9f08b1..bb6c9a1cb52 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -86,6 +86,7 @@ typedef struct uiLayout uiLayout;
/* names */
#define UI_MAX_DRAW_STR 400
#define UI_MAX_NAME_STR 128
+#define UI_MAX_SHORTCUT_STR 64
/* use for clamping popups within the screen */
#define UI_SCREEN_MARGIN 10
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e045db8fdd2..1a62fb4b3ae 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2825,7 +2825,7 @@ void ui_but_update(uiBut *but)
}
else {
UI_GET_BUT_VALUE_INIT(but, value);
- str = WM_key_event_string((short)value);
+ str = WM_key_event_string((short)value, false);
}
BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str);
break;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 58cf6b900b9..c51d9906fa5 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3651,7 +3651,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
if (event->val == KM_PRESS) {
if (ISHOTKEY(event->type)) {
- if (WM_key_event_string(event->type)[0])
+ if (WM_key_event_string(event->type, false)[0])
ui_but_value_set(but, event->type);
else
data->cancel = true;
@@ -3687,7 +3687,7 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, c
}
if (event->val == KM_PRESS) {
- if (WM_key_event_string(event->type)[0])
+ if (WM_key_event_string(event->type, false)[0])
ui_but_value_set(but, event->type);
else
data->cancel = true;
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index a61b208278d..0e30ba54d1c 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -668,7 +668,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
char buf[128];
- WM_keymap_item_to_string(ptr->data, buf, sizeof(buf));
+ WM_keymap_item_to_string(ptr->data, buf, sizeof(buf), false);
but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 0c1d6318638..b86d670a28c 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1139,7 +1139,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
int a = 0;
for (kmi = km->items.first; kmi; kmi = kmi->next, a++) {
- const char *key = WM_key_event_string(kmi->type);
+ const char *key = WM_key_event_string(kmi->type, false);
if (key[0]) {
wmOperatorType *ot = NULL;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 66146ff1d71..0497967c04a 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -4422,7 +4422,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
if (t->keymap) {
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
if (kmi) {
- ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs);
+ ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs, false);
}
}
BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"),
@@ -7743,7 +7743,7 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[MAX_INFO_L
if (t->keymap) {
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE);
if (kmi) {
- ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs);
+ ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs, false);
}
}
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"),
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 4446f5d9a2b..86c6d432f9d 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -168,34 +168,34 @@ static EnumPropertyItem event_ndof_type_items[] = {
/* not returned: CAPSLOCKKEY, UNKNOWNKEY */
EnumPropertyItem event_type_items[] = {
-
+ /* Note we abuse 'tooltip' message here to store a 'compact' form of some (too) long names. */
{0, "NONE", 0, "", ""},
- {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", ""},
- {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", ""},
- {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", ""},
- {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", ""},
- {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", ""},
- {BUTTON6MOUSE, "BUTTON6MOUSE", 0, "Button6 Mouse", ""},
- {BUTTON7MOUSE, "BUTTON7MOUSE", 0, "Button7 Mouse", ""},
- {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", ""},
- {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""},
+ {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", "LMB"},
+ {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", "MMB"},
+ {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", "RMB"},
+ {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", "MB4"},
+ {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", "MB5"},
+ {BUTTON6MOUSE, "BUTTON6MOUSE", 0, "Button6 Mouse", "MB6"},
+ {BUTTON7MOUSE, "BUTTON7MOUSE", 0, "Button7 Mouse", "MB7"},
+ {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", "MBA"},
+ {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", "MBS"},
{0, "", 0, NULL, NULL},
- {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""},
- {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "In-between Move", ""},
- {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""},
- {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""},
- {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""},
+ {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", "MsMov"},
+ {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "In-between Move", "MsSubMov"},
+ {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", "MsPan"},
+ {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", "MsZoom"},
+ {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", "MsRot"},
{0, "", 0, NULL, NULL},
- {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
- {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
- {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
- {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
+ {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", "WhUp"},
+ {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", "WhDown"},
+ {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", "WhIn"},
+ {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", "WhOut"},
{0, "", 0, NULL, NULL},
- {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", ""},
- {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", ""},
- {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", ""},
- {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", ""},
- {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", ""},
+ {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", "TwkL"},
+ {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", "TwkM"},
+ {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", "TwkR"},
+ {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", "TwkA"},
+ {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", "TwkS"},
{0, "", 0, NULL, NULL},
{AKEY, "A", 0, "A", ""},
{BKEY, "B", 0, "B", ""},
@@ -235,22 +235,22 @@ EnumPropertyItem event_type_items[] = {
{EIGHTKEY, "EIGHT", 0, "8", ""},
{NINEKEY, "NINE", 0, "9", ""},
{0, "", 0, NULL, NULL},
- {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""},
- {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""},
- {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", ""},
- {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""},
- {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", ""},
- {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", ""},
+ {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", "CtrlL"},
+ {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", "AltL"},
+ {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", "ShiftL"},
+ {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", "AltR"},
+ {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", "CtrlR"},
+ {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", "ShiftR"},
{0, "", 0, NULL, NULL},
- {OSKEY, "OSKEY", 0, "OS Key", ""},
+ {OSKEY, "OSKEY", 0, "OS Key", "Cmd"},
{GRLESSKEY, "GRLESS", 0, "Grless", ""},
{ESCKEY, "ESC", 0, "Esc", ""},
{TABKEY, "TAB", 0, "Tab", ""},
- {RETKEY, "RET", 0, "Return", ""},
- {SPACEKEY, "SPACE", 0, "Spacebar", ""},
+ {RETKEY, "RET", 0, "Return", "Enter"},
+ {SPACEKEY, "SPACE", 0, "Spacebar", "Space"},
{LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
- {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""},
- {DELKEY, "DEL", 0, "Delete", ""},
+ {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", "BkSpace"},
+ {DELKEY, "DEL", 0, "Delete", "Del"},
{SEMICOLONKEY, "SEMI_COLON", 0, ";", ""},
{PERIODKEY, "PERIOD", 0, ".", ""},
{COMMAKEY, "COMMA", 0, ",", ""},
@@ -262,26 +262,26 @@ EnumPropertyItem event_type_items[] = {
{EQUALKEY, "EQUAL", 0, "=", ""},
{LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""},
{RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""},
- {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""},
- {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""},
- {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""},
- {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", ""},
- {PAD2, "NUMPAD_2", 0, "Numpad 2", ""},
- {PAD4, "NUMPAD_4", 0, "Numpad 4", ""},
- {PAD6, "NUMPAD_6", 0, "Numpad 6", ""},
- {PAD8, "NUMPAD_8", 0, "Numpad 8", ""},
- {PAD1, "NUMPAD_1", 0, "Numpad 1", ""},
- {PAD3, "NUMPAD_3", 0, "Numpad 3", ""},
- {PAD5, "NUMPAD_5", 0, "Numpad 5", ""},
- {PAD7, "NUMPAD_7", 0, "Numpad 7", ""},
- {PAD9, "NUMPAD_9", 0, "Numpad 9", ""},
- {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", ""},
- {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", ""},
- {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", ""},
- {PAD0, "NUMPAD_0", 0, "Numpad 0", ""},
- {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", ""},
- {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", ""},
- {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", ""},
+ {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", "←"},
+ {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", "↓"},
+ {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", "→"},
+ {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", "↑"},
+ {PAD2, "NUMPAD_2", 0, "Numpad 2", "Pad2"},
+ {PAD4, "NUMPAD_4", 0, "Numpad 4", "Pad4"},
+ {PAD6, "NUMPAD_6", 0, "Numpad 6", "Pad6"},
+ {PAD8, "NUMPAD_8", 0, "Numpad 8", "Pad8"},
+ {PAD1, "NUMPAD_1", 0, "Numpad 1", "Pad1"},
+ {PAD3, "NUMPAD_3", 0, "Numpad 3", "Pad3"},
+ {PAD5, "NUMPAD_5", 0, "Numpad 5", "Pad5"},
+ {PAD7, "NUMPAD_7", 0, "Numpad 7", "Pad7"},
+ {PAD9, "NUMPAD_9", 0, "Numpad 9", "Pad9"},
+ {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", "Pad."},
+ {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", "Pad/"},
+ {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", "Pad*"},
+ {PAD0, "NUMPAD_0", 0, "Numpad 0", "Pad0"},
+ {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", "Pad-"},
+ {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", "PadEnter"},
+ {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", "Pad+"},
{F1KEY, "F1", 0, "F1", ""},
{F2KEY, "F2", 0, "F2", ""},
{F3KEY, "F3", 0, "F3", ""},
@@ -302,75 +302,75 @@ EnumPropertyItem event_type_items[] = {
{F18KEY, "F18", 0, "F18", ""},
{F19KEY, "F19", 0, "F19", ""},
{PAUSEKEY, "PAUSE", 0, "Pause", ""},
- {INSERTKEY, "INSERT", 0, "Insert", ""},
+ {INSERTKEY, "INSERT", 0, "Insert", "Ins"},
{HOMEKEY, "HOME", 0, "Home", ""},
- {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""},
- {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
+ {PAGEUPKEY, "PAGE_UP", 0, "Page Up", "PgUp"},
+ {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", "PgDown"},
{ENDKEY, "END", 0, "End", ""},
{0, "", 0, NULL, NULL},
- {MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ""},
- {MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", ""},
- {MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", ""},
- {MEDIALAST, "MEDIA_LAST", 0, "Media Last", ""},
+ {MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ">/||"},
+ {MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", "Stop"},
+ {MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", "|<<"},
+ {MEDIALAST, "MEDIA_LAST", 0, "Media Last", ">>|"},
{0, "", 0, NULL, NULL},
- {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
+ {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", "TxtIn"},
{0, "", 0, NULL, NULL},
{WINDEACTIVATE, "WINDOW_DEACTIVATE", 0, "Window Deactivate", ""},
- {TIMER, "TIMER", 0, "Timer", ""},
- {TIMER0, "TIMER0", 0, "Timer 0", ""},
- {TIMER1, "TIMER1", 0, "Timer 1", ""},
- {TIMER2, "TIMER2", 0, "Timer 2", ""},
- {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", ""},
- {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", ""},
- {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", ""},
- {TIMERREGION, "TIMERREGION", 0, "Timer Region", ""},
+ {TIMER, "TIMER", 0, "Timer", "Tmr"},
+ {TIMER0, "TIMER0", 0, "Timer 0", "Tmr0"},
+ {TIMER1, "TIMER1", 0, "Timer 1", "Tmr1"},
+ {TIMER2, "TIMER2", 0, "Timer 2", "Tmr2"},
+ {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", "TmrJob"},
+ {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", "TmrSave"},
+ {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", "TmrReport"},
+ {TIMERREGION, "TIMERREGION", 0, "Timer Region", "TmrReg"},
{0, "", 0, NULL, NULL},
- {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", ""},
+ {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", "NdofMov"},
/* buttons on all 3dconnexion devices */
- {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", ""},
- {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", ""},
+ {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"},
+ {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", "NdofFit"},
/* view buttons */
- {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", ""},
- {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "NDOF Bottom", ""},
- {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", ""},
- {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "NDOF Right", ""},
- {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", ""},
- {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", ""},
+ {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", "Ndof↑"},
+ {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "NDOF Bottom", "Ndof↓"},
+ {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", "Ndof←"},
+ {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "NDOF Right", "Ndof→"},
+ {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", "NdofFront"},
+ {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", "NdofBack"},
/* more views */
- {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "NDOF Isometric 1", ""},
- {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "NDOF Isometric 2", ""},
+ {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "NDOF Isometric 1", "NdofIso1"},
+ {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "NDOF Isometric 2", "NdofIso2"},
/* 90 degree rotations */
- {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "NDOF Roll CW", ""},
- {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "NDOF Roll CCW", ""},
- {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "NDOF Spin CW", ""},
- {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "NDOF Spin CCW", ""},
- {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "NDOF Tilt CW", ""},
- {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "NDOF Tilt CCW", ""},
+ {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "NDOF Roll CW", "NdofRCW"},
+ {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "NDOF Roll CCW", "NdofRCCW"},
+ {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "NDOF Spin CW", "NdofSCW"},
+ {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "NDOF Spin CCW", "NdofSCCW"},
+ {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "NDOF Tilt CW", "NdofTCW"},
+ {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "NDOF Tilt CCW", "NdofTCCW"},
/* device control */
- {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "NDOF Rotate", ""},
- {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "NDOF Pan/Zoom", ""},
- {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "NDOF Dominant", ""},
- {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "NDOF Plus", ""},
- {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "NDOF Minus", ""},
+ {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "NDOF Rotate", "NdofRot"},
+ {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "NDOF Pan/Zoom", "NdofPanZoom"},
+ {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "NDOF Dominant", "NdofDom"},
+ {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "NDOF Plus", "Ndof+"},
+ {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "NDOF Minus", "Ndof-"},
/* keyboard emulation */
- {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "NDOF Esc"},
- {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "NDOF Alt"},
- {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "NDOF Shift"},
- {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "NDOF Ctrl"},
+ {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "NDOF Esc", "NdofEsc"},
+ {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "NDOF Alt", "NdofAlt"},
+ {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "NDOF Shift", "NdofShift"},
+ {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "NDOF Ctrl", "NdofCtrl"},
/* general-purpose buttons */
- {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "NDOF Button 1", ""},
- {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "NDOF Button 2", ""},
- {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "NDOF Button 3", ""},
- {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "NDOF Button 4", ""},
- {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "NDOF Button 5", ""},
- {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "NDOF Button 6", ""},
- {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "NDOF Button 7", ""},
- {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "NDOF Button 8", ""},
- {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "NDOF Button 9", ""},
- {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "NDOF Button 10", ""},
- {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "NDOF Button A", ""},
- {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", ""},
- {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", ""},
+ {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "NDOF Button 1", "NdofB1"},
+ {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "NDOF Button 2", "NdofB2"},
+ {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "NDOF Button 3", "NdofB3"},
+ {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "NDOF Button 4", "NdofB4"},
+ {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "NDOF Button 5", "NdofB5"},
+ {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "NDOF Button 6", "NdofB6"},
+ {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "NDOF Button 7", "NdofB7"},
+ {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "NDOF Button 8", "NdofB8"},
+ {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "NDOF Button 9", "NdofB9"},
+ {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "NDOF Button 10", "NdofB10"},
+ {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "NDOF Button A", "NdofBA"},
+ {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"},
+ {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"},
{0, NULL, 0, NULL, NULL}
};
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index fdde28c6bf1..987cbb4234c 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -68,7 +68,7 @@ wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname
int val, int modifier, int keymodifier);
bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
-int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len);
+int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len, const bool compact);
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
@@ -82,6 +82,12 @@ int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
/* Modal Keymap */
+int WM_modalkeymap_operator_items_to_string(struct wmOperatorType *ot, const int propvalue,
+ char *str, const int len, const bool compact);
+char *WM_modalkeymap_operator_items_to_string_buf(
+ struct wmOperatorType *ot, const int propvalue,
+ char **str, int *available_len, const int max_len, const bool compact);
+
wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, struct EnumPropertyItem *items);
wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname);
wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value);
@@ -98,7 +104,10 @@ int WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
/* Key Event */
-const char *WM_key_event_string(short type);
+const char *WM_key_event_string(const short type, const bool compact);
+int WM_keymap_item_raw_to_string(
+ const short shift, const short ctrl, const short alt, const short oskey, const short keymodifier,
+ const short type, char *str, const int len, const bool compact);
int WM_key_event_operator_id(
const struct bContext *C, const char *opname, int opcontext,
struct IDProperty *properties, const bool is_hotkey,
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 45177903cce..6d1ce43c6e6 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -42,6 +42,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_math.h"
#include "BKE_context.h"
#include "BKE_idprop.h"
@@ -820,12 +821,11 @@ wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, int type, int val, int m
return kmi;
}
-wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue)
+static wmKeyMapItem *wm_modalkeymap_find_propvalue_iter(wmKeyMap *km, wmKeyMapItem *kmi, const int propvalue)
{
-
if (km->flag & KEYMAP_MODAL) {
- wmKeyMapItem *kmi;
- for (kmi = km->items.first; kmi; kmi = kmi->next) {
+ kmi = kmi ? kmi->next : km->items.first;
+ for (; kmi; kmi = kmi->next) {
if (kmi->propvalue == propvalue) {
return kmi;
}
@@ -838,6 +838,11 @@ wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue)
return NULL;
}
+wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue)
+{
+ return wm_modalkeymap_find_propvalue_iter(km, NULL, propvalue);
+}
+
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
@@ -881,50 +886,139 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
/* ***************** get string from key events **************** */
-const char *WM_key_event_string(short type)
+const char *WM_key_event_string(const short type, const bool compact)
{
const char *name = NULL;
- if (RNA_enum_name(event_type_items, (int)type, &name))
- return name;
-
+ /* We first try enum items' description (abused as shortname here), and fall back to usual name if empty. */
+ if ((compact && RNA_enum_description(event_type_items, (int)type, &name) && name[0]) ||
+ RNA_enum_name(event_type_items, (int)type, &name))
+ {
+ return IFACE_(name);
+ }
+
return "";
}
-int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len)
+/* TODO: also support (some) value, like e.g. double-click? */
+int WM_keymap_item_raw_to_string(const short shift, const short ctrl, const short alt, const short oskey,
+ const short keymodifier, const short type,
+ char *str, const int len, const bool compact)
{
+#define ADD_SEP if (p != buf) *p++ = ' '; (void)0
+
char buf[128];
char *p = buf;
- buf[0] = 0;
+ buf[0] = '\0';
- if (kmi->shift == KM_ANY &&
- kmi->ctrl == KM_ANY &&
- kmi->alt == KM_ANY &&
- kmi->oskey == KM_ANY)
+ /* TODO: support order (KM_SHIFT vs. KM_SHIFT2) ? */
+ if (shift == KM_ANY &&
+ ctrl == KM_ANY &&
+ alt == KM_ANY &&
+ oskey == KM_ANY)
{
- p += BLI_strcpy_rlen(p, "Any ");
+ /* make it implicit in case of compact result expected. */
+ if (!compact) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, IFACE_("Any"));
+ }
}
else {
- if (kmi->shift)
- p += BLI_strcpy_rlen(p, "Shift ");
+ if (shift) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, IFACE_("Shift"));
+ }
- if (kmi->ctrl)
- p += BLI_strcpy_rlen(p, "Ctrl ");
+ if (ctrl) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, IFACE_("Ctrl"));
+ }
- if (kmi->alt)
- p += BLI_strcpy_rlen(p, "Alt ");
+ if (alt) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, IFACE_("Alt"));
+ }
- if (kmi->oskey)
- p += BLI_strcpy_rlen(p, "Cmd ");
+ if (oskey) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, IFACE_("Cmd"));
+ }
}
-
- if (kmi->keymodifier) {
- p += BLI_strcpy_rlen(p, WM_key_event_string(kmi->keymodifier));
- p += BLI_strcpy_rlen(p, " ");
+
+ if (keymodifier) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, WM_key_event_string(keymodifier, compact));
+ }
+
+ if (type) {
+ ADD_SEP;
+ p += BLI_strcpy_rlen(p, WM_key_event_string(type, compact));
+ }
+
+ /* We assume size of buf is enough to always store any possible shortcut, but let's add a debug check about it! */
+ BLI_assert(p - buf < sizeof(buf));
+
+ /* We need utf8 here, otherwise we may 'cut' some unicode chars like arrows... */
+ return BLI_strncpy_utf8_rlen(str, buf, len);
+
+#undef ADD_SEP
+}
+
+int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len, const bool compact)
+{
+ return WM_keymap_item_raw_to_string(kmi->shift, kmi->ctrl, kmi->alt, kmi->oskey,
+ kmi->keymodifier, kmi->type, str, len, compact);
+}
+
+int WM_modalkeymap_operator_items_to_string(
+ wmOperatorType *ot, const int propvalue, char *str, const int len, const bool compact)
+{
+ wmKeyMap *km = ot->modalkeymap;
+ int totlen = 0;
+ bool add_sep = false;
+
+ if (km) {
+ wmKeyMapItem *kmi;
+
+ /* Find all shortcuts related to that propvalue! */
+ for (kmi = WM_modalkeymap_find_propvalue(km, propvalue);
+ kmi && totlen < (len - 2);
+ kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue))
+ {
+ if (add_sep) {
+ str[totlen++] = '/';
+ str[totlen] = '\0';
+ }
+ else {
+ add_sep = true;
+ }
+ totlen += WM_keymap_item_to_string(kmi, &str[totlen], len - totlen, compact);
+ }
+ }
+
+ return totlen;
+}
+
+char *WM_modalkeymap_operator_items_to_string_buf(
+ wmOperatorType *ot, const int propvalue, char **str, int *available_len, const int max_len, const bool compact)
+{
+ char *ret = *str;
+
+ if (*available_len > 1) {
+ int used_len = WM_modalkeymap_operator_items_to_string(
+ ot, propvalue, ret, min_ii(*available_len, max_len), compact) + 1;
+
+ *available_len -= used_len;
+ *str += used_len;
+ if (*available_len == 0) {
+ (*str)--; /* So that *str keeps pointing on a valid char, we'll stay on it anyway. */
+ }
+ }
+ else {
+ *ret = '\0';
}
- p += BLI_strcpy_rlen(p, WM_key_event_string(kmi->type));
- return BLI_strncpy_rlen(str, buf, len);
+ return ret;
}
static wmKeyMapItem *wm_keymap_item_find_handlers(
@@ -947,7 +1041,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
if (kmi->flag & KMI_INACTIVE)
continue;
- if (STREQ(kmi->idname, opname) && WM_key_event_string(kmi->type)[0]) {
+ if (STREQ(kmi->idname, opname) && WM_key_event_string(kmi->type, false)[0]) {
if (is_hotkey) {
if (!ISHOTKEY(kmi->type))
continue;
@@ -984,7 +1078,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) {
char kmi_str[128];
- WM_keymap_item_to_string(kmi, kmi_str, sizeof(kmi_str));
+ WM_keymap_item_to_string(kmi, kmi_str, sizeof(kmi_str), false);
/* Note gievn properties could come from other things than menu entry... */
printf("%s: Some set values in menu entry match default op values, "
"this might not be desired!\n", opname);
@@ -1134,7 +1228,7 @@ static wmKeyMapItem *wm_keymap_item_find(
kmi = wm_keymap_item_find_props(C, opname, opcontext, properties_default, is_strict, is_hotkey, &km);
if (kmi) {
char kmi_str[128];
- WM_keymap_item_to_string(kmi, kmi_str, sizeof(kmi_str));
+ WM_keymap_item_to_string(kmi, kmi_str, sizeof(kmi_str), false);
printf("%s: Some set values in keymap entry match default op values, "
"this might not be desired!\n", opname);
printf("\tkm: '%s', kmi: '%s'\n", km->idname, kmi_str);
@@ -1165,7 +1259,7 @@ char *WM_key_event_operator_string(
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, false, is_strict, NULL);
if (kmi) {
- WM_keymap_item_to_string(kmi, str, len);
+ WM_keymap_item_to_string(kmi, str, len, false);
return str;
}