early-access version 1988
This commit is contained in:
+37
-20
@@ -294,31 +294,31 @@ WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL_MouseID mou
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data)
|
||||
WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID)
|
||||
{
|
||||
if (rawButtons != data->mouse_button_flags) {
|
||||
Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL);
|
||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_1_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_1_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_1_UP), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_1_UP), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_2_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_2_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_2_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_2_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_2_UP), mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_2_UP), mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_3_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_3_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_3_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_3_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_3_UP), mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_3_UP), mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_4_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_4_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_X1, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_4_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_X1, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_4_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_4_UP), mouseFlags, swapButtons, data, SDL_BUTTON_X1, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_4_UP), mouseFlags, swapButtons, data, SDL_BUTTON_X1, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_5_DOWN))
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_5_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_X2, 0);
|
||||
WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_5_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_X2, mouseID);
|
||||
if ((rawButtons & RI_MOUSE_BUTTON_5_UP))
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_5_UP), mouseFlags, swapButtons, data, SDL_BUTTON_X2, 0);
|
||||
WIN_CheckWParamMouseButton(!(rawButtons & RI_MOUSE_BUTTON_5_UP), mouseFlags, swapButtons, data, SDL_BUTTON_X2, mouseID);
|
||||
data->mouse_button_flags = rawButtons;
|
||||
}
|
||||
}
|
||||
@@ -714,15 +714,17 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
/* Mouse data (ignoring synthetic mouse events generated for touchscreens) */
|
||||
if (inp.header.dwType == RIM_TYPEMOUSE) {
|
||||
SDL_MouseID mouseID;
|
||||
if (SDL_GetNumTouchDevices() > 0 &&
|
||||
(GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) {
|
||||
break;
|
||||
}
|
||||
mouseID = (SDL_MouseID)(uintptr_t)inp.header.hDevice;
|
||||
if (isRelative) {
|
||||
RAWMOUSE* rawmouse = &inp.data.mouse;
|
||||
|
||||
if ((rawmouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) {
|
||||
SDL_SendMouseMotion(data->window, 0, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
||||
SDL_SendMouseMotion(data->window, mouseID, 1, (int)rawmouse->lLastX, (int)rawmouse->lLastY);
|
||||
} else if (rawmouse->lLastX || rawmouse->lLastY) {
|
||||
/* synthesize relative moves from the abs position */
|
||||
static SDL_Point lastMousePoint;
|
||||
@@ -737,12 +739,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
lastMousePoint.y = y;
|
||||
}
|
||||
|
||||
SDL_SendMouseMotion(data->window, 0, 1, (int)(x-lastMousePoint.x), (int)(y-lastMousePoint.y));
|
||||
SDL_SendMouseMotion(data->window, mouseID, 1, (int)(x-lastMousePoint.x), (int)(y-lastMousePoint.y));
|
||||
|
||||
lastMousePoint.x = x;
|
||||
lastMousePoint.y = y;
|
||||
}
|
||||
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data);
|
||||
WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID);
|
||||
} else if (isCapture) {
|
||||
/* we check for where Windows thinks the system cursor lives in this case, so we don't really lose mouse accel, etc. */
|
||||
POINT pt;
|
||||
@@ -758,12 +760,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
if(currentHnd != hwnd || pt.x < 0 || pt.y < 0 || pt.x > hwndRect.right || pt.y > hwndRect.right) {
|
||||
SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0;
|
||||
|
||||
SDL_SendMouseMotion(data->window, 0, 0, (int)pt.x, (int)pt.y);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
|
||||
SDL_SendMouseButton(data->window, 0, GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X2);
|
||||
SDL_SendMouseMotion(data->window, mouseID, 0, (int)pt.x, (int)pt.y);
|
||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT);
|
||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT);
|
||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1);
|
||||
SDL_SendMouseButton(data->window, mouseID, GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X2);
|
||||
}
|
||||
} else {
|
||||
SDL_assert(0 && "Shouldn't happen");
|
||||
@@ -961,6 +963,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
/* Fix our size to the current size */
|
||||
info = (MINMAXINFO *) lParam;
|
||||
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
|
||||
if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS) {
|
||||
int screenW = GetSystemMetrics(SM_CXSCREEN);
|
||||
int screenH = GetSystemMetrics(SM_CYSCREEN);
|
||||
info->ptMaxSize.x = SDL_max(w, screenW);
|
||||
info->ptMaxSize.y = SDL_max(h, screenH);
|
||||
info->ptMaxPosition.x = SDL_min(0, ((screenW - w) / 2));
|
||||
info->ptMaxPosition.y = SDL_min(0, ((screenH - h) / 2));
|
||||
}
|
||||
info->ptMinTrackSize.x = w + min_w;
|
||||
info->ptMinTrackSize.y = h + min_h;
|
||||
if (constrain_max_size) {
|
||||
@@ -1363,6 +1373,13 @@ WIN_PumpEvents(_THIS)
|
||||
if ((keystate[SDL_SCANCODE_RSHIFT] == SDL_PRESSED) && !(GetKeyState(VK_RSHIFT) & 0x8000)) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
|
||||
}
|
||||
/* The Windows key state gets lost when using Windows+Space or Windows+G shortcuts */
|
||||
if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
|
||||
}
|
||||
if ((keystate[SDL_SCANCODE_RGUI] == SDL_PRESSED) && !(GetKeyState(VK_RWIN) & 0x8000)) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
|
||||
}
|
||||
|
||||
/* Update the clipping rect in case someone else has stolen it */
|
||||
WIN_UpdateClipCursorForWindows();
|
||||
|
||||
+4
-1
@@ -31,7 +31,7 @@ HCURSOR SDL_cursor = NULL;
|
||||
|
||||
static int rawInputEnableCount = 0;
|
||||
|
||||
static int
|
||||
static int
|
||||
ToggleRawInput(SDL_bool enabled)
|
||||
{
|
||||
RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */
|
||||
@@ -57,6 +57,9 @@ ToggleRawInput(SDL_bool enabled)
|
||||
|
||||
/* (Un)register raw input for mice */
|
||||
if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
|
||||
/* Reset the enable count, otherwise subsequent enable calls will
|
||||
believe raw input is enabled */
|
||||
rawInputEnableCount = 0;
|
||||
|
||||
/* Only return an error when registering. If we unregister and fail,
|
||||
then it's probably that we unregistered twice. That's OK. */
|
||||
|
||||
@@ -108,7 +108,10 @@ WIN_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
|
||||
|
||||
if (_this->egl_data == NULL) {
|
||||
/* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */
|
||||
#if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 0, while the below lines function. */
|
||||
SDL_assert(!_this->gl_config.driver_loaded);
|
||||
#endif
|
||||
if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) {
|
||||
SDL_EGL_UnloadLibrary(_this);
|
||||
return -1;
|
||||
|
||||
+26
-37
@@ -162,7 +162,7 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags)
|
||||
top = HWND_NOTOPMOST;
|
||||
}
|
||||
|
||||
WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_TRUE);
|
||||
WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_TRUE);
|
||||
|
||||
data->expected_resize = SDL_TRUE;
|
||||
SetWindowPos(hwnd, top, x, y, w, h, flags);
|
||||
@@ -364,7 +364,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
return 0;
|
||||
#else
|
||||
return SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||
}
|
||||
#endif /* SDL_VIDEO_OPENGL_ES2 */
|
||||
|
||||
@@ -559,7 +559,7 @@ WIN_ShowWindow(_THIS, SDL_Window * window)
|
||||
DWORD style;
|
||||
HWND hwnd;
|
||||
int nCmdShow;
|
||||
|
||||
|
||||
hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
|
||||
nCmdShow = SW_SHOW;
|
||||
style = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
@@ -992,33 +992,12 @@ WIN_UpdateClipCursor(SDL_Window *window)
|
||||
|
||||
if ((mouse->relative_mode || (window->flags & SDL_WINDOW_MOUSE_GRABBED)) &&
|
||||
(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
|
||||
if (mouse->relative_mode && !mouse->relative_mode_warp) {
|
||||
if (GetWindowRect(data->hwnd, &rect)) {
|
||||
LONG cx, cy;
|
||||
|
||||
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;
|
||||
|
||||
if (SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
|
||||
if (ClipCursor(&rect)) {
|
||||
data->cursor_clipped_rect = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
|
||||
ClientToScreen(data->hwnd, (LPPOINT) & rect);
|
||||
ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
|
||||
if (SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
|
||||
if (ClipCursor(&rect)) {
|
||||
data->cursor_clipped_rect = rect;
|
||||
}
|
||||
if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
|
||||
ClientToScreen(data->hwnd, (LPPOINT) & rect);
|
||||
ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
|
||||
if (SDL_memcmp(&rect, &clipped_rect, sizeof(rect)) != 0) {
|
||||
if (ClipCursor(&rect)) {
|
||||
data->cursor_clipped_rect = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1085,17 +1064,27 @@ WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept)
|
||||
}
|
||||
|
||||
int
|
||||
WIN_FlashWindow(_THIS, SDL_Window * window, Uint32 flash_count)
|
||||
WIN_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation)
|
||||
{
|
||||
HWND hwnd;
|
||||
FLASHWINFO desc;
|
||||
|
||||
hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
SDL_zero(desc);
|
||||
desc.cbSize = sizeof(desc);
|
||||
desc.hwnd = hwnd;
|
||||
desc.dwFlags = FLASHW_TRAY;
|
||||
desc.uCount = flash_count; /* flash x times */
|
||||
desc.dwTimeout = 0;
|
||||
desc.hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
switch (operation) {
|
||||
case SDL_FLASH_CANCEL:
|
||||
desc.dwFlags = FLASHW_STOP;
|
||||
break;
|
||||
case SDL_FLASH_BRIEFLY:
|
||||
desc.dwFlags = FLASHW_TRAY;
|
||||
desc.uCount = 1;
|
||||
break;
|
||||
case SDL_FLASH_UNTIL_FOCUSED:
|
||||
desc.dwFlags = (FLASHW_TRAY | FLASHW_TIMERNOFG);
|
||||
break;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
FlashWindowEx(&desc);
|
||||
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
|
||||
extern void WIN_UpdateClipCursor(SDL_Window *window);
|
||||
extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||
extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
|
||||
extern int WIN_FlashWindow(_THIS, SDL_Window * window, Uint32 flash_count);
|
||||
extern int WIN_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation);
|
||||
|
||||
#endif /* SDL_windowswindow_h_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user