mirror of https://github.com/encounter/SDL.git
Fixed Windows relative mouse coordinates when capturing the mouse over RDP
This commit is contained in:
parent
0c26373842
commit
13c4d5e7e3
|
@ -586,16 +586,22 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
||||||
} else {
|
} else {
|
||||||
/* synthesize relative moves from the abs position */
|
/* synthesize relative moves from the abs position */
|
||||||
static SDL_Point initialMousePoint;
|
static SDL_Point lastMousePoint;
|
||||||
if (initialMousePoint.x == 0 && initialMousePoint.y == 0) {
|
SDL_bool virtual_desktop = (rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) ? SDL_TRUE : SDL_FALSE;
|
||||||
initialMousePoint.x = rawmouse->lLastX;
|
int w = GetSystemMetrics(virtual_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN);
|
||||||
initialMousePoint.y = rawmouse->lLastY;
|
int h = GetSystemMetrics(virtual_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN);
|
||||||
|
int x = (int)(((float)rawmouse->lLastX / 65535.0f) * w);
|
||||||
|
int y = (int)(((float)rawmouse->lLastY / 65535.0f) * h);
|
||||||
|
|
||||||
|
if (lastMousePoint.x == 0 && lastMousePoint.y == 0) {
|
||||||
|
lastMousePoint.x = x;
|
||||||
|
lastMousePoint.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SendMouseMotion(data->window, 0, 1, (int)(rawmouse->lLastX-initialMousePoint.x), (int)(rawmouse->lLastY-initialMousePoint.y));
|
SDL_SendMouseMotion(data->window, 0, 1, (int)(x-lastMousePoint.x), (int)(y-lastMousePoint.y));
|
||||||
|
|
||||||
initialMousePoint.x = rawmouse->lLastX;
|
lastMousePoint.x = x;
|
||||||
initialMousePoint.y = rawmouse->lLastY;
|
lastMousePoint.y = y;
|
||||||
}
|
}
|
||||||
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data);
|
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data);
|
||||||
} else if (isCapture) {
|
} else if (isCapture) {
|
||||||
|
|
Loading…
Reference in New Issue