summaryrefslogtreecommitdiffstats
path: root/platform/android/java/lib
diff options
context:
space:
mode:
authorFredia Huya-Kouadio <fhuyakou@gmail.com>2024-07-07 14:16:29 -0700
committerFredia Huya-Kouadio <fhuyakou@gmail.com>2024-07-09 09:15:18 -0700
commit5e598197274d983c4b8460d58158a77a94bdd4a2 (patch)
tree9e63c75f6d38d63d7263c339ff2a209ac2000c04 /platform/android/java/lib
parentf3af22b10b1e64146d48be7726f6395c9a4185e9 (diff)
downloadredot-engine-5e598197274d983c4b8460d58158a77a94bdd4a2.tar.gz
Cleanup Android input on render thread settings
Follow up to https://github.com/godotengine/godot/pull/93933 Clean up the set of settings use to control whether Android input should be dispatched on the render thread. Addresses comments in https://github.com/godotengine/godot/pull/93933#issuecomment-2210437977
Diffstat (limited to 'platform/android/java/lib')
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.kt33
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotLib.java7
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java12
3 files changed, 17 insertions, 35 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
index c188a97ca5..7e2a44ab39 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt
@@ -628,26 +628,19 @@ class Godot(private val context: Context) : SensorEventListener {
private fun onGodotSetupCompleted() {
Log.v(TAG, "OnGodotSetupCompleted")
- if (!isEditorBuild()) {
- // These properties are defined after Godot setup completion, so we retrieve them here.
- val longPressEnabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_long_press_as_right_click"))
- val panScaleEnabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_pan_and_scale_gestures"))
- val rotaryInputAxisValue = GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis")
-
- val useInputBuffering = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/buffering/android/use_input_buffering"))
- val useAccumulatedInput = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/buffering/android/use_accumulated_input"))
- GodotLib.updateInputDispatchSettings(useAccumulatedInput, useInputBuffering)
-
- runOnUiThread {
- renderView?.inputHandler?.apply {
- enableLongPress(longPressEnabled)
- enablePanningAndScalingGestures(panScaleEnabled)
- enableInputDispatchToRenderThread(!useInputBuffering && !useAccumulatedInput)
- try {
- setRotaryInputAxis(Integer.parseInt(rotaryInputAxisValue))
- } catch (e: NumberFormatException) {
- Log.w(TAG, e)
- }
+ // These properties are defined after Godot setup completion, so we retrieve them here.
+ val longPressEnabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_long_press_as_right_click"))
+ val panScaleEnabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_pan_and_scale_gestures"))
+ val rotaryInputAxisValue = GodotLib.getGlobal("input_devices/pointing/android/rotary_input_scroll_axis")
+
+ runOnUiThread {
+ renderView?.inputHandler?.apply {
+ enableLongPress(longPressEnabled)
+ enablePanningAndScalingGestures(panScaleEnabled)
+ try {
+ setRotaryInputAxis(Integer.parseInt(rotaryInputAxisValue))
+ } catch (e: NumberFormatException) {
+ Log.w(TAG, e)
}
}
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
index 37e889daf7..909daf05c9 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java
@@ -242,9 +242,8 @@ public class GodotLib {
public static native void onRendererPaused();
/**
- * Invoked on the GL thread to update the input dispatch settings
- * @param useAccumulatedInput True to use accumulated input, false otherwise
- * @param useInputBuffering True to use input buffering, false otherwise
+ * @return true if input must be dispatched from the render thread. If false, input is
+ * dispatched from the UI thread.
*/
- public static native void updateInputDispatchSettings(boolean useAccumulatedInput, boolean useInputBuffering);
+ public static native boolean shouldDispatchInputToRenderThread();
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
index 889618914d..afe570dcc6 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
@@ -77,8 +77,6 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {
private int rotaryInputAxis = ROTARY_INPUT_VERTICAL_AXIS;
- private boolean dispatchInputToRenderThread = false;
-
public GodotInputHandler(GodotRenderView godotView) {
final Context context = godotView.getView().getContext();
mRenderView = godotView;
@@ -111,19 +109,11 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {
}
/**
- * Specifies whether input should be dispatch on the UI thread or on the Render thread.
- * @param enable true to dispatch input on the Render thread, false to dispatch input on the UI thread
- */
- public void enableInputDispatchToRenderThread(boolean enable) {
- this.dispatchInputToRenderThread = enable;
- }
-
- /**
* @return true if input must be dispatched from the render thread. If false, input is
* dispatched from the UI thread.
*/
private boolean shouldDispatchInputToRenderThread() {
- return dispatchInputToRenderThread;
+ return GodotLib.shouldDispatchInputToRenderThread();
}
/**