Skip to content

Commit

Permalink
add get_digital/analog_action_origins
Browse files Browse the repository at this point in the history
  • Loading branch information
Noxime committed Sep 17, 2024
1 parent cbc9e8a commit 5d2575c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,48 @@ impl<Manager> Input<Manager> {
}
}

/// 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<sys::EInputActionOrigin> {
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<sys::EInputActionOrigin> {
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) }
}
Expand Down

0 comments on commit 5d2575c

Please sign in to comment.