/* * NOTE: This does not provide StateUp/StateDown for grip. */ public bool GetGrip(InputDeviceRole hand) { if (hand.Equals(InputDeviceRole.LeftHanded)) { return(lController.TryGetFeatureValue(CommonUsages.gripButton, out bool gripValue) && gripValue); } else if (hand.Equals(InputDeviceRole.RightHanded)) { return(rController.TryGetFeatureValue(CommonUsages.gripButton, out bool gripValue) && gripValue); } else { return(false); } }
/* * NOTE: This does not provide StateUp/StateDown for trigger. */ public bool GetTrigger(InputDeviceRole hand) { if (hand.Equals(InputDeviceRole.LeftHanded)) { return(lController.TryGetFeatureValue(CommonUsages.triggerButton, out bool triggerValue) && triggerValue); } else if (hand.Equals(InputDeviceRole.RightHanded)) { return(rController.TryGetFeatureValue(CommonUsages.triggerButton, out bool triggerValue) && triggerValue); } else { return(false); } }
/* * Invoke haptic feedback for controllers via amplitude and timing. */ public void ProvideHaptic(InputDeviceRole hand, float amplitude, float duration) { HapticCapabilities capabilities; uint channel = 0; if (hand.Equals(InputDeviceRole.LeftHanded) && lController.TryGetHapticCapabilities(out capabilities)) { if (capabilities.supportsImpulse) { lController.SendHapticImpulse(channel, amplitude, duration); } } else if (hand.Equals(InputDeviceRole.RightHanded) && rController.TryGetHapticCapabilities(out capabilities)) { if (capabilities.supportsImpulse) { rController.SendHapticImpulse(channel, amplitude, duration); } } }