mirror of https://github.com/encounter/SDL.git
Use a blank cursor instead of PointerIcon.TYPE_NULL since that shows the default cursor on Samsung DeX
This commit is contained in:
parent
a515853569
commit
88dfa46644
|
@ -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)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
extern void Android_InitMouse(void);
|
||||
extern void Android_OnMouse(int button, int action, float x, float y, SDL_bool relative);
|
||||
extern void Android_QuitMouse(void);
|
||||
|
||||
#endif /* SDL_androidmouse_h_ */
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ Android_VideoInit(_THIS)
|
|||
void
|
||||
Android_VideoQuit(_THIS)
|
||||
{
|
||||
Android_QuitMouse();
|
||||
Android_QuitTouch();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue