Controller role accessors

This commit is contained in:
Benjamin Saunders
2017-05-14 12:17:27 -07:00
parent 436f168bc4
commit 8217cf31b3
2 changed files with 23 additions and 1 deletions

View File

@ -136,6 +136,22 @@ impl<'a> System<'a> {
green: coord.rfGreen green: coord.rfGreen
}) })
} }
/// Returns the device index associated with a specific role, for example the left hand or the right hand.
pub fn tracked_device_index_for_controller_role(&self, role: TrackedControllerRole) -> Option<TrackedDeviceIndex> {
let x = unsafe { self.0.GetTrackedDeviceIndexForControllerRole.unwrap()(role as sys::ETrackedControllerRole) };
if x == tracked_device_index::INVALID { None } else { Some(x) }
}
/// Returns the controller type associated with a device index.
pub fn get_controller_role_for_tracked_device_index(&self, i: TrackedDeviceIndex) -> Option<TrackedControllerRole> {
let x = unsafe { self.0.GetControllerRoleForTrackedDeviceIndex.unwrap()(i) };
match x {
sys::ETrackedControllerRole_ETrackedControllerRole_TrackedControllerRole_LeftHand => Some(TrackedControllerRole::LeftHand),
sys::ETrackedControllerRole_ETrackedControllerRole_TrackedControllerRole_RightHand => Some(TrackedControllerRole::RightHand),
_ => None,
}
}
} }
/// Values represent the tangents of the half-angles from the center view axis /// Values represent the tangents of the half-angles from the center view axis

View File

@ -58,3 +58,9 @@ pub mod tracked_device_index {
} }
pub type TrackedDeviceProperty = sys::ETrackedDeviceProperty; pub type TrackedDeviceProperty = sys::ETrackedDeviceProperty;
#[derive(Debug, Copy, Clone)]
pub enum TrackedControllerRole {
LeftHand = sys::ETrackedControllerRole_ETrackedControllerRole_TrackedControllerRole_LeftHand as isize,
RightHand = sys::ETrackedControllerRole_ETrackedControllerRole_TrackedControllerRole_RightHand as isize,
}