From 36b23e4ab476856839c8b4b388072edee31bc018 Mon Sep 17 00:00:00 2001 From: kotofyt Date: Sun, 20 Jul 2025 15:33:36 +0300 Subject: [PATCH] fixed building on windows (clangd is moron) --- engine/engine.cpp | 4 ++-- engine/input.cpp | 23 ++++++++++++++++++----- engine/server.cpp | 2 +- engine/vk_videosdl.cpp | 12 ++++++------ launcher/__build.cpp | 1 - public/input.h | 14 +++++++------- tier0/platform.cpp | 6 ++++-- 7 files changed, 38 insertions(+), 24 deletions(-) diff --git a/engine/engine.cpp b/engine/engine.cpp index 6d1668b..0ac399a 100644 --- a/engine/engine.cpp +++ b/engine/engine.cpp @@ -118,8 +118,8 @@ void IEngine::Init() // Init IO IVideo::Init(); - IInput::Init(); - IInput::SetInputMode(INPUT_MODE_MENU); + Input()->Init(); + Input()->SetInputMode(INPUT_MODE_MENU); IFGUI::Init(); }; diff --git a/engine/input.cpp b/engine/input.cpp index 4d1ce6a..d6bf0dc 100644 --- a/engine/input.cpp +++ b/engine/input.cpp @@ -1,5 +1,6 @@ #include "input.h" #include "console.h" +#include "interface.h" #include "mainmenu.h" #include "tier0/lib.h" #include "tier1/commandline.h" @@ -105,10 +106,22 @@ EInputKey IInput_StringToKey( char *psz ) }; +interface CInput: public IInput +{ +public: + virtual void Init() override; + virtual void Frame() override; + virtual void Deinit() override; + virtual void KeyEvent( EInputKey key, EKeyEventType event ) override; + virtual void AxisEvent( EInputAxis axis, float fValue ) override; +}; + +DECLARE_ENGINE_INTERFACE(Input, CInput) + //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -void IInput::Init( void ) +void CInput::Init( void ) { } @@ -134,7 +147,7 @@ CUtlVector g_inputModeStack = {INPUT_MODE_GAME, INPUT_MODE_MENU}; // INPUT FIELD: // Doesn't recieve any events except for KEY_ESCAPE and KEY_ENTER //----------------------------------------------------------------------------- -void IInput::KeyEvent( EInputKey key, EKeyEventType event ) +void CInput::KeyEvent( EInputKey key, EKeyEventType event ) { if (event == KEY_EVENT_TYPE_DOWN && key == KEY_ESCAPE) { @@ -213,7 +226,7 @@ void IInput::KeyEvent( EInputKey key, EKeyEventType event ) // Axis events for the input devices such as mouse and controller. // Game needs to explicitly support all of the devices. //----------------------------------------------------------------------------- -void IInput::AxisEvent( EInputAxis axis, float fValue ) +void CInput::AxisEvent( EInputAxis axis, float fValue ) { if (g_inputModeStack[g_inputModeStack.GetSize()-1] == INPUT_MODE_GAME) { @@ -233,7 +246,7 @@ void IInput::AxisEvent( EInputAxis axis, float fValue ) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -void IInput::Frame( void ) +void CInput::Frame( void ) { g_fAxisValues[AXIS_MOUSE_X] += g_fAxisModifiers[AXIS_CONTROLLER_PITCH]; g_fAxisValues[AXIS_MOUSE_Y] += g_fAxisModifiers[AXIS_CONTROLLER_YAW]; @@ -242,7 +255,7 @@ void IInput::Frame( void ) //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- -void IInput::Deinit( void ) +void CInput::Deinit( void ) { } diff --git a/engine/server.cpp b/engine/server.cpp index b9b233f..a03b08a 100644 --- a/engine/server.cpp +++ b/engine/server.cpp @@ -55,7 +55,7 @@ void IServer::Think( float fDelta ) while(g_fAccumulator>=fTickrate) { if (INetworking::IsClient()) - IInput::Frame(); + Input()->Frame(); Console()->Execute(); g_fAccumulator-=fTickrate; for (auto &entity: EntityManager()->m_entities) diff --git a/engine/vk_videosdl.cpp b/engine/vk_videosdl.cpp index 88caa21..176f499 100644 --- a/engine/vk_videosdl.cpp +++ b/engine/vk_videosdl.cpp @@ -452,16 +452,16 @@ void IVideo_HandleEvents() break; case SDL_EVENT_KEY_DOWN: if (!key->repeat) - IInput::KeyEvent(ISDL_KeyName(key->key),KEY_EVENT_TYPE_DOWN); + Input()->KeyEvent(ISDL_KeyName(key->key),KEY_EVENT_TYPE_DOWN); break; case SDL_EVENT_KEY_UP: key = &event.key; if (!key->repeat) - IInput::KeyEvent(ISDL_KeyName(key->key),KEY_EVENT_TYPE_UP); + Input()->KeyEvent(ISDL_KeyName(key->key),KEY_EVENT_TYPE_UP); break; case SDL_EVENT_MOUSE_MOTION: - IInput::AxisEvent(AXIS_MOUSE_X, motion->yrel*m_pitch.GetFloat()); - IInput::AxisEvent(AXIS_MOUSE_Y, -motion->xrel*m_yaw.GetFloat()); + Input()->AxisEvent(AXIS_MOUSE_X, motion->yrel*m_pitch.GetFloat()); + Input()->AxisEvent(AXIS_MOUSE_Y, -motion->xrel*m_yaw.GetFloat()); break; case SDL_EVENT_GAMEPAD_AXIS_MOTION: { @@ -473,11 +473,11 @@ void IVideo_HandleEvents() if (axis == SDL_GAMEPAD_AXIS_RIGHTY) { - IInput::AxisEvent(AXIS_CONTROLLER_PITCH, value); + Input()->AxisEvent(AXIS_CONTROLLER_PITCH, value); } if (axis == SDL_GAMEPAD_AXIS_RIGHTX) { - IInput::AxisEvent(AXIS_CONTROLLER_YAW, -value); + Input()->AxisEvent(AXIS_CONTROLLER_YAW, -value); } } break; diff --git a/launcher/__build.cpp b/launcher/__build.cpp index d64afc0..11c1474 100644 --- a/launcher/__build.cpp +++ b/launcher/__build.cpp @@ -50,7 +50,6 @@ int launcher_build() { ldProject.objects.AppendTail((CObject){"external/windows/vulkan-1.dll"}); ldProject.objects.AppendTail((CObject){"external/windows/libSDL3.a"}); - ldProject.objects.AppendTail((CObject){"external/windows/libdbghelp.a"}); ldProject.objects.AppendTail((CObject){"external/windows/libpthread.a"}); ldProject.objects.AppendTail((CObject){"external/windows/libstdc++.a"}); if (bSteam) diff --git a/public/input.h b/public/input.h index d43f283..c1f267b 100644 --- a/public/input.h +++ b/public/input.h @@ -1,6 +1,7 @@ #ifndef INPUT_H #define INPUT_H +#include "interface.h" #include "tier0/platform.h" #include "tier1/utlvector.h" @@ -120,17 +121,16 @@ enum EInputMode extern CUtlVector g_inputModeStack; -interface IInput +interface IInput: public IInterface { public: - static void Init( void ); - static void KeyEvent( EInputKey key, EKeyEventType event ); - static void AxisEvent( EInputAxis axis, float fValue ); - static void SetInputMode( EInputMode mode ); - static void Frame( void ); - static void Deinit( void ); + virtual void KeyEvent( EInputKey key, EKeyEventType event ) = 0; + virtual void AxisEvent( EInputAxis axis, float fValue ) = 0; + virtual void SetInputMode( EInputMode mode ); }; +IInput *Input(); + extern float g_fAxisValues[AXIS_NUM_AXIS]; #endif diff --git a/tier0/platform.cpp b/tier0/platform.cpp index d964f95..fdcdcd0 100644 --- a/tier0/platform.cpp +++ b/tier0/platform.cpp @@ -6,7 +6,7 @@ #include "dirent.h" #include "time.h" #include "signal.h" -#include + #ifdef __linux__ #include "dlfcn.h" #include "execinfo.h" @@ -16,8 +16,8 @@ #endif #ifdef __WIN32__ #include "windows.h" -#include "dbghelp.h" #endif + PLATFORM_INTERFACE void Plat_FatalErrorFunc(const char* szFormat, ...) { va_list list; @@ -136,6 +136,7 @@ PLATFORM_INTERFACE void Plat_Backtrace( void ) free(symbols); #endif #ifdef __WIN32__ + /* void* buffer[64]; USHORT nptrs = CaptureStackBackTrace(0, 64, buffer, NULL); @@ -160,6 +161,7 @@ PLATFORM_INTERFACE void Plat_Backtrace( void ) } free(symbol); + */ #endif };