Fixed bug 4152 - Windows 10 v1803 update seems to have fixed the jumping mouse bug (see bug #3931.)
authorSam Lantinga <slouken@libsdl.org>
Sat, 05 May 2018 10:27:53 -0700
changeset 11955719dece50dde
parent 11954 bc2aba33ae1f
child 11956 f162f5d7798d
Fixed bug 4152 - Windows 10 v1803 update seems to have fixed the jumping mouse bug (see bug #3931.)
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Mon Apr 23 22:29:14 2018 -0700
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Sat May 05 10:27:53 2018 -0700
     1.3 @@ -359,11 +359,6 @@
     1.4      return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE);
     1.5  }
     1.6  
     1.7 -/* Win10 "Fall Creators Update" introduced the bug that SetCursorPos() (as used by SDL_WarpMouseInWindow())
     1.8 -   doesn't reliably generate WM_MOUSEMOVE events anymore (see #3931) which breaks relative mouse mode via warping.
     1.9 -   This is used to implement a workaround.. */
    1.10 -static SDL_bool isWin10FCUorNewer = SDL_FALSE;
    1.11 -
    1.12  LRESULT CALLBACK
    1.13  WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.14  {
    1.15 @@ -486,17 +481,6 @@
    1.16              if (!mouse->relative_mode || mouse->relative_mode_warp) {
    1.17                  SDL_MouseID mouseID = (((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) ? SDL_TOUCH_MOUSEID : 0);
    1.18                  SDL_SendMouseMotion(data->window, mouseID, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
    1.19 -                if (isWin10FCUorNewer && mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) {
    1.20 -                    /* To work around #3931, Win10 bug introduced in Fall Creators Update, where
    1.21 -                       SetCursorPos() (SDL_WarpMouseInWindow()) doesn't reliably generate mouse events anymore,
    1.22 -                       after each windows mouse event generate a fake event for the middle of the window
    1.23 -                       if relative_mode_warp is used */
    1.24 -                    int center_x = 0, center_y = 0;
    1.25 -                    SDL_GetWindowSize(data->window, &center_x, &center_y);
    1.26 -                    center_x /= 2;
    1.27 -                    center_y /= 2;
    1.28 -                    SDL_SendMouseMotion(data->window, mouseID, 0, center_x, center_y);
    1.29 -                }
    1.30              }
    1.31          }
    1.32          /* don't break here, fall through to check the wParam like the button presses */
    1.33 @@ -1074,43 +1058,6 @@
    1.34      }
    1.35  }
    1.36  
    1.37 -/* to work around #3931, a bug introduced in Win10 Fall Creators Update (build nr. 16299)
    1.38 -   we need to detect the windows version. this struct and the function below does that.
    1.39 -   usually this struct and the corresponding function (RtlGetVersion) are in <Ntddk.h>
    1.40 -   but here we just load it dynamically */
    1.41 -struct SDL_WIN_OSVERSIONINFOW {
    1.42 -    ULONG dwOSVersionInfoSize;
    1.43 -    ULONG dwMajorVersion;
    1.44 -    ULONG dwMinorVersion;
    1.45 -    ULONG dwBuildNumber;
    1.46 -    ULONG dwPlatformId;
    1.47 -    WCHAR szCSDVersion[128];
    1.48 -};
    1.49 -
    1.50 -static SDL_bool
    1.51 -IsWin10FCUorNewer(void)
    1.52 -{
    1.53 -    HMODULE handle = GetModuleHandleW(L"ntdll.dll");
    1.54 -    if (handle) {
    1.55 -        typedef LONG(WINAPI* RtlGetVersionPtr)(struct SDL_WIN_OSVERSIONINFOW*);
    1.56 -        RtlGetVersionPtr getVersionPtr = (RtlGetVersionPtr)GetProcAddress(handle, "RtlGetVersion");
    1.57 -        if (getVersionPtr != NULL) {
    1.58 -            struct SDL_WIN_OSVERSIONINFOW info;
    1.59 -            SDL_zero(info);
    1.60 -            info.dwOSVersionInfoSize = sizeof(info);
    1.61 -            if (getVersionPtr(&info) == 0) { /* STATUS_SUCCESS == 0 */
    1.62 -                if (   (info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber >= 16299)
    1.63 -                    || (info.dwMajorVersion == 10 && info.dwMinorVersion > 0)
    1.64 -                    || (info.dwMajorVersion > 10) )
    1.65 -                {
    1.66 -                    return SDL_TRUE;
    1.67 -                }
    1.68 -            }
    1.69 -        }
    1.70 -    }
    1.71 -    return SDL_FALSE;
    1.72 -}
    1.73 -
    1.74  static int app_registered = 0;
    1.75  LPTSTR SDL_Appname = NULL;
    1.76  Uint32 SDL_Appstyle = 0;
    1.77 @@ -1175,8 +1122,6 @@
    1.78          return SDL_SetError("Couldn't register application class");
    1.79      }
    1.80  
    1.81 -    isWin10FCUorNewer = IsWin10FCUorNewer();
    1.82 -
    1.83      app_registered = 1;
    1.84      return 0;
    1.85  }