mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Fixed relative mouse mode with multiple windows.
The window cursor clipping will be taken care of when SDL_UpdateWindowGrab() is called.
This commit is contained in:
parent
54debf84e4
commit
973d890b83
@ -196,16 +196,11 @@ static int
|
||||
WIN_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */
|
||||
HWND hWnd;
|
||||
hWnd = GetActiveWindow();
|
||||
|
||||
rawMouse.hwndTarget = hWnd;
|
||||
if (!enabled) {
|
||||
rawMouse.dwFlags |= RIDEV_REMOVE;
|
||||
rawMouse.hwndTarget = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* (Un)register raw input for mice */
|
||||
if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
|
||||
|
||||
@ -215,25 +210,6 @@ WIN_SetRelativeMouseMode(SDL_bool enabled)
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
LONG cx, cy;
|
||||
RECT rect;
|
||||
GetWindowRect(hWnd, &rect);
|
||||
|
||||
cx = (rect.left + rect.right) / 2;
|
||||
cy = (rect.top + rect.bottom) / 2;
|
||||
|
||||
/* Make an absurdly small clip rect */
|
||||
rect.left = cx-1;
|
||||
rect.right = cx+1;
|
||||
rect.top = cy-1;
|
||||
rect.bottom = cy+1;
|
||||
|
||||
ClipCursor(&rect);
|
||||
} else {
|
||||
ClipCursor(NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user