diff options
Diffstat (limited to 'platform/android/java')
3 files changed, 20 insertions, 33 deletions
| 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 26aad867b1..33896ecb95 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -110,7 +110,7 @@ public class GodotLib {  	/**  	 * Forward touch events.  	 */ -	public static native void dispatchTouchEvent(int event, int pointer, int pointerCount, float[] positions); +	public static native void dispatchTouchEvent(int event, int pointer, int pointerCount, float[] positions, boolean doubleTap);  	/**  	 * Dispatch mouse events diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt index 9715c31fc1..a7a57621de 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotGestureHandler.kt @@ -55,18 +55,15 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi  	 */  	var panningAndScalingEnabled = false -	private var doubleTapInProgress = false +	private var nextDownIsDoubleTap = false  	private var dragInProgress = false  	private var scaleInProgress = false  	private var contextClickInProgress = false  	private var pointerCaptureInProgress = false  	override fun onDown(event: MotionEvent): Boolean { -		// Don't send / register a down event while we're in the middle of a double-tap -		if (!doubleTapInProgress) { -			// Send the down event -			GodotInputHandler.handleMotionEvent(event) -		} +		GodotInputHandler.handleMotionEvent(event.source, MotionEvent.ACTION_DOWN, event.buttonState, event.x, event.y, nextDownIsDoubleTap) +		nextDownIsDoubleTap = false  		return true  	} @@ -209,24 +206,14 @@ internal class GodotGestureHandler : SimpleOnGestureListener(), OnScaleGestureLi  	override fun onDoubleTapEvent(event: MotionEvent): Boolean {  		if (event.actionMasked == MotionEvent.ACTION_UP) { -			doubleTapInProgress = false +			nextDownIsDoubleTap = false +			GodotInputHandler.handleMotionEvent(event)  		}  		return true  	}  	override fun onDoubleTap(event: MotionEvent): Boolean { -		doubleTapInProgress = true -		val x = event.x -		val y = event.y -		val buttonMask = -			if (GodotInputHandler.isMouseEvent(event)) { -				event.buttonState -			} else { -				MotionEvent.BUTTON_PRIMARY -			} -		GodotInputHandler.handleMouseEvent(MotionEvent.ACTION_DOWN, buttonMask, x, y, true) -		GodotInputHandler.handleMouseEvent(MotionEvent.ACTION_UP, 0, x, y, false) - +		nextDownIsDoubleTap = true  		return true  	} 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 03cb8034fa..d2f3c5aed2 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 @@ -438,15 +438,19 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {  	}  	static boolean handleMotionEvent(int eventSource, int eventAction, int buttonsMask, float x, float y) { -		return handleMotionEvent(eventSource, eventAction, buttonsMask, x, y, 0, 0); +		return handleMotionEvent(eventSource, eventAction, buttonsMask, x, y, false);  	} -	static boolean handleMotionEvent(int eventSource, int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY) { +	static boolean handleMotionEvent(int eventSource, int eventAction, int buttonsMask, float x, float y, boolean doubleTap) { +		return handleMotionEvent(eventSource, eventAction, buttonsMask, x, y, 0, 0, doubleTap); +	} + +	static boolean handleMotionEvent(int eventSource, int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleTap) {  		if (isMouseEvent(eventSource)) { -			return handleMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, false, false); +			return handleMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleTap, false);  		} -		return handleTouchEvent(eventAction, x, y); +		return handleTouchEvent(eventAction, x, y, doubleTap);  	}  	static boolean handleMouseEvent(final MotionEvent event) { @@ -468,10 +472,6 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {  		return handleMouseEvent(eventAction, buttonsMask, x, y, 0, 0, false, false);  	} -	static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, boolean doubleClick) { -		return handleMouseEvent(eventAction, buttonsMask, x, y, 0, 0, doubleClick, false); -	} -  	static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative) {  		switch (eventAction) {  			case MotionEvent.ACTION_CANCEL: @@ -508,14 +508,14 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {  		final int action = event.getActionMasked();  		final int actionPointerId = event.getPointerId(event.getActionIndex()); -		return handleTouchEvent(action, actionPointerId, pointerCount, positions); +		return handleTouchEvent(action, actionPointerId, pointerCount, positions, false);  	} -	static boolean handleTouchEvent(int eventAction, float x, float y) { -		return handleTouchEvent(eventAction, 0, 1, new float[] { 0, x, y }); +	static boolean handleTouchEvent(int eventAction, float x, float y, boolean doubleTap) { +		return handleTouchEvent(eventAction, 0, 1, new float[] { 0, x, y }, doubleTap);  	} -	static boolean handleTouchEvent(int eventAction, int actionPointerId, int pointerCount, float[] positions) { +	static boolean handleTouchEvent(int eventAction, int actionPointerId, int pointerCount, float[] positions, boolean doubleTap) {  		switch (eventAction) {  			case MotionEvent.ACTION_DOWN:  			case MotionEvent.ACTION_CANCEL: @@ -523,7 +523,7 @@ public class GodotInputHandler implements InputManager.InputDeviceListener {  			case MotionEvent.ACTION_MOVE:  			case MotionEvent.ACTION_POINTER_UP:  			case MotionEvent.ACTION_POINTER_DOWN: { -				GodotLib.dispatchTouchEvent(eventAction, actionPointerId, pointerCount, positions); +				GodotLib.dispatchTouchEvent(eventAction, actionPointerId, pointerCount, positions, doubleTap);  				return true;  			}  		} |