From ab03c984c75b942c2aa495fcb6d9cde1a1009ebd Mon Sep 17 00:00:00 2001 From: Mats Date: Wed, 14 Oct 2026 18:22:24 +0200 Subject: [PATCH] Update ISteamUtils --- include/mist.h | 44 +++++++++++++++++++++ include/mist_callbacks.h | 1 + mist/lib/utils.rs | 77 +++++++++++++++++++++++++++++++++++- mist/src/callbacks.rs | 1 + mist/src/service.rs | 4 ++ mist/src/subprocess/utils.rs | 64 ++++++++++++++++++++++++++++++ mist/src/types.rs | 22 +++++++++++ 7 files changed, 212 insertions(+), 1 deletion(-) diff --git a/include/mist.h b/include/mist.h index 33eb10f..a32e1d7 100644 --- a/include/mist.h +++ b/include/mist.h @@ -837,6 +837,24 @@ typedef enum MistFloatingGamepadTextInputMode { MistFloatingGamepadTextInputMode_Numeric = 3, } MistFloatingGamepadTextInputMode; +typedef enum MistSteamHardwareType { + MistSteamHardwareType_None = 0, + MistSteamHardwareType_SteamDeck = 1, + MistSteamHardwareType_SteamMachine = 2, + MistSteamHardwareType_SteamFrame = 3, +} MistSteamHardwareType; + +typedef enum MistSteamHardwareDefaultConfig { + MistSteamHardwareDefaultConfig_None = 0, + MistSteamHardwareDefaultConfig_Low = 1, + MistSteamHardwareDefaultConfig_Medium = 2, + MistSteamHardwareDefaultConfig_High = 3, + MistSteamHardwareDefaultConfig_Max = 4, + MistSteamHardwareDefaultConfig_SteamDeck = 5, + MistSteamHardwareDefaultConfig_SteamMachine = 6, + MistSteamHardwareDefaultConfig_SteamFrame = 7, +} MistSteamHardwareDefaultConfig; + typedef uint32_t MistResult; typedef int32_t SteamUser; @@ -1479,6 +1497,7 @@ MistResult mist_steam_utils_is_vr_headset_streaming_enabled(bool *vr_streaming_e /** * Return if steam is running on a steam deck in the out ptr + * Deprecated by Steamworks, prefer mist_steam_utils_is_running_on_steam_hardware * Returns MistResult */ MistResult mist_steam_utils_is_steam_running_on_steam_deck(bool *on_deck); @@ -1525,6 +1544,31 @@ MistResult mist_steam_utils_set_game_launcher_mode(bool launcher_mode); */ MistResult mist_steam_utils_start_vr_dashboard(void); +/** + * Dismiss the full-screen gamepad text input, returns if it was dismissed in the out ptr + * Returns MistResult + */ +MistResult mist_steam_utils_dismiss_gamepad_text_input(bool *dismissed); + +/** + * Return the Steam hardware the game is running on in the out ptr + * Meant for analytics, support or diagnostics, not functional decisions + * Returns MistResult + */ +MistResult mist_steam_utils_is_running_on_steam_hardware(enum MistSteamHardwareType *hardware_type); + +/** + * Return the default settings config tuned for the Steam hardware in the out ptr + * Returns MistResult + */ +MistResult mist_steam_utils_get_steam_hardware_default_config(enum MistSteamHardwareDefaultConfig *config); + +/** + * Return if the game is running under Proton in the out ptr + * Returns MistResult + */ +MistResult mist_steam_utils_is_running_under_proton(bool *under_proton); + #include "mist_callbacks.h" #endif /* mist_h */ diff --git a/include/mist_callbacks.h b/include/mist_callbacks.h index 810ccfe..12528a7 100644 --- a/include/mist_callbacks.h +++ b/include/mist_callbacks.h @@ -17,6 +17,7 @@ typedef struct MistCallbackRemoteStorageLocalFileChange { typedef struct MistCallbackGamepadTextInputDismissed { bool submitted; uint32_t submitted_len; + AppId app_id; } MistCallbackGamepadTextInputDismissed; typedef struct MistCallbackFloatingGamepadTextInputDismissed { diff --git a/mist/lib/utils.rs b/mist/lib/utils.rs index a188242..647576c 100644 --- a/mist/lib/utils.rs +++ b/mist/lib/utils.rs @@ -7,7 +7,7 @@ use crate::{ result::{Error, MistResult, SteamUtilsError, Success}, types::{ AppId, MistFloatingGamepadTextInputMode, MistGamepadTextInputLineMode, - MistGamepadTextInputMode, + MistGamepadTextInputMode, MistSteamHardwareDefaultConfig, MistSteamHardwareType, }, }; @@ -172,6 +172,7 @@ pub extern "C" fn mist_steam_utils_is_vr_headset_streaming_enabled( } /// Return if steam is running on a steam deck in the out ptr +/// Deprecated by Steamworks, prefer mist_steam_utils_is_running_on_steam_hardware /// Returns MistResult #[no_mangle] pub extern "C" fn mist_steam_utils_is_steam_running_on_steam_deck( @@ -298,3 +299,77 @@ pub extern "C" fn mist_steam_utils_start_vr_dashboard() -> MistResult { Success } + +/// Dismiss the full-screen gamepad text input, returns if it was dismissed in the out ptr +/// Returns MistResult +#[no_mangle] +pub extern "C" fn mist_steam_utils_dismiss_gamepad_text_input(dismissed: *mut bool) -> MistResult { + let mut subprocess = get_subprocess!(); + + let result = unwrap_client_result!(subprocess + .client() + .steam_utils() + .dismiss_gamepad_text_input()); + + unsafe { + *dismissed = result; + } + + Success +} + +/// Return the Steam hardware the game is running on in the out ptr +/// Meant for analytics, support or diagnostics, not functional decisions +/// Returns MistResult +#[no_mangle] +pub extern "C" fn mist_steam_utils_is_running_on_steam_hardware( + hardware_type: *mut MistSteamHardwareType, +) -> MistResult { + let mut subprocess = get_subprocess!(); + + let result = unwrap_client_result!(subprocess + .client() + .steam_utils() + .is_running_on_steam_hardware()); + + unsafe { + *hardware_type = result; + } + + Success +} + +/// Return the default settings config tuned for the Steam hardware in the out ptr +/// Returns MistResult +#[no_mangle] +pub extern "C" fn mist_steam_utils_get_steam_hardware_default_config( + config: *mut MistSteamHardwareDefaultConfig, +) -> MistResult { + let mut subprocess = get_subprocess!(); + + let result = unwrap_client_result!(subprocess + .client() + .steam_utils() + .get_steam_hardware_default_config()); + + unsafe { + *config = result; + } + + Success +} + +/// Return if the game is running under Proton in the out ptr +/// Returns MistResult +#[no_mangle] +pub extern "C" fn mist_steam_utils_is_running_under_proton(under_proton: *mut bool) -> MistResult { + let mut subprocess = get_subprocess!(); + + let result = unwrap_client_result!(subprocess.client().steam_utils().is_running_under_proton()); + + unsafe { + *under_proton = result; + } + + Success +} diff --git a/mist/src/callbacks.rs b/mist/src/callbacks.rs index 115652c..d5a512f 100644 --- a/mist/src/callbacks.rs +++ b/mist/src/callbacks.rs @@ -22,6 +22,7 @@ mist_callbacks!( GamepadTextInputDismissed { m_bSubmitted => submitted: bool, m_unSubmittedText => submitted_len: u32, + m_unAppID => app_id: AppId, [(|server, event| { if !event.m_bSubmitted { return; } diff --git a/mist/src/service.rs b/mist/src/service.rs index 2375834..e0889ff 100644 --- a/mist/src/service.rs +++ b/mist/src/service.rs @@ -125,6 +125,10 @@ mist_service!( ) -> bool; fn set_game_launcher_mode(launcher_mode: bool); fn start_vr_dashboard(); + fn dismiss_gamepad_text_input() -> bool; + fn is_running_on_steam_hardware() -> MistSteamHardwareType; + fn get_steam_hardware_default_config() -> MistSteamHardwareDefaultConfig; + fn is_running_under_proton() -> bool; } // Internal diff --git a/mist/src/subprocess/utils.rs b/mist/src/subprocess/utils.rs index 49dedd6..29ab429 100644 --- a/mist/src/subprocess/utils.rs +++ b/mist/src/subprocess/utils.rs @@ -132,4 +132,68 @@ impl MistServiceSteamUtils for MistServerService { fn start_vr_dashboard(&mut self) -> Result<(), Error> { Ok(unsafe { steamworks_sys::SteamAPI_ISteamUtils_StartVRDashboard(self.steam_utils) }) } + + fn dismiss_gamepad_text_input(&mut self) -> Result { + Ok(unsafe { + steamworks_sys::SteamAPI_ISteamUtils_DismissGamepadTextInput(self.steam_utils) + }) + } + + fn is_running_on_steam_hardware(&mut self) -> Result { + let hardware_type = unsafe { + steamworks_sys::SteamAPI_ISteamUtils_IsRunningOnSteamHardware(self.steam_utils) + }; + + // Map instead of transmute so unknown future hardware types are not UB + Ok(match hardware_type { + steamworks_sys::ESteamHardwareType_k_ESteamHardwareTypeSteamDeck => { + MistSteamHardwareType::SteamDeck + } + steamworks_sys::ESteamHardwareType_k_ESteamHardwareTypeSteamMachine => { + MistSteamHardwareType::SteamMachine + } + steamworks_sys::ESteamHardwareType_k_ESteamHardwareTypeSteamFrame => { + MistSteamHardwareType::SteamFrame + } + _ => MistSteamHardwareType::None, + }) + } + + fn get_steam_hardware_default_config( + &mut self, + ) -> Result { + let config = unsafe { + steamworks_sys::SteamAPI_ISteamUtils_GetSteamHardwareDefaultConfig(self.steam_utils) + }; + + // Map instead of transmute so unknown future configs are not UB + Ok(match config { + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigLow => { + MistSteamHardwareDefaultConfig::Low + } + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigMedium => { + MistSteamHardwareDefaultConfig::Medium + } + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigHigh => { + MistSteamHardwareDefaultConfig::High + } + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigMax => { + MistSteamHardwareDefaultConfig::Max + } + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigSteamDeck => { + MistSteamHardwareDefaultConfig::SteamDeck + } + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigSteamMachine => { + MistSteamHardwareDefaultConfig::SteamMachine + } + steamworks_sys::ESteamHardwareDefaultConfig_k_ESteamHardwareDefaultConfigSteamFrame => { + MistSteamHardwareDefaultConfig::SteamFrame + } + _ => MistSteamHardwareDefaultConfig::None, + }) + } + + fn is_running_under_proton(&mut self) -> Result { + Ok(unsafe { steamworks_sys::SteamAPI_ISteamUtils_IsRunningUnderProton(self.steam_utils) }) + } } diff --git a/mist/src/types.rs b/mist/src/types.rs index 25a1eaa..1485c39 100644 --- a/mist/src/types.rs +++ b/mist/src/types.rs @@ -885,6 +885,28 @@ pub enum MistGamepadTextInputMode { Password = 1, } +#[derive(Copy, Clone, Serialize, Deserialize, Eq, PartialEq)] +#[repr(C)] +pub enum MistSteamHardwareType { + None = 0, + SteamDeck = 1, + SteamMachine = 2, + SteamFrame = 3, +} + +#[derive(Copy, Clone, Serialize, Deserialize, Eq, PartialEq)] +#[repr(C)] +pub enum MistSteamHardwareDefaultConfig { + None = 0, + Low = 1, + Medium = 2, + High = 3, + Max = 4, + SteamDeck = 5, + SteamMachine = 6, + SteamFrame = 7, +} + #[derive(Serialize, Deserialize, Eq, PartialEq)] #[repr(C)] pub enum MistFloatingGamepadTextInputMode {