Skip to content

Commit

Permalink
Add SteamRemotePlay
Browse files Browse the repository at this point in the history
  • Loading branch information
trdwll committed Dec 11, 2020
1 parent c03f987 commit 52a6d69
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ISteamNetworkingMessages | :x: |
ISteamNetworkingSockets | :x: |
ISteamNetworkingUtils | :x: |
ISteamParties | :heavy_check_mark: |
ISteamRemotePlay | :x: |
ISteamRemotePlay | :heavy_check_mark: |
ISteamRemoteStorage | :x: |
ISteamScreenshots | :x: |
ISteamUGC | :x: |
Expand Down
35 changes: 35 additions & 0 deletions Source/SteamBridge/Private/Core/SteamRemotePlay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 Russ 'trdwll' Treadwell <trdwll.com>. All Rights Reserved.

#include "Core/SteamRemotePlay.h"

#include "SteamBridgeUtils.h"

USteamRemotePlay::USteamRemotePlay()
{
OnSteamRemotePlaySessionConnectedCallback.Register(this, &USteamRemotePlay::OnSteamRemotePlaySessionConnected);
OnSteamRemotePlaySessionDisconnectedCallback.Register(this, &USteamRemotePlay::OnSteamRemotePlaySessionDisconnected);
}

USteamRemotePlay::~USteamRemotePlay()
{
OnSteamRemotePlaySessionConnectedCallback.Unregister();
OnSteamRemotePlaySessionDisconnectedCallback.Unregister();
}

bool USteamRemotePlay::BGetSessionClientResolution(int32 SessionID, FIntPoint& Resolution) const
{
int32 x, y;
bool bResult = SteamRemotePlay()->BGetSessionClientResolution(SessionID, &x, &y);
Resolution = {x,y};
return bResult;
}

void USteamRemotePlay::OnSteamRemotePlaySessionConnected(SteamRemotePlaySessionConnected_t* pParam)
{
m_OnSteamRemotePlaySessionConnected.Broadcast(pParam->m_unSessionID);
}

void USteamRemotePlay::OnSteamRemotePlaySessionDisconnected(SteamRemotePlaySessionDisconnected_t* pParam)
{
m_OnSteamRemotePlaySessionDisconnected.Broadcast(pParam->m_unSessionID);
}
107 changes: 107 additions & 0 deletions Source/SteamBridge/Public/Core/SteamRemotePlay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright 2020 Russ 'trdwll' Treadwell <trdwll.com>. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Steam.h"
#include "SteamEnums.h"
#include "SteamStructs.h"
#include "UObject/NoExportTypes.h"

#include "SteamRemotePlay.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSteamRemotePlaySessionConnectedDelegate, int32, SessionID);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSteamRemotePlaySessionDisconnectedDelegate, int32, SessionID);

/**
* Functions that provide information about Steam Remote Play sessions, streaming your game content to another computer or to a Steam Link app or hardware.
* https://partner.steamgames.com/doc/api/ISteamRemotePlay
*/
UCLASS()
class STEAMBRIDGE_API USteamRemotePlay final : public UObject
{
GENERATED_BODY()

public:
USteamRemotePlay();
~USteamRemotePlay();

UFUNCTION(BlueprintPure, Category = "SteamBridgeCore", meta = (DisplayName = "Steam Remote Play", CompactNodeTitle = "SteamRemotePlay"))
static USteamRemotePlay* GetSteamRemotePlay() { return USteamRemotePlay::StaticClass()->GetDefaultObject<USteamRemotePlay>(); }

/**
* Get the number of currently connected Steam Remote Play sessions
*
* @return int32 - The number of currently connected Steam Remote Play sessions
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|RemotePlay")
int32 GetSessionCount() const { return SteamRemotePlay()->GetSessionCount(); }

/**
* Get the currently connected Steam Remote Play session ID at the specified index
*
* @param int32 SessionIndex - The index of the specified session
* @return int32 - The session ID of the session at the specified index, or 0 if the index is less than 0 or greater than or equal to GetSessionCount()
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|RemotePlay")
int32 GetSessionID(int32 SessionIndex) const { return SteamRemotePlay()->GetSessionID(SessionIndex); }

/**
* Get the SteamID of the connected user
*
* @param int32 SessionID - The session ID to get information about
* @return FSteamID - The Steam ID of the user associated with the Remote Play session. This would normally be the logged in user, or a friend in the case of Remote Play Together.
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|RemotePlay")
FSteamID GetSessionSteamID(int32 SessionID) const { return SteamRemotePlay()->GetSessionSteamID(SessionID).ConvertToUint64(); }

/**
* Get the name of the session client device
*
* @param int32 SessionID - The session ID to get information about
* @return FString - The name of the device associated with the Remote Play session, or NULL if the session ID is not valid.
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|RemotePlay")
FString GetSessionClientName(int32 SessionID) const { return UTF8_TO_TCHAR(*SteamRemotePlay()->GetSessionClientName(SessionID)); }

/**
* Get the form factor of the session client device
*
* @param int32 SessionID - The session ID to get information about
* @return ESteamDeviceFormFactor_ - The form factor of the device associated with the Remote Play session, or k_ESteamDeviceFormFactorUnknown if the session ID is not valid.
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|RemotePlay")
ESteamDeviceFormFactor_ GetSessionClientFormFactor(int32 SessionID) const { return (ESteamDeviceFormFactor_)SteamRemotePlay()->GetSessionClientFormFactor(SessionID); }

/**
* Get the resolution, in pixels, of the session client device. This is set to 0x0 if the resolution is not available.
*
* @param int32 SessionID - The session ID to get information about
* @param FIntPoint & Resolution - device resolution
* @return bool - true if the session ID is valid; otherwise, false.
*/
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "SteamBridgeCore|RemotePlay")
bool BGetSessionClientResolution(int32 SessionID, FIntPoint& Resolution) const;

/**
* Invite a friend to join the game using Remote Play Together
*
* @param FSteamID SteamIDFriend - The Steam ID of the friend you'd like to invite
* @return bool - true if the invite was successfully sent; otherwise, false.
*/
UFUNCTION(BlueprintPure, Category = "SteamBridgeCore|RemotePlay")
bool BSendRemotePlayTogetherInvite(FSteamID SteamIDFriend) const { return SteamRemotePlay()->BSendRemotePlayTogetherInvite(SteamIDFriend); }

/** Delegates */

UPROPERTY(BlueprintAssignable, Category = "SteamBridgeCore|RemotePlay", meta = (DisplayName = "OnSteamRemotePlaySessionConnected"))
FOnSteamRemotePlaySessionConnectedDelegate m_OnSteamRemotePlaySessionConnected;

UPROPERTY(BlueprintAssignable, Category = "SteamBridgeCore|RemotePlay", meta = (DisplayName = "OnSteamRemotePlaySessionDisconnected"))
FOnSteamRemotePlaySessionDisconnectedDelegate m_OnSteamRemotePlaySessionDisconnected;

protected:
private:
STEAM_CALLBACK_MANUAL(USteamRemotePlay, OnSteamRemotePlaySessionConnected, SteamRemotePlaySessionConnected_t, OnSteamRemotePlaySessionConnectedCallback);
STEAM_CALLBACK_MANUAL(USteamRemotePlay, OnSteamRemotePlaySessionDisconnected, SteamRemotePlaySessionDisconnected_t, OnSteamRemotePlaySessionDisconnectedCallback);
};
11 changes: 11 additions & 0 deletions Source/SteamBridge/Public/SteamEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -917,4 +917,15 @@ enum class ESteamPartyBeaconLocationData_ : uint8
IconURLSmall = 2,
IconURLMedium = 3,
IconURLLarge = 4,
};

// Added the _ since Steam actually has this enum already and we need it accessible in BP
UENUM(BlueprintType)
enum class ESteamDeviceFormFactor_ : uint8
{
Unknown = 0,
Phone = 1,
Tablet = 2,
Computer = 3,
TV = 4,
};

0 comments on commit 52a6d69

Please sign in to comment.