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