From 5d2575c139e90997ecd3169a93108605abd735e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aaro=20Per=C3=A4maa?= Date: Tue, 17 Sep 2024 19:56:15 +0300 Subject: [PATCH] add get_digital/analog_action_origins --- src/input.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/input.rs b/src/input.rs index 977fbb0..2b8887d 100644 --- a/src/input.rs +++ b/src/input.rs @@ -189,6 +189,48 @@ impl Input { } } + /// Get the origin(s) for a digital action within an action set. + pub fn get_digital_action_origins( + &self, + input_handle: sys::InputHandle_t, + action_set_handle: sys::InputActionSetHandle_t, + digital_action_handle: sys::InputDigitalActionHandle_t, + ) -> Vec { + unsafe { + let mut origins = Vec::with_capacity(sys::STEAM_INPUT_MAX_ORIGINS as usize); + let len = sys::SteamAPI_ISteamInput_GetDigitalActionOrigins( + self.input, + input_handle, + action_set_handle, + digital_action_handle, + origins.as_mut_ptr(), + ); + origins.set_len(len as usize); + origins + } + } + + /// Get the origin(s) for an analog action within an action set. + pub fn get_analog_action_origins( + &self, + input_handle: sys::InputHandle_t, + action_set_handle: sys::InputActionSetHandle_t, + analog_action_handle: sys::InputAnalogActionHandle_t, + ) -> Vec { + unsafe { + let mut origins = Vec::with_capacity(sys::STEAM_INPUT_MAX_ORIGINS as usize); + let len = sys::SteamAPI_ISteamInput_GetAnalogActionOrigins( + self.input, + input_handle, + action_set_handle, + analog_action_handle, + origins.as_mut_ptr(), + ); + origins.set_len(len as usize); + origins + } + } + pub fn get_motion_data(&self, input_handle: sys::InputHandle_t) -> sys::InputMotionData_t { unsafe { sys::SteamAPI_ISteamInput_GetMotionData(self.input, input_handle) } }