1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #96139 from Alex2782/reverting_pr_84331

Add configuration option to disable `Scroll Deadzone` on Android
This commit is contained in:
Thaddeus Crews
2025-04-11 09:51:08 -05:00
7 changed files with 24 additions and 2 deletions

View File

@@ -497,6 +497,11 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
protected open fun enableLongPressGestures() =
java.lang.Boolean.parseBoolean(GodotLib.getEditorSetting("interface/touchscreen/enable_long_press_as_right_click"))
/**
* Disable scroll deadzone for the Godot Android editor.
*/
protected open fun disableScrollDeadzone() = true
/**
* Enable pan and scale gestures for the Godot Android editor.
*/

View File

@@ -52,6 +52,8 @@ abstract class BaseGodotGame: GodotEditor() {
override fun enablePanAndScaleGestures() = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/enable_pan_and_scale_gestures"))
override fun disableScrollDeadzone() = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/disable_scroll_deadzone"))
override fun onGodotSetupCompleted() {
super.onGodotSetupCompleted()
Log.v(TAG, "OnGodotSetupCompleted")

View File

@@ -714,12 +714,14 @@ class Godot(private val context: Context) {
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 overrideVolumeButtons = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/override_volume_buttons"))
val scrollDeadzoneDisabled = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("input_devices/pointing/android/disable_scroll_deadzone"))
runOnUiThread {
renderView?.inputHandler?.apply {
enableLongPress(longPressEnabled)
enablePanningAndScalingGestures(panScaleEnabled)
setOverrideVolumeButtons(overrideVolumeButtons)
disableScrollDeadzone(scrollDeadzoneDisabled)
try {
setRotaryInputAxis(Integer.parseInt(rotaryInputAxisValue))
} catch (e: NumberFormatException) {

View File

@@ -55,6 +55,8 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
*/
var panningAndScalingEnabled = false
var scrollDeadzoneDisabled = false
private var nextDownIsDoubleTap = false
private var dragInProgress = false
private var scaleInProgress = false
@@ -153,7 +155,7 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
if (contextClickInProgress) {
inputHandler.handleMouseEvent(event, event.actionMasked, MotionEvent.BUTTON_SECONDARY, false)
return true
} else if (!scaleInProgress) {
} else if (scrollDeadzoneDisabled && !scaleInProgress) {
// The 'onScroll' event is triggered with a long delay.
// Force the 'InputEventScreenDrag' event earlier here.
// We don't toggle 'dragInProgress' here so that the scaling logic can override the drag operation if needed.
@@ -191,7 +193,7 @@ internal class GodotGestureHandler(private val inputHandler: GodotInputHandler)
distanceY: Float
): Boolean {
if (scaleInProgress) {
if (dragInProgress || lastDragX != 0.0f || lastDragY != 0.0f) {
if (dragInProgress || (scrollDeadzoneDisabled && (lastDragX != 0.0f || lastDragY != 0.0f))) {
if (originEvent != null) {
// Cancel the drag
inputHandler.handleMotionEvent(originEvent, MotionEvent.ACTION_CANCEL)

View File

@@ -118,6 +118,13 @@ public class GodotInputHandler implements InputManager.InputDeviceListener, Sens
this.gestureDetector.setIsLongpressEnabled(enable);
}
/**
* Disable scroll deadzone. This is false by default.
*/
public void disableScrollDeadzone(boolean disable) {
this.godotGestureHandler.setScrollDeadzoneDisabled(disable);
}
/**
* Enable multi-fingers pan & scale gestures. This is false by default.
* <p>