moved in_restart to the shared client code

the platform layers implement Sys_InitInput and Sys_ShutdownInput
This commit is contained in:
myT 2017-10-04 17:33:35 +02:00
parent dfd9c9b462
commit be890e5b70
9 changed files with 31 additions and 57 deletions

View file

@ -828,6 +828,16 @@ static void IN_Button15Down(void) {IN_KeyDown(&in_buttons[15]);}
static void IN_Button15Up(void) {IN_KeyUp(&in_buttons[15]);}
static void IN_Restart_f()
{
Sys_ShutdownInput();
CL_ShutdownInput();
CL_InitInput();
Sys_InitInput();
}
static const cvarTableItem_t cl_cvars[] =
{
{ NULL, "cl_drawMouseLag", "0", 0, CVART_BOOL, NULL, NULL, "draws sampling to display/upload delays" },
@ -855,6 +865,7 @@ static const cvarTableItem_t cl_cvars[] =
static const cmdTableItem_t cl_cmds[] =
{
#define help_button1 "\nYou can't move and there's a chat bubble over your head."
{ "in_restart", IN_Restart_f, NULL, "restarts the input system" },
{ "+moveup", IN_UpDown, NULL, "starts jumping/moving up" help_plus_minus },
{ "-moveup", IN_UpUp, NULL, "stops jumping/moving up" help_plus_minus },
{ "+movedown", IN_DownDown, NULL, "starts crouching/moving down" help_plus_minus },
@ -919,10 +930,6 @@ static const cmdTableItem_t cl_cmds[] =
};
// @TODO: move "in_restart" here and let the platform layer
// implement Sys_InitInput and Sys_ShutdownInput
void CL_InitInput()
{
Cmd_RegisterArray( cl_cmds, MODULE_INPUT );

View file

@ -1736,6 +1736,7 @@ static void CL_Vid_Restart_f()
CL_ShutdownUI();
CL_ShutdownCGame();
CL_ShutdownInput();
CL_ShutdownRef();
// client is no longer pure until new checksums are sent
@ -1765,6 +1766,9 @@ static void CL_Vid_Restart_f()
// initialize the renderer interface
CL_InitRef();
// initialize input
CL_InitInput();
// startup all the client stuff
CL_StartHunkUsers();
@ -2055,13 +2059,12 @@ void CL_Init()
cls.state = CA_DISCONNECTED; // no longer CA_UNINITIALIZED
cls.realtime = 0;
CL_InitInput();
Cvar_RegisterArray( cl_cvars, MODULE_CLIENT );
Cmd_RegisterArray( cl_cmds, MODULE_CLIENT );
CL_InitRef();
CL_InitInput();
SCR_Init();
@ -2096,7 +2099,6 @@ void CL_Shutdown()
S_Shutdown();
CL_ShutdownInput();
CL_ShutdownRef();
CL_ShutdownUI();

View file

@ -1063,6 +1063,10 @@ sysEvent_t Sys_GetEvent();
void Sys_Init();
void Sys_Quit( int status ); // status is the engine's exit code
// both of these must handle duplicate calls correctly
void Sys_InitInput();
void Sys_ShutdownInput();
// general development dll loading for virtual machine testing
void* QDECL Sys_LoadDll( const char* name, dllSyscall_t *entryPoint, dllSyscall_t systemcalls );
void Sys_UnloadDll( void* dllHandle );

View file

@ -1092,7 +1092,7 @@ void GLimp_Init( void )
QGL_SwapInterval( dpy, win, r_swapInterval->integer );
IN_Init();
Sys_InitInput();
}
@ -1277,11 +1277,7 @@ static void IN_StartupMouse()
}
void IN_Init()
void Sys_InitInput()
{
QSUBSYSTEM_INIT_START( "Input" );
//IN_InitKeyboard();
@ -1308,7 +1304,7 @@ void IN_Init()
}
void IN_Shutdown(void)
void Sys_ShutdownInput(void)
{
mouse_avail = qfalse;
@ -1316,7 +1312,7 @@ void IN_Shutdown(void)
if (mouse) {
mouse->Shutdown();
mouse = 0;
mouse = NULL;
}
}

View file

@ -713,15 +713,6 @@ sysEvent_t Sys_GetEvent()
///////////////////////////////////////////////////////////////
#ifndef DEDICATED
static void Sys_In_Restart_f( void )
{
IN_Shutdown();
IN_Init();
}
#endif
char *Sys_GetClipboardData(void)
{
return NULL;
@ -830,9 +821,6 @@ void Sys_Print( const char *msg )
void Sys_Init()
{
#ifndef DEDICATED
Cmd_AddCommand( "in_restart", Sys_In_Restart_f );
#endif
Cvar_Set( "arch", OS_STRING " " ARCH_STRING );
}

View file

@ -738,11 +738,7 @@ void GLimp_Shutdown()
const char* success[] = { "failed", "success" };
int retVal;
if ( g_wv.inputInitialized )
{
IN_Shutdown();
g_wv.inputInitialized = qfalse;
}
Sys_ShutdownInput();
// FIXME: Brian, we need better fallbacks from partially initialized failures
if ( !qwglMakeCurrent ) {

View file

@ -341,7 +341,7 @@ static void IN_Startup()
}
void IN_Init()
void Sys_InitInput()
{
if (g_wv.inputInitialized)
return;
@ -359,7 +359,7 @@ void IN_Init()
}
void IN_Shutdown()
void Sys_ShutdownInput()
{
if (!g_wv.inputInitialized)
return;
@ -423,7 +423,7 @@ void IN_Frame()
{
// lazily initialize if needed
if ( !com_dedicated->integer && !g_wv.inputInitialized )
IN_Init();
Sys_InitInput();
IN_JoyMove();
IN_UpdateHotKey();
@ -1339,9 +1339,6 @@ static void IN_StartupHotKey( qbool fullStartUp )
static void IN_ShutDownHotKey()
{
// @TODO: remove this once Sys_InitInput and Sys_ShutdownInput are done
Cmd_RemoveCommand( "minimizekeynames" );
WIN_UnregisterHotKey();
}

View file

@ -31,12 +31,9 @@ void Sys_DestroyConsole( void );
const char* Sys_ConsoleInput();
void Conbuf_AppendText( const char *msg );
void IN_Init();
void IN_Activate( qbool active );
qbool IN_ProcessMessage( UINT msg, WPARAM wParam, LPARAM lParam ); // returns true if the event was handled
void IN_Frame();
void IN_Shutdown();
void WIN_UpdateMonitorIndexFromCvar();
void WIN_UpdateMonitorIndexFromMainWindow();

View file

@ -91,7 +91,7 @@ void QDECL Sys_Error( const char *error, ... )
WIN_EndTimePeriod();
#ifndef DEDICATED
IN_Shutdown();
Sys_ShutdownInput();
#endif
// wait for the user to quit
@ -113,7 +113,7 @@ void Sys_Quit( int status )
{
WIN_EndTimePeriod();
#ifndef DEDICATED
IN_Shutdown();
Sys_ShutdownInput();
#endif
Sys_DestroyConsole();
exit( status );
@ -519,15 +519,6 @@ sysEvent_t Sys_GetEvent()
///////////////////////////////////////////////////////////////
#ifndef DEDICATED
static void Sys_In_Restart_f( void )
{
IN_Shutdown();
IN_Init();
}
#endif
static void Sys_Net_Restart_f( void )
{
NET_Restart();
@ -540,10 +531,6 @@ void Sys_Init()
// make sure the timer is high precision, otherwise NT gets 18ms resolution
WIN_BeginTimePeriod();
#ifndef DEDICATED
Cmd_AddCommand( "in_restart", Sys_In_Restart_f );
Cmd_SetHelp( "in_restart", "restarts the input system" );
#endif
Cmd_AddCommand( "net_restart", Sys_Net_Restart_f );
Cmd_SetHelp( "net_restart", "restarts the network system" );
@ -675,7 +662,7 @@ int WINAPI WinMainImpl( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCm
#ifndef DEDICATED
if (!com_dedicated->integer)
IN_Init();
Sys_InitInput();
#endif
int totalMsec = 0, countMsec = 0;