From 9c477c6bd927de5b8015597c7bfa8f0e8a5417f8 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Mon, 17 Dec 2012 20:36:11 +0100 Subject: [PATCH 1/3] Possible fix for the linker problems on Ubuntu 12.04 64 bit --- neo/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 16253001..935ce253 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -1105,6 +1105,8 @@ else() idlib GL pthread + dl + rt ${SDLx_LIBRARY} ) endif() From dd987814f78855176a7c9e9f40010a171a9150be Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 18 Dec 2012 00:27:37 +0100 Subject: [PATCH 2/3] Fix cursor in menus it didn't work correctly because the mouse isn't grabbed (in contrast to dhewm3). It's fixed now by returning absolute coordinates when a menu is open, furthermore the cursor is now always hidden. --- neo/sys/sdl/sdl_events.cpp | 33 ++++++++++++++++++++++++++------- neo/sys/sdl/sdl_glimp.cpp | 12 +++++++++--- 2 files changed, 35 insertions(+), 10 deletions(-) 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 } From f3c4948b2fa9d87e36758594a050f5b44ef6571d Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 18 Dec 2012 01:07:45 +0100 Subject: [PATCH 3/3] R_GetModeListForDisplay() for SDL2 --- neo/sys/sdl/sdl_glimp.cpp | 67 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/neo/sys/sdl/sdl_glimp.cpp b/neo/sys/sdl/sdl_glimp.cpp index b11a8818..1c6635a2 100644 --- a/neo/sys/sdl/sdl_glimp.cpp +++ b/neo/sys/sdl/sdl_glimp.cpp @@ -447,14 +447,71 @@ R_GetModeListForDisplay */ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList& modeList ) { + assert( requestedDisplayNum >= 0 ); + modeList.Clear(); - #if SDL_VERSION_ATLEAST(2, 0, 0) - // RB: TODO didn't find SDL_ListModes API - FillStaticVidModes( modeList ); - return true; + // DG: SDL2 implementation + if( requestedDisplayNum >= SDL_GetNumVideoDisplays() ) + { + // requested invalid displaynum + return false; + } -#else + int numModes = SDL_GetNumDisplayModes( requestedDisplayNum ); + if( numModes > 1 ) + { + for( int i = 0; i < numModes; i++ ) + { + SDL_DisplayMode m; + int ret = SDL_GetDisplayMode( requestedDisplayNum, i, &m ); + if( ret != 0 ) + { + common->Warning( "Can't get video mode no %i, because of %s\n", i, SDL_GetError() ); + continue; + } + + vidMode_t mode; + mode.width = m.w; + mode.height = m.h; + mode.displayHz = m.refresh_rate ? m.refresh_rate : 60; // default to 60 if unknown (0) + modeList.AddUnique( mode ); + } + + if( modeList.Num() < 1 ) + { + common->Warning( "Couldn't get information for a single video mode, using default ones..!\n" ); + FillStaticVidModes( modeList ); + } + + // sort with lowest resolution first + modeList.SortWithTemplate( idSort_VidMode() ); + + return true; + } + else + { + common->Warning( "Can't get Video Info!\n" ); + if( numModes < 0 ) + { + common->Warning( "Reason was: %s\n", SDL_GetError() ); + } + FillStaticVidModes( modeList ); + return true; + } + + return true; + // DG end + +#else // SDL 1 + + // DG: SDL1 only knows of one display - some functions rely on + // R_GetModeListForDisplay() returning false for invalid displaynum to iterate all displays + if( requestedDisplayNum >= 1 ) + { + return false; + } + // DG end bool verbose = false;