From 0d71fad5f6ca8e188296151d8576b708ed13c94c Mon Sep 17 00:00:00 2001 From: Rollin'Barrel Date: Sun, 21 Sep 2025 11:17:48 +0300 Subject: [PATCH 1/2] add Friends.setRichPresence --- native/friends.cpp | 5 +++++ steam/Friends.hx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/native/friends.cpp b/native/friends.cpp index f4ad92d..65e54de 100644 --- a/native/friends.cpp +++ b/native/friends.cpp @@ -60,6 +60,10 @@ HL_PRIM void HL_NAME(activate_overlay_store)( int appid, int flag ) { SteamFriends()->ActivateGameOverlayToStore((AppId_t)appid,(EOverlayToStoreFlag)flag); } +HL_PRIM void HL_NAME(set_rich_presence)( vbyte *pchKey, vbyte *pchValue ) { + SteamFriends()->SetRichPresence((char*)pchKey, (char*)pchValue); +} + DEFINE_PRIM(_BYTES, get_user_name, _UID); DEFINE_PRIM(_BYTES, get_user_avatar, _UID _I32 _REF(_I32) _REF(_I32)); DEFINE_PRIM(_BOOL, request_user_information, _UID _BOOL); @@ -67,4 +71,5 @@ DEFINE_PRIM(_ARR, get_friends, _I32); DEFINE_PRIM(_BOOL, has_friend, _UID _I32); DEFINE_PRIM(_VOID, activate_overlay_user, _BYTES _UID); DEFINE_PRIM(_VOID, activate_overlay_store, _I32 _I32); +DEFINE_PRIM(_VOID, set_rich_presence, _UID _UID); diff --git a/steam/Friends.hx b/steam/Friends.hx index 75b1262..a04e10d 100644 --- a/steam/Friends.hx +++ b/steam/Friends.hx @@ -92,11 +92,16 @@ class Friends { public static function activateOverlay( overlay : OverlayKind, ?uid : UID ) { activate_overlay_user( overlay == None ? null : @:privateAccess overlay.toString().toUtf8(), uid); } + + public static function setRichPresence(key:String, value:String) { + @:privateAccess set_rich_presence(key.toUtf8(), value.toUtf8()); + } public static function activateOverlayStore( appId : Int, flags : OverlayToStoreFlag ) : Void {} static function get_friends( flags : FriendFlags ) : hl.NativeArray { return null; } static function has_friend( uid : UID, flags : FriendFlags ) : Bool { return false; } static function activate_overlay_user( overlay : hl.Bytes, uid : UID ) : Void {} + static function set_rich_presence( pchKey:hl.Bytes, pchValue:hl.Bytes ) : Void {} } \ No newline at end of file From d0144281459998d8ddca6949981925eacdf91b66 Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Tue, 9 Jun 2026 12:06:22 +0200 Subject: [PATCH 2/2] Improve rich presence and add a small doc --- native/friends.cpp | 12 ++++++++---- steam/Friends.hx | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/native/friends.cpp b/native/friends.cpp index 65e54de..6e2f73a 100644 --- a/native/friends.cpp +++ b/native/friends.cpp @@ -60,8 +60,12 @@ HL_PRIM void HL_NAME(activate_overlay_store)( int appid, int flag ) { SteamFriends()->ActivateGameOverlayToStore((AppId_t)appid,(EOverlayToStoreFlag)flag); } -HL_PRIM void HL_NAME(set_rich_presence)( vbyte *pchKey, vbyte *pchValue ) { - SteamFriends()->SetRichPresence((char*)pchKey, (char*)pchValue); +HL_PRIM bool HL_NAME(set_rich_presence)( vbyte *pchKey, vbyte *pchValue ) { + return SteamFriends()->SetRichPresence((char*)pchKey, (char*)pchValue); +} + +HL_PRIM void HL_NAME(clear_rich_presence)() { + SteamFriends()->ClearRichPresence(); } DEFINE_PRIM(_BYTES, get_user_name, _UID); @@ -71,5 +75,5 @@ DEFINE_PRIM(_ARR, get_friends, _I32); DEFINE_PRIM(_BOOL, has_friend, _UID _I32); DEFINE_PRIM(_VOID, activate_overlay_user, _BYTES _UID); DEFINE_PRIM(_VOID, activate_overlay_store, _I32 _I32); -DEFINE_PRIM(_VOID, set_rich_presence, _UID _UID); - +DEFINE_PRIM(_BOOL, set_rich_presence, _BYTES _BYTES); +DEFINE_PRIM(_VOID, clear_rich_presence, _NO_ARG); diff --git a/steam/Friends.hx b/steam/Friends.hx index a04e10d..c9e037a 100644 --- a/steam/Friends.hx +++ b/steam/Friends.hx @@ -93,15 +93,21 @@ class Friends { activate_overlay_user( overlay == None ? null : @:privateAccess overlay.toString().toUtf8(), uid); } - public static function setRichPresence(key:String, value:String) { - @:privateAccess set_rich_presence(key.toUtf8(), value.toUtf8()); - } - public static function activateOverlayStore( appId : Int, flags : OverlayToStoreFlag ) : Void {} + /** + Key `steam_display` requires localized token as value, see https://partner.steamgames.com/doc/api/ISteamFriends#richpresencelocalization + Set `value` to empty or null to remove the key. + **/ + public static function setRichPresence( key : String, value : Null ) : Bool { + return @:privateAccess set_rich_presence(key.toUtf8(), value == null ? null : value.toUtf8()); + } + + public static function clearRichPresence() : Void {} + static function get_friends( flags : FriendFlags ) : hl.NativeArray { return null; } static function has_friend( uid : UID, flags : FriendFlags ) : Bool { return false; } static function activate_overlay_user( overlay : hl.Bytes, uid : UID ) : Void {} - static function set_rich_presence( pchKey:hl.Bytes, pchValue:hl.Bytes ) : Void {} + static function set_rich_presence( pchKey : hl.Bytes, pchValue : hl.Bytes ) : Bool { return false; } -} \ No newline at end of file +}