From 2c30239ed6879ed0ce0d0352f59036aa2518e94c Mon Sep 17 00:00:00 2001 From: Rollin'Barrel Date: Sun, 21 Sep 2025 11:28:45 +0300 Subject: [PATCH] add launch param API's --- native/common.cpp | 18 ++++++++++++++++++ native/events.h | 1 + steam/Api.hx | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/native/common.cpp b/native/common.cpp index b9d5f64..b16799b 100644 --- a/native/common.cpp +++ b/native/common.cpp @@ -181,6 +181,22 @@ HL_PRIM vbyte *HL_NAME(get_current_game_language)(){ return (vbyte*)SteamApps()->GetCurrentGameLanguage(); } +HL_PRIM vbyte *HL_NAME(get_launch_command_line)(){ + if (!CheckInit()) return NULL; + char *pszCommandLine = (char *)hl_gc_alloc_noptr(4096); + int size = SteamApps()->GetLaunchCommandLine(pszCommandLine, 4096); + return (vbyte*)pszCommandLine; +} + +HL_PRIM vbyte *HL_NAME(get_launch_query_param)(vbyte *pchKey){ + if (!CheckInit()) return NULL; + return (vbyte*)SteamApps()->GetLaunchQueryParam((char*)pchKey); +} + +vdynamic *CallbackHandler::EncodeNewUrlLaunchParameters(NewUrlLaunchParameters_t *d) { + return NULL; +} + HL_PRIM bool HL_NAME(is_dlc_installed)( int appid ) { return SteamApps()->BIsDlcInstalled((AppId_t)appid); } @@ -347,6 +363,8 @@ DEFINE_PRIM(_BOOL, is_steam_in_big_picture_mode, _NO_ARG); DEFINE_PRIM(_BOOL, is_steam_running_on_steam_deck, _NO_ARG); DEFINE_PRIM(_BOOL, is_steam_running, _NO_ARG); DEFINE_PRIM(_BYTES, get_current_game_language, _NO_ARG); +DEFINE_PRIM(_BYTES, get_launch_command_line, _NO_ARG); +DEFINE_PRIM(_BYTES, get_launch_query_param, _BYTES); DEFINE_PRIM(_BYTES, get_auth_ticket, _REF(_I32) _REF(_I32)); DEFINE_PRIM(_VOID, request_encrypted_app_ticket, _BYTES _I32 _FUN(_VOID, _BYTES _I32)); DEFINE_PRIM(_VOID, cancel_call_result, _CRESULT); diff --git a/native/events.h b/native/events.h index 73bd848..eee025e 100644 --- a/native/events.h +++ b/native/events.h @@ -2,6 +2,7 @@ EVENT_DECL( PersonaChange, PersonaStateChange_t ) EVENT_DECL( OverlayActivated, GameOverlayActivated_t ) EVENT_DECL( AuthSessionTicketResponse, GetAuthSessionTicketResponse_t ) +EVENT_DECL( NewUrlLaunchParameters, NewUrlLaunchParameters_t ) // matchmaking EVENT_DECL( LobbyData, LobbyDataUpdate_t ) diff --git a/steam/Api.hx b/steam/Api.hx index 8372399..db95aaa 100644 --- a/steam/Api.hx +++ b/steam/Api.hx @@ -61,6 +61,7 @@ class Api // User-settable Callbacks public static var onOverlay : Bool -> Void; + public static var onNewUrlLaunchParameters : Void -> Void; /** * @param appId_ Your Steam APP ID (the numbers on the end of your store page URL - store.steampowered.com/app/XYZ) @@ -92,6 +93,12 @@ class Api } }); + // NewUrlLaunchParameters_t + registerGlobalEvent(1000 + 14, function(data:{ok:Bool}) { + if ( onNewUrlLaunchParameters != null ) + onNewUrlLaunchParameters(); + }); + // if we get this far, the dlls loaded ok and we need Steam to init. // otherwise, we're trying to run the Steam version without the Steam client active = _Init(steamWrap_onEvent, onGlobalEvent); @@ -201,6 +208,16 @@ class Api return l==null ? null : @:privateAccess String.fromUTF8(l); } + public static function getLaunchCommandLine():String { + var l = _GetLaunchCommandLine(); + return l==null ? null : @:privateAccess String.fromUTF8(l); + } + + public static function getLaunchQueryParam(query:String):String { + var l = _GetLaunchQueryParam(@:privateAccess query.toUtf8()); + return l==null ? null : @:privateAccess String.fromUTF8(l); + } + public static function getCurrentBetaName():String { var l = _GetCurrentBetaName(); return l == null ? null : @:privateAccess String.fromUTF8(l);