From 7a7c690a7048eb065d6a991c93cc7da67b536af2 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 23 Jan 2016 02:28:15 +0100 Subject: [PATCH] [DEBUG] correct android up and down for touch event --- android/src/org/gale/GaleSurfaceViewGL.java | 56 ++++++++++----------- gale/context/Android/Context.cpp | 12 ++--- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/android/src/org/gale/GaleSurfaceViewGL.java b/android/src/org/gale/GaleSurfaceViewGL.java index 71147f8..3ed853d 100644 --- a/android/src/org/gale/GaleSurfaceViewGL.java +++ b/android/src/org/gale/GaleSurfaceViewGL.java @@ -87,12 +87,12 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { m_galeNative.inputEventMotion(_event.getPointerId(p), (float)_event.getX(p), (float)_event.getY(p)); } } - } else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN - || tmpActionType == MotionEvent.ACTION_DOWN) { + } else if ( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN + || tmpActionType == MotionEvent.ACTION_DOWN) { if (SDK_VERSION>=14) { final int typeOfPointer = _event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(0), true, (float)_event.getX(0), (float)_event.getY(0)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(0), true, (float)_event.getX(0), (float)_event.getY(0)); @@ -101,13 +101,13 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { m_galeNative.inputEventState(_event.getPointerId(0), true, (float)_event.getX(0), (float)_event.getY(0)); } inputDown1 = true; - } else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) { - if (SDK_VERSION>=14) { + } else if (tmpActionType == MotionEvent.ACTION_POINTER_1_UP) { + if (SDK_VERSION >= 14) { final int typeOfPointer = _event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); - } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { + } else if (typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); } } else { @@ -117,8 +117,8 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) { if (SDK_VERSION>=14) { final int typeOfPointer = _event.getToolType(1); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(1), true, (float)_event.getX(1), (float)_event.getY(1)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(1), true, (float)_event.getX(1), (float)_event.getY(1)); @@ -130,8 +130,8 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { } else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) { if (SDK_VERSION>=14) { final int typeOfPointer = _event.getToolType(1); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(1), false, (float)_event.getX(1), (float)_event.getY(1)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(1), false, (float)_event.getX(1), (float)_event.getY(1)); @@ -141,10 +141,10 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { } inputDown2 = false; } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) { - if (SDK_VERSION>=14) { + if (SDK_VERSION >= 14) { final int typeOfPointer = _event.getToolType(2); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(2), true, (float)_event.getX(2), (float)_event.getY(2)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(2), true, (float)_event.getX(2), (float)_event.getY(2)); @@ -154,10 +154,10 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { } inputDown3 = true; } else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) { - if (SDK_VERSION>=14) { + if (SDK_VERSION >= 14) { final int typeOfPointer = _event.getToolType(2); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(2), false, (float)_event.getX(2), (float)_event.getY(2)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(2), false, (float)_event.getX(2), (float)_event.getY(2)); @@ -168,10 +168,10 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { inputDown3 = false; } else if(tmpActionType == MotionEvent.ACTION_UP){ if (inputDown1) { - if (SDK_VERSION>=14) { + if (SDK_VERSION >= 14) { final int typeOfPointer = _event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); @@ -181,10 +181,10 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { } inputDown1 = false; } else if (inputDown2) { - if (SDK_VERSION>=14) { + if (SDK_VERSION >= 14) { final int typeOfPointer = _event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); @@ -194,10 +194,10 @@ public class GaleSurfaceViewGL extends GLSurfaceView implements GaleConstants { } inputDown2 = false; } else { - if (SDK_VERSION>=14) { + if (SDK_VERSION >= 14) { final int typeOfPointer = _event.getToolType(0); - if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER - || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { + if ( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER + || typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) { m_galeNative.inputEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); } else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) { m_galeNative.mouseEventState(_event.getPointerId(0), false, (float)_event.getX(0), (float)_event.getY(0)); diff --git a/gale/context/Android/Context.cpp b/gale/context/Android/Context.cpp index bf95065..408af06 100644 --- a/gale/context/Android/Context.cpp +++ b/gale/context/Android/Context.cpp @@ -713,19 +713,19 @@ extern "C" { jobject _thiz, jint _id, jint _pointerID, - jboolean _isUp, + jboolean _isDown, jfloat _x, jfloat _y) { std::unique_lock lock(g_interfaceMutex); if( _id >= (int32_t)s_listInstance.size() - || _id<0 - || nullptr == s_listInstance[_id] ) { + || _id < 0 + || s_listInstance[_id] == nullptr ) { GALE_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); // TODO : generate error in java to stop the current instance return; } s_listInstance[_id]->OS_SetInput(gale::key::type_finger, - (_isUp==false?gale::key::status_down:gale::key::status_up), + (_isDown==true?gale::key::status_down:gale::key::status_up), _pointerID+1, vec2(_x,_y)); } @@ -754,7 +754,7 @@ extern "C" { jobject _thiz, jint _id, jint _pointerID, - jboolean _isUp, + jboolean _isDown, jfloat _x, jfloat _y) { std::unique_lock lock(g_interfaceMutex); @@ -766,7 +766,7 @@ extern "C" { return; } s_listInstance[_id]->OS_SetInput(gale::key::type_mouse, - (_isUp==false?gale::key::status_down:gale::key::status_up), + (_isDown==true?gale::key::status_down:gale::key::status_up), _pointerID+1, vec2(_x,_y)); }