Browse Source

engine: dirty sdl1.2 port

pull/2/head
Alibek Omarov 5 years ago
parent
commit
9e99a2bc37
  1. 15
      common/defaults.h
  2. 4
      engine/client/cl_game.c
  3. 2
      engine/client/cl_main.c
  4. 8
      engine/client/input.c
  5. 4
      engine/client/vgui/vgui_draw.c
  6. 14
      engine/common/host.c
  7. 2
      engine/common/system.c

15
common/defaults.h

@ -27,17 +27,22 @@ SETUP BACKENDS DEFINITIONS @@ -27,17 +27,22 @@ SETUP BACKENDS DEFINITIONS
*/
#ifndef XASH_DEDICATED
#ifdef XASH_SDL
#if XASH_SDL == 2
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_SDL
#endif
#else
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_LINUX
#endif
#endif
#ifdef XASH_SDL
// by default, use SDL subsystems
#ifndef XASH_VIDEO
#define XASH_VIDEO VIDEO_SDL
#endif // XASH_VIDEO
#ifndef XASH_TIMER
#define XASH_TIMER TIMER_SDL
#endif
#ifndef XASH_INPUT
#define XASH_INPUT INPUT_SDL
#endif

4
engine/client/cl_game.c

@ -1988,7 +1988,7 @@ static int pfnGetWindowCenterX( void ) @@ -1988,7 +1988,7 @@ static int pfnGetWindowCenterX( void )
}
#endif
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_GetWindowPosition( host.hWnd, &x, NULL );
#endif
@ -2013,7 +2013,7 @@ static int pfnGetWindowCenterY( void ) @@ -2013,7 +2013,7 @@ static int pfnGetWindowCenterY( void )
}
#endif
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_GetWindowPosition( host.hWnd, NULL, &y );
#endif

2
engine/client/cl_main.c

@ -1938,7 +1938,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) @@ -1938,7 +1938,7 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
return;
}
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_ShowWindow( host.hWnd );
#endif
args = MSG_ReadString( msg );

8
engine/client/input.c

@ -194,7 +194,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) @@ -194,7 +194,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
else if( newstate == key_game )
{
// reset mouse pos, so cancel effect in game
#ifdef XASH_SDL
#if XASH_SDL == 2
if( CVAR_TO_BOOL(touch_enable) )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
@ -214,7 +214,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate ) @@ -214,7 +214,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( )))
{
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_SetWindowGrab(host.hWnd, SDL_FALSE);
if( clgame.dllFuncs.pfnLookEvent )
SDL_SetRelativeMouseMode( SDL_FALSE );
@ -316,7 +316,7 @@ void IN_DeactivateMouse( void ) @@ -316,7 +316,7 @@ void IN_DeactivateMouse( void )
}
in_mouseactive = false;
#ifdef XASH_SDL
#if XASH_SDL == 2
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
#endif
}
@ -416,7 +416,7 @@ void IN_MouseEvent( void ) @@ -416,7 +416,7 @@ void IN_MouseEvent( void )
}
else
{
#if defined(XASH_SDL) && !defined(_WIN32)
#if XASH_SDL == 2 && !defined(_WIN32)
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_ShowCursor( SDL_TRUE );
#endif

4
engine/client/vgui/vgui_draw.c

@ -72,7 +72,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y ) @@ -72,7 +72,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
void VGUI_InitCursors( void )
{
// load up all default cursors
#ifdef XASH_SDL
#if XASH_SDL == 2
s_pDefaultCursor[dc_none] = NULL;
s_pDefaultCursor[dc_arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
s_pDefaultCursor[dc_ibeam] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
@ -108,7 +108,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor ) @@ -108,7 +108,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
break;
}
#ifdef XASH_SDL
#if XASH_SDL == 2
/// TODO: platform cursors
if( CVAR_TO_BOOL( touch_emulate ) )

14
engine/common/host.c

@ -323,7 +323,7 @@ void Host_MemStats_f( void ) @@ -323,7 +323,7 @@ void Host_MemStats_f( void )
void Host_Minimize_f( void )
{
#ifdef XASH_SDL
#if XASH_SDL == 2
if( host.hWnd ) SDL_MinimizeWindow( host.hWnd );
#endif
}
@ -733,7 +733,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha @@ -733,7 +733,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
#if TARGET_OS_IOS
const char *IOS_GetDocsDir();
Q_strncpy( host.rootdir, IOS_GetDocsDir(), sizeof(host.rootdir) );
#elif defined(XASH_SDL)
#elif XASH_SDL == 2
char *szBasePath;
if( !( szBasePath = SDL_GetBasePath() ) )
@ -817,15 +817,21 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha @@ -817,15 +817,21 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
// should work even if it failed
SDL_Init( SDL_INIT_TIMER );
#ifndef SDL_INIT_EVENTS
#define SDL_INIT_EVENTS 0
#endif
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) )
{
Sys_Warn( "SDL_Init failed: %s", SDL_GetError() );
host.type = HOST_DEDICATED;
}
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
#if XASH_SDL == 2
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
SDL_StopTextInput();
#endif
#endif // XASH_SDL == 2
#endif // XASH_SDL
if ( !host.rootdir[0] || SetCurrentDirectory( host.rootdir ) != 0)
Con_Reportf( "%s is working directory now\n", host.rootdir );

2
engine/common/system.c

@ -426,7 +426,7 @@ void Sys_Error( const char *error, ... ) @@ -426,7 +426,7 @@ void Sys_Error( const char *error, ... )
if( !Host_IsDedicated() )
{
#ifdef XASH_SDL
#if XASH_SDL == 2
if( host.hWnd ) SDL_HideWindow( host.hWnd );
#endif
}

Loading…
Cancel
Save