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;
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:
GLint GLint GLint GLint GLint x
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)
void Android_JNI_SetSeparateMouseAndTouch(SDL_bool new_value)
#define SDL_TOUCH_MOUSEID
void Android_InitTouch(void)
GLuint const GLchar * name
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure)
#define SDL_GetWindowSize
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
SDL_Window * Android_Window
GLint GLint GLint GLint GLint GLint y
int SDL_AddTouch(SDL_TouchID touchID, const char *name)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_AddHintCallback
#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH
A variable to control whether mouse and touch events are to be treated together or separately...
#define SDL_DelHintCallback
int Android_JNI_GetTouchDeviceIds(int **ids)
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
void Android_QuitTouch(void)