From 68b7c25a10296a765fbc050203c86b09a4419f67 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:59:37 +0100 Subject: [PATCH] InputSystem: fully implement CInputStackSystem in the SDK The implementation currently only servers as reference, but if we ever have to replace the engine's implementation with the SDK's one, it should now be fully compatible and working. --- src/inputsystem/inputstacksystem.cpp | 53 ++++++++++++++-------------- src/inputsystem/inputstacksystem.h | 15 ++++---- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/inputsystem/inputstacksystem.cpp b/src/inputsystem/inputstacksystem.cpp index 723a22a1..bc3b8422 100644 --- a/src/inputsystem/inputstacksystem.cpp +++ b/src/inputsystem/inputstacksystem.cpp @@ -216,36 +216,35 @@ void CInputStackSystem::UpdateCursorState() } } -//----------------------------------------------------------------------------- -// Get dependencies -//----------------------------------------------------------------------------- -//static AppSystemInfo_t s_Dependencies[] = -//{ -// { "inputsystem" DLL_EXT_STRING, INPUTSYSTEM_INTERFACE_VERSION }, -// { NULL, NULL } -//}; -// -//const AppSystemInfo_t* CInputStackSystem::GetDependencies() -//{ -// return s_Dependencies; -//} - - //----------------------------------------------------------------------------- // Shutdown //----------------------------------------------------------------------------- -//void CInputStackSystem::Shutdown() -//{ -// // Delete any leaked contexts -// while( m_ContextStack.Count() ) -// { -// InputContext_t *pContext = NULL; -// m_ContextStack.Pop( pContext ); -// delete pContext; -// } -// -// BaseClass::Shutdown(); -//} +void CInputStackSystem::Shutdown() +{ + // Delete any leaked contexts + while( m_ContextStack.Count() ) + { + InputContext_t *pContext = NULL; + m_ContextStack.Pop( pContext ); + delete pContext; + } + + BaseClass::Shutdown(); +} + +//----------------------------------------------------------------------------- +// Get dependencies +//----------------------------------------------------------------------------- +static AppSystemInfo_t s_Dependencies[] = +{ + { "inputsystem" DLL_EXT_STRING, INPUTSYSTEM_INTERFACE_VERSION }, + { NULL, NULL } +}; + +const AppSystemInfo_t* CInputStackSystem::GetDependencies() +{ + return s_Dependencies; +} //----------------------------------------------------------------------------- // Singleton instance diff --git a/src/inputsystem/inputstacksystem.h b/src/inputsystem/inputstacksystem.h index 1c4d8455..b8e888da 100644 --- a/src/inputsystem/inputstacksystem.h +++ b/src/inputsystem/inputstacksystem.h @@ -30,13 +30,9 @@ class CInputStackSystem : public CTier1AppSystem< IInputStackSystem > typedef CTier1AppSystem< IInputStackSystem > BaseClass; // Methods of IAppSystem - // NOTE: currently, the implementation in the game engine is used. If the - // vtable ever gets swapped with the implementation in the SDK, make sure - // to implement BaseClass::Shutdown() and uncomment the functions below !!! - // The implementation in this SDK is identical to that of the engine. public: - //virtual const AppSystemInfo_t* GetDependencies(); - //virtual void Shutdown(); + virtual void Shutdown(); + virtual const AppSystemInfo_t* GetDependencies(); // Methods of IInputStackSystem public: @@ -56,6 +52,13 @@ private: CUtlStack< InputContext_t* > m_ContextStack; }; +// NOTE: we use the engine's implementation of CInputStackSystem, even though +// we have the entire class implemented in the SDK. If, for whatever reason, +// the SDK's implementation is used, make sure all methods are tested properly +// first before fully migrating to the SDK's implementation. The only method +// that appeared to have changed compared to other source game interfaces is +// CInputStackSystem::PopInputContext(), which now actually takes the context +// handle to pop it rather than pushing/popping handles in an explicit order. extern CInputStackSystem* g_pInputStackSystem; ///////////////////////////////////////////////////////////////////////////////