diff --git a/engine/platform/dos/sys_dos.c b/engine/platform/dos/sys_dos.c index 6256b068..8cfabeef 100644 --- a/engine/platform/dos/sys_dos.c +++ b/engine/platform/dos/sys_dos.c @@ -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 ); diff --git a/engine/platform/platform.h b/engine/platform/platform.h index dc2aac87..3083ca53 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -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; +} + /* ============================================================================== diff --git a/engine/platform/posix/sys_posix.c b/engine/platform/posix/sys_posix.c index 08533c5c..7d5e2261 100644 --- a/engine/platform/posix/sys_posix.c +++ b/engine/platform/posix/sys_posix.c @@ -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 ) { diff --git a/engine/platform/sdl/events.c b/engine/platform/sdl/events.c index e14dc493..0f41f61e 100644 --- a/engine/platform/sdl/events.c +++ b/engine/platform/sdl/events.c @@ -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 diff --git a/engine/platform/sdl/sys_sdl.c b/engine/platform/sdl/sys_sdl.c index ca05879f..50f0c4b9 100644 --- a/engine/platform/sdl/sys_sdl.c +++ b/engine/platform/sdl/sys_sdl.c @@ -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 } diff --git a/engine/platform/win32/sys_win.c b/engine/platform/win32/sys_win.c index 917404ea..ecc5070b 100644 --- a/engine/platform/win32/sys_win.c +++ b/engine/platform/win32/sys_win.c @@ -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