LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_SETCURSOR) { if (LOWORD(lParam) == HTCLIENT && !MouseShouldBeGrabbed()) { SetCursor(LoadCursor(NULL, IDC_ARROW)); return true; } } else if (msg == WM_SYSCOMMAND) { if ((wParam & 0xfff0) == SC_MAXIMIZE) { ToggleFullScreen(); return true; } else if ((wParam & 0xfff0) == SC_KEYMENU) return false; } else if (msg == WM_SYSKEYDOWN && wParam == VK_RETURN && !(lParam & 0x40000000)) { ToggleFullScreen(); return true; } else if (msg == WM_DEVICECHANGE) I_InitGamepad(); return CallWindowProc(oldProc, hwnd, msg, wParam, lParam); }
static void I_ReadMouse(void) { int x, y; event_t ev; SDL_GetRelativeMouseState(&x, &y); if (x != 0 || y != 0) { ev.type = ev_mouse; ev.data1 = mouse_button_state; ev.data2 = AccelerateMouse(x); if (!novert) { ev.data3 = -AccelerateMouse(y); } else { ev.data3 = 0; } D_PostEvent(&ev); } if (MouseShouldBeGrabbed()) { CenterMouse(); } }
// // Read the change in mouse state to generate mouse motion events // // This is to combine all mouse movement for a tic into one mouse // motion event. static void I_ReadMouse(void) { static int mouse_currently_grabbed = true; int x, y; event_t ev; if (!usemouse) return; if (!MouseShouldBeGrabbed()) { mouse_currently_grabbed = false; return; } if (!mouse_currently_grabbed && !desired_fullscreen) { CenterMouse(); mouse_currently_grabbed = true; } SDL_GetRelativeMouseState(&x, &y); if (x != 0 || y != 0) { ev.type = ev_mouse; ev.data1 = I_SDLtoDoomMouseState(SDL_GetMouseState(NULL, NULL)); ev.data2 = x << 5; ev.data3 = (-y) << 5; D_PostEvent(&ev); } CenterMouse(); }
// // UpdateGrab (From chocolate-doom) // static void UpdateGrab(void) { bool grab = MouseShouldBeGrabbed(); if (grab && !mousegrabbed) { SetCursorState(false); SDL_WM_GrabInput(SDL_GRAB_ON); // Warp the mouse back to the middle of the screen if(screen) SDL_WarpMouse(screen->width/ 2, screen->height / 2); // eat all pending input from outside the game SDL_Event ev; while (SDL_PollEvent(&ev)); } else if (!grab && mousegrabbed) { SetCursorState(true); SDL_WM_GrabInput(SDL_GRAB_OFF); } mousegrabbed = grab; }
static void UpdateGrab(void) { static boolean currently_grabbed = false; boolean grab; grab = MouseShouldBeGrabbed(); if (screensaver_mode) { // Hide the cursor in screensaver mode SetShowCursor(false); } else if (grab && !currently_grabbed) { SetShowCursor(false); CenterMouse(); } else if (!grab && currently_grabbed) { SetShowCursor(true); // When releasing the mouse from grab, warp the mouse cursor to // the bottom-right of the screen. This is a minimally distracting // place for it to appear - we may only have released the grab // because we're at an end of level intermission screen, for // example. SDL_WarpMouse(screen->w - 16, screen->h - 16); SDL_GetRelativeMouseState(NULL, NULL); } currently_grabbed = grab; }
// // UpdateGrab (From chocolate-doom) // static void UpdateGrab(void) { bool grab = MouseShouldBeGrabbed(); if (grab && !mousegrabbed) { SetCursorState(false); SDL_WM_GrabInput(SDL_GRAB_ON); // Warp the mouse back to the middle of the screen if(screen) SDL_WarpMouse(screen->width/ 2, screen->height / 2); I_FlushInput(); } else if (!grab && mousegrabbed) { SetCursorState(true); SDL_WM_GrabInput(SDL_GRAB_OFF); } #if defined WIN32 && !defined _XBOX if (Args.CheckParm ("-gdi")) { if (grab) FixGDIMouseInput(); else RestoreGDIMouseSettings(); } #endif mousegrabbed = grab; }
static void UpdateGrab(void) { static boolean currently_grabbed = false; boolean grab; grab = MouseShouldBeGrabbed(); if (screensaver_mode) { // Hide the cursor in screensaver mode SDL_SetCursor(cursors[0]); } else if (grab && !currently_grabbed) { SDL_SetCursor(cursors[0]); SDL_WM_GrabInput(SDL_GRAB_ON); } else if (!grab && currently_grabbed) { SDL_SetCursor(cursors[1]); SDL_WM_GrabInput(SDL_GRAB_OFF); } currently_grabbed = grab; }
static void I_ReadMouse(void) { int x, y; event_t ev; #if SDL_VERSION_ATLEAST(1, 3, 0) SDL_GetRelativeMouseState(0, &x, &y); #else SDL_GetRelativeMouseState(&x, &y); #endif if (x != 0 || y != 0) { ev.type = ev_mouse; ev.data1 = MouseButtonState(); ev.data2 = AccelerateMouse(x); ev.data3 = -AccelerateMouse(y); D_PostEvent(&ev); } if (MouseShouldBeGrabbed()) { CenterMouse(); } }
void UpdateGrab(void) { static dboolean currently_grabbed = false; dboolean grab; grab = MouseShouldBeGrabbed(); if (grab && !currently_grabbed) { ActivateMouse(); } if (!grab && currently_grabbed) { DeactivateMouse(); } currently_grabbed = grab; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_SETCURSOR) { if (LOWORD(lParam) == HTCLIENT && !MouseShouldBeGrabbed()) { SetCursor(LoadCursor(NULL, IDC_ARROW)); return true; } } else if (msg == WM_SYSCOMMAND) { if ((wParam & 0xFFF0) == SC_MAXIMIZE) { I_ToggleFullscreen(); return true; } else if ((wParam & 0xFFF0) == SC_KEYMENU) return false; } else if (msg == WM_SYSKEYDOWN && wParam == VK_RETURN && !(lParam & 0x40000000)) { I_ToggleFullscreen(); return true; } else if (msg == WM_DEVICECHANGE) I_InitGamepad(); else if (msg == WM_SIZE && !vid_fullscreen) blitfunc(); else if (msg == WM_GETMINMAXINFO) { LPMINMAXINFO minmaxinfo = (LPMINMAXINFO)lParam; minmaxinfo->ptMinTrackSize.x = ORIGINALWIDTH + windowborderwidth; minmaxinfo->ptMinTrackSize.y = ORIGINALWIDTH * 3 / 4 + windowborderheight; return false; } return CallWindowProc(oldProc, hwnd, msg, wParam, lParam); }
// // UpdateGrab (From chocolate-doom) // static void UpdateGrab(void) { bool grab; grab = MouseShouldBeGrabbed(); if (grab && !mousegrabbed) { if(screen) SDL_WarpMouse(screen->width/ 2, screen->height / 2); SetCursorState(false); SDL_WM_GrabInput(SDL_GRAB_ON); flushmouse = true; } else if (!grab && mousegrabbed) { SetCursorState(true); SDL_WM_GrabInput(SDL_GRAB_OFF); } mousegrabbed = grab; }
// // UpdateGrab // // haleyjd 10/08/05: from Chocolate DOOM // void UpdateGrab(SDL_Window *window) { static bool currently_grabbed = false; bool grab; grab = MouseShouldBeGrabbed(); if(grab && !currently_grabbed) { // When the cursor is hidden, grab the input. // Relative mode implicitly hides the cursor. SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetWindowGrab(window, SDL_TRUE); } else if(!grab && currently_grabbed) { int window_w, window_h; SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetWindowGrab(window, SDL_FALSE); // When releasing the mouse from grab, warp the mouse cursor to // the bottom-right of the screen. This is a minimally distracting // place for it to appear - we may only have released the grab // because we're at an end of level intermission screen, for // example. SDL_GetWindowSize(window, &window_w, &window_h); // Disable handling the mouse during this action SDL_EventState(SDL_MOUSEMOTION, SDL_DISABLE); SDL_WarpMouseInWindow(window, window_w - 16, window_h - 16); SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); } currently_grabbed = grab; }