示例#1
0
        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);
                }
            }
        }
示例#2
0
        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;
            }
        }
示例#3
0
        // 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;
        }
示例#4
0
 /*
  * 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);
     }
 }
示例#5
0
 /*
  * 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);
     }
 }
示例#6
0
        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);
                }
            }
        }
示例#9
0
    /*
     * 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);
            }
        }
    }
示例#10
0
        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;
        }