diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index 54e03681dc1..ef1d829e69c 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -275,7 +275,6 @@ class USERPREF_PT_system(bpy.types.Panel): sub1.itemR(system, "dpi") sub1.itemR(system, "frame_server_port") sub1.itemR(system, "scrollback", text="Console Scrollback") - sub1.itemR(system, "emulate_numpad") sub1.itemR(system, "auto_run_python_scripts") sub1.itemS() @@ -1129,7 +1128,9 @@ class USERPREF_PT_input(bpy.types.Panel): sub.row().itemR(inputs, "middle_mouse", expand=True) sub.itemS() - sub.itemS() + + sub.itemR(inputs, "emulate_numpad") + sub.itemS() sub.itemL(text="Orbit Style:") diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index c9056e386ac..1d4e422c7d5 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2160,10 +2160,6 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_DONT_DOSCRIPTLINKS); RNA_def_property_ui_text(prop, "Auto Run Python Scripts", "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)."); - prop= RNA_def_property(srna, "emulate_numpad", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_NONUMPAD); - RNA_def_property_ui_text(prop, "Emulate Numpad", "Causes the 1 to 0 keys to act as the numpad (useful for laptops)."); - prop= RNA_def_property(srna, "prefetch_frames", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "prefetchframes"); RNA_def_property_range(prop, 0, 500); @@ -2326,6 +2322,10 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TWOBUTTONMOUSE); RNA_def_property_boolean_funcs(prop, NULL, "rna_userdef_emulate_set"); RNA_def_property_ui_text(prop, "Emulate 3 Button Mouse", "Emulates Middle Mouse with Alt+LeftMouse (doesnt work with Left Mouse Select option.)"); + + prop= RNA_def_property(srna, "emulate_numpad", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_NONUMPAD); + RNA_def_property_ui_text(prop, "Emulate Numpad", "Causes the 1 to 0 keys to act as the numpad (useful for laptops)."); } static void rna_def_userdef_filepaths(BlenderRNA *brna) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 02fb56f93c8..56455f87d4d 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -774,6 +774,30 @@ static int wm_eventmatch(wmEvent *winevent, wmKeyMapItem *kmi) return 1; } } + /* exception for numpad emulation */ + else if(U.flag & USER_NONUMPAD) { + wmKeyMapItem tmp= *kmi; + + switch(kmi->type) { + case PAD0: tmp.type = ZEROKEY; break; + case PAD1: tmp.type = ONEKEY; break; + case PAD2: tmp.type = TWOKEY; break; + case PAD3: tmp.type = THREEKEY; break; + case PAD4: tmp.type = FOURKEY; break; + case PAD5: tmp.type = FIVEKEY; break; + case PAD6: tmp.type = SIXKEY; break; + case PAD7: tmp.type = SEVENKEY; break; + case PAD8: tmp.type = EIGHTKEY; break; + case PAD9: tmp.type = NINEKEY; break; + case PADMINUS: tmp.type = MINUSKEY; break; + case PADPLUSKEY: tmp.type = EQUALKEY; break; + case PADSLASHKEY: tmp.type = BACKSLASHKEY; break; + } + + if(tmp.type != kmi->type) + if(wm_eventmatch(winevent, &tmp)) + return 1; + } /* the matching rules */ if(kmitype==KM_TEXTINPUT)