mirror of
https://github.com/overte-org/overte.git
synced 2025-06-09 12:41:30 +02:00
Make Steamworks a plugin
This commit is contained in:
parent
1829f540cf
commit
0dec97fc03
18 changed files with 290 additions and 151 deletions
|
@ -175,10 +175,6 @@ if (WIN32)
|
||||||
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF")
|
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT ANDROID)
|
|
||||||
set(NON_ANDROID_LIBRARIES steamworks-wrapper)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# link required hifi libraries
|
# link required hifi libraries
|
||||||
link_hifi_libraries(
|
link_hifi_libraries(
|
||||||
shared octree gpu gl gpu-gl procedural model render
|
shared octree gpu gl gpu-gl procedural model render
|
||||||
|
|
|
@ -90,9 +90,10 @@
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <PhysicsEngine.h>
|
#include <PhysicsEngine.h>
|
||||||
#include <PhysicsHelpers.h>
|
#include <PhysicsHelpers.h>
|
||||||
|
#include <plugins/CodecPlugin.h>
|
||||||
#include <plugins/PluginManager.h>
|
#include <plugins/PluginManager.h>
|
||||||
#include <plugins/PluginUtils.h>
|
#include <plugins/PluginUtils.h>
|
||||||
#include <plugins/CodecPlugin.h>
|
#include <plugins/SteamClientPlugin.h>
|
||||||
#include <RecordingScriptingInterface.h>
|
#include <RecordingScriptingInterface.h>
|
||||||
#include <RenderableWebEntityItem.h>
|
#include <RenderableWebEntityItem.h>
|
||||||
#include <RenderShadowTask.h>
|
#include <RenderShadowTask.h>
|
||||||
|
@ -103,7 +104,6 @@
|
||||||
#include <ScriptEngines.h>
|
#include <ScriptEngines.h>
|
||||||
#include <ScriptCache.h>
|
#include <ScriptCache.h>
|
||||||
#include <SoundCache.h>
|
#include <SoundCache.h>
|
||||||
#include <steamworks-wrapper/SteamClient.h>
|
|
||||||
#include <Tooltip.h>
|
#include <Tooltip.h>
|
||||||
#include <udt/PacketHeaders.h>
|
#include <udt/PacketHeaders.h>
|
||||||
#include <UserActivityLogger.h>
|
#include <UserActivityLogger.h>
|
||||||
|
@ -421,6 +421,10 @@ bool setupEssentials(int& argc, char** argv) {
|
||||||
|
|
||||||
Setting::preInit();
|
Setting::preInit();
|
||||||
|
|
||||||
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
|
steamClient->init();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// Select appropriate audio DLL
|
// Select appropriate audio DLL
|
||||||
QString audioDLLPath = QCoreApplication::applicationDirPath();
|
QString audioDLLPath = QCoreApplication::applicationDirPath();
|
||||||
|
@ -551,7 +555,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
_maxOctreePPS(maxOctreePacketsPerSecond.get()),
|
_maxOctreePPS(maxOctreePacketsPerSecond.get()),
|
||||||
_lastFaceTrackerUpdate(0)
|
_lastFaceTrackerUpdate(0)
|
||||||
{
|
{
|
||||||
setProperty(hifi::properties::STEAM, SteamClient::isRunning());
|
auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
|
||||||
|
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
|
||||||
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -606,7 +611,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
_deadlockWatchdogThread = new DeadlockWatchdogThread();
|
_deadlockWatchdogThread = new DeadlockWatchdogThread();
|
||||||
_deadlockWatchdogThread->start();
|
_deadlockWatchdogThread->start();
|
||||||
|
|
||||||
qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << SteamClient::getSteamVRBuildID();
|
if (steamClient) {
|
||||||
|
qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();
|
||||||
|
}
|
||||||
qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
|
qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
|
||||||
qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
|
qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
|
||||||
qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
|
qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
|
||||||
|
@ -1695,6 +1702,10 @@ Application::~Application() {
|
||||||
|
|
||||||
Leapmotion::destroy();
|
Leapmotion::destroy();
|
||||||
|
|
||||||
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
|
steamClient->shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ConnexionClient::getInstance().destroy();
|
ConnexionClient::getInstance().destroy();
|
||||||
#endif
|
#endif
|
||||||
|
@ -1874,8 +1885,10 @@ void Application::initializeUi() {
|
||||||
|
|
||||||
rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
|
rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
|
||||||
|
|
||||||
rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine));
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
|
rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_glWidget->installEventFilter(offscreenUi.data());
|
_glWidget->installEventFilter(offscreenUi.data());
|
||||||
offscreenUi->setMouseTranslator([=](const QPointF& pt) {
|
offscreenUi->setMouseTranslator([=](const QPointF& pt) {
|
||||||
|
@ -3201,7 +3214,9 @@ void Application::idle(float nsecsElapsed) {
|
||||||
|
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
|
|
||||||
SteamClient::runCallbacks();
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
|
steamClient->runCallbacks();
|
||||||
|
}
|
||||||
|
|
||||||
float secondsSinceLastUpdate = nsecsElapsed / NSECS_PER_MSEC / MSECS_PER_SECOND;
|
float secondsSinceLastUpdate = nsecsElapsed / NSECS_PER_MSEC / MSECS_PER_SECOND;
|
||||||
|
|
||||||
|
@ -3533,12 +3548,16 @@ void Application::init() {
|
||||||
|
|
||||||
_timerStart.start();
|
_timerStart.start();
|
||||||
_lastTimeUpdated.start();
|
_lastTimeUpdated.start();
|
||||||
// when +connect_lobby in command line, join steam lobby
|
|
||||||
const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
|
|
||||||
int lobbyIndex = arguments().indexOf(STEAM_LOBBY_COMMAND_LINE_KEY);
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
if (lobbyIndex != -1) {
|
// when +connect_lobby in command line, join steam lobby
|
||||||
QString lobbyId = arguments().value(lobbyIndex + 1);
|
const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
|
||||||
SteamClient::joinLobby(lobbyId);
|
int lobbyIndex = arguments().indexOf(STEAM_LOBBY_COMMAND_LINE_KEY);
|
||||||
|
if (lobbyIndex != -1) {
|
||||||
|
QString lobbyId = arguments().value(lobbyIndex + 1);
|
||||||
|
steamClient->joinLobby(lobbyId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5193,8 +5212,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
||||||
scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine));
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
|
scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine, steamClient.get()));
|
||||||
|
}
|
||||||
auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();
|
auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();
|
||||||
scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());
|
scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());
|
||||||
UserInputMapper::registerControllerTypes(scriptEngine);
|
UserInputMapper::registerControllerTypes(scriptEngine);
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
#include <DomainHandler.h>
|
#include <DomainHandler.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <steamworks-wrapper/SteamClient.h>
|
#include <plugins/PluginManager.h>
|
||||||
|
#include <plugins/SteamClientPlugin.h>
|
||||||
#include <UserActivityLogger.h>
|
#include <UserActivityLogger.h>
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
|
|
||||||
|
@ -111,7 +112,9 @@ void DiscoverabilityManager::updateLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Steam
|
// Update Steam
|
||||||
SteamClient::updateLocation(domainHandler.getHostname(), addressManager->currentFacingShareableAddress());
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
|
steamClient->updateLocation(domainHandler.getHostname(), addressManager->currentFacingShareableAddress());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscoverabilityManager::handleHeartbeatResponse(QNetworkReply& requestReply) {
|
void DiscoverabilityManager::handleHeartbeatResponse(QNetworkReply& requestReply) {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <gl/OpenGLVersionChecker.h>
|
#include <gl/OpenGLVersionChecker.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
#include <steamworks-wrapper/SteamClient.h>
|
|
||||||
|
|
||||||
#include "AddressManager.h"
|
#include "AddressManager.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
@ -129,8 +128,10 @@ int main(int argc, const char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
|
QCommandLineOption checkMinSpecOption("checkMinSpec", "Check machine has minimum specifications");
|
||||||
QCommandLineOption runServerOption("runServer", "Whether to run the server");
|
QCommandLineOption runServerOption("runServer", "Whether to run the server");
|
||||||
QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath");
|
QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content", "serverContentPath");
|
||||||
|
parser.addOption(checkMinSpecOption);
|
||||||
parser.addOption(runServerOption);
|
parser.addOption(runServerOption);
|
||||||
parser.addOption(serverContentPathOption);
|
parser.addOption(serverContentPathOption);
|
||||||
parser.parse(arguments);
|
parser.parse(arguments);
|
||||||
|
@ -157,11 +158,9 @@ int main(int argc, const char* argv[]) {
|
||||||
// or in the main window ctor, before GL startup.
|
// or in the main window ctor, before GL startup.
|
||||||
Application::initPlugins(arguments);
|
Application::initPlugins(arguments);
|
||||||
|
|
||||||
SteamClient::init();
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec
|
// If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec
|
||||||
if (SteamClient::isRunning()) {
|
if (parser.isSet(checkMinSpecOption)) {
|
||||||
QString appPath;
|
QString appPath;
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
|
@ -245,8 +244,6 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
Application::shutdownPlugins();
|
Application::shutdownPlugins();
|
||||||
|
|
||||||
SteamClient::shutdown();
|
|
||||||
|
|
||||||
qCDebug(interfaceapp, "Normal exit.");
|
qCDebug(interfaceapp, "Normal exit.");
|
||||||
#if !defined(DEBUG) && !defined(Q_OS_LINUX)
|
#if !defined(DEBUG) && !defined(Q_OS_LINUX)
|
||||||
// HACK: exit immediately (don't handle shutdown callbacks) for Release build
|
// HACK: exit immediately (don't handle shutdown callbacks) for Release build
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
|
||||||
#include <NetworkingConstants.h>
|
#include <NetworkingConstants.h>
|
||||||
#include <steamworks-wrapper/SteamClient.h>
|
#include <plugins/PluginManager.h>
|
||||||
|
#include <plugins/SteamClientPlugin.h>
|
||||||
|
|
||||||
#include "AccountManager.h"
|
#include "AccountManager.h"
|
||||||
#include "DependencyManager.h"
|
#include "DependencyManager.h"
|
||||||
|
@ -56,7 +57,8 @@ void LoginDialog::toggleAction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoginDialog::isSteamRunning() const {
|
bool LoginDialog::isSteamRunning() const {
|
||||||
return SteamClient::isRunning();
|
auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
|
||||||
|
return steamClient && steamClient->isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDialog::login(const QString& username, const QString& password) const {
|
void LoginDialog::login(const QString& username, const QString& password) const {
|
||||||
|
@ -66,69 +68,75 @@ void LoginDialog::login(const QString& username, const QString& password) const
|
||||||
|
|
||||||
void LoginDialog::loginThroughSteam() {
|
void LoginDialog::loginThroughSteam() {
|
||||||
qDebug() << "Attempting to login through Steam";
|
qDebug() << "Attempting to login through Steam";
|
||||||
SteamClient::requestTicket([this](Ticket ticket) {
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
if (ticket.isNull()) {
|
steamClient->requestTicket([this](Ticket ticket) {
|
||||||
emit handleLoginFailed();
|
if (ticket.isNull()) {
|
||||||
return;
|
emit handleLoginFailed();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DependencyManager::get<AccountManager>()->requestAccessTokenWithSteam(ticket);
|
DependencyManager::get<AccountManager>()->requestAccessTokenWithSteam(ticket);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDialog::linkSteam() {
|
void LoginDialog::linkSteam() {
|
||||||
qDebug() << "Attempting to link Steam account";
|
qDebug() << "Attempting to link Steam account";
|
||||||
SteamClient::requestTicket([this](Ticket ticket) {
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
if (ticket.isNull()) {
|
steamClient->requestTicket([this](Ticket ticket) {
|
||||||
emit handleLoginFailed();
|
if (ticket.isNull()) {
|
||||||
return;
|
emit handleLoginFailed();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JSONCallbackParameters callbackParams;
|
JSONCallbackParameters callbackParams;
|
||||||
callbackParams.jsonCallbackReceiver = this;
|
callbackParams.jsonCallbackReceiver = this;
|
||||||
callbackParams.jsonCallbackMethod = "linkCompleted";
|
callbackParams.jsonCallbackMethod = "linkCompleted";
|
||||||
callbackParams.errorCallbackReceiver = this;
|
callbackParams.errorCallbackReceiver = this;
|
||||||
callbackParams.errorCallbackMethod = "linkFailed";
|
callbackParams.errorCallbackMethod = "linkFailed";
|
||||||
|
|
||||||
const QString LINK_STEAM_PATH = "api/v1/user/steam/link";
|
const QString LINK_STEAM_PATH = "api/v1/user/steam/link";
|
||||||
|
|
||||||
QJsonObject payload;
|
QJsonObject payload;
|
||||||
payload.insert("steam_auth_ticket", QJsonValue::fromVariant(QVariant(ticket)));
|
payload.insert("steam_auth_ticket", QJsonValue::fromVariant(QVariant(ticket)));
|
||||||
|
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
accountManager->sendRequest(LINK_STEAM_PATH, AccountManagerAuth::Required,
|
accountManager->sendRequest(LINK_STEAM_PATH, AccountManagerAuth::Required,
|
||||||
QNetworkAccessManager::PostOperation, callbackParams,
|
QNetworkAccessManager::PostOperation, callbackParams,
|
||||||
QJsonDocument(payload).toJson());
|
QJsonDocument(payload).toJson());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDialog::createAccountFromStream(QString username) {
|
void LoginDialog::createAccountFromStream(QString username) {
|
||||||
qDebug() << "Attempting to create account from Steam info";
|
qDebug() << "Attempting to create account from Steam info";
|
||||||
SteamClient::requestTicket([this, username](Ticket ticket) {
|
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
|
||||||
if (ticket.isNull()) {
|
steamClient->requestTicket([this, username](Ticket ticket) {
|
||||||
emit handleLoginFailed();
|
if (ticket.isNull()) {
|
||||||
return;
|
emit handleLoginFailed();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JSONCallbackParameters callbackParams;
|
JSONCallbackParameters callbackParams;
|
||||||
callbackParams.jsonCallbackReceiver = this;
|
callbackParams.jsonCallbackReceiver = this;
|
||||||
callbackParams.jsonCallbackMethod = "createCompleted";
|
callbackParams.jsonCallbackMethod = "createCompleted";
|
||||||
callbackParams.errorCallbackReceiver = this;
|
callbackParams.errorCallbackReceiver = this;
|
||||||
callbackParams.errorCallbackMethod = "createFailed";
|
callbackParams.errorCallbackMethod = "createFailed";
|
||||||
|
|
||||||
const QString CREATE_ACCOUNT_FROM_STEAM_PATH = "api/v1/user/steam/create";
|
const QString CREATE_ACCOUNT_FROM_STEAM_PATH = "api/v1/user/steam/create";
|
||||||
|
|
||||||
QJsonObject payload;
|
QJsonObject payload;
|
||||||
payload.insert("steam_auth_ticket", QJsonValue::fromVariant(QVariant(ticket)));
|
payload.insert("steam_auth_ticket", QJsonValue::fromVariant(QVariant(ticket)));
|
||||||
if (!username.isEmpty()) {
|
if (!username.isEmpty()) {
|
||||||
payload.insert("username", QJsonValue::fromVariant(QVariant(username)));
|
payload.insert("username", QJsonValue::fromVariant(QVariant(username)));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
accountManager->sendRequest(CREATE_ACCOUNT_FROM_STEAM_PATH, AccountManagerAuth::None,
|
accountManager->sendRequest(CREATE_ACCOUNT_FROM_STEAM_PATH, AccountManagerAuth::None,
|
||||||
QNetworkAccessManager::PostOperation, callbackParams,
|
QNetworkAccessManager::PostOperation, callbackParams,
|
||||||
QJsonDocument(payload).toJson());
|
QJsonDocument(payload).toJson());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ enum class PluginType {
|
||||||
class DisplayPlugin;
|
class DisplayPlugin;
|
||||||
class InputPlugin;
|
class InputPlugin;
|
||||||
class CodecPlugin;
|
class CodecPlugin;
|
||||||
|
class SteamClientPlugin;
|
||||||
class Plugin;
|
class Plugin;
|
||||||
class PluginContainer;
|
class PluginContainer;
|
||||||
class PluginManager;
|
class PluginManager;
|
||||||
|
@ -29,4 +30,4 @@ using InputPluginPointer = std::shared_ptr<InputPlugin>;
|
||||||
using InputPluginList = std::vector<InputPluginPointer>;
|
using InputPluginList = std::vector<InputPluginPointer>;
|
||||||
using CodecPluginPointer = std::shared_ptr<CodecPlugin>;
|
using CodecPluginPointer = std::shared_ptr<CodecPlugin>;
|
||||||
using CodecPluginList = std::vector<CodecPluginPointer>;
|
using CodecPluginList = std::vector<CodecPluginPointer>;
|
||||||
|
using SteamClientPluginPointer = std::shared_ptr<SteamClientPlugin>;
|
||||||
|
|
|
@ -147,6 +147,22 @@ const CodecPluginList& PluginManager::getCodecPlugins() {
|
||||||
return codecPlugins;
|
return codecPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SteamClientPluginPointer PluginManager::getSteamClientPlugin() {
|
||||||
|
static SteamClientPluginPointer steamClientPlugin;
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
// Now grab the dynamic plugins
|
||||||
|
for (auto loader : getLoadedPlugins()) {
|
||||||
|
SteamClientProvider* steamClientProvider = qobject_cast<SteamClientProvider*>(loader->instance());
|
||||||
|
if (steamClientProvider) {
|
||||||
|
steamClientPlugin = steamClientProvider->getSteamClientPlugin();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return steamClientPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
|
|
||||||
// TODO migrate to a DLL model where plugins are discovered and loaded at runtime by the PluginManager class
|
// TODO migrate to a DLL model where plugins are discovered and loaded at runtime by the PluginManager class
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
const DisplayPluginList& getDisplayPlugins();
|
const DisplayPluginList& getDisplayPlugins();
|
||||||
const InputPluginList& getInputPlugins();
|
const InputPluginList& getInputPlugins();
|
||||||
const CodecPluginList& getCodecPlugins();
|
const CodecPluginList& getCodecPlugins();
|
||||||
|
const SteamClientPluginPointer getSteamClientPlugin();
|
||||||
|
|
||||||
DisplayPluginList getPreferredDisplayPlugins();
|
DisplayPluginList getPreferredDisplayPlugins();
|
||||||
void setPreferredDisplayPlugins(const QStringList& displays);
|
void setPreferredDisplayPlugins(const QStringList& displays);
|
||||||
|
|
|
@ -45,3 +45,11 @@ public:
|
||||||
#define CodecProvider_iid "com.highfidelity.plugins.codec"
|
#define CodecProvider_iid "com.highfidelity.plugins.codec"
|
||||||
Q_DECLARE_INTERFACE(CodecProvider, CodecProvider_iid)
|
Q_DECLARE_INTERFACE(CodecProvider, CodecProvider_iid)
|
||||||
|
|
||||||
|
class SteamClientProvider {
|
||||||
|
public:
|
||||||
|
virtual ~SteamClientProvider() {}
|
||||||
|
virtual SteamClientPluginPointer getSteamClientPlugin() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SteamClientProvider_iid "com.highfidelity.plugins.steamclient"
|
||||||
|
Q_DECLARE_INTERFACE(SteamClientProvider, SteamClientProvider_iid)
|
||||||
|
|
59
libraries/plugins/src/plugins/SteamClientPlugin.h
Normal file
59
libraries/plugins/src/plugins/SteamClientPlugin.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
//
|
||||||
|
// SteamClientPlugin.h
|
||||||
|
// libraries/plugins/src/plugins
|
||||||
|
//
|
||||||
|
// Created by Clement Brisset on 12/14/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef hifi_SteamClientPlugin_h
|
||||||
|
#define hifi_SteamClientPlugin_h
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
|
||||||
|
using Ticket = QByteArray;
|
||||||
|
using TicketRequestCallback = std::function<void(Ticket)>;
|
||||||
|
|
||||||
|
class SteamClientPlugin {
|
||||||
|
public:
|
||||||
|
virtual ~SteamClientPlugin() {};
|
||||||
|
|
||||||
|
virtual bool init() = 0;
|
||||||
|
virtual void shutdown() = 0;
|
||||||
|
|
||||||
|
virtual bool isRunning() = 0;
|
||||||
|
|
||||||
|
virtual void runCallbacks() = 0;
|
||||||
|
|
||||||
|
virtual void requestTicket(TicketRequestCallback callback) = 0;
|
||||||
|
virtual void updateLocation(QString status, QUrl locationUrl) = 0;
|
||||||
|
virtual void openInviteOverlay() = 0;
|
||||||
|
virtual void joinLobby(QString lobbyId) = 0;
|
||||||
|
|
||||||
|
virtual int getSteamVRBuildID() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SteamScriptingInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(bool isRunning READ isRunning)
|
||||||
|
|
||||||
|
public:
|
||||||
|
SteamScriptingInterface(QObject* parent, SteamClientPlugin* plugin) : QObject(parent) {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
bool isRunning() const { return _plugin->isRunning(); }
|
||||||
|
void openInviteOverlay() const { _plugin->openInviteOverlay(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
SteamClientPlugin* _plugin;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* hifi_SteamClientPlugin_h */
|
|
@ -1,5 +0,0 @@
|
||||||
set(TARGET_NAME steamworks-wrapper)
|
|
||||||
setup_hifi_library()
|
|
||||||
link_hifi_libraries()
|
|
||||||
|
|
||||||
target_steamworks()
|
|
|
@ -1,57 +0,0 @@
|
||||||
//
|
|
||||||
// SteamClient.h
|
|
||||||
// steamworks-wrapper/src/steamworks-wrapper
|
|
||||||
//
|
|
||||||
// Created by Clement Brisset on 6/8/16.
|
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef hifi_SteamClient_h
|
|
||||||
#define hifi_SteamClient_h
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
|
|
||||||
using Ticket = QByteArray;
|
|
||||||
using TicketRequestCallback = std::function<void(Ticket)>;
|
|
||||||
|
|
||||||
class QUrl;
|
|
||||||
|
|
||||||
class SteamClient {
|
|
||||||
public:
|
|
||||||
static bool isRunning();
|
|
||||||
|
|
||||||
static bool init();
|
|
||||||
static void shutdown();
|
|
||||||
|
|
||||||
static void runCallbacks();
|
|
||||||
|
|
||||||
static void requestTicket(TicketRequestCallback callback);
|
|
||||||
static void updateLocation(QString status, QUrl locationUrl);
|
|
||||||
static void openInviteOverlay();
|
|
||||||
static void joinLobby(QString lobbyId);
|
|
||||||
|
|
||||||
static int getSteamVRBuildID();
|
|
||||||
};
|
|
||||||
|
|
||||||
class SteamScriptingInterface : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(bool isRunning READ isRunning)
|
|
||||||
|
|
||||||
public:
|
|
||||||
SteamScriptingInterface(QObject* parent) : QObject(parent) {}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
bool isRunning() const { return SteamClient::isRunning(); }
|
|
||||||
void openInviteOverlay() const { SteamClient::openInviteOverlay(); }
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // hifi_SteamClient_h
|
|
|
@ -26,9 +26,10 @@ if (NOT SERVER_ONLY AND NOT ANDROID)
|
||||||
add_subdirectory(${DIR})
|
add_subdirectory(${DIR})
|
||||||
set(DIR "hifiNeuron")
|
set(DIR "hifiNeuron")
|
||||||
add_subdirectory(${DIR})
|
add_subdirectory(${DIR})
|
||||||
|
|
||||||
set(DIR "hifiKinect")
|
set(DIR "hifiKinect")
|
||||||
add_subdirectory(${DIR})
|
add_subdirectory(${DIR})
|
||||||
|
set(DIR "steamClient")
|
||||||
|
add_subdirectory(${DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# server-side plugins
|
# server-side plugins
|
||||||
|
|
12
plugins/steamClient/CMakeLists.txt
Normal file
12
plugins/steamClient/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#
|
||||||
|
# Created by Clément Brisset on 12/14/16
|
||||||
|
# Copyright 2016 High Fidelity, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the Apache License, Version 2.0.
|
||||||
|
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
#
|
||||||
|
|
||||||
|
set(TARGET_NAME steamClient)
|
||||||
|
setup_hifi_plugin(Gui)
|
||||||
|
link_hifi_libraries(plugins)
|
||||||
|
target_steamworks()
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// SteamClient.cpp
|
// SteamAPIPlugin.cpp
|
||||||
// steamworks-wrapper/src/steamworks-wrapper
|
// plugins/steamClient/src
|
||||||
//
|
//
|
||||||
// Created by Clement Brisset on 6/8/16.
|
// Created by Clement Brisset on 6/8/16.
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "SteamClient.h"
|
#include "SteamAPIPlugin.h"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
@ -226,18 +226,18 @@ static std::atomic_bool initialized { false };
|
||||||
static SteamCallbackManager steamCallbackManager;
|
static SteamCallbackManager steamCallbackManager;
|
||||||
|
|
||||||
|
|
||||||
bool SteamClient::isRunning() {
|
bool SteamAPIPlugin::isRunning() {
|
||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SteamClient::init() {
|
bool SteamAPIPlugin::init() {
|
||||||
if (SteamAPI_IsSteamRunning() && !initialized) {
|
if (SteamAPI_IsSteamRunning() && !initialized) {
|
||||||
initialized = SteamAPI_Init();
|
initialized = SteamAPI_Init();
|
||||||
}
|
}
|
||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamClient::shutdown() {
|
void SteamAPIPlugin::shutdown() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
SteamAPI_Shutdown();
|
SteamAPI_Shutdown();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ void SteamClient::shutdown() {
|
||||||
steamCallbackManager.getTicketRequests().stopAll();
|
steamCallbackManager.getTicketRequests().stopAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SteamClient::getSteamVRBuildID() {
|
int SteamAPIPlugin::getSteamVRBuildID() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
static const int MAX_PATH_SIZE = 512;
|
static const int MAX_PATH_SIZE = 512;
|
||||||
static const int STEAMVR_APPID = 250820;
|
static const int STEAMVR_APPID = 250820;
|
||||||
|
@ -271,7 +271,7 @@ int SteamClient::getSteamVRBuildID() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SteamClient::runCallbacks() {
|
void SteamAPIPlugin::runCallbacks() {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ void SteamClient::runCallbacks() {
|
||||||
Steam_RunCallbacks(steamPipe, false);
|
Steam_RunCallbacks(steamPipe, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamClient::requestTicket(TicketRequestCallback callback) {
|
void SteamAPIPlugin::requestTicket(TicketRequestCallback callback) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
if (SteamAPI_IsSteamRunning()) {
|
if (SteamAPI_IsSteamRunning()) {
|
||||||
init();
|
init();
|
||||||
|
@ -304,7 +304,7 @@ void SteamClient::requestTicket(TicketRequestCallback callback) {
|
||||||
steamCallbackManager.getTicketRequests().startRequest(callback);
|
steamCallbackManager.getTicketRequests().startRequest(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamClient::updateLocation(QString status, QUrl locationUrl) {
|
void SteamAPIPlugin::updateLocation(QString status, QUrl locationUrl) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ void SteamClient::updateLocation(QString status, QUrl locationUrl) {
|
||||||
SteamFriends()->SetRichPresence("connect", connectStr.toLocal8Bit().data());
|
SteamFriends()->SetRichPresence("connect", connectStr.toLocal8Bit().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamClient::openInviteOverlay() {
|
void SteamAPIPlugin::openInviteOverlay() {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ void SteamClient::openInviteOverlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SteamClient::joinLobby(QString lobbyIdStr) {
|
void SteamAPIPlugin::joinLobby(QString lobbyIdStr) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
if (SteamAPI_IsSteamRunning()) {
|
if (SteamAPI_IsSteamRunning()) {
|
||||||
init();
|
init();
|
37
plugins/steamClient/src/SteamAPIPlugin.h
Normal file
37
plugins/steamClient/src/SteamAPIPlugin.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// SteamAPIPlugin.h
|
||||||
|
// plugins/steamClient/src
|
||||||
|
//
|
||||||
|
// Created by Clement Brisset on 6/8/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef hifi_SteamAPIPlugin_h
|
||||||
|
#define hifi_SteamAPIPlugin_h
|
||||||
|
|
||||||
|
#include <plugins/SteamClientPlugin.h>
|
||||||
|
|
||||||
|
class QUrl;
|
||||||
|
|
||||||
|
class SteamAPIPlugin : public SteamClientPlugin {
|
||||||
|
public:
|
||||||
|
bool isRunning();
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
void shutdown();
|
||||||
|
|
||||||
|
void runCallbacks();
|
||||||
|
|
||||||
|
void requestTicket(TicketRequestCallback callback);
|
||||||
|
void updateLocation(QString status, QUrl locationUrl);
|
||||||
|
void openInviteOverlay();
|
||||||
|
void joinLobby(QString lobbyId);
|
||||||
|
|
||||||
|
int getSteamVRBuildID();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_SteamAPIPlugin_h
|
41
plugins/steamClient/src/SteamClientProvider.cpp
Normal file
41
plugins/steamClient/src/SteamClientProvider.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// Created by Clément Brisset on 12/14/16
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QtPlugin>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
#include <plugins/RuntimePlugin.h>
|
||||||
|
#include <plugins/SteamClientPlugin.h>
|
||||||
|
|
||||||
|
#include "SteamAPIPlugin.h"
|
||||||
|
|
||||||
|
class SteamAPIProvider : public QObject, public SteamClientProvider {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID SteamClientProvider_iid FILE "plugin.json")
|
||||||
|
Q_INTERFACES(SteamClientProvider)
|
||||||
|
|
||||||
|
public:
|
||||||
|
SteamAPIProvider(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
|
virtual ~SteamAPIProvider() {}
|
||||||
|
|
||||||
|
virtual SteamClientPluginPointer getSteamClientPlugin() override {
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
_steamClientPlugin = std::make_shared<SteamAPIPlugin>();
|
||||||
|
});
|
||||||
|
return _steamClientPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SteamClientPluginPointer _steamClientPlugin;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "SteamClientProvider.moc"
|
1
plugins/steamClient/src/plugin.json
Normal file
1
plugins/steamClient/src/plugin.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"name":"Steam Client"}
|
Loading…
Reference in a new issue