Skip to content

Commit e26b40d

Browse files
authored
Basic Steam Dick support (#166)
Without gamepadui library
1 parent f63849b commit e26b40d

File tree

6 files changed

+62
-10
lines changed

6 files changed

+62
-10
lines changed

engine/sys_getmodes.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,13 @@ void CVideoMode_Common::SetupStartupGraphic()
819819

820820
// loading.vtf
821821
buf.Clear(); // added this Clear() because we saw cases where LoadVTF was not emptying the buf fully in the above section
822-
m_pLoadingTexture = LoadVTF( buf, "materials/console/startup_loading.vtf" );
822+
const char* loading = "materials/console/startup_loading.vtf";
823+
if ( IsSteamDeck() )
824+
loading = "materials/gamepadui/game_logo.vtf";
825+
m_pLoadingTexture = LoadVTF( buf, loading );
823826
if ( !m_pLoadingTexture )
824827
{
825-
Error( "Can't find background image materials/console/startup_loading.vtf\n" );
828+
Error( "Can't find background image '%s'\n", loading );
826829
return;
827830
}
828831
}
@@ -883,8 +886,12 @@ void CVideoMode_Common::DrawStartupGraphic()
883886
pVMTKeyValues->SetInt( "$nocull", 1 );
884887
IMaterial *pMaterial = g_pMaterialSystem->CreateMaterial( "__background", pVMTKeyValues );
885888

889+
const char* loading = "console/startup_loading.vtf";
890+
if ( IsSteamDeck() )
891+
loading = "gamepadui/game_logo.vtf";
892+
886893
pVMTKeyValues = new KeyValues( "UnlitGeneric" );
887-
pVMTKeyValues->SetString( "$basetexture", "Console/startup_loading.vtf" );
894+
pVMTKeyValues->SetString( "$basetexture", loading );
888895
pVMTKeyValues->SetInt( "$translucent", 1 );
889896
pVMTKeyValues->SetInt( "$ignorez", 1 );
890897
pVMTKeyValues->SetInt( "$nofog", 1 );
@@ -922,7 +929,11 @@ void CVideoMode_Common::DrawStartupGraphic()
922929
slide = 0;
923930

924931
DrawScreenSpaceRectangle( pMaterial, 0, 0+slide, w, h-50, 0, 0, tw-1, th-1, tw, th, NULL,1,1,depth );
925-
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
932+
if ( !IsSteamDeck() )
933+
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
934+
else
935+
// TODO: Steam Deck
936+
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
926937
}
927938

928939
if(0)

engine/vgui_baseui_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void CEngineVGui::Init()
613613
return;
614614
}
615615

616-
if ( IsX360() )
616+
if ( IsX360() || IsSteamDeck() )
617617
{
618618
CCommand ccommand;
619619
if ( CL_ShouldLoadBackgroundLevel( ccommand ) )
@@ -1273,7 +1273,7 @@ void CEngineVGui::OnLevelLoadingStarted()
12731273
}
12741274
}
12751275

1276-
if ( IsX360() )
1276+
if ( IsX360() || IsSteamDeck() )
12771277
{
12781278
// TCR requirement, always!!!
12791279
m_bShowProgressDialog = true;

game/client/hud_crosshair.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,15 @@ void CHudCrosshair::Paint( void )
258258
pWeapon->GetWeaponCrosshairScale( flWeaponScale );
259259
}
260260

261-
float flPlayerScale = 1.0f;
261+
int iScreenDiv = 1600;
262+
if ( IsSteamDeck() )
263+
iScreenDiv = 1440;
264+
265+
float flPlayerScale;
266+
if ( !m_pCrosshair->bRenderUsingFont )
267+
flPlayerScale = (ScreenHeight() / iScreenDiv) + 1;
268+
else
269+
flPlayerScale = 1.0f;
262270
#ifdef TF_CLIENT_DLL
263271
Color clr( cl_crosshair_red.GetInt(), cl_crosshair_green.GetInt(), cl_crosshair_blue.GetInt(), 255 );
264272
flPlayerScale = cl_crosshair_scale.GetFloat() / 32.0f; // the player can change the scale in the options/multiplayer tab

gameui/BasePanel.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,8 +1801,11 @@ void CBasePanel::ApplySchemeSettings(IScheme *pScheme)
18011801
// load the loading icon
18021802
if ( m_iLoadingImageID == -1 )
18031803
{
1804+
const char* loading = "console/startup_loading";
1805+
if ( IsSteamDeck() )
1806+
loading = "gamepadui/game_logo";
18041807
m_iLoadingImageID = surface()->CreateNewTextureID();
1805-
surface()->DrawSetTextureFile( m_iLoadingImageID, "Console/startup_loading", false, false );
1808+
surface()->DrawSetTextureFile( m_iLoadingImageID, loading, false, false );
18061809
}
18071810
}
18081811
}

public/tier1/KeyValues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ inline bool KeyValues::IsEmpty( int keySymbol )
428428
return dat ? dat->IsEmpty( ) : true;
429429
}
430430

431+
bool IsSteamDeck();
432+
431433
bool EvaluateConditional( const char *str );
432434

433435
class CUtlSortVectorKeyValuesByName

tier1/KeyValues.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,34 @@ void KeyValues::RecursiveMergeKeyValues( KeyValues *baseKV )
21792179
}
21802180
}
21812181

2182+
static int s_nSteamDeckCached = -1;
2183+
2184+
bool IsSteamDeck()
2185+
{
2186+
if (s_nSteamDeckCached == -1) {
2187+
if ( CommandLine()->CheckParm( "-nogamepadui" ) != 0 )
2188+
{
2189+
s_nSteamDeckCached = 0;
2190+
}
2191+
else
2192+
{
2193+
if ( CommandLine()->CheckParm( "-gamepadui" ) != 0 )
2194+
{
2195+
s_nSteamDeckCached = 1;
2196+
}
2197+
else
2198+
{
2199+
char *deck = getenv("SteamDeck");
2200+
if ( deck == 0 || *deck == 0 )
2201+
s_nSteamDeckCached = 0;
2202+
else
2203+
s_nSteamDeckCached = atoi(deck) != 0;
2204+
}
2205+
}
2206+
}
2207+
return s_nSteamDeckCached;
2208+
}
2209+
21822210
//-----------------------------------------------------------------------------
21832211
// Returns whether a keyvalues conditional evaluates to true or false
21842212
// Needs more flexibility with conditionals, checking convars would be nice.
@@ -2195,8 +2223,8 @@ bool EvaluateConditional( const char *str )
21952223
if ( *str == '!' )
21962224
bNot = true;
21972225

2198-
if( Q_stristr( str, "$DECK" ) )
2199-
return false ^ bNot; // Steam deck unsupported
2226+
if ( Q_stristr( str, "$DECK" ) )
2227+
return IsSteamDeck() ^ bNot;
22002228

22012229
if ( Q_stristr( str, "$X360" ) )
22022230
return IsX360() ^ bNot;

0 commit comments

Comments
 (0)