|
@@ -52,6 +52,8 @@ typedef struct
|
|
|
/* Last known Android mouse button state (includes all buttons) */
|
|
|
static int last_state;
|
|
|
|
|
|
+/* Blank cursor */
|
|
|
+static SDL_Cursor *empty_cursor;
|
|
|
|
|
|
static SDL_Cursor *
|
|
|
Android_WrapCursor(int custom_cursor, int system_cursor)
|
|
@@ -115,9 +117,35 @@ Android_FreeCursor(SDL_Cursor * cursor)
|
|
|
SDL_free(cursor);
|
|
|
}
|
|
|
|
|
|
+static SDL_Cursor *
|
|
|
+Android_CreateEmptyCursor()
|
|
|
+{
|
|
|
+ if (!empty_cursor) {
|
|
|
+ SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888);
|
|
|
+ if (empty_surface) {
|
|
|
+ SDL_memset(empty_surface->pixels, 0, empty_surface->h * empty_surface->pitch);
|
|
|
+ empty_cursor = Android_CreateCursor(empty_surface, 0, 0);
|
|
|
+ SDL_FreeSurface(empty_surface);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return empty_cursor;
|
|
|
+}
|
|
|
+
|
|
|
+static void
|
|
|
+Android_DestroyEmptyCursor()
|
|
|
+{
|
|
|
+ if (empty_cursor) {
|
|
|
+ Android_FreeCursor(empty_cursor);
|
|
|
+ empty_cursor = NULL;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static int
|
|
|
Android_ShowCursor(SDL_Cursor * cursor)
|
|
|
{
|
|
|
+ if (!cursor) {
|
|
|
+ cursor = Android_CreateEmptyCursor();
|
|
|
+ }
|
|
|
if (cursor) {
|
|
|
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)cursor->driverdata;
|
|
|
if (data->custom_cursor) {
|
|
@@ -129,12 +157,11 @@ Android_ShowCursor(SDL_Cursor * cursor)
|
|
|
return SDL_Unsupported();
|
|
|
}
|
|
|
}
|
|
|
+ return 0;
|
|
|
} else {
|
|
|
- if (!Android_JNI_SetSystemCursor(-1)) {
|
|
|
- return SDL_Unsupported();
|
|
|
- }
|
|
|
+ /* SDL error set inside Android_CreateEmptyCursor() */
|
|
|
+ return -1;
|
|
|
}
|
|
|
- return 0;
|
|
|
}
|
|
|
|
|
|
static int
|
|
@@ -167,6 +194,12 @@ Android_InitMouse(void)
|
|
|
last_state = 0;
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+Android_QuitMouse(void)
|
|
|
+{
|
|
|
+ Android_DestroyEmptyCursor();
|
|
|
+}
|
|
|
+
|
|
|
/* Translate Android mouse button state to SDL mouse button */
|
|
|
static Uint8
|
|
|
TranslateButton(int state)
|