mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-01-31 13:40:48 +00:00
Merge branch 'master' into glew
This commit is contained in:
commit
978044d491
3 changed files with 99 additions and 15 deletions
|
@ -1104,6 +1104,8 @@ else()
|
|||
idlib
|
||||
GL
|
||||
pthread
|
||||
dl
|
||||
rt
|
||||
${SDLx_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -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 ) );
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
@ -441,14 +447,71 @@ R_GetModeListForDisplay
|
|||
*/
|
||||
bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>& 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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue