Basic Steam Dick support (#166)

Without gamepadui library
This commit is contained in:
exstrim401
2023-01-08 15:38:24 +03:00
committed by GitHub
parent f63849bb34
commit e26b40d889
6 changed files with 62 additions and 10 deletions
+30 -2
View File
@@ -2179,6 +2179,34 @@ void KeyValues::RecursiveMergeKeyValues( KeyValues *baseKV )
}
}
static int s_nSteamDeckCached = -1;
bool IsSteamDeck()
{
if (s_nSteamDeckCached == -1) {
if ( CommandLine()->CheckParm( "-nogamepadui" ) != 0 )
{
s_nSteamDeckCached = 0;
}
else
{
if ( CommandLine()->CheckParm( "-gamepadui" ) != 0 )
{
s_nSteamDeckCached = 1;
}
else
{
char *deck = getenv("SteamDeck");
if ( deck == 0 || *deck == 0 )
s_nSteamDeckCached = 0;
else
s_nSteamDeckCached = atoi(deck) != 0;
}
}
}
return s_nSteamDeckCached;
}
//-----------------------------------------------------------------------------
// Returns whether a keyvalues conditional evaluates to true or false
// Needs more flexibility with conditionals, checking convars would be nice.
@@ -2195,8 +2223,8 @@ bool EvaluateConditional( const char *str )
if ( *str == '!' )
bNot = true;
if( Q_stristr( str, "$DECK" ) )
return false ^ bNot; // Steam deck unsupported
if ( Q_stristr( str, "$DECK" ) )
return IsSteamDeck() ^ bNot;
if ( Q_stristr( str, "$X360" ) )
return IsX360() ^ bNot;