mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
update sdl to release 2.0.22
This commit is contained in:
parent
3f796d2a06
commit
d4307ea413
135 changed files with 5746 additions and 1161 deletions
|
|
@ -638,6 +638,7 @@ SDL_SetKeyboardFocus(SDL_Window * window)
|
|||
/* old window must lose an existing mouse capture. */
|
||||
if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) {
|
||||
SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */
|
||||
SDL_UpdateMouseCapture(SDL_TRUE);
|
||||
SDL_assert(!(keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,28 @@ SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldVal
|
|||
mouse->touch_mouse_events = SDL_GetStringBoolean(hint, SDL_TRUE);
|
||||
}
|
||||
|
||||
#if defined(__vita__)
|
||||
static void SDLCALL
|
||||
SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
|
||||
if (hint) {
|
||||
switch(*hint) {
|
||||
default:
|
||||
case '0':
|
||||
mouse->vita_touch_mouse_device = 0;
|
||||
break;
|
||||
case '1':
|
||||
mouse->vita_touch_mouse_device = 1;
|
||||
break;
|
||||
case '2':
|
||||
mouse->vita_touch_mouse_device = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void SDLCALL
|
||||
SDL_MouseTouchEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
|
|
@ -134,12 +156,8 @@ SDL_MouseAutoCaptureChanged(void *userdata, const char *name, const char *oldVal
|
|||
SDL_bool auto_capture = SDL_GetStringBoolean(hint, SDL_TRUE);
|
||||
|
||||
if (auto_capture != mouse->auto_capture) {
|
||||
/* Turn off mouse capture if it's currently active because of button presses */
|
||||
if (!auto_capture && SDL_GetMouseState(NULL, NULL) != 0) {
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
}
|
||||
|
||||
mouse->auto_capture = auto_capture;
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,6 +184,11 @@ SDL_MouseInit(void)
|
|||
SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS,
|
||||
SDL_TouchMouseEventsChanged, mouse);
|
||||
|
||||
#if defined(__vita__)
|
||||
SDL_AddHintCallback(SDL_HINT_VITA_TOUCH_MOUSE_DEVICE,
|
||||
SDL_VitaTouchMouseDeviceChanged, mouse);
|
||||
#endif
|
||||
|
||||
SDL_AddHintCallback(SDL_HINT_MOUSE_TOUCH_EVENTS,
|
||||
SDL_MouseTouchEventsChanged, mouse);
|
||||
|
||||
|
|
@ -384,12 +407,9 @@ SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relativ
|
|||
|
||||
/* Ignore relative motion when first positioning the mouse */
|
||||
if (!mouse->has_position) {
|
||||
xrel = 0;
|
||||
yrel = 0;
|
||||
mouse->x = x;
|
||||
mouse->y = y;
|
||||
mouse->has_position = SDL_TRUE;
|
||||
return 0;
|
||||
} else if (!xrel && !yrel) { /* Drop events that don't change state */
|
||||
#ifdef DEBUG_MOUSE
|
||||
SDL_Log("Mouse event didn't change state - dropped!\n");
|
||||
|
|
@ -540,7 +560,6 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
|
|||
Uint32 type;
|
||||
Uint32 buttonstate;
|
||||
SDL_MouseInputSource *source;
|
||||
SDL_bool had_buttons_pressed = (SDL_GetMouseState(NULL, NULL) ? SDL_TRUE : SDL_FALSE);
|
||||
|
||||
source = GetMouseInputSource(mouse, mouseID);
|
||||
if (!source) {
|
||||
|
|
@ -643,10 +662,7 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
|
|||
|
||||
/* Automatically capture the mouse while buttons are pressed */
|
||||
if (mouse->auto_capture) {
|
||||
SDL_bool has_buttons_pressed = (SDL_GetMouseState(NULL, NULL) ? SDL_TRUE : SDL_FALSE);
|
||||
if (has_buttons_pressed != had_buttons_pressed) {
|
||||
SDL_CaptureMouse(has_buttons_pressed);
|
||||
}
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
}
|
||||
|
||||
return posted;
|
||||
|
|
@ -743,6 +759,7 @@ SDL_MouseQuit(void)
|
|||
|
||||
if (mouse->CaptureMouse) {
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
SDL_UpdateMouseCapture(SDL_TRUE);
|
||||
}
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
SDL_ShowCursor(1);
|
||||
|
|
@ -947,6 +964,8 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
|
|||
if (!enabled) {
|
||||
SDL_WarpMouseInWindow(focusWindow, mouse->x, mouse->y);
|
||||
}
|
||||
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
|
|
@ -968,39 +987,59 @@ SDL_GetRelativeMouseMode()
|
|||
return mouse->relative_mode;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_UpdateMouseCapture(SDL_bool force_release)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_Window *capture_window = NULL;
|
||||
|
||||
if (!mouse->CaptureMouse) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!force_release) {
|
||||
if (mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseState(NULL, NULL) != 0)) {
|
||||
if (!mouse->relative_mode) {
|
||||
capture_window = SDL_GetKeyboardFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (capture_window != mouse->capture_window) {
|
||||
if (mouse->capture_window) {
|
||||
mouse->CaptureMouse(NULL);
|
||||
mouse->capture_window->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
|
||||
mouse->capture_window = NULL;
|
||||
}
|
||||
|
||||
if (capture_window) {
|
||||
if (mouse->CaptureMouse(capture_window) < 0) {
|
||||
/* CaptureMouse() will have set an error */
|
||||
return -1;
|
||||
}
|
||||
capture_window->flags |= SDL_WINDOW_MOUSE_CAPTURE;
|
||||
}
|
||||
|
||||
mouse->capture_window = capture_window;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_CaptureMouse(SDL_bool enabled)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_Window *focusWindow;
|
||||
SDL_bool isCaptured;
|
||||
|
||||
if (!mouse->CaptureMouse) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
focusWindow = SDL_GetKeyboardFocus();
|
||||
|
||||
isCaptured = focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE);
|
||||
if (isCaptured == enabled) {
|
||||
return 0; /* already done! */
|
||||
if (enabled && SDL_GetKeyboardFocus() == NULL) {
|
||||
return SDL_SetError("No window has focus");
|
||||
}
|
||||
mouse->capture_desired = enabled;
|
||||
|
||||
if (enabled) {
|
||||
if (!focusWindow) {
|
||||
return SDL_SetError("No window has focus");
|
||||
} else if (mouse->CaptureMouse(focusWindow) == -1) {
|
||||
return -1; /* CaptureMouse() should call SetError */
|
||||
}
|
||||
focusWindow->flags |= SDL_WINDOW_MOUSE_CAPTURE;
|
||||
} else {
|
||||
if (mouse->CaptureMouse(NULL) == -1) {
|
||||
return -1; /* CaptureMouse() should call SetError */
|
||||
}
|
||||
focusWindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
}
|
||||
|
||||
SDL_Cursor *
|
||||
|
|
|
|||
|
|
@ -100,7 +100,12 @@ typedef struct
|
|||
SDL_bool touch_mouse_events;
|
||||
SDL_bool mouse_touch_events;
|
||||
SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */
|
||||
#if defined(__vita__)
|
||||
Uint8 vita_touch_mouse_device;
|
||||
#endif
|
||||
SDL_bool auto_capture;
|
||||
SDL_bool capture_desired;
|
||||
SDL_Window *capture_window;
|
||||
|
||||
/* Data for input source state */
|
||||
int num_sources;
|
||||
|
|
@ -132,6 +137,9 @@ extern void SDL_SetDefaultCursor(SDL_Cursor * cursor);
|
|||
/* Set the mouse focus window */
|
||||
extern void SDL_SetMouseFocus(SDL_Window * window);
|
||||
|
||||
/* Update the mouse capture window */
|
||||
extern int SDL_UpdateMouseCapture(SDL_bool force_release);
|
||||
|
||||
/* Send a mouse motion event */
|
||||
extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
|
||||
|
||||
|
|
|
|||
|
|
@ -265,8 +265,13 @@ SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window * window,
|
|||
|
||||
#if SYNTHESIZE_TOUCH_TO_MOUSE
|
||||
/* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
|
||||
/* SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */
|
||||
{
|
||||
#if defined(__vita__)
|
||||
if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2)) ) {
|
||||
#else
|
||||
if (mouse->touch_mouse_events) {
|
||||
#endif
|
||||
/* FIXME: maybe we should only restrict to a few SDL_TouchDeviceType */
|
||||
if (id != SDL_MOUSE_TOUCHID) {
|
||||
if (window) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue