Fixed bug 2368 - Security Software is blocking RegisterRawInputDevices()
authorSam Lantinga <slouken@libsdl.org>
Sat, 01 Mar 2014 09:59:06 -0800
changeset 82696e18328e25e0
parent 8268 3f8410f20405
child 8270 75a296e647e7
Fixed bug 2368 - Security Software is blocking RegisterRawInputDevices()

Yamagi

A customer of mine had the strange problem, that SDL_SetRelativeMouseMode() was failing for him on Windows 7. Luckily he was willing to provide some debug informations. We could track this problem down to RegisterRawInputDevices() failing due to security software running on his system (Norton Internet Security to be precise, but there are reports of similar problems with other products. For example [1]). Working around this issue with SDL_WarpMouseInWindow() is easy, and while I don't think that SDL2 can provide an internal workaround it would be really nice and helpfull if this could be documentated somewhere.

1: http://forums.codeguru.com/showthread.php?498374-How-to-run-a-very-long-SQL-statement
src/events/SDL_mouse.c
src/video/windows/SDL_windowsmouse.c
     1.1 --- a/src/events/SDL_mouse.c	Sat Mar 01 09:50:52 2014 -0800
     1.2 +++ b/src/events/SDL_mouse.c	Sat Mar 01 09:59:06 2014 -0800
     1.3 @@ -538,7 +538,10 @@
     1.4      } else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
     1.5          mouse->relative_mode_warp = SDL_TRUE;
     1.6      } else if (mouse->SetRelativeMouseMode(enabled) < 0) {
     1.7 -        return -1;
     1.8 +        if (enabled) {
     1.9 +            // Fall back to warp mode if native relative mode failed
    1.10 +            mouse->relative_mode_warp = SDL_TRUE;
    1.11 +        }
    1.12      }
    1.13      mouse->relative_mode = enabled;
    1.14  
     2.1 --- a/src/video/windows/SDL_windowsmouse.c	Sat Mar 01 09:50:52 2014 -0800
     2.2 +++ b/src/video/windows/SDL_windowsmouse.c	Sat Mar 01 09:59:06 2014 -0800
     2.3 @@ -210,8 +210,8 @@
     2.4      /* (Un)register raw input for mice */
     2.5      if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
     2.6  
     2.7 -        /* Only return an error when registering. If we unregister and fail, then
     2.8 -        it's probably that we unregistered twice. That's OK. */
     2.9 +        /* Only return an error when registering. If we unregister and fail,
    2.10 +           then it's probably that we unregistered twice. That's OK. */
    2.11          if (enabled) {
    2.12              return SDL_Unsupported();
    2.13          }