|
@@ -296,7 +296,7 @@ static void WIN_CheckRawMouseButtons(Uint64 timestamp, HANDLE hDevice, ULONG raw
|
|
|
|
|
|
static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data)
|
|
|
{
|
|
|
- SDL_MouseID mouseID = data->videodata->mouseID;
|
|
|
+ SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID;
|
|
|
Uint32 mouseFlags;
|
|
|
SHORT keyState;
|
|
|
SDL_bool swapButtons;
|
|
@@ -367,7 +367,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
|
|
|
if (!SDL_GetMouse()->relative_mode) {
|
|
|
GetCursorPos(&cursorPos);
|
|
|
ScreenToClient(hwnd, &cursorPos);
|
|
|
- SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, data->videodata->mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
+ SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
}
|
|
|
|
|
|
WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data);
|
|
@@ -508,9 +508,9 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
}
|
|
|
|
|
|
if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) {
|
|
|
- SDL_SendKeyboardKey(0, data->keyboardID, SDL_PRESSED, scanCode);
|
|
|
+ SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, scanCode);
|
|
|
} else {
|
|
|
- SDL_SendKeyboardKey(0, data->keyboardID, SDL_RELEASED, scanCode);
|
|
|
+ SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, scanCode);
|
|
|
|
|
|
/* If the key was down prior to our hook being installed, allow the
|
|
|
key up message to pass normally the first time. This ensures other
|
|
@@ -752,7 +752,6 @@ static void GetDeviceName(HDEVINFO devinfo, const char *instance, char *name, si
|
|
|
|
|
|
void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_check)
|
|
|
{
|
|
|
- SDL_VideoData *data = _this->driverdata;
|
|
|
PRAWINPUTDEVICELIST raw_devices = NULL;
|
|
|
UINT raw_device_count = 0;
|
|
|
int old_keyboard_count = 0;
|
|
@@ -864,22 +863,12 @@ void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, SDL_bool initial_c
|
|
|
SDL_RemoveKeyboard(old_keyboards[i]);
|
|
|
}
|
|
|
}
|
|
|
- if (new_keyboard_count > 0) {
|
|
|
- data->keyboardID = new_keyboards[0];
|
|
|
- } else {
|
|
|
- data->keyboardID = 0;
|
|
|
- }
|
|
|
|
|
|
for (int i = old_mouse_count; i--;) {
|
|
|
if (!HasDeviceID(old_mice[i], new_mice, new_mouse_count)) {
|
|
|
SDL_RemoveMouse(old_mice[i]);
|
|
|
}
|
|
|
}
|
|
|
- if (new_mouse_count > 0) {
|
|
|
- data->mouseID = new_mice[0];
|
|
|
- } else {
|
|
|
- data->mouseID = 0;
|
|
|
- }
|
|
|
|
|
|
SDL_free(old_keyboards);
|
|
|
SDL_free(old_mice);
|
|
@@ -1001,7 +990,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
/* Only generate mouse events for real mouse */
|
|
|
if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
|
|
lParam != data->last_pointer_update) {
|
|
|
- SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, SDL_FALSE, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam));
|
|
|
+ SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam));
|
|
|
}
|
|
|
}
|
|
|
} break;
|
|
@@ -1023,7 +1012,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
if (!mouse->relative_mode || mouse->relative_mode_warp) {
|
|
|
if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
|
|
lParam != data->last_pointer_update) {
|
|
|
- WIN_CheckWParamMouseButtons(WIN_GetEventTimestamp(), wParam, data, data->videodata->mouseID);
|
|
|
+ WIN_CheckWParamMouseButtons(WIN_GetEventTimestamp(), wParam, data, SDL_GLOBAL_MOUSE_ID);
|
|
|
}
|
|
|
}
|
|
|
} break;
|
|
@@ -1061,9 +1050,9 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
short amount = GET_WHEEL_DELTA_WPARAM(wParam);
|
|
|
float fAmount = (float)amount / WHEEL_DELTA;
|
|
|
if (msg == WM_MOUSEWHEEL) {
|
|
|
- SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL);
|
|
|
+ SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL);
|
|
|
} else {
|
|
|
- SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL);
|
|
|
+ SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL);
|
|
|
}
|
|
|
} break;
|
|
|
|
|
@@ -1076,13 +1065,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
ScreenToClient(hwnd, &cursorPos);
|
|
|
mouse = SDL_GetMouse();
|
|
|
if (!mouse->was_touch_mouse_events) { /* we're not a touch handler causing a mouse leave? */
|
|
|
- SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
+ SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
} else { /* touch handling? */
|
|
|
mouse->was_touch_mouse_events = SDL_FALSE; /* not anymore */
|
|
|
if (mouse->touch_mouse_events) { /* convert touch to mouse events */
|
|
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
} else { /* normal handling */
|
|
|
- SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, data->videodata->mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
+ SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1115,7 +1104,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
}
|
|
|
|
|
|
if (code != SDL_SCANCODE_UNKNOWN) {
|
|
|
- SDL_SendKeyboardKey(WIN_GetEventTimestamp(), data->videodata->keyboardID, SDL_PRESSED, code);
|
|
|
+ SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, code);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1131,9 +1120,9 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
|
|
|
if (code != SDL_SCANCODE_UNKNOWN) {
|
|
|
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
|
|
keyboardState[code] == SDL_RELEASED) {
|
|
|
- SDL_SendKeyboardKey(WIN_GetEventTimestamp(), data->videodata->keyboardID, SDL_PRESSED, code);
|
|
|
+ SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, SDL_PRESSED, code);
|
|
|
}
|
|
|
- SDL_SendKeyboardKey(WIN_GetEventTimestamp(), data->videodata->keyboardID, SDL_RELEASED, code);
|
|
|
+ SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, code);
|
|
|
}
|
|
|
}
|
|
|
returnCode = 0;
|
|
@@ -1850,7 +1839,7 @@ static void WIN_UpdateMouseCapture()
|
|
|
|
|
|
if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) {
|
|
|
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
|
|
- SDL_MouseID mouseID = data->videodata->mouseID;
|
|
|
+ SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID;
|
|
|
|
|
|
SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, SDL_FALSE, (float)cursorPos.x, (float)cursorPos.y);
|
|
|
SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED,
|
|
@@ -2000,10 +1989,10 @@ void WIN_PumpEvents(SDL_VideoDevice *_this)
|
|
|
and if we think a key is pressed when Windows doesn't, unstick it in SDL's state. */
|
|
|
keystate = SDL_GetKeyboardState(NULL);
|
|
|
if ((keystate[SDL_SCANCODE_LSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_LSHIFT) & 0x8000)) {
|
|
|
- SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
|
|
+ SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
|
|
}
|
|
|
if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
|
|
|
- SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
|
|
+ SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
|
|
}
|
|
|
|
|
|
/* The Windows key state gets lost when using Windows+Space or Windows+G shortcuts and
|
|
@@ -2012,10 +2001,10 @@ void WIN_PumpEvents(SDL_VideoDevice *_this)
|
|
|
focusWindow = SDL_GetKeyboardFocus();
|
|
|
if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) {
|
|
|
if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) {
|
|
|
- SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_LGUI);
|
|
|
+ SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_LGUI);
|
|
|
}
|
|
|
if ((keystate[SDL_SCANCODE_RGUI] == SDL_PRESSED) && !(GetKeyState(VK_RWIN) & 0x8000)) {
|
|
|
- SDL_SendKeyboardKey(0, _this->driverdata->keyboardID, SDL_RELEASED, SDL_SCANCODE_RGUI);
|
|
|
+ SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, SDL_RELEASED, SDL_SCANCODE_RGUI);
|
|
|
}
|
|
|
}
|
|
|
|