Skip to content

Commit

Permalink
Merge pull request #209 from Noxime/input-action-origins
Browse files Browse the repository at this point in the history
add get_digital/analog_action_origins
  • Loading branch information
Noxime authored Sep 18, 2024
2 parents ee61f95 + 5d2575c commit d05eaa6
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 d05eaa6

Please sign in to comment.