Skip to content

Commit c5f0d57

Browse files
committed
Merge pull request #97985 from RobProductions/add-tablet-nav-preset
Add `Tablet/Trackpad` 3D navigation preset
2 parents 9c290c4 + bd47e4f commit c5f0d57

5 files changed

+49
-12
lines changed

doc/classes/EditorSettings.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,13 @@
360360
If [code]true[/code], invert the vertical mouse axis when panning, orbiting, or using freelook mode in the 3D editor.
361361
</member>
362362
<member name="editors/3d/navigation/navigation_scheme" type="int" setter="" getter="">
363-
The navigation scheme preset to use in the 3D editor. Changing this setting will affect the mouse button and modifier controls used to navigate the 3D editor viewport.
363+
The navigation scheme preset to use in the 3D editor. Changing this setting will affect the mouse button and modifier keys used to navigate the 3D editor viewport.
364364
All schemes can use [kbd]Mouse wheel[/kbd] to zoom.
365365
- [b]Godot:[/b] [kbd]Middle mouse button[/kbd] to orbit. [kbd]Shift + Middle mouse button[/kbd] to pan. [kbd]Ctrl + Middle mouse button[/kbd] to zoom.
366366
- [b]Maya:[/b] [kbd]Alt + Left mouse button[/kbd] to orbit. [kbd]Middle mouse button[/kbd] to pan, [kbd]Shift + Middle mouse button[/kbd] to pan 10 times faster. [kbd]Alt + Right mouse button[/kbd] to zoom.
367367
- [b]Modo:[/b] [kbd]Alt + Left mouse button[/kbd] to orbit. [kbd]Alt + Shift + Left mouse button[/kbd] to pan. [kbd]Ctrl + Alt + Left mouse button[/kbd] to zoom.
368-
See also [member editors/3d/navigation/orbit_mouse_button], [member editors/3d/navigation/pan_mouse_button], [member editors/3d/navigation/zoom_mouse_button], and [member editors/3d/freelook/freelook_navigation_scheme].
368+
- [b]Tablet/Trackpad:[/b] [kbd]Alt[/kbd] to orbit. [kbd]Shift[/kbd] to pan. [kbd]Ctrl[/kbd] to zoom. Enables 3-button mouse emulation mode.
369+
See also [member editors/3d/navigation/orbit_mouse_button], [member editors/3d/navigation/pan_mouse_button], [member editors/3d/navigation/zoom_mouse_button], [member editors/3d/freelook/freelook_navigation_scheme], and [member editors/3d/navigation/emulate_3_button_mouse].
369370
[b]Note:[/b] On certain window managers on Linux, the [kbd]Alt[/kbd] key will be intercepted by the window manager when clicking a mouse button at the same time. This means Godot will not see the modifier key as being pressed.
370371
</member>
371372
<member name="editors/3d/navigation/orbit_mouse_button" type="int" setter="" getter="">

editor/editor_settings.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
816816
// 3D: Navigation
817817
_initial_set("editors/3d/navigation/invert_x_axis", false, true);
818818
_initial_set("editors/3d/navigation/invert_y_axis", false, true);
819-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/navigation_scheme", 0, "Godot,Maya,Modo,Custom")
820-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/orbit_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse")
821-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/pan_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse")
822-
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/zoom_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse")
819+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/navigation_scheme", 0, "Godot:0,Maya:1,Modo:2,Tablet/Trackpad:4,Custom:3")
820+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/orbit_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse,Mouse Button 4,Mouse Button 5")
821+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/pan_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse,Mouse Button 4,Mouse Button 5")
822+
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/zoom_mouse_button", 1, "Left Mouse,Middle Mouse,Right Mouse,Mouse Button 4,Mouse Button 5")
823823
EDITOR_SETTING_BASIC(Variant::INT, PROPERTY_HINT_ENUM, "editors/3d/navigation/zoom_style", 0, "Vertical,Horizontal")
824824

825825
_initial_set("editors/3d/navigation/emulate_numpad", false, true);

editor/editor_settings_dialog.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
7777
EditorSettings::get_singleton()->set_manually("text_editor/theme/color_theme", "Custom");
7878
} else if (full_name.begins_with("editors/visual_editors/connection_colors") || full_name.begins_with("editors/visual_editors/category_colors")) {
7979
EditorSettings::get_singleton()->set_manually("editors/visual_editors/color_theme", "Custom");
80-
} else if (full_name == "editors/3d/navigation/orbit_mouse_button" || full_name == "editors/3d/navigation/pan_mouse_button" || full_name == "editors/3d/navigation/zoom_mouse_button") {
80+
} else if (full_name == "editors/3d/navigation/orbit_mouse_button" || full_name == "editors/3d/navigation/pan_mouse_button" || full_name == "editors/3d/navigation/zoom_mouse_button" || full_name == "editors/3d/navigation/emulate_3_button_mouse") {
8181
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/navigation_scheme", (int)Node3DEditorViewport::NAVIGATION_CUSTOM);
8282
} else if (full_name == "editors/3d/navigation/navigation_scheme") {
8383
update_navigation_preset();
@@ -89,6 +89,7 @@ void EditorSettingsDialog::update_navigation_preset() {
8989
Node3DEditorViewport::ViewportNavMouseButton set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
9090
Node3DEditorViewport::ViewportNavMouseButton set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
9191
Node3DEditorViewport::ViewportNavMouseButton set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
92+
bool set_3_button_mouse = false;
9293
Ref<InputEventKey> orbit_mod_key_1;
9394
Ref<InputEventKey> orbit_mod_key_2;
9495
Ref<InputEventKey> pan_mod_key_1;
@@ -102,6 +103,7 @@ void EditorSettingsDialog::update_navigation_preset() {
102103
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
103104
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
104105
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
106+
set_3_button_mouse = false;
105107
orbit_mod_key_1 = InputEventKey::create_reference(Key::NONE);
106108
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
107109
pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT);
@@ -113,6 +115,7 @@ void EditorSettingsDialog::update_navigation_preset() {
113115
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
114116
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
115117
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_RIGHT_MOUSE;
118+
set_3_button_mouse = false;
116119
orbit_mod_key_1 = InputEventKey::create_reference(Key::ALT);
117120
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
118121
pan_mod_key_1 = InputEventKey::create_reference(Key::NONE);
@@ -124,18 +127,32 @@ void EditorSettingsDialog::update_navigation_preset() {
124127
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
125128
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
126129
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_LEFT_MOUSE;
130+
set_3_button_mouse = false;
127131
orbit_mod_key_1 = InputEventKey::create_reference(Key::ALT);
128132
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
129133
pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT);
130134
pan_mod_key_2 = InputEventKey::create_reference(Key::ALT);
131135
zoom_mod_key_1 = InputEventKey::create_reference(Key::ALT);
132136
zoom_mod_key_2 = InputEventKey::create_reference(Key::CTRL);
137+
} else if (nav_scheme == Node3DEditorViewport::NAVIGATION_TABLET) {
138+
set_preset = true;
139+
set_orbit_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
140+
set_pan_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
141+
set_zoom_mouse_button = Node3DEditorViewport::NAVIGATION_MIDDLE_MOUSE;
142+
set_3_button_mouse = true;
143+
orbit_mod_key_1 = InputEventKey::create_reference(Key::ALT);
144+
orbit_mod_key_2 = InputEventKey::create_reference(Key::NONE);
145+
pan_mod_key_1 = InputEventKey::create_reference(Key::SHIFT);
146+
pan_mod_key_2 = InputEventKey::create_reference(Key::NONE);
147+
zoom_mod_key_1 = InputEventKey::create_reference(Key::CTRL);
148+
zoom_mod_key_2 = InputEventKey::create_reference(Key::NONE);
133149
}
134150
// Set settings to the desired preset values.
135151
if (set_preset) {
136152
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/orbit_mouse_button", (int)set_orbit_mouse_button);
137153
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/pan_mouse_button", (int)set_pan_mouse_button);
138154
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/zoom_mouse_button", (int)set_zoom_mouse_button);
155+
EditorSettings::get_singleton()->set_manually("editors/3d/navigation/emulate_3_button_mouse", set_3_button_mouse);
139156
_set_shortcut_input("spatial_editor/viewport_orbit_modifier_1", orbit_mod_key_1);
140157
_set_shortcut_input("spatial_editor/viewport_orbit_modifier_2", orbit_mod_key_2);
141158
_set_shortcut_input("spatial_editor/viewport_pan_modifier_1", pan_mod_key_1);
@@ -775,7 +792,11 @@ PropertyInfo EditorSettingsDialog::_create_mouse_shortcut_property_info(const St
775792
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
776793
hint_string += "Middle Mouse,";
777794
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
778-
hint_string += "Right Mouse";
795+
hint_string += "Right Mouse,";
796+
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
797+
hint_string += "Mouse Button 4,";
798+
hint_string += _get_shortcut_button_string(p_shortcut_1_name) + _get_shortcut_button_string(p_shortcut_2_name);
799+
hint_string += "Mouse Button 5";
779800

780801
return PropertyInfo(Variant::INT, p_property_name, PROPERTY_HINT_ENUM, hint_string);
781802
}

editor/plugins/node_3d_editor_plugin.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,18 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
21402140
nav_mode = change_nav_from_shortcut;
21412141
}
21422142

2143+
} else if (m->get_button_mask().has_flag(MouseButtonMask::MB_XBUTTON1)) {
2144+
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_MOUSE_4, shortcut_check_sets, false);
2145+
if (change_nav_from_shortcut != NAVIGATION_NONE) {
2146+
nav_mode = change_nav_from_shortcut;
2147+
}
2148+
2149+
} else if (m->get_button_mask().has_flag(MouseButtonMask::MB_XBUTTON2)) {
2150+
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_MOUSE_5, shortcut_check_sets, false);
2151+
if (change_nav_from_shortcut != NAVIGATION_NONE) {
2152+
nav_mode = change_nav_from_shortcut;
2153+
}
2154+
21432155
} else if (EDITOR_GET("editors/3d/navigation/emulate_3_button_mouse")) {
21442156
// Handle trackpad (no external mouse) use case
21452157
NavigationMode change_nav_from_shortcut = _get_nav_mode_from_shortcut_check(NAVIGATION_LEFT_MOUSE, shortcut_check_sets, true);

editor/plugins/node_3d_editor_plugin.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ class Node3DEditorViewport : public Control {
192192
};
193193

194194
enum NavigationScheme {
195-
NAVIGATION_GODOT,
196-
NAVIGATION_MAYA,
197-
NAVIGATION_MODO,
198-
NAVIGATION_CUSTOM,
195+
NAVIGATION_GODOT = 0,
196+
NAVIGATION_MAYA = 1,
197+
NAVIGATION_MODO = 2,
198+
NAVIGATION_CUSTOM = 3,
199+
NAVIGATION_TABLET = 4,
199200
};
200201

201202
enum FreelookNavigationScheme {
@@ -208,6 +209,8 @@ class Node3DEditorViewport : public Control {
208209
NAVIGATION_LEFT_MOUSE,
209210
NAVIGATION_MIDDLE_MOUSE,
210211
NAVIGATION_RIGHT_MOUSE,
212+
NAVIGATION_MOUSE_4,
213+
NAVIGATION_MOUSE_5,
211214
};
212215

213216
private:

0 commit comments

Comments
 (0)