21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_ANDROID
25 #include <android/log.h>
31 #include "../../events/SDL_mouse_c.h"
32 #include "../../events/SDL_touch_c.h"
33 #include "../../core/android/SDL_android.h"
38 #define ACTION_CANCEL 3
39 #define ACTION_OUTSIDE 4
40 #define ACTION_POINTER_DOWN 5
41 #define ACTION_POINTER_UP 6
43 static void Android_GetWindowCoordinates(
float x,
float y,
44 int *window_x,
int *window_y)
49 *window_x = (int)(x * window_w);
50 *window_y = (int)(y * window_h);
56 SeparateEventsHintWatcher(
void *userdata,
const char *
name,
57 const char *oldValue,
const char *newValue)
59 separate_mouse_and_touch = (newValue && (
SDL_strcmp(newValue,
"1") == 0));
71 SeparateEventsHintWatcher,
NULL);
74 for (i = 0; i < number; ++
i) {
84 SeparateEventsHintWatcher,
NULL);
88 void Android_OnTouch(
int touch_device_id_in,
int pointer_finger_id_in,
int action,
float x,
float y,
float p)
92 int window_x, window_y;
95 if (!Android_Window) {
101 SDL_Log(
"error: can't add touch %s, %d", __FILE__, __LINE__);
108 if (!separate_mouse_and_touch) {
109 Android_GetWindowCoordinates(x, y, &window_x, &window_y);
115 pointerFingerID = fingerId;
116 case ACTION_POINTER_DOWN:
122 if (!pointerFingerID) {
123 if (!separate_mouse_and_touch) {
124 Android_GetWindowCoordinates(x, y, &window_x, &window_y);
134 if (!separate_mouse_and_touch) {
139 case ACTION_POINTER_UP: