diff --git a/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosAndroidPlayerActivity.java b/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosAndroidPlayerActivity.java index a4c00090b..53d81c7e7 100644 --- a/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosAndroidPlayerActivity.java +++ b/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosAndroidPlayerActivity.java @@ -55,6 +55,7 @@ public void onCreate(Bundle savedInstanceState) int[] id = new int[256]; int[] x = new int[256]; int[] y = new int[256]; + float[] pressure = new float[256]; @Override public void onStart() @@ -166,6 +167,7 @@ public boolean onTouch(View v, MotionEvent event) id[i] = event.getPointerId(i); x[i] = (int) event.getX(i); y[i] = (int) event.getY(i); + pressure[i] = (float) event.getPressure(i); } int actionMasked = event.getActionMasked(); @@ -174,16 +176,16 @@ public boolean onTouch(View v, MotionEvent event) if (actionMasked == MotionEvent.ACTION_DOWN || actionMasked == MotionEvent.ACTION_POINTER_DOWN) { - app.onTouchesBegin(size, id, x, y, actionIndex); + app.onTouchesBegin(size, id, x, y, pressure, actionIndex); } else if (actionMasked == MotionEvent.ACTION_MOVE) { - app.onTouchesMove(size, id, x, y); + app.onTouchesMove(size, id, x, y, pressure); } else if (actionMasked == MotionEvent.ACTION_UP || actionMasked == MotionEvent.ACTION_POINTER_UP) { - app.onTouchesEnd(size, id, x, y, actionIndex); + app.onTouchesEnd(size, id, x, y, pressure, actionIndex); } else if (actionMasked == MotionEvent.ACTION_CANCEL) { - app.onTouchesCancel(size, id, x, y); + app.onTouchesCancel(size, id, x, y, pressure); } return true; diff --git a/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosApplication.java b/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosApplication.java index 6de950cde..1271a4464 100644 --- a/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosApplication.java +++ b/android/GiderosAndroidPlayer/src/com/giderosmobile/android/player/GiderosApplication.java @@ -642,32 +642,29 @@ public void onDrawFrame() } } - public void onTouchesBegin(int size, int[] id, int[] x, int[] y, int actionIndex) + public void onTouchesBegin(int size, int[] id, int[] x, int[] y, float[] pressure, int actionIndex) { if(!isRunning()){ if(projectList != null && projectList.getVisibility() == View.GONE){ projectList.setVisibility(View.VISIBLE); } } - GiderosApplication.nativeTouchesBegin(size, id, x, y, actionIndex); + GiderosApplication.nativeTouchesBegin(size, id, x, y, pressure, actionIndex); } - public void onTouchesMove(int size, int[] id, int[] x, - int[] y) + public void onTouchesMove(int size, int[] id, int[] x, int[] y, float[] pressure) { - GiderosApplication.nativeTouchesMove(size, id, x, y); + GiderosApplication.nativeTouchesMove(size, id, x, y, pressure); } - public void onTouchesEnd(int size, int[] id, int[] x, - int[] y, int actionIndex) + public void onTouchesEnd(int size, int[] id, int[] x, int[] y, float[] pressure, int actionIndex) { - GiderosApplication.nativeTouchesEnd(size, id, x, y, actionIndex); + GiderosApplication.nativeTouchesEnd(size, id, x, y, pressure, actionIndex); } - public void onTouchesCancel(int size, int[] id, int[] x, - int[] y) + public void onTouchesCancel(int size, int[] id, int[] x, int[] y, float[] pressure) { - GiderosApplication.nativeTouchesCancel(size, id, x, y); + GiderosApplication.nativeTouchesCancel(size, id, x, y, pressure); } public boolean onKeyDown(int keyCode, KeyEvent event) @@ -1111,10 +1108,10 @@ static public void throwLuaException(String error) throws LuaException{ static private native void nativeSurfaceCreated(); static private native void nativeSurfaceChanged(int w, int h, int rotation); static private native void nativeDrawFrame(); - static private native void nativeTouchesBegin(int size, int[] id, int[] x, int[] y, int actionIndex); - static private native void nativeTouchesMove(int size, int[] id, int[] x, int[] y); - static private native void nativeTouchesEnd(int size, int[] id, int[] x, int[] y, int actionIndex); - static private native void nativeTouchesCancel(int size, int[] id, int[] x, int[] y); + static private native void nativeTouchesBegin(int size, int[] id, int[] x, int[] y, float[] pressure, int actionIndex); + static private native void nativeTouchesMove(int size, int[] id, int[] x, int[] y, float[] pressure); + static private native void nativeTouchesEnd(int size, int[] id, int[] x, int[] y, float[] pressure, int actionIndex); + static private native void nativeTouchesCancel(int size, int[] id, int[] x, int[] y, float[] pressure); static private native void nativeStop(); static private native void nativeStart(); } diff --git a/android/lib/jni/gideros.cpp b/android/lib/jni/gideros.cpp index 233b5e760..4fbff8e0f 100644 --- a/android/lib/jni/gideros.cpp +++ b/android/lib/jni/gideros.cpp @@ -180,10 +180,10 @@ class ApplicationManager void setProjectProperties(const ProjectProperties &properties); bool isRunning(); - void touchesBegin(int size, int *id, int *x, int *y, int actionIndex); - void touchesMove(int size, int *id, int *x, int *y); - void touchesEnd(int size, int *id, int *x, int *y, int actionIndex); - void touchesCancel(int size, int *id, int *x, int *y); + void touchesBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex); + void touchesMove(int size, int *id, int *x, int *y, float *pressure); + void touchesEnd(int size, int *id, int *x, int *y, float *pressure, int actionIndex); + void touchesCancel(int size, int *id, int *x, int *y, float *pressure); bool keyDown(int keyCode, int repeatCount); bool keyUp(int keyCode, int repeatCount); @@ -1145,24 +1145,24 @@ void ApplicationManager::setProjectProperties(const ProjectProperties &propertie properties_ = properties; } -void ApplicationManager::touchesBegin(int size, int *id, int *x, int *y, int actionIndex) +void ApplicationManager::touchesBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { - ginputp_touchBegin(size, id, x, y, actionIndex); + ginputp_touchBegin(size, id, x, y, pressure, actionIndex); } -void ApplicationManager::touchesMove(int size, int *id, int *x, int *y) +void ApplicationManager::touchesMove(int size, int *id, int *x, int *y, float *pressure) { - ginputp_touchesMove(size, id, x, y); + ginputp_touchesMove(size, id, x, y, pressure); } -void ApplicationManager::touchesEnd(int size, int *id, int *x, int *y, int actionIndex) +void ApplicationManager::touchesEnd(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { - ginputp_touchEnd(size, id, x, y, actionIndex); + ginputp_touchEnd(size, id, x, y, pressure, actionIndex); } -void ApplicationManager::touchesCancel(int size, int *id, int *x, int *y) +void ApplicationManager::touchesCancel(int size, int *id, int *x, int *y, float *pressure) { - ginputp_touchesCancel(size, id, x, y); + ginputp_touchesCancel(size, id, x, y, pressure); } bool ApplicationManager::keyDown(int keyCode, int repeatCount) @@ -1308,56 +1308,64 @@ void Java_com_giderosmobile_android_player_GiderosApplication_nativeOpenProject( s_applicationManager->setOpenProject(project.c_str()); } -void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesBegin(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy, jint actionIndex) +void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesBegin(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy, jfloatArray jpressure, jint actionIndex) { jint* id = (jint*)env->GetPrimitiveArrayCritical(jid, 0); jint* x = (jint*)env->GetPrimitiveArrayCritical(jx, 0); jint* y = (jint*)env->GetPrimitiveArrayCritical(jy, 0); + jfloat* pressure = (jfloat*)env->GetPrimitiveArrayCritical(jpressure, 0); - s_applicationManager->touchesBegin(size, id, x, y, actionIndex); + s_applicationManager->touchesBegin(size, id, x, y, pressure, actionIndex); env->ReleasePrimitiveArrayCritical(jid, id, 0); env->ReleasePrimitiveArrayCritical(jx, x, 0); env->ReleasePrimitiveArrayCritical(jy, y, 0); + env->ReleasePrimitiveArrayCritical(jpressure, pressure, 0); } -void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesMove(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy) +void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesMove(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy, jfloatArray jpressure) { jint* id = (jint*)env->GetPrimitiveArrayCritical(jid, 0); jint* x = (jint*)env->GetPrimitiveArrayCritical(jx, 0); jint* y = (jint*)env->GetPrimitiveArrayCritical(jy, 0); + jfloat* pressure = (jfloat*)env->GetPrimitiveArrayCritical(jpressure, 0); - s_applicationManager->touchesMove(size, id, x, y); + s_applicationManager->touchesMove(size, id, x, y, pressure); env->ReleasePrimitiveArrayCritical(jid, id, 0); env->ReleasePrimitiveArrayCritical(jx, x, 0); env->ReleasePrimitiveArrayCritical(jy, y, 0); + env->ReleasePrimitiveArrayCritical(jpressure, pressure, 0); } -void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesEnd(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy, jint actionIndex) +void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesEnd(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy, jfloatArray jpressure, jint actionIndex) { jint* id = (jint*)env->GetPrimitiveArrayCritical(jid, 0); jint* x = (jint*)env->GetPrimitiveArrayCritical(jx, 0); jint* y = (jint*)env->GetPrimitiveArrayCritical(jy, 0); + jfloat* pressure = (jfloat*)env->GetPrimitiveArrayCritical(jpressure, 0); - s_applicationManager->touchesEnd(size, id, x, y, actionIndex); + s_applicationManager->touchesEnd(size, id, x, y, pressure, actionIndex); env->ReleasePrimitiveArrayCritical(jid, id, 0); env->ReleasePrimitiveArrayCritical(jx, x, 0); env->ReleasePrimitiveArrayCritical(jy, y, 0); + env->ReleasePrimitiveArrayCritical(jpressure, pressure, 0); } -void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesCancel(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy) +void Java_com_giderosmobile_android_player_GiderosApplication_nativeTouchesCancel(JNIEnv* env, jobject thiz, jint size, jintArray jid, jintArray jx, jintArray jy, jfloatArray jpressure) { jint* id = (jint*)env->GetPrimitiveArrayCritical(jid, 0); jint* x = (jint*)env->GetPrimitiveArrayCritical(jx, 0); jint* y = (jint*)env->GetPrimitiveArrayCritical(jy, 0); + jfloat* pressure = (jfloat*)env->GetPrimitiveArrayCritical(jpressure, 0); - s_applicationManager->touchesCancel(size, id, x, y); + s_applicationManager->touchesCancel(size, id, x, y, pressure); env->ReleasePrimitiveArrayCritical(jid, id, 0); env->ReleasePrimitiveArrayCritical(jx, x, 0); env->ReleasePrimitiveArrayCritical(jy, y, 0); + env->ReleasePrimitiveArrayCritical(jpressure, pressure, 0); } jboolean Java_com_giderosmobile_android_player_GiderosApplication_nativeKeyDown(JNIEnv* env, jclass cls, jint keyCode, jint repeatCount) diff --git a/libgid/include/android/ginput-android.h b/libgid/include/android/ginput-android.h index d92604dfe..3d1ca57b9 100644 --- a/libgid/include/android/ginput-android.h +++ b/libgid/include/android/ginput-android.h @@ -7,10 +7,10 @@ extern "C" { #endif -G_API void ginputp_touchBegin(int size, int *id, int *x, int *y, int actionIndex); -G_API void ginputp_touchesMove(int size, int *id, int *x, int *y); -G_API void ginputp_touchEnd(int size, int *id, int *x, int *y, int actionIndex); -G_API void ginputp_touchesCancel(int size, int *id, int *x, int *y); +G_API void ginputp_touchBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex); +G_API void ginputp_touchesMove(int size, int *id, int *x, int *y, float *pressure); +G_API void ginputp_touchEnd(int size, int *id, int *x, int *y, float *pressure, int actionIndex); +G_API void ginputp_touchesCancel(int size, int *id, int *x, int *y, float *pressure); G_API g_bool ginputp_keyDown(int keyCode, int repeatCount); G_API g_bool ginputp_keyUp(int keyCode, int repeatCount); diff --git a/libgid/src/android/ginput-android.cpp b/libgid/src/android/ginput-android.cpp index 067e9bce6..749b9b014 100644 --- a/libgid/src/android/ginput-android.cpp +++ b/libgid/src/android/ginput-android.cpp @@ -372,13 +372,13 @@ class GGInputManager } public: - void touchBegin(int size, int *id, int *x, int *y, int actionIndex) + void touchBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { ginput_TouchEvent *touchEvent = newTouchEvent(size); touchEvent->touch.x = x[actionIndex]; touchEvent->touch.y = y[actionIndex]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[actionIndex]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[actionIndex]; @@ -386,7 +386,7 @@ class GGInputManager { touchEvent->allTouches[i].x = x[i]; touchEvent->allTouches[i].y = y[i]; - touchEvent->allTouches[i].pressure = 0; + touchEvent->allTouches[i].pressure = pressure[i]; touchEvent->allTouches[i].touchType = 0; touchEvent->allTouches[i].id = id[i]; } @@ -418,7 +418,7 @@ class GGInputManager } } - void touchesMove(int size, int *id, int *x, int *y) + void touchesMove(int size, int *id, int *x, int *y, float *pressure) { for (int i = 0; i < size; ++i) { @@ -426,7 +426,7 @@ class GGInputManager touchEvent->touch.x = x[i]; touchEvent->touch.y = y[i]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[i]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[i]; @@ -434,7 +434,7 @@ class GGInputManager { touchEvent->allTouches[j].x = x[j]; touchEvent->allTouches[j].y = y[j]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[j]; touchEvent->touch.touchType = 0; touchEvent->allTouches[j].id = id[j]; } @@ -466,13 +466,13 @@ class GGInputManager } } - void touchEnd(int size, int *id, int *x, int *y, int actionIndex) + void touchEnd(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { ginput_TouchEvent *touchEvent = newTouchEvent(size); touchEvent->touch.x = x[actionIndex]; touchEvent->touch.y = y[actionIndex]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[actionIndex]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[actionIndex]; @@ -480,7 +480,7 @@ class GGInputManager { touchEvent->allTouches[i].x = x[i]; touchEvent->allTouches[i].y = y[i]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[i]; touchEvent->touch.touchType = 0; touchEvent->allTouches[i].id = id[i]; } @@ -511,7 +511,7 @@ class GGInputManager } } - void touchesCancel(int size, int *id, int *x, int *y) + void touchesCancel(int size, int *id, int *x, int *y, float *pressure) { for (int i = 0; i < size; ++i) { @@ -519,7 +519,7 @@ class GGInputManager touchEvent->touch.x = x[i]; touchEvent->touch.y = y[i]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[i]; touchEvent->touch.touchType = 0; touchEvent->touch.id = id[i]; @@ -527,7 +527,7 @@ class GGInputManager { touchEvent->allTouches[j].x = x[j]; touchEvent->allTouches[j].y = y[j]; - touchEvent->touch.pressure = 0; + touchEvent->touch.pressure = pressure[j]; touchEvent->touch.touchType = 0; touchEvent->allTouches[j].id = id[j]; } @@ -829,25 +829,25 @@ void ginput_getGyroscopeRotationRate(double *x, double *y, double *z) s_manager->getGyroscopeRotationRate(x, y, z); } -void ginputp_touchBegin(int size, int *id, int *x, int *y, int actionIndex) +void ginputp_touchBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { if (s_manager) - s_manager->touchBegin(size, id, x, y, actionIndex); + s_manager->touchBegin(size, id, x, y, pressure, actionIndex); } -void ginputp_touchesMove(int size, int *id, int *x, int *y) +void ginputp_touchesMove(int size, int *id, int *x, int *y, float *pressure) { if (s_manager) - s_manager->touchesMove(size, id, x, y); + s_manager->touchesMove(size, id, x, y, pressure); } -void ginputp_touchEnd(int size, int *id, int *x, int *y, int actionIndex) +void ginputp_touchEnd(int size, int *id, int *x, int *y, float *pressure, int actionIndex) { if (s_manager) - s_manager->touchEnd(size, id, x, y, actionIndex); + s_manager->touchEnd(size, id, x, y, pressure, actionIndex); } -void ginputp_touchesCancel(int size, int *id, int *x, int *y) +void ginputp_touchesCancel(int size, int *id, int *x, int *y, float *pressure) { if (s_manager) - s_manager->touchesCancel(size, id, x, y); + s_manager->touchesCancel(size, id, x, y, pressure); } g_bool ginputp_keyDown(int keyCode, int repeatCount)