diff --git a/neo/sys/sdl/sdl_events.cpp b/neo/sys/sdl/sdl_events.cpp index a7cf78cb..7fc5eabc 100644 --- a/neo/sys/sdl/sdl_events.cpp +++ b/neo/sys/sdl/sdl_events.cpp @@ -607,10 +607,16 @@ void Sys_GrabMouseCursor( bool grabIt ) int flags; if( grabIt ) - flags = GRAB_ENABLE | GRAB_HIDECURSOR | GRAB_SETSTATE; + { + // DG: disabling the cursor is now done once in GLimp_Init() because it should always be disabled + flags = GRAB_ENABLE | GRAB_SETSTATE; + // DG end + } else + { flags = GRAB_SETSTATE; - + } + GLimp_GrabInput( flags ); } @@ -678,8 +684,9 @@ sysEvent_t Sys_GetEvent() newmod |= KMOD_CAPS; SDL_SetModState( ( SDL_Keymod )newmod ); - - GLimp_GrabInput( GRAB_ENABLE | GRAB_REENABLE | GRAB_HIDECURSOR ); + // DG: disabling the cursor is now done once in GLimp_Init() because it should always be disabled + GLimp_GrabInput( GRAB_ENABLE | GRAB_REENABLE ); + // DG end break; } @@ -786,9 +793,21 @@ sysEvent_t Sys_GetEvent() #endif case SDL_MOUSEMOTION: - res.evType = SE_MOUSE; - res.evValue = ev.motion.xrel; - res.evValue2 = ev.motion.yrel; + // DG: return event with absolute mouse-coordinates when in menu + // to fix cursor problems in windowed mode + if( game && game->Shell_IsActive() ) + { + res.evType = SE_MOUSE_ABSOLUTE; + res.evValue = ev.motion.x; + res.evValue2 = ev.motion.y; + } + else // this is the old, default behavior + { + res.evType = SE_MOUSE; + res.evValue = ev.motion.xrel; + res.evValue2 = ev.motion.yrel; + } + // DG end mouse_polls.Append( mouse_poll_t( M_DELTAX, ev.motion.xrel ) ); mouse_polls.Append( mouse_poll_t( M_DELTAY, ev.motion.yrel ) ); diff --git a/neo/sys/sdl/sdl_glimp.cpp b/neo/sys/sdl/sdl_glimp.cpp index 7f311035..b11a8818 100644 --- a/neo/sys/sdl/sdl_glimp.cpp +++ b/neo/sys/sdl/sdl_glimp.cpp @@ -267,6 +267,10 @@ bool GLimp_Init( glimpParms_t parms ) QGL_Init( "nodriverlib" ); + // DG: disable cursor, we have two cursors in menu (because mouse isn't grabbed in menu) + SDL_ShowCursor( SDL_DISABLE ); + // DG end + return true; } @@ -374,11 +378,13 @@ void GLimp_GrabInput( int flags ) } #if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_ShowCursor( flags & GRAB_HIDECURSOR ? SDL_DISABLE : SDL_ENABLE ); - SDL_SetRelativeMouseMode( flags & GRAB_HIDECURSOR ? SDL_TRUE : SDL_FALSE ); + // DG: disabling the cursor is now done once in GLimp_Init() because it should always be disabled + + // DG: check for GRAB_ENABLE instead of GRAB_HIDECURSOR because we always wanna hide it + SDL_SetRelativeMouseMode( flags & GRAB_ENABLE ? SDL_TRUE : SDL_FALSE ); SDL_SetWindowGrab( window, grab ? SDL_TRUE : SDL_FALSE ); #else - SDL_ShowCursor( flags & GRAB_HIDECURSOR ? SDL_DISABLE : SDL_ENABLE ); + // DG end SDL_WM_GrabInput( grab ? SDL_GRAB_ON : SDL_GRAB_OFF ); #endif }