mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 01:45:19 +01:00
engine: platform: refactor Platform_Init/Shutdown/GetNativeObject functions. They are now defined in the header, and call platform-specific functios that defined in platform code
This commit is contained in:
parent
c7d748e8df
commit
c16a10e6f3
@ -25,13 +25,6 @@ void Platform_SetClipboardText( const char *buffer, size_t size )
|
||||
|
||||
}
|
||||
|
||||
|
||||
void *Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void Platform_Vibrate(float life, char flags)
|
||||
{
|
||||
|
||||
@ -89,7 +82,7 @@ static void __interrupt __far timerhandler()
|
||||
// in_dos.c
|
||||
extern void __interrupt __far keyhandler( void );
|
||||
|
||||
void Platform_Init( void )
|
||||
void DOS_Init( void )
|
||||
{
|
||||
// save original vectors
|
||||
orig_int_1c = _dos_getvect( 0x1c );
|
||||
@ -104,7 +97,7 @@ void Platform_Init( void )
|
||||
}
|
||||
|
||||
|
||||
void Platform_Shutdown( void )
|
||||
void DOS_Shutdown( void )
|
||||
{
|
||||
// restore freq
|
||||
outp( 0x43, 0x34 );
|
||||
|
@ -30,15 +30,21 @@ GNU General Public License for more details.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
void Platform_Init( void );
|
||||
void Platform_Shutdown( void );
|
||||
double Platform_DoubleTime( void );
|
||||
void Platform_Sleep( int msec );
|
||||
void Platform_ShellExecute( const char *path, const char *parms );
|
||||
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow );
|
||||
qboolean Sys_DebuggerPresent( void ); // optional, see Sys_DebugBreak
|
||||
|
||||
#if XASH_POSIX
|
||||
void Posix_Daemonize( void );
|
||||
#endif
|
||||
|
||||
#if XASH_SDL
|
||||
void SDLash_Init( void );
|
||||
void SDLash_Shutdown( void );
|
||||
#endif
|
||||
|
||||
#if XASH_ANDROID
|
||||
const char *Android_GetAndroidID( void );
|
||||
const char *Android_LoadID( void );
|
||||
@ -49,6 +55,8 @@ int Android_GetKeyboardHeight( void );
|
||||
#endif
|
||||
|
||||
#if XASH_WIN32
|
||||
void Wcon_CreateConsole( void );
|
||||
void Wcon_DestroyConsole( void );
|
||||
void Platform_UpdateStatusLine( void );
|
||||
#else
|
||||
static inline void Platform_UpdateStatusLine( void ) { }
|
||||
@ -67,6 +75,62 @@ int PSVita_GetArgv( int in_argc, char **in_argv, char ***out_argv );
|
||||
void PSVita_InputUpdate( void );
|
||||
#endif
|
||||
|
||||
#if XASH_DOS
|
||||
void DOS_Init( void );
|
||||
void DOS_Shutdown( void );
|
||||
#endif
|
||||
|
||||
static inline void Platform_Init( void )
|
||||
{
|
||||
#if XASH_POSIX
|
||||
Posix_Daemonize( );
|
||||
#endif
|
||||
|
||||
#if XASH_WIN32
|
||||
Wcon_CreateConsole( );
|
||||
#endif
|
||||
|
||||
#if XASH_SDL
|
||||
SDLash_Init( );
|
||||
#endif
|
||||
|
||||
#if XASH_ANDROID
|
||||
Android_Init( );
|
||||
#elif XASH_NSWITCH
|
||||
NSwitch_Init( );
|
||||
#elif XASH_PSVITA
|
||||
PSVita_Init( );
|
||||
#elif XASH_DOS
|
||||
DOS_Init( );
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void Platform_Shutdown( void )
|
||||
{
|
||||
#if XASH_NSWITCH
|
||||
NSwitch_Shutdown( );
|
||||
#elif XASH_PSVITA
|
||||
PSVita_Shutdown( );
|
||||
#elif XASH_DOS
|
||||
DOS_Shutdown( );
|
||||
#endif
|
||||
|
||||
#if XASH_SDL
|
||||
SDLash_Shutdown( );
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void *Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
||||
#if XASH_ANDROID
|
||||
ptr = Android_GetNativeObject( name );
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
@ -146,23 +146,6 @@ void Posix_Daemonize( void )
|
||||
|
||||
}
|
||||
|
||||
#if !XASH_SDL && !XASH_ANDROID
|
||||
void Platform_Init( void )
|
||||
{
|
||||
Posix_Daemonize();
|
||||
}
|
||||
|
||||
void Platform_Shutdown( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void *Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if XASH_TIMER == TIMER_POSIX
|
||||
double Platform_DoubleTime( void )
|
||||
{
|
||||
|
@ -689,15 +689,6 @@ void Platform_RunEvents( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
void* Platform_GetNativeObject( const char *name )
|
||||
{
|
||||
#if XASH_ANDROID
|
||||
return Android_GetNativeObject( name );
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
Platform_PreCreateMove
|
||||
|
@ -45,13 +45,12 @@ void Platform_MessageBox( const char *title, const char *message, qboolean paren
|
||||
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, title, message, parentMainWindow ? host.hWnd : NULL );
|
||||
}
|
||||
#endif // XASH_MESSAGEBOX == MSGBOX_SDL
|
||||
void Posix_Daemonize( void );
|
||||
void Platform_Init( void )
|
||||
|
||||
void SDLash_Init( void )
|
||||
{
|
||||
#ifndef SDL_INIT_EVENTS
|
||||
#define SDL_INIT_EVENTS 0
|
||||
#endif
|
||||
|
||||
if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS ) )
|
||||
{
|
||||
Sys_Warn( "SDL_Init failed: %s", SDL_GetError() );
|
||||
@ -63,31 +62,10 @@ void Platform_Init( void )
|
||||
SDL_StopTextInput();
|
||||
#endif // XASH_SDL == 2
|
||||
|
||||
#if XASH_WIN32
|
||||
Wcon_CreateConsole(); // system console used by dedicated server or show fatal errors
|
||||
#elif XASH_POSIX
|
||||
Posix_Daemonize();
|
||||
#if XASH_PSVITA
|
||||
PSVita_Init();
|
||||
#elif XASH_NSWITCH
|
||||
NSwitch_Init();
|
||||
#elif XASH_ANDROID
|
||||
Android_Init();
|
||||
#endif
|
||||
#endif // XASH_POSIX
|
||||
|
||||
SDLash_InitCursors();
|
||||
}
|
||||
|
||||
void Platform_Shutdown( void )
|
||||
void SDLash_Shutdown( void )
|
||||
{
|
||||
SDLash_FreeCursors();
|
||||
|
||||
#if XASH_NSWITCH
|
||||
NSwitch_Shutdown();
|
||||
#elif XASH_WIN32
|
||||
Wcon_DestroyConsole();
|
||||
#elif XASH_PSVITA
|
||||
PSVita_Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
@ -81,16 +81,3 @@ void Platform_MessageBox( const char *title, const char *message, qboolean paren
|
||||
MessageBox( parentMainWindow ? host.hWnd : NULL, message, title, MB_OK|MB_SETFOREGROUND|MB_ICONSTOP );
|
||||
}
|
||||
#endif // XASH_MESSAGEBOX == MSGBOX_WIN32
|
||||
|
||||
#ifndef XASH_SDL
|
||||
|
||||
void Platform_Init( void )
|
||||
{
|
||||
Wcon_CreateConsole(); // system console used by dedicated server or show fatal errors
|
||||
|
||||
}
|
||||
void Platform_Shutdown( void )
|
||||
{
|
||||
Wcon_DestroyConsole();
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user