Renamed SDL_Get/SetRelativeMouseMode to SDL_Get/SetWindowRelativeMouseMode()
Fixes https://github.com/libsdl-org/SDL/issues/10041
This commit is contained in:
@@ -386,7 +386,6 @@ SDL3_0.0.0 {
|
||||
SDL_GetRectIntersectionFloat;
|
||||
SDL_GetRectUnion;
|
||||
SDL_GetRectUnionFloat;
|
||||
SDL_GetRelativeMouseMode;
|
||||
SDL_GetRelativeMouseState;
|
||||
SDL_GetRenderClipRect;
|
||||
SDL_GetRenderColorScale;
|
||||
@@ -485,6 +484,7 @@ SDL3_0.0.0 {
|
||||
SDL_GetWindowPixelFormat;
|
||||
SDL_GetWindowPosition;
|
||||
SDL_GetWindowProperties;
|
||||
SDL_GetWindowRelativeMouseMode;
|
||||
SDL_GetWindowSafeArea;
|
||||
SDL_GetWindowSize;
|
||||
SDL_GetWindowSizeInPixels;
|
||||
@@ -749,7 +749,6 @@ SDL3_0.0.0 {
|
||||
SDL_SetPointerProperty;
|
||||
SDL_SetPointerPropertyWithCleanup;
|
||||
SDL_SetPrimarySelectionText;
|
||||
SDL_SetRelativeMouseMode;
|
||||
SDL_SetRenderClipRect;
|
||||
SDL_SetRenderColorScale;
|
||||
SDL_SetRenderDrawBlendMode;
|
||||
@@ -795,6 +794,7 @@ SDL3_0.0.0 {
|
||||
SDL_SetWindowMouseRect;
|
||||
SDL_SetWindowOpacity;
|
||||
SDL_SetWindowPosition;
|
||||
SDL_SetWindowRelativeMouseMode;
|
||||
SDL_SetWindowResizable;
|
||||
SDL_SetWindowShape;
|
||||
SDL_SetWindowSize;
|
||||
|
||||
@@ -411,7 +411,6 @@
|
||||
#define SDL_GetRectIntersectionFloat SDL_GetRectIntersectionFloat_REAL
|
||||
#define SDL_GetRectUnion SDL_GetRectUnion_REAL
|
||||
#define SDL_GetRectUnionFloat SDL_GetRectUnionFloat_REAL
|
||||
#define SDL_GetRelativeMouseMode SDL_GetRelativeMouseMode_REAL
|
||||
#define SDL_GetRelativeMouseState SDL_GetRelativeMouseState_REAL
|
||||
#define SDL_GetRenderClipRect SDL_GetRenderClipRect_REAL
|
||||
#define SDL_GetRenderColorScale SDL_GetRenderColorScale_REAL
|
||||
@@ -510,6 +509,7 @@
|
||||
#define SDL_GetWindowPixelFormat SDL_GetWindowPixelFormat_REAL
|
||||
#define SDL_GetWindowPosition SDL_GetWindowPosition_REAL
|
||||
#define SDL_GetWindowProperties SDL_GetWindowProperties_REAL
|
||||
#define SDL_GetWindowRelativeMouseMode SDL_GetWindowRelativeMouseMode_REAL
|
||||
#define SDL_GetWindowSafeArea SDL_GetWindowSafeArea_REAL
|
||||
#define SDL_GetWindowSize SDL_GetWindowSize_REAL
|
||||
#define SDL_GetWindowSizeInPixels SDL_GetWindowSizeInPixels_REAL
|
||||
@@ -774,7 +774,6 @@
|
||||
#define SDL_SetPointerProperty SDL_SetPointerProperty_REAL
|
||||
#define SDL_SetPointerPropertyWithCleanup SDL_SetPointerPropertyWithCleanup_REAL
|
||||
#define SDL_SetPrimarySelectionText SDL_SetPrimarySelectionText_REAL
|
||||
#define SDL_SetRelativeMouseMode SDL_SetRelativeMouseMode_REAL
|
||||
#define SDL_SetRenderClipRect SDL_SetRenderClipRect_REAL
|
||||
#define SDL_SetRenderColorScale SDL_SetRenderColorScale_REAL
|
||||
#define SDL_SetRenderDrawBlendMode SDL_SetRenderDrawBlendMode_REAL
|
||||
@@ -820,6 +819,7 @@
|
||||
#define SDL_SetWindowMouseRect SDL_SetWindowMouseRect_REAL
|
||||
#define SDL_SetWindowOpacity SDL_SetWindowOpacity_REAL
|
||||
#define SDL_SetWindowPosition SDL_SetWindowPosition_REAL
|
||||
#define SDL_SetWindowRelativeMouseMode SDL_SetWindowRelativeMouseMode_REAL
|
||||
#define SDL_SetWindowResizable SDL_SetWindowResizable_REAL
|
||||
#define SDL_SetWindowShape SDL_SetWindowShape_REAL
|
||||
#define SDL_SetWindowSize SDL_SetWindowSize_REAL
|
||||
|
||||
@@ -431,7 +431,6 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectIntersection,(const SDL_Rect *a, const SDL_R
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectIntersectionFloat,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetRectUnion,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetRectUnionFloat,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRelativeMouseMode,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_MouseButtonFlags,SDL_GetRelativeMouseState,(float *a, float *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetRenderClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetRenderColorScale,(SDL_Renderer *a, float *b),(a,b),return)
|
||||
@@ -530,6 +529,7 @@ SDL_DYNAPI_PROC(float,SDL_GetWindowPixelDensity,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_PixelFormat,SDL_GetWindowPixelFormat,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetWindowPosition,(SDL_Window *a, int *b, int *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetWindowProperties,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowRelativeMouseMode,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetWindowSafeArea,(SDL_Window *a, SDL_Rect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetWindowSize,(SDL_Window *a, int *b, int *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetWindowSizeInPixels,(SDL_Window *a, int *b, int *c),(a,b,c),return)
|
||||
@@ -784,7 +784,6 @@ SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, in
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPointerProperty,(SDL_PropertiesID a, const char *b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPointerPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, SDL_CleanupPropertyCallback d, void *e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPrimarySelectionText,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetRelativeMouseMode,(SDL_bool a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetRenderClipRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetRenderColorScale,(SDL_Renderer *a, float b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode b),(a,b),return)
|
||||
@@ -830,6 +829,7 @@ SDL_DYNAPI_PROC(int,SDL_SetWindowMouseGrab,(SDL_Window *a, SDL_bool b),(a,b),ret
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowMouseRect,(SDL_Window *a, const SDL_Rect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowOpacity,(SDL_Window *a, float b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowPosition,(SDL_Window *a, int b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowRelativeMouseMode,(SDL_Window *a, SDL_bool b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetWindowSize,(SDL_Window *a, int b, int c),(a,b,c),return)
|
||||
|
||||
@@ -357,6 +357,9 @@ int SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UpdateRelativeMouseMode();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1393,6 +1393,17 @@ SDL_bool SDL_GetRelativeMouseMode(void)
|
||||
return mouse->relative_mode;
|
||||
}
|
||||
|
||||
void SDL_UpdateRelativeMouseMode(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_Window *focus = SDL_GetKeyboardFocus();
|
||||
SDL_bool relative_mode = (focus && (focus->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE));
|
||||
|
||||
if (relative_mode != mouse->relative_mode) {
|
||||
SDL_SetRelativeMouseMode(relative_mode);
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_UpdateMouseCapture(SDL_bool force_release)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
@@ -179,6 +179,11 @@ extern int SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID
|
||||
/* Warp the mouse within the window, potentially overriding relative mode */
|
||||
extern void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool ignore_relative_mode);
|
||||
|
||||
/* Relative mouse mode */
|
||||
extern int SDL_SetRelativeMouseMode(SDL_bool enabled);
|
||||
extern SDL_bool SDL_GetRelativeMouseMode(void);
|
||||
extern void SDL_UpdateRelativeMouseMode(void);
|
||||
|
||||
/* TODO RECONNECT: Set mouse state to "zero" */
|
||||
#if 0
|
||||
extern void SDL_ResetMouse(void);
|
||||
|
||||
@@ -2353,9 +2353,9 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
|
||||
}
|
||||
}
|
||||
if (withShift) {
|
||||
SDL_Window *current_win = SDL_GetKeyboardFocus();
|
||||
if (current_win) {
|
||||
const SDL_bool shouldCapture = !(SDL_GetWindowFlags(current_win) & SDL_WINDOW_MOUSE_CAPTURE);
|
||||
SDL_Window *window = SDL_GetWindowFromEvent(event);
|
||||
if (window) {
|
||||
const SDL_bool shouldCapture = !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_CAPTURE);
|
||||
const int rc = SDL_CaptureMouse(shouldCapture);
|
||||
SDL_Log("%sapturing mouse %s!\n", shouldCapture ? "C" : "Unc", (rc == 0) ? "succeeded" : "failed");
|
||||
}
|
||||
@@ -2364,7 +2364,10 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
|
||||
case SDLK_R:
|
||||
if (withControl) {
|
||||
/* Ctrl-R toggle mouse relative mode */
|
||||
SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode());
|
||||
SDL_Window *window = SDL_GetWindowFromEvent(event);
|
||||
if (window) {
|
||||
SDL_SetWindowRelativeMouseMode(window, !SDL_GetWindowRelativeMouseMode(window));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDLK_T:
|
||||
|
||||
@@ -3780,6 +3780,35 @@ const SDL_Rect *SDL_GetWindowMouseRect(SDL_Window *window)
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_SetWindowRelativeMouseMode(SDL_Window *window, SDL_bool enabled)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (enabled == SDL_GetWindowRelativeMouseMode(window)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
window->flags |= SDL_WINDOW_MOUSE_RELATIVE_MODE;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_MOUSE_RELATIVE_MODE;
|
||||
}
|
||||
SDL_UpdateRelativeMouseMode();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_bool SDL_GetWindowRelativeMouseMode(SDL_Window *window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
|
||||
|
||||
if (window->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
@@ -5389,7 +5418,6 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
{
|
||||
int dummybutton;
|
||||
int retval = -1;
|
||||
SDL_bool relative_mode;
|
||||
SDL_bool show_cursor_prev;
|
||||
SDL_Window *current_window;
|
||||
SDL_MessageBoxData mbdata;
|
||||
@@ -5403,7 +5431,6 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
(void)SDL_AtomicIncRef(&SDL_messagebox_count);
|
||||
|
||||
current_window = SDL_GetKeyboardFocus();
|
||||
relative_mode = SDL_GetRelativeMouseMode();
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
show_cursor_prev = SDL_CursorVisible();
|
||||
@@ -5477,7 +5504,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
if (!show_cursor_prev) {
|
||||
SDL_HideCursor();
|
||||
}
|
||||
SDL_SetRelativeMouseMode(relative_mode);
|
||||
SDL_UpdateRelativeMouseMode();
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
|
||||
return retval;
|
||||
|
||||
Reference in New Issue
Block a user