Skip to content

Instantly share code, notes, and snippets.

@IntriguingTiles
Last active January 10, 2023 07:18
Show Gist options
  • Select an option

  • Save IntriguingTiles/5a1615c8212d4c461c2ddc1928246489 to your computer and use it in GitHub Desktop.

Select an option

Save IntriguingTiles/5a1615c8212d4c461c2ddc1928246489 to your computer and use it in GitHub Desktop.
Source SDK 2013 GamepadUI patch - reverse engineered from macOS binaries
diff --git a/sp/src/game/client/cdll_client_int.cpp b/sp/src/game/client/cdll_client_int.cpp
index 10cce078..e0016269 100644
--- a/sp/src/game/client/cdll_client_int.cpp
+++ b/sp/src/game/client/cdll_client_int.cpp
@@ -203,6 +203,7 @@ ISceneFileCache *scenefilecache = NULL;
IXboxSystem *xboxsystem = NULL; // Xbox 360 only
IMatchmaking *matchmaking = NULL;
IUploadGameStats *gamestatsuploader = NULL;
+IGamepadUI* g_pGamepadUI = NULL;
IClientReplayContext *g_pClientReplayContext = NULL;
#if defined( REPLAY_ENABLED )
IReplayManager *g_pReplayManager = NULL;
@@ -1137,6 +1138,28 @@ void CHLClient::PostInit()
g_ClientVirtualReality.StartupComplete();
+ CSysModule* pModule = g_pFullFileSystem->LoadModule("gamepadui", "GAMEBIN");
+ const Color blue(0, 148, 255, 255);
+ if (pModule) {
+ ConColorMsg(blue, "[GamepadUI] Loaded gamepadui module.\n");
+ CreateInterfaceFn factory = Sys_GetFactory(pModule);
+ if (factory) {
+ g_pGamepadUI = (IGamepadUI*)factory("GamepadUI001", 0);
+ if (g_pGamepadUI) {
+ ConColorMsg(blue, "[GamepadUI] Initializing IGamepadUI interface...\n");
+ factorylist_t list;
+ FactoryList_Retrieve(list);
+ g_pGamepadUI->Init(list.appSystemFactory);
+ } else {
+ ConColorMsg(blue, "[GamepadUI] Unable to pull IGamepadUI interface.\n");
+ }
+ } else {
+ ConColorMsg(blue, "[GamepadUI] Unable to get gamepadui factory.\n");
+ }
+ } else {
+ ConColorMsg(blue, "[GamepadUI] Unable to load gamepadui module\n");
+ }
+
#ifdef HL1MP_CLIENT_DLL
if ( s_cl_load_hl1_content.GetBool() && steamapicontext && steamapicontext->SteamApps() )
{
@@ -1192,6 +1215,8 @@ void CHLClient::Shutdown( void )
UncacheAllMaterials();
IGameSystem::ShutdownAllSystems();
+
+ if (g_pGamepadUI) g_pGamepadUI->Shutdown();
gHUD.Shutdown();
VGui_Shutdown();
@@ -1281,6 +1306,8 @@ void CHLClient::HudUpdate( bool bActive )
// I can check into this further.
C_BaseTempEntity::CheckDynamicTempEnts();
+ if (g_pGamepadUI) g_pGamepadUI->HudUpdate(frametime);
+
#ifdef SIXENSE
// If we're not connected, update sixense so we can move the mouse cursor when in the menus
if( !engine->IsConnected() || engine->IsPaused() )
@@ -1627,6 +1654,8 @@ void CHLClient::LevelInitPreEntity( char const* pMapName )
gHUD.LevelInit();
+ if (g_pGamepadUI) g_pGamepadUI->LevelInitPreEntity();
+
#if defined( REPLAY_ENABLED )
// Initialize replay ragdoll recorder
if ( !engine->IsPlayingDemo() )
@@ -1645,6 +1674,7 @@ void CHLClient::LevelInitPostEntity( )
IGameSystem::LevelInitPostEntityAllSystems();
C_PhysPropClientside::RecreateAll();
internalCenterPrint->Clear();
+ if (g_pGamepadUI) g_pGamepadUI->LevelInitPostEntity();
}
//-----------------------------------------------------------------------------
@@ -1711,6 +1741,8 @@ void CHLClient::LevelShutdown( void )
StopAllRumbleEffects();
+ if (g_pGamepadUI) g_pGamepadUI->LevelShutdown();
+
gHUD.LevelShutdown();
internalCenterPrint->Clear();
diff --git a/sp/src/game/client/cdll_client_int.h b/sp/src/game/client/cdll_client_int.h
index c2456332..ab06e8dd 100644
--- a/sp/src/game/client/cdll_client_int.h
+++ b/sp/src/game/client/cdll_client_int.h
@@ -60,6 +60,17 @@ class IEngineClientReplay;
class IReplayScreenshotManager;
class CSteamID;
+abstract_class IGamepadUI {
+public:
+ virtual void Unused() = 0;
+ virtual void Init(CreateInterfaceFn) = 0;
+ virtual void Shutdown() = 0;
+ virtual void HudUpdate(float frametime) = 0;
+ virtual void LevelInitPreEntity() = 0;
+ virtual void LevelInitPostEntity() = 0;
+ virtual void LevelShutdown() = 0;
+};
+
//=============================================================================
// HPE_BEGIN
// [dwenger] Necessary for stats display
@@ -103,6 +114,7 @@ extern IXboxSystem *xboxsystem; // Xbox 360 only
extern IMatchmaking *matchmaking;
extern IVideoServices *g_pVideo;
extern IUploadGameStats *gamestatsuploader;
+extern IGamepadUI* g_pGamepadUI;
extern CSteamAPIContext *steamapicontext;
extern IReplaySystem *g_pReplay;
extern IClientReplayContext *g_pClientReplayContext;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment