mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-03-12 04:01:17 +01:00
Whoops, lost this in the merge.
This commit is contained in:
parent
84cb232067
commit
4318910e02
@ -614,6 +614,41 @@ SDL_GetRelativeMouseMode()
|
||||
return mouse->relative_mode;
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
SDL_Cursor *
|
||||
SDL_CreateCursor(const Uint8 * data, const Uint8 * mask,
|
||||
int w, int h, int hot_x, int hot_y)
|
||||
|
Loading…
Reference in New Issue
Block a user