1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00
astra/launcher/src/steamapi.cpp

50 lines
904 B
C++
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "steamapi.h"
2022-09-05 18:03:59 -04:00
#ifdef ENABLE_STEAM
#include <steam/steam_api.h>
#endif
#include "astra_log.h"
#include "launchercore.h"
SteamAPI::SteamAPI(LauncherCore &core, QObject *parent)
: QObject(parent)
{
2022-09-05 18:03:59 -04:00
#ifdef ENABLE_STEAM
2023-10-11 12:59:25 -04:00
qputenv("SteamAppId", "39210");
qputenv("SteamGameId", "39210");
2022-09-06 10:54:34 -04:00
if (!SteamAPI_Init()) {
qFatal(ASTRA_LOG) << "Failed to initialize steam api!";
}
#endif
}
SteamAPI::~SteamAPI()
{
2023-10-11 12:59:25 -04:00
#ifdef ENABLE_STEAM
SteamAPI_Shutdown();
2023-10-11 12:59:25 -04:00
#endif
}
void SteamAPI::setLauncherMode(bool isLauncher)
{
#ifdef ENABLE_STEAM
SteamUtils()->SetGameLauncherMode(isLauncher);
2023-07-30 10:34:22 -04:00
#else
Q_UNUSED(isLauncher)
#endif
}
bool SteamAPI::isDeck() const
{
#ifdef ENABLE_STEAM
return SteamUtils()->IsSteamRunningOnSteamDeck();
#else
return false;
#endif
}