Skip to content

Commit a07ef7a

Browse files
committed
try simpler with overload
1 parent 01c78d8 commit a07ef7a

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

platform/android/java/lib/src/org/godotengine/godot/GodotLib.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class GodotLib {
105105
/**
106106
* Dispatch mouse events
107107
*/
108-
public static native void dispatchMouseEvent(int event, int buttonMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative);
108+
public static native void dispatchMouseEvent(int event, int buttonMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative, float pressure, float tiltX, float tiltY);
109109

110110
public static native void magnify(float x, float y, float factor);
111111

platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java

+19-7
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ static boolean handleMouseEvent(final MotionEvent event) {
483483
final int eventAction = event.getActionMasked();
484484
final float x = event.getX();
485485
final float y = event.getY();
486+
final float pressure = event.getPressure();
487+
final float tiltX = event.getTiltX();
488+
final float tiltY = event.getTiltY();
486489
final int buttonsMask = event.getButtonState();
487490

488491
float verticalFactor = 0;
@@ -505,18 +508,27 @@ static boolean handleMouseEvent(final MotionEvent event) {
505508
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
506509
sourceMouseRelative = event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE);
507510
}
508-
return handleMouseEvent(eventAction, buttonsMask, x, y, horizontalFactor, verticalFactor, false, sourceMouseRelative);
511+
512+
Log.d("GodotInputHandler", "handleMouseEvent " + horizontalFactor + " " + verticalFactor + " ACTION " + eventAction + " buttonMask " + buttonsMask, pressure, tiltX, tiltY);
513+
return handleMouseEvent(eventAction, buttonsMask, x, y, horizontalFactor, verticalFactor, false, sourceMouseRelative, pressure, tiltX, tiltY);
514+
}
515+
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative) {
516+
return handleMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, sourceMouseRelative, 1, 0, 0);
509517
}
510518

511-
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y) {
512-
return handleMouseEvent(eventAction, buttonsMask, x, y, 0, 0, false, false);
519+
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick) {
520+
return handleMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, false, 1, 0, 0);
513521
}
514522

515-
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, boolean doubleClick) {
516-
return handleMouseEvent(eventAction, buttonsMask, x, y, 0, 0, doubleClick, false);
523+
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY) {
524+
return handleMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, false, false, 1, 0, 0);
517525
}
518526

519-
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative) {
527+
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y) {
528+
return handleMouseEvent(eventAction, buttonsMask, x, y, 0, 0);
529+
}
530+
531+
static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative, float pressure, float tiltX, float tiltY) {
520532
// Fix the buttonsMask
521533
switch (eventAction) {
522534
case MotionEvent.ACTION_CANCEL:
@@ -544,7 +556,7 @@ static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float
544556
case MotionEvent.ACTION_HOVER_MOVE:
545557
case MotionEvent.ACTION_MOVE:
546558
case MotionEvent.ACTION_SCROLL: {
547-
GodotLib.dispatchMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, sourceMouseRelative);
559+
GodotLib.dispatchMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, sourceMouseRelative, pressure, tiltX, tiltY);
548560
return true;
549561
}
550562
}

platform/android/java_godot_lib_jni.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env,
303303
}
304304

305305
// Called on the UI thread
306-
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative) {
306+
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y) {
307307
if (step.get() <= 0) {
308308
return;
309309
}

platform/android/java_godot_lib_jni.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en
4545
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jint id, jint pos);
4646
JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz);
4747
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz);
48-
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative);
48+
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y);
4949
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchTouchEvent(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jboolean p_double_tap);
5050
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnify(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_factor);
5151
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_pan(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y);

0 commit comments

Comments
 (0)