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) */
|
/* Last known Android mouse button state (includes all buttons) */
|
||||||
static int last_state;
|
static int last_state;
|
||||||
|
|
||||||
|
/* Blank cursor */
|
||||||
|
static SDL_Cursor *empty_cursor;
|
||||||
|
|
||||||
static SDL_Cursor *
|
static SDL_Cursor *
|
||||||
Android_WrapCursor(int custom_cursor, int system_cursor)
|
Android_WrapCursor(int custom_cursor, int system_cursor)
|
||||||
|
@ -115,9 +117,35 @@ Android_FreeCursor(SDL_Cursor * cursor)
|
||||||
SDL_free(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
|
static int
|
||||||
Android_ShowCursor(SDL_Cursor * cursor)
|
Android_ShowCursor(SDL_Cursor * cursor)
|
||||||
{
|
{
|
||||||
|
if (!cursor) {
|
||||||
|
cursor = Android_CreateEmptyCursor();
|
||||||
|
}
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)cursor->driverdata;
|
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)cursor->driverdata;
|
||||||
if (data->custom_cursor) {
|
if (data->custom_cursor) {
|
||||||
|
@ -129,12 +157,11 @@ Android_ShowCursor(SDL_Cursor * cursor)
|
||||||
return SDL_Unsupported();
|
return SDL_Unsupported();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
if (!Android_JNI_SetSystemCursor(-1)) {
|
/* SDL error set inside Android_CreateEmptyCursor() */
|
||||||
return SDL_Unsupported();
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -167,6 +194,12 @@ Android_InitMouse(void)
|
||||||
last_state = 0;
|
last_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Android_QuitMouse(void)
|
||||||
|
{
|
||||||
|
Android_DestroyEmptyCursor();
|
||||||
|
}
|
||||||
|
|
||||||
/* Translate Android mouse button state to SDL mouse button */
|
/* Translate Android mouse button state to SDL mouse button */
|
||||||
static Uint8
|
static Uint8
|
||||||
TranslateButton(int state)
|
TranslateButton(int state)
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
extern void Android_InitMouse(void);
|
extern void Android_InitMouse(void);
|
||||||
extern void Android_OnMouse(int button, int action, float x, float y, SDL_bool relative);
|
extern void Android_OnMouse(int button, int action, float x, float y, SDL_bool relative);
|
||||||
|
extern void Android_QuitMouse(void);
|
||||||
|
|
||||||
#endif /* SDL_androidmouse_h_ */
|
#endif /* SDL_androidmouse_h_ */
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,7 @@ Android_VideoInit(_THIS)
|
||||||
void
|
void
|
||||||
Android_VideoQuit(_THIS)
|
Android_VideoQuit(_THIS)
|
||||||
{
|
{
|
||||||
|
Android_QuitMouse();
|
||||||
Android_QuitTouch();
|
Android_QuitTouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue