src/video/android/SDL_androidtouch.c
changeset 8030 7b0d28c202d2
parent 7786 cfc1285375e1
child 8093 b43765095a6f
     1.1 --- a/src/video/android/SDL_androidtouch.c	Sat Nov 23 23:38:16 2013 +0100
     1.2 +++ b/src/video/android/SDL_androidtouch.c	Mon Nov 25 12:28:09 2013 -0300
     1.3 @@ -38,11 +38,8 @@
     1.4  #define ACTION_MOVE 2
     1.5  #define ACTION_CANCEL 3
     1.6  #define ACTION_OUTSIDE 4
     1.7 -/* The following two are deprecated but it seems they are still emitted (instead the corresponding ACTION_UP/DOWN) as of Android 3.2 */
     1.8 -#define ACTION_POINTER_1_DOWN 5
     1.9 -#define ACTION_POINTER_1_UP 6
    1.10 -
    1.11 -static SDL_FingerID leftFingerDown = 0;
    1.12 +#define ACTION_POINTER_DOWN 5
    1.13 +#define ACTION_POINTER_UP 6
    1.14  
    1.15  static void Android_GetWindowCoordinates(float x, float y,
    1.16                                           int *window_x, int *window_y)
    1.17 @@ -72,6 +69,7 @@
    1.18      SDL_TouchID touchDeviceId = 0;
    1.19      SDL_FingerID fingerId = 0;
    1.20      int window_x, window_y;
    1.21 +    static SDL_FingerID pointerFingerID = 0;
    1.22  
    1.23      if (!Android_Window) {
    1.24          return;
    1.25 @@ -85,22 +83,20 @@
    1.26      fingerId = (SDL_FingerID)pointer_finger_id_in;
    1.27      switch (action) {
    1.28          case ACTION_DOWN:
    1.29 -        case ACTION_POINTER_1_DOWN:
    1.30 -            if (!leftFingerDown) {
    1.31 -                Android_GetWindowCoordinates(x, y, &window_x, &window_y);
    1.32 -
    1.33 -                /* send moved event */
    1.34 -                SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
    1.35 -
    1.36 -                /* send mouse down event */
    1.37 -                SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.38 -
    1.39 -                leftFingerDown = fingerId;
    1.40 -            }
    1.41 +            /* Primary pointer down */
    1.42 +            Android_GetWindowCoordinates(x, y, &window_x, &window_y);
    1.43 +            /* send moved event */
    1.44 +            SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
    1.45 +            /* send mouse down event */
    1.46 +            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.47 +            pointerFingerID = fingerId;
    1.48 +        case ACTION_POINTER_DOWN:
    1.49 +            /* Non primary pointer down */
    1.50              SDL_SendTouch(touchDeviceId, fingerId, SDL_TRUE, x, y, p);
    1.51              break;
    1.52 +            
    1.53          case ACTION_MOVE:
    1.54 -            if (!leftFingerDown) {
    1.55 +            if (!pointerFingerID) {
    1.56                  Android_GetWindowCoordinates(x, y, &window_x, &window_y);
    1.57  
    1.58                  /* send moved event */
    1.59 @@ -108,15 +104,17 @@
    1.60              }
    1.61              SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
    1.62              break;
    1.63 +            
    1.64          case ACTION_UP:
    1.65 -        case ACTION_POINTER_1_UP:
    1.66 -            if (fingerId == leftFingerDown) {
    1.67 -                /* send mouse up */
    1.68 -                SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.69 -                leftFingerDown = 0;
    1.70 -            }
    1.71 +            /* Primary pointer up */
    1.72 +            /* send mouse up */
    1.73 +            pointerFingerID = (SDL_FingerID) 0;
    1.74 +            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.75 +        case ACTION_POINTER_UP:
    1.76 +            /* Non primary pointer up */
    1.77              SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
    1.78              break;
    1.79 +            
    1.80          default:
    1.81              break;
    1.82      }