23 #if SDL_VIDEO_DRIVER_ANDROID
25 #include <android/log.h>
28 #include "../../events/SDL_mouse_c.h"
29 #include "../../events/SDL_touch_c.h"
38 #define ACTION_CANCEL 3
39 #define ACTION_OUTSIDE 4
41 #define ACTION_POINTER_1_DOWN 5
42 #define ACTION_POINTER_1_UP 6
46 static void Android_GetWindowCoordinates(
float x,
float y,
47 int *window_x,
int *window_y)
49 int window_w, window_h;
52 *window_x = (
int)(x * window_w);
53 *window_y = (
int)(y * window_h);
56 void Android_OnTouch(
int touch_device_id_in,
int pointer_finger_id_in,
int action,
float x,
float y,
float p)
60 int window_x, window_y;
68 SDL_Log(
"error: can't add touch %s, %d", __FILE__, __LINE__);
74 case ACTION_POINTER_1_DOWN:
75 if (!leftFingerDown) {
76 Android_GetWindowCoordinates(x, y, &window_x, &window_y);
84 leftFingerDown = fingerId;
89 if (!leftFingerDown) {
90 Android_GetWindowCoordinates(x, y, &window_x, &window_y);
98 case ACTION_POINTER_1_UP:
99 if (fingerId == leftFingerDown) {
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure)
void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
Get the size of a window's client area.
#define SDL_TOUCH_MOUSEID
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
SDL_Window * Android_Window
int SDL_AddTouch(SDL_TouchID touchID, const char *name)
EGLSurface EGLint EGLint y
DECLSPEC void SDLCALL SDL_Log(const char *fmt,...)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)