Skip to content

Commit

Permalink
Merge pull request #83173 from m4gr3d/fix_gestures_properties_retriev…
Browse files Browse the repository at this point in the history
…al_timing

Fix the timeframe when the Android gestures properties are retrieved
  • Loading branch information
akien-mga committed Oct 16, 2023
2 parents 4a6e8dc + c1a7222 commit 39bc8aa
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions platform/android/java/lib/src/org/godotengine/godot/Godot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,6 @@ class Godot(private val context: Context) : SensorEventListener {
GodotGLRenderView(host, this, xrMode, useDebugOpengl)
}

renderView?.inputHandler?.enableLongPress(java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_long_press_as_right_click")))
renderView?.inputHandler?.enablePanningAndScalingGestures(java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_pan_and_scale_gestures")))

if (host == primaryHost) {
renderView!!.startRenderer()
}
Expand Down Expand Up @@ -575,6 +572,19 @@ class Godot(private val context: Context) : SensorEventListener {
* Invoked on the render thread when the Godot setup is complete.
*/
private fun onGodotSetupCompleted() {
Log.d(TAG, "OnGodotSetupCompleted")

// 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"))

runOnUiThread {
renderView?.inputHandler?.apply {
enableLongPress(longPressEnabled)
enablePanningAndScalingGestures(panScaleEnabled)
}
}

for (plugin in pluginRegistry.allPlugins) {
plugin.onGodotSetupCompleted()
}
Expand All @@ -585,6 +595,8 @@ class Godot(private val context: Context) : SensorEventListener {
* Invoked on the render thread when the Godot main loop has started.
*/
private fun onGodotMainLoopStarted() {
Log.d(TAG, "OnGodotMainLoopStarted")

for (plugin in pluginRegistry.allPlugins) {
plugin.onGodotMainLoopStarted()
}
Expand Down

0 comments on commit 39bc8aa

Please sign in to comment.