|
@@ -47,6 +47,25 @@ void Android_QuitTouch(void)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+SDL_TouchID Android_ConvertJavaTouchID(int touchID)
|
|
|
|
+{
|
|
|
|
+ SDL_TouchID retval = touchID;
|
|
|
|
+
|
|
|
|
+ if (touchID < 0) {
|
|
|
|
+ // Touch ID -1 appears when using Android emulator, eg:
|
|
|
|
+ // adb shell input mouse tap 100 100
|
|
|
|
+ // adb shell input touchscreen tap 100 100
|
|
|
|
+ //
|
|
|
|
+ // Prevent to be -1, since it's used in SDL internal for synthetic events:
|
|
|
|
+ retval -= 1;
|
|
|
|
+ } else {
|
|
|
|
+ // Touch ID 0 is invalid
|
|
|
|
+ retval += 1;
|
|
|
|
+ }
|
|
|
|
+ return retval;
|
|
|
|
+}
|
|
|
|
+
|
|
void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
|
|
void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
|
|
{
|
|
{
|
|
SDL_TouchID touchDeviceId = 0;
|
|
SDL_TouchID touchDeviceId = 0;
|
|
@@ -56,11 +75,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- /* Touch device -1 appears when using Android emulator, eg:
|
|
|
|
- * adb shell input mouse tap 100 100
|
|
|
|
- * adb shell input touchscreen tap 100 100
|
|
|
|
- */
|
|
|
|
- touchDeviceId = (SDL_TouchID)(touch_device_id_in + 2);
|
|
|
|
|
|
+ touchDeviceId = Android_ConvertJavaTouchID(touch_device_id_in);
|
|
|
|
|
|
// Finger ID should be greater than 0
|
|
// Finger ID should be greater than 0
|
|
fingerId = (SDL_FingerID)(pointer_finger_id_in + 1);
|
|
fingerId = (SDL_FingerID)(pointer_finger_id_in + 1);
|