Skip to content

Commit

Permalink
Change emulate from project settings to editor settings
Browse files Browse the repository at this point in the history
  • Loading branch information
JayTropper committed Oct 10, 2024
1 parent f7c567e commit 532a610
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 23 deletions.
4 changes: 2 additions & 2 deletions doc/classes/Control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1193,11 +1193,11 @@
</constant>
<constant name="NOTIFICATION_SCROLL_BEGIN" value="47">
Sent when this node is inside a [ScrollContainer] which has begun being scrolled when dragging the scrollable area [i]with a touch event[/i]. This notification is [i]not[/i] sent when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
</constant>
<constant name="NOTIFICATION_SCROLL_END" value="48">
Sent when this node is inside a [ScrollContainer] which has stopped being scrolled when dragging the scrollable area [i]with a touch event[/i]. This notification is [i]not[/i] sent when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
</constant>
<constant name="NOTIFICATION_LAYOUT_DIRECTION_CHANGED" value="49">
Sent when control layout direction is changed.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/DisplayServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@
<method name="is_touchscreen_available" qualifiers="const">
<return type="bool" />
<description>
Returns [code]true[/code] if touch events are available (Android or iOS), the capability is detected on the Web platform or if [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is [code]true[/code].
Returns [code]true[/code] if touch events are available (Android or iOS), the capability is detected on the Web platform or if [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse] is [code]true[/code].
</description>
</method>
<method name="is_window_transparency_available" qualifiers="const">
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,12 @@
Input accumulation can be disabled to get slightly more precise/reactive input at the cost of increased CPU usage.
[b]Note:[/b] Input accumulation is [i]enabled[/i] by default.
</member>
<member name="input_devices/pointing/emulate_mouse_from_touch" type="bool" setter="" getter="" default="true">
If [code]true[/code], sends mouse input events when tapping or swiping on the touchscreen.
</member>
<member name="input_devices/pointing/emulate_touch_from_mouse" type="bool" setter="" getter="" default="false">
If [code]true[/code], sends touch input events when clicking or dragging the mouse.
</member>
<member name="interface/editor/accept_dialog_cancel_ok_buttons" type="int" setter="" getter="">
How to position the Cancel and OK buttons in the editor's [AcceptDialog]s. Different platforms have different standard behaviors for this, which can be overridden using this setting. This is useful if you use Godot both on Windows and macOS/Linux and your Godot muscle memory is stronger than your OS specific one.
- [b]Auto[/b] follows the platform convention: Cancel first on macOS and Linux, OK first on Windows.
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/Input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,10 @@
</methods>
<members>
<member name="emulate_mouse_from_touch" type="bool" setter="set_emulate_mouse_from_touch" getter="is_emulating_mouse_from_touch">
If [code]true[/code], sends mouse input events when tapping or swiping on the touchscreen. See also [member ProjectSettings.input_devices/pointing/emulate_mouse_from_touch].
If [code]true[/code], sends mouse input events when tapping or swiping on the touchscreen. See also [member EditorSettings.input_devices/pointing/emulate_mouse_from_touch].
</member>
<member name="emulate_touch_from_mouse" type="bool" setter="set_emulate_touch_from_mouse" getter="is_emulating_touch_from_mouse">
If [code]true[/code], sends touch input events when clicking or dragging the mouse. See also [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse].
If [code]true[/code], sends touch input events when clicking or dragging the mouse. See also [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse].
</member>
<member name="mouse_mode" type="int" setter="set_mouse_mode" getter="get_mouse_mode" enum="Input.MouseMode">
Controls the mouse mode. See [enum MouseMode] for more information.
Expand Down
6 changes: 0 additions & 6 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1421,12 +1421,6 @@
<member name="input_devices/pointing/android/rotary_input_scroll_axis" type="int" setter="" getter="" default="1">
On Wear OS devices, defines which axis of the mouse wheel rotary input is mapped to. This rotary input is usually performed by rotating the physical or virtual (touch-based) bezel on a smartwatch.
</member>
<member name="input_devices/pointing/emulate_mouse_from_touch" type="bool" setter="" getter="" default="true">
If [code]true[/code], sends mouse input events when tapping or swiping on the touchscreen.
</member>
<member name="input_devices/pointing/emulate_touch_from_mouse" type="bool" setter="" getter="" default="false">
If [code]true[/code], sends touch input events when clicking or dragging the mouse.
</member>
<member name="input_devices/sensors/enable_accelerometer" type="bool" setter="" getter="" default="false">
If [code]true[/code], the accelerometer sensor is enabled and [method Input.get_accelerometer] returns valid data.
</member>
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/ScrollContainer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
<signal name="scroll_ended">
<description>
Emitted when scrolling stops when dragging the scrollable area [i]with a touch event[/i]. This signal is [i]not[/i] emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
</description>
</signal>
<signal name="scroll_started">
<description>
Emitted when scrolling starts when dragging the scrollable area w[i]ith a touch event[/i]. This signal is [i]not[/i] emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
[b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
</description>
</signal>
</signals>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<description>
Triggers the given [param event] in this [Viewport]. This can be used to pass an [InputEvent] between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If [param in_local_coords] is [code]false[/code], the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If [param in_local_coords] is [code]true[/code], the event's position is in viewport coordinates.
While this method serves a similar purpose as [method Input.parse_input_event], it does not remap the specified [param event] based on project settings like [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse].
While this method serves a similar purpose as [method Input.parse_input_event], it does not remap the specified [param event] based on editor settings like [member EditorSettings.input_devices/pointing/emulate_touch_from_mouse].
Calling this method will propagate calls to child nodes for following methods in the given order:
- [method Node._input]
- [method Control._gui_input] for [Control] nodes
Expand Down
16 changes: 16 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,22 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
}
}
}

Input *id = Input::get_singleton();
Variant ret_val;
_get("input_devices/pointing/emulate_touch_from_mouse", ret_val);
if (bool(ret_val) && id) {
if (!DisplayServer::get_singleton()->is_touchscreen_available()) {
//only if no touchscreen ui hint, set emulation
id->set_emulate_touch_from_mouse(true);
}
}
_initial_set("input_devices/pointing/emulate_touch_from_mouse", bool(ret_val));
_get("input_devices/pointing/emulate_mouse_from_touch", ret_val);
_initial_set("input_devices/pointing/emulate_mouse_from_touch", bool(ret_val));
id->set_emulate_mouse_from_touch(bool(ret_val));
/*_initial_set("input_devices/pointing/emulate_mouse_from_touch", true);
_initial_set("input_devices/pointing/emulate_touch_from_mouse", false);*/
}

void EditorSettings::_load_godot2_text_editor_theme() {
Expand Down
18 changes: 9 additions & 9 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3165,15 +3165,15 @@ Error Main::setup2(bool p_show_boot_logo) {
bool agile_input_event_flushing = GLOBAL_DEF("input_devices/buffering/agile_event_flushing", false);
id->set_agile_input_event_flushing(agile_input_event_flushing);

if (bool(GLOBAL_DEF_BASIC("input_devices/pointing/emulate_touch_from_mouse", false)) &&
!(editor || project_manager)) {
if (!DisplayServer::get_singleton()->is_touchscreen_available()) {
//only if no touchscreen ui hint, set emulation
id->set_emulate_touch_from_mouse(true);
}
}

id->set_emulate_mouse_from_touch(bool(GLOBAL_DEF_BASIC("input_devices/pointing/emulate_mouse_from_touch", true)));
//if (bool(GLOBAL_DEF_BASIC("input_devices/pointing/emulate_touch_from_mouse", false)) &&
// !(editor || project_manager)) {
// if (!DisplayServer::get_singleton()->is_touchscreen_available()) {
// //only if no touchscreen ui hint, set emulation
// id->set_emulate_touch_from_mouse(true);
// }
//}

//id->set_emulate_mouse_from_touch(bool(GLOBAL_DEF_BASIC("input_devices/pointing/emulate_mouse_from_touch", true)));
}

OS::get_singleton()->benchmark_end_measure("Startup", "Setup Window and Boot");
Expand Down

0 comments on commit 532a610

Please sign in to comment.