| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | misrepresented as being the original software. |
| | | 3. This notice may not be removed or altered from any source distribution. |
| | | */ |
| | | #include "SDL_config.h" |
| | | #include "../../SDL_internal.h" |
| | | |
| | | #if SDL_VIDEO_DRIVER_WINDOWS |
| | | |
| | |
| | | static void |
| | | WIN_WarpMouse(SDL_Window * window, int x, int y) |
| | | { |
| | | HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; |
| | | SDL_WindowData *data = (SDL_WindowData *)window->driverdata; |
| | | HWND hwnd = data->hwnd; |
| | | POINT pt; |
| | | |
| | | /* Don't warp the mouse while we're doing a modal interaction */ |
| | | if (data->in_title_click || data->in_modal_loop) { |
| | | return; |
| | | } |
| | | |
| | | pt.x = x; |
| | | pt.y = y; |
| | |
| | | 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) { |
| | | if (!enabled) { |
| | | rawMouse.dwFlags |= RIDEV_REMOVE; |
| | | rawMouse.hwndTarget = NULL; |
| | | } |
| | | |
| | | |
| | | /* (Un)register raw input for mice */ |
| | | if(RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) { |
| | | if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) { |
| | | |
| | | /* Only return an error when registering. If we unregister and fail, then |
| | | it's probably that we unregistered twice. That's OK. */ |
| | | if(enabled) { |
| | | /* Only return an error when registering. If we unregister and fail, |
| | | then it's probably that we unregistered twice. That's OK. */ |
| | | if (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; |
| | | } |
| | | |
| | |
| | | mouse->SetRelativeMouseMode = WIN_SetRelativeMouseMode; |
| | | |
| | | SDL_SetDefaultCursor(WIN_CreateDefaultCursor()); |
| | | |
| | | SDL_SetDoubleClickTime(GetDoubleClickTime()); |
| | | } |
| | | |
| | | void |