Skip to content

Gamepadui #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions engine/sys_getmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ void CVideoMode_Common::SetupStartupGraphic()
// loading.vtf
buf.Clear(); // added this Clear() because we saw cases where LoadVTF was not emptying the buf fully in the above section
const char* loading = "materials/console/startup_loading.vtf";
if ( IsSteamDeck() )
if ( IsGamepadUI() )
loading = "materials/gamepadui/game_logo.vtf";
m_pLoadingTexture = LoadVTF( buf, loading );
if ( !m_pLoadingTexture )
Expand Down Expand Up @@ -887,7 +887,7 @@ void CVideoMode_Common::DrawStartupGraphic()
IMaterial *pMaterial = g_pMaterialSystem->CreateMaterial( "__background", pVMTKeyValues );

const char* loading = "console/startup_loading.vtf";
if ( IsSteamDeck() )
if ( IsGamepadUI() )
loading = "gamepadui/game_logo.vtf";

pVMTKeyValues = new KeyValues( "UnlitGeneric" );
Expand All @@ -896,7 +896,7 @@ void CVideoMode_Common::DrawStartupGraphic()
pVMTKeyValues->SetInt( "$ignorez", 1 );
pVMTKeyValues->SetInt( "$nofog", 1 );
pVMTKeyValues->SetInt( "$no_fullbright", 1 );
pVMTKeyValues->SetInt( "$nocull", 1 );
pVMTKeyValues->SetInt( "$nocull", 1 );
IMaterial *pLoadingMaterial = g_pMaterialSystem->CreateMaterial( "__loading", pVMTKeyValues );

int w = GetModeStereoWidth();
Expand Down Expand Up @@ -929,7 +929,7 @@ void CVideoMode_Common::DrawStartupGraphic()
slide = 0;

DrawScreenSpaceRectangle( pMaterial, 0, 0+slide, w, h-50, 0, 0, tw-1, th-1, tw, th, NULL,1,1,depth );
if ( !IsSteamDeck() )
if ( !IsGamepadUI() )
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
else
// TODO: Steam Deck
Expand Down Expand Up @@ -978,11 +978,15 @@ void CVideoMode_Common::DrawStartupGraphic()
pRenderContext->ClearColor3ub( 0, 0, 0 );
pRenderContext->ClearBuffers( true, true, true );
DrawScreenSpaceRectangle( pMaterial, 0, 0, w, h, 0, 0, tw-1, th-1, tw, th, NULL,1,1,depth );
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth );
if(!IsGamepadUI())
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth );

g_pMaterialSystem->SwapBuffers();
}
}



#ifdef DX_TO_GL_ABSTRACTION
g_pMaterialSystem->DoStartupShaderPreloading();
#endif
Expand Down
10 changes: 8 additions & 2 deletions engine/vgui_baseui_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void CEngineVGui::Init()
return;
}

if ( IsX360() || IsSteamDeck() )
if ( IsX360() || IsGamepadUI() )
{
CCommand ccommand;
if ( CL_ShouldLoadBackgroundLevel( ccommand ) )
Expand Down Expand Up @@ -1273,12 +1273,18 @@ void CEngineVGui::OnLevelLoadingStarted()
}
}

if ( IsX360() || IsSteamDeck() )
if ( IsX360() || !IsGamepadUI() )
{
// TCR requirement, always!!!
m_bShowProgressDialog = true;
}

// i dont want gamepadui menu while loading
//if (IsGamepadUI())
//{
// m_bShowProgressDialog = false;
//}

// we've starting loading a level/connecting to a server
staticGameUIFuncs->OnLevelLoadingStarted( m_bShowProgressDialog );

Expand Down
103 changes: 103 additions & 0 deletions game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
#include "haptics/haptic_utils.h"
#include "haptics/haptic_msgs.h"

#ifdef GAMEPADUI
#include "../gamepadui/igamepadui.h"
ConVar cl_gamepadui_mainmenu_draw("cl_gamepadui_mainmenu_draw", "0", FCVAR_DEVELOPMENTONLY);
#endif // GAMEPADUI

#if defined( TF_CLIENT_DLL )
#include "abuse_report.h"
#endif
Expand Down Expand Up @@ -217,6 +222,10 @@ IEngineClientReplay *g_pEngineClientReplay = NULL;
IReplaySystem *g_pReplay = NULL;
#endif

#if defined(GAMEPADUI)
IGamepadUI* g_pGamepadUI = nullptr;
#endif // GAMEPADUI

IHaptics* haptics = NULL;// NVNT haptics system interface singleton

//=============================================================================
Expand Down Expand Up @@ -1156,6 +1165,54 @@ void CHLClient::PostInit()
}
}
#endif

#ifndef PORTAL
#if defined(GAMEPADUI)
if (IsGamepadUI())
{
CSysModule* pGamepadUIModule = g_pFullFileSystem->LoadModule("gamepadui", "GAMEBIN", false);
if (pGamepadUIModule != nullptr)
{
GamepadUI_Log("Loaded gamepadui module.\n");

CreateInterfaceFn gamepaduiFactory = Sys_GetFactory(pGamepadUIModule);
if (gamepaduiFactory != nullptr)
{
g_pGamepadUI = (IGamepadUI*)gamepaduiFactory(GAMEPADUI_INTERFACE_VERSION, NULL);
if (g_pGamepadUI != nullptr)
{
GamepadUI_Log("Initializing IGamepadUI interface...\n");

factorylist_t factories;
FactoryList_Retrieve(factories);
g_pGamepadUI->Initialize(factories.appSystemFactory);

#ifdef STEAM_INPUT
g_pSteamInput->SetGamepadUI(true);
g_pGamepadUI->SetSteamInput(g_pSteamInput);
#endif
}
else
{
GamepadUI_Log("Unable to pull IGamepadUI interface.\n");
}
}
else
{
GamepadUI_Log("Unable to get gamepadui factory.\n");
}
}
else
{
GamepadUI_Log("Unable to load gamepadui module\n");
}
}
#endif // GAMEPADUI
#else
if (IsGamepadUI())
GamepadUI_Log("This version of GamepadUI doesnt work with portal 1. Idk why.");
#endif // !PORTAL

}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1196,6 +1253,11 @@ void CHLClient::Shutdown( void )
UncacheAllMaterials();

IGameSystem::ShutdownAllSystems();

#if defined(GAMEPADUI)
if (g_pGamepadUI != nullptr)
g_pGamepadUI->Shutdown();
#endif // GAMEPADUI

gHUD.Shutdown();
VGui_Shutdown();
Expand Down Expand Up @@ -1243,6 +1305,11 @@ int CHLClient::HudVidInit( void )

GetClientVoiceMgr()->VidInit();

#if defined(GAMEPADUI)
if (g_pGamepadUI != nullptr)
g_pGamepadUI->VidInit();
#endif // GAMEPADUI

return 1;
}

Expand All @@ -1267,6 +1334,16 @@ void CHLClient::HudUpdate( bool bActive )
CRTime::UpdateRealTime();
#endif

#ifdef GAMEPADUI
if (IsGamepadUI())
{
if (!enginevgui->IsGameUIVisible())
{
engine->ExecuteClientCmd("gamepadui_resetfade");
}
}
#endif // GAMEPADUI

GetClientVoiceMgr()->Frame( frametime );

gHUD.UpdateHud( bActive );
Expand All @@ -1293,6 +1370,11 @@ void CHLClient::HudUpdate( bool bActive )
g_pSixenseInput->SixenseFrame( 0, NULL );
}
#endif

#if defined(GAMEPADUI)
if (g_pGamepadUI != nullptr)
g_pGamepadUI->OnUpdate(frametime);
#endif // GAMEPADUI
}

//-----------------------------------------------------------------------------
Expand All @@ -1301,6 +1383,12 @@ void CHLClient::HudUpdate( bool bActive )
void CHLClient::HudReset( void )
{
gHUD.VidInit();
#ifdef GAMEPADUI
if (IsGamepadUI())
{
engine->ExecuteClientCmd("gamepadui_resetfade");
}
#endif // GAMEPADUI
PhysicsReset();
}

Expand Down Expand Up @@ -1640,6 +1728,11 @@ void CHLClient::LevelInitPreEntity( char const* pMapName )
CReplayRagdollRecorder::Instance().Init();
}
#endif

#if defined(GAMEPADUI)
if (g_pGamepadUI != nullptr)
g_pGamepadUI->OnLevelInitializePreEntity();
#endif // GAMEPADUI
}


Expand All @@ -1651,6 +1744,11 @@ void CHLClient::LevelInitPostEntity( )
IGameSystem::LevelInitPostEntityAllSystems();
C_PhysPropClientside::RecreateAll();
internalCenterPrint->Clear();

#if defined(GAMEPADUI)
if (g_pGamepadUI != nullptr)
g_pGamepadUI->OnLevelInitializePostEntity();
#endif // GAMEPADUI
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1717,6 +1815,11 @@ void CHLClient::LevelShutdown( void )

StopAllRumbleEffects();

#if defined(GAMEPADUI)
if (g_pGamepadUI != nullptr)
g_pGamepadUI->OnLevelShutdown();
#endif // GAMEPADUI

gHUD.LevelShutdown();

internalCenterPrint->Clear();
Expand Down
2 changes: 2 additions & 0 deletions game/client/client_base.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ $Configuration
$PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;fopen=dont_use_fopen" [$WIN32]
$PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;" [$OSXALL]
$PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;USE_WEBM_FOR_REPLAY;" [$LINUXALL]
$PreprocessorDefinitions "$BASE;GAMEPADUI_DLL;"
$PreprocessorDefinitions "$BASE;GAMEPADUI;"
$PreprocessorDefinitions "$BASE;CURL_STATICLIB" [$WIN32 && $BUILD_REPLAY]
$Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"
$Create/UsePCHThroughFile "cbase.h"
Expand Down
6 changes: 5 additions & 1 deletion game/client/hl1/hl1_clientmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

// default FOV for HL1
ConVar default_fov( "default_fov", "90", FCVAR_CHEAT );
ConVar fov_desired( "fov_desired", "90", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 110.0 );
#ifdef GAMEPADUI
ConVar fov_desired("fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 120.0);
#else
ConVar fov_desired("fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 110.0);
#endif // GAMEPADUI

// The current client mode. Always ClientModeNormal in HL.
IClientMode *g_pClientMode = NULL;
Expand Down
4 changes: 4 additions & 0 deletions game/client/hl2/clientmode_hlnormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

extern bool g_bRollingCredits;

#ifdef GAMEPADUI
ConVar fov_desired("fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 120.0);
#else
ConVar fov_desired( "fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 110.0 );
#endif // GAMEPADUI

//-----------------------------------------------------------------------------
// Globals
Expand Down
2 changes: 1 addition & 1 deletion game/client/hud_crosshair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void CHudCrosshair::Paint( void )
}

int iScreenDiv = 1600;
if ( IsSteamDeck() )
if ( IsGamepadUI() )
iScreenDiv = 1440;

float flPlayerScale;
Expand Down
6 changes: 5 additions & 1 deletion game/client/portal/clientmode_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

// default FOV for HL2
ConVar default_fov( "default_fov", "75", FCVAR_CHEAT );
ConVar fov_desired( "fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 110.0 );
#ifdef GAMEPADUI
ConVar fov_desired("fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 120.0);
#else
ConVar fov_desired("fov_desired", "75", FCVAR_ARCHIVE | FCVAR_USERINFO, "Sets the base field-of-view.", true, 75.0, true, 110.0);
#endif // GAMEPADUI

// The current client mode. Always ClientModeNormal in HL.
IClientMode *g_pClientMode = NULL;
Expand Down
Loading