diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 5 | ||||
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/GodotView.java | 2 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 32 |
3 files changed, 19 insertions, 20 deletions
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 37f25cc839..b5b0afb9e0 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -828,7 +828,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC //@Override public boolean dispatchTouchEvent (MotionEvent event) { public boolean gotTouchEvent(final MotionEvent event) { - super.onTouchEvent(event); final int evcount = event.getPointerCount(); if (evcount == 0) return true; @@ -842,6 +841,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC arr[i * 3 + 1] = (int)event.getX(i); arr[i * 3 + 2] = (int)event.getY(i); } + final int pointer_idx = event.getPointerId(event.getActionIndex()); //System.out.printf("gaction: %d\n",event.getAction()); final int action = event.getAction() & MotionEvent.ACTION_MASK; @@ -862,13 +862,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC */ } break; case MotionEvent.ACTION_POINTER_UP: { - final int indexPointUp = event.getActionIndex(); - final int pointer_idx = event.getPointerId(indexPointUp); GodotLib.touch(4, pointer_idx, evcount, arr); //System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; case MotionEvent.ACTION_POINTER_DOWN: { - int pointer_idx = event.getActionIndex(); GodotLib.touch(3, pointer_idx, evcount, arr); //System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx)); } break; diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java index ca4895a2be..0222758c2b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/src/org/godotengine/godot/GodotView.java @@ -110,7 +110,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener { @Override public boolean onTouchEvent(MotionEvent event) { - + super.onTouchEvent(event); return activity.gotTouchEvent(event); }; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 93272a1000..23811f963a 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -444,25 +444,27 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> } touch.clear(); } - } break; - case 3: { // add tuchi - - ERR_FAIL_INDEX(p_pointer, p_points.size()); + case 3: { // add touch - TouchPos tp = p_points[p_pointer]; - touch.push_back(tp); + for (int i = 0; i < p_points.size(); i++) { + if (p_points[i].id == p_pointer) { + TouchPos tp = p_points[i]; + touch.push_back(tp); - Ref<InputEventScreenTouch> ev; - ev.instance(); + Ref<InputEventScreenTouch> ev; + ev.instance(); - ev->set_index(tp.id); - ev->set_pressed(true); - ev->set_position(tp.pos); - input->parse_input_event(ev); + ev->set_index(tp.id); + ev->set_pressed(true); + ev->set_position(tp.pos); + input->parse_input_event(ev); + break; + } + } } break; - case 4: { + case 4: { // remove touch for (int i = 0; i < touch.size(); i++) { if (touch[i].id == p_pointer) { @@ -474,10 +476,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> ev->set_position(touch[i].pos); input->parse_input_event(ev); touch.remove(i); - i--; + + break; } } - } break; } } |