public static void GetDevicesWithRole(InputDeviceRole role, List <InputDevice> inputDevices) { bool flag = inputDevices == null; if (flag) { throw new ArgumentNullException("inputDevices"); } bool flag2 = InputDevices.s_InputDeviceList == null; if (flag2) { InputDevices.s_InputDeviceList = new List <InputDevice>(); } InputDevices.GetDevices_Internal(InputDevices.s_InputDeviceList); inputDevices.Clear(); foreach (InputDevice current in InputDevices.s_InputDeviceList) { bool flag3 = current.role == role; if (flag3) { inputDevices.Add(current); } } }
private void InitController() { List <InputDevice> inputDeviceList = new List <InputDevice>(); InputDeviceRole role = driver.poseSource == TrackedPoseDriver.TrackedPose.LeftPose ? InputDeviceRole.LeftHanded : InputDeviceRole.RightHanded; InputDevices.GetDevicesWithRole(role, inputDeviceList); try { if (inputDeviceList.Count > 0) { } InputDevice = inputDeviceList[0]; } catch (System.ArgumentOutOfRangeException e) { ; } if (XRSettings.loadedDeviceName.IndexOf("Oculus") != -1) { Primary2dAxisHasThumbstick = true; } }
// changes the device's role to either left or right handed void ChangePoseSource(InputDeviceRole deviceRole) { trackedPoseDriver.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRController, deviceRole == InputDeviceRole.LeftHanded ? TrackedPoseDriver.TrackedPose.LeftPose : TrackedPoseDriver.TrackedPose.RightPose); axisController.deviceRole = deviceRole; buttonController.deviceRole = deviceRole; }
/* * 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); } }
private DeviceType GetTypeFromRole(InputDeviceRole role) { switch (role) { case InputDeviceRole.Generic: // This is the camera. return(DeviceType.Head); case InputDeviceRole.LeftHanded: return(DeviceType.LeftHand); case InputDeviceRole.RightHanded: return(DeviceType.RightHand); default: Debug.LogError("Ignoring unhandled input device: " + role); return(DeviceType.Unknown); } }
//probably an opportinuty for imporvement, since I'm getting the controller and checking if it exists for every button public static bool ButtonCheck(InputDeviceRole role, CommonFeaturesString inputFeatureUsage) { var device = new List <InputDevice>(); InputDevices.GetDevicesWithRole(role, device); if (device.Count > 0) { if (device[0].TryGetFeatureValue(GetFeature(inputFeatureUsage), out bool controlValue)) { return(controlValue); } else { Debug.LogError("Match3_Cube: attempted to get a button which is not acessible on this controller!"); return(false); } } return(false); }
public static void GetDevicesWithRole(InputDeviceRole role, List <InputDevice> inputDevices) { if (null == inputDevices) { throw new ArgumentNullException("inputDevices"); } List <InputDevice> allDevices = new List <InputDevice>(); GetDevices_Internal(allDevices); inputDevices.Clear(); foreach (var device in allDevices) { if (device.role == role) { inputDevices.Add(device); } } }
/* * 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); } } }
private void UpdateController(InputDeviceRole role) { UpdateButton(CommonUsages.triggerButton, TriggerButton); UpdateButton(CommonUsages.primary2DAxisClick, Primary2dAxisButton); UpdateButton(CommonUsages.primary2DAxisTouch, Primary2dAxisTouch); UpdateButton(CommonUsages.gripButton, GripButton); Vector2 axis = Vector2.zero; if (Primary2dAxisTouch.Down) { InputDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out axis); } Primary2dAxis = axis; float val = 0.0f; if (InputDevice.TryGetFeatureValue(CommonUsages.trigger, out val)) { TriggerValue = val; } }
public static void GetDevicesWithRole(InputDeviceRole role, List <InputDevice> inputDevices) { }
private void Start() { mallet = GetComponent <Mallet> (); role = (mallet.hand == Mallet.MalletHand.Left) ? InputDeviceRole.LeftHanded : InputDeviceRole.RightHanded; }