update sdl Merge commit '4d48f9d23713d94b861da7b5d41baf2a41334994'
This commit is contained in:
2
external/sdl/SDL/src/events/SDL_events.c
vendored
2
external/sdl/SDL/src/events/SDL_events.c
vendored
@ -580,8 +580,6 @@ int SDL_StartEventLoop(void)
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_TEXT, SDL_FALSE);
|
||||
#endif
|
||||
SDL_SetEventEnabled(SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, SDL_FALSE);
|
||||
SDL_SetEventEnabled(SDL_EVENT_GAMEPAD_UPDATE_COMPLETE, SDL_FALSE);
|
||||
|
||||
SDL_EventQ.active = SDL_TRUE;
|
||||
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||
|
33
external/sdl/SDL/src/events/SDL_keyboard.c
vendored
33
external/sdl/SDL/src/events/SDL_keyboard.c
vendored
@ -33,8 +33,9 @@
|
||||
typedef enum
|
||||
{
|
||||
KEYBOARD_HARDWARE = 0x01,
|
||||
KEYBOARD_AUTORELEASE = 0x02,
|
||||
KEYBOARD_IGNOREMODIFIERS = 0x04
|
||||
KEYBOARD_VIRTUAL = 0x02,
|
||||
KEYBOARD_AUTORELEASE = 0x04,
|
||||
KEYBOARD_IGNOREMODIFIERS = 0x08
|
||||
} SDL_KeyboardFlags;
|
||||
|
||||
#define KEYBOARD_SOURCE_MASK (KEYBOARD_HARDWARE | KEYBOARD_AUTORELEASE)
|
||||
@ -50,6 +51,7 @@ struct SDL_Keyboard
|
||||
Uint8 keystate[SDL_NUM_SCANCODES];
|
||||
SDL_Keycode keymap[SDL_NUM_SCANCODES];
|
||||
SDL_bool autorelease_pending;
|
||||
Uint64 hardware_timestamp;
|
||||
};
|
||||
|
||||
static SDL_Keyboard SDL_keyboard;
|
||||
@ -875,7 +877,9 @@ static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, SDL_KeyboardFlags flags
|
||||
keycode = keyboard->keymap[scancode];
|
||||
}
|
||||
|
||||
if (source == KEYBOARD_AUTORELEASE) {
|
||||
if (source == KEYBOARD_HARDWARE) {
|
||||
keyboard->hardware_timestamp = SDL_GetTicks();
|
||||
} else if (source == KEYBOARD_AUTORELEASE) {
|
||||
keyboard->autorelease_pending = SDL_TRUE;
|
||||
}
|
||||
|
||||
@ -978,20 +982,25 @@ int SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch)
|
||||
|
||||
if (mod & SDL_KMOD_SHIFT) {
|
||||
/* If the character uses shift, press shift down */
|
||||
SDL_SendKeyboardKey(timestamp, SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDLK_UNKNOWN);
|
||||
}
|
||||
|
||||
/* Send a keydown and keyup for the character */
|
||||
SDL_SendKeyboardKey(timestamp, SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey(timestamp, SDL_RELEASED, code);
|
||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_PRESSED, code, SDLK_UNKNOWN);
|
||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_RELEASED, code, SDLK_UNKNOWN);
|
||||
|
||||
if (mod & SDL_KMOD_SHIFT) {
|
||||
/* If the character uses shift, release shift */
|
||||
SDL_SendKeyboardKey(timestamp, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDLK_UNKNOWN);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SendVirtualKeyboardKey(Uint64 timestamp, Uint8 state, SDL_Scancode scancode)
|
||||
{
|
||||
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_VIRTUAL, state, scancode, SDLK_UNKNOWN);
|
||||
}
|
||||
|
||||
int SDL_SendKeyboardKey(Uint64 timestamp, Uint8 state, SDL_Scancode scancode)
|
||||
{
|
||||
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_HARDWARE, state, scancode, SDLK_UNKNOWN);
|
||||
@ -1025,6 +1034,13 @@ void SDL_ReleaseAutoReleaseKeys(void)
|
||||
}
|
||||
keyboard->autorelease_pending = SDL_FALSE;
|
||||
}
|
||||
|
||||
if (keyboard->hardware_timestamp) {
|
||||
/* Keep hardware keyboard "active" for 250 ms */
|
||||
if (SDL_GetTicks() >= keyboard->hardware_timestamp + 250) {
|
||||
keyboard->hardware_timestamp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool SDL_HardwareKeyboardKeyPressed(void)
|
||||
@ -1037,7 +1053,8 @@ SDL_bool SDL_HardwareKeyboardKeyPressed(void)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
|
||||
return keyboard->hardware_timestamp ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
int SDL_SendKeyboardText(const char *text)
|
||||
|
3
external/sdl/SDL/src/events/SDL_keyboard_c.h
vendored
3
external/sdl/SDL/src/events/SDL_keyboard_c.h
vendored
@ -49,6 +49,9 @@ extern int SDL_SetKeyboardFocus(SDL_Window *window);
|
||||
*/
|
||||
extern int SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch);
|
||||
|
||||
/* Send a key from a virtual key source, like an on-screen keyboard */
|
||||
extern int SDL_SendVirtualKeyboardKey(Uint64 timestamp, Uint8 state, SDL_Scancode scancode);
|
||||
|
||||
/* Send a keyboard key event */
|
||||
extern int SDL_SendKeyboardKey(Uint64 timestamp, Uint8 state, SDL_Scancode scancode);
|
||||
extern int SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode);
|
||||
|
45
external/sdl/SDL/src/events/SDL_mouse.c
vendored
45
external/sdl/SDL/src/events/SDL_mouse.c
vendored
@ -162,7 +162,7 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
int SDL_InitMouse(void)
|
||||
int SDL_PreInitMouse(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
@ -203,8 +203,17 @@ int SDL_InitMouse(void)
|
||||
mouse->was_touch_mouse_events = SDL_FALSE; /* no touch to mouse movement event pending */
|
||||
|
||||
mouse->cursor_shown = SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mouse->CreateCursor) {
|
||||
void SDL_PostInitMouse(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
/* Create a dummy mouse cursor for video backends that don't support true cursors,
|
||||
* so that mouse grab and focus functionality will work.
|
||||
*/
|
||||
if (!mouse->def_cursor) {
|
||||
SDL_Surface *surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (surface) {
|
||||
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
||||
@ -212,14 +221,29 @@ int SDL_InitMouse(void)
|
||||
SDL_DestroySurface(surface);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if (cursor == mouse->def_cursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mouse->def_cursor) {
|
||||
SDL_Cursor *default_cursor = mouse->def_cursor;
|
||||
|
||||
if (mouse->cur_cursor == mouse->def_cursor) {
|
||||
mouse->cur_cursor = NULL;
|
||||
}
|
||||
mouse->def_cursor = NULL;
|
||||
|
||||
SDL_DestroyCursor(default_cursor);
|
||||
}
|
||||
|
||||
mouse->def_cursor = cursor;
|
||||
|
||||
if (!mouse->cur_cursor) {
|
||||
SDL_SetCursor(cursor);
|
||||
}
|
||||
@ -845,6 +869,10 @@ void SDL_QuitMouse(void)
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
SDL_ShowCursor();
|
||||
|
||||
if (mouse->def_cursor) {
|
||||
SDL_SetDefaultCursor(NULL);
|
||||
}
|
||||
|
||||
cursor = mouse->cursors;
|
||||
while (cursor) {
|
||||
next = cursor->next;
|
||||
@ -854,15 +882,6 @@ void SDL_QuitMouse(void)
|
||||
mouse->cursors = NULL;
|
||||
mouse->cur_cursor = NULL;
|
||||
|
||||
if (mouse->def_cursor) {
|
||||
if (mouse->FreeCursor) {
|
||||
mouse->FreeCursor(mouse->def_cursor);
|
||||
} else {
|
||||
SDL_free(mouse->def_cursor);
|
||||
}
|
||||
mouse->def_cursor = NULL;
|
||||
}
|
||||
|
||||
if (mouse->sources) {
|
||||
SDL_free(mouse->sources);
|
||||
mouse->sources = NULL;
|
||||
@ -1377,7 +1396,7 @@ void SDL_DestroyCursor(SDL_Cursor *cursor)
|
||||
mouse->cursors = curr->next;
|
||||
}
|
||||
|
||||
if (mouse->FreeCursor) {
|
||||
if (mouse->FreeCursor && curr->driverdata) {
|
||||
mouse->FreeCursor(curr);
|
||||
} else {
|
||||
SDL_free(curr);
|
||||
|
7
external/sdl/SDL/src/events/SDL_mouse_c.h
vendored
7
external/sdl/SDL/src/events/SDL_mouse_c.h
vendored
@ -122,8 +122,11 @@ typedef struct
|
||||
void *driverdata;
|
||||
} SDL_Mouse;
|
||||
|
||||
/* Initialize the mouse subsystem */
|
||||
extern int SDL_InitMouse(void);
|
||||
/* Initialize the mouse subsystem, called before the main video driver is initialized */
|
||||
extern int SDL_PreInitMouse(void);
|
||||
|
||||
/* Finish initializing the mouse subsystem, called after the main video driver was initialized */
|
||||
extern void SDL_PostInitMouse(void);
|
||||
|
||||
/* Get the mouse state structure */
|
||||
SDL_Mouse *SDL_GetMouse(void);
|
||||
|
Reference in New Issue
Block a user