src/video/android/SDL_androidtouch.c
changeset 7786 cfc1285375e1
parent 7261 df37802bf7db
child 8030 7b0d28c202d2
equal deleted inserted replaced
7785:d01823d85840 7786:cfc1285375e1
    29 #include "../../events/SDL_touch_c.h"
    29 #include "../../events/SDL_touch_c.h"
    30 #include "SDL_log.h"
    30 #include "SDL_log.h"
    31 
    31 
    32 #include "SDL_androidtouch.h"
    32 #include "SDL_androidtouch.h"
    33 
    33 
       
    34 #include "../../core/android/SDL_android.h"
    34 
    35 
    35 #define ACTION_DOWN 0
    36 #define ACTION_DOWN 0
    36 #define ACTION_UP 1
    37 #define ACTION_UP 1
    37 #define ACTION_MOVE 2
    38 #define ACTION_MOVE 2
    38 #define ACTION_CANCEL 3
    39 #define ACTION_CANCEL 3
    49     int window_w, window_h;
    50     int window_w, window_h;
    50 
    51 
    51     SDL_GetWindowSize(Android_Window, &window_w, &window_h);
    52     SDL_GetWindowSize(Android_Window, &window_w, &window_h);
    52     *window_x = (int)(x * window_w);
    53     *window_x = (int)(x * window_w);
    53     *window_y = (int)(y * window_h);
    54     *window_y = (int)(y * window_h);
       
    55 }
       
    56 
       
    57 void Android_InitTouch(void)
       
    58 {
       
    59     int i;
       
    60     int* ids;
       
    61     int number = Android_JNI_GetTouchDeviceIds(&ids);
       
    62     if (0 < number) {
       
    63         for (i = 0; i < number; ++i) {
       
    64             SDL_AddTouch((SDL_TouchID) ids[i], ""); /* no error handling */
       
    65         }
       
    66         SDL_free(ids);
       
    67     }
    54 }
    68 }
    55 
    69 
    56 void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
    70 void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
    57 {
    71 {
    58     SDL_TouchID touchDeviceId = 0;
    72     SDL_TouchID touchDeviceId = 0;