internal WindowsMixedRealityTouchController(TouchControllerHand hand, SpatialInteractionManager interactionManager)
        {
            this.hand = (SpatialInteractionSourceHandedness)(hand + 1);
            this.interactionManager = interactionManager;

            interactionManager.SourceLost += InteractionManager_SourceLost;
        }
Exemplo n.º 2
0
        public OpenXrTouchController(OpenXRHmd hmd, TouchControllerHand whichHand)
        {
            baseHMD           = hmd;
            handLocation.Type = StructureType.TypeSpaceLocation;
            myHand            = whichHand;

            myAimAction = OpenXRInput.MappedActions[(int)myHand, (int)OpenXRInput.HAND_PATHS.AimPosition];
            ActionSpaceCreateInfo action_space_info = new ActionSpaceCreateInfo()
            {
                Type              = StructureType.TypeActionSpaceCreateInfo,
                Action            = myAimAction,
                PoseInActionSpace = new Posef(new Quaternionf(0f, 0f, 0f, 1f), new Vector3f(0f, 0f, 0f)),
            };

            OpenXRHmd.CheckResult(baseHMD.Xr.CreateActionSpace(baseHMD.globalSession, in action_space_info, ref myAimSpace), "CreateActionSpaceAim");

            myGripAction = OpenXRInput.MappedActions[(int)myHand, (int)OpenXRInput.HAND_PATHS.GripPosition];
            ActionSpaceCreateInfo action_grip_space_info = new ActionSpaceCreateInfo()
            {
                Type              = StructureType.TypeActionSpaceCreateInfo,
                Action            = myGripAction,
                PoseInActionSpace = action_space_info.PoseInActionSpace,
            };

            OpenXRHmd.CheckResult(baseHMD.Xr.CreateActionSpace(baseHMD.globalSession, in action_grip_space_info, ref myGripSpace), "CreateActionSpaceGrip");
        }
Exemplo n.º 3
0
        public static float GetActionFloat(TouchControllerHand hand, TouchControllerButton button, out bool wasChangedSinceLast, INPUT_DESIRED inputMode, bool fallback = false)
        {
            ActionStateGetInfo getfloat = new ActionStateGetInfo()
            {
                Action = GetAction(hand, button, inputMode),
                Type   = StructureType.TypeActionStateGetInfo
            };

            ActionStateFloat floatresult = new ActionStateFloat()
            {
                Type = StructureType.TypeActionStateFloat
            };

            baseHMD.Xr.GetActionStateFloat(baseHMD.globalSession, in getfloat, ref floatresult);

            if (floatresult.IsActive == 0)
            {
                if (fallback)
                {
                    // couldn't find an input...
                    wasChangedSinceLast = false;
                    return(0f);
                }

                // fallback if couldn't find float
                return(GetActionBool(hand, button, out wasChangedSinceLast, true) ? 1f : 0f);
            }

            wasChangedSinceLast = floatresult.ChangedSinceLastSync == 1;
            return(floatresult.CurrentState);
        }
Exemplo n.º 4
0
        public static bool GetActionBool(TouchControllerHand hand, TouchControllerButton button, out bool wasChangedSinceLast, bool fallback = false)
        {
            ActionStateGetInfo getbool = new ActionStateGetInfo()
            {
                Action = GetAction(hand, button, INPUT_DESIRED.CLICK),
                Type   = StructureType.TypeActionStateGetInfo
            };

            ActionStateBoolean boolresult = new ActionStateBoolean()
            {
                Type = StructureType.TypeActionStateBoolean
            };

            baseHMD.Xr.GetActionStateBoolean(baseHMD.globalSession, in getbool, ref boolresult);

            if (boolresult.IsActive == 0)
            {
                if (fallback)
                {
                    // couldn't find an input...
                    wasChangedSinceLast = false;
                    return(false);
                }

                // fallback if couldn't find bool
                return(GetActionFloat(hand, button, out wasChangedSinceLast, INPUT_DESIRED.VALUE, true) >= 0.75f);
            }

            wasChangedSinceLast = boolresult.ChangedSinceLastSync == 1;
            return(boolresult.CurrentState == 1);
        }
Exemplo n.º 5
0
        public static Silk.NET.OpenXR.Action GetAction(TouchControllerHand hand, TouchControllerButton button, INPUT_DESIRED wantMode)
        {
            switch (button)
            {
            case TouchControllerButton.ButtonXA:
                return(MappedActions[(int)hand, (int)HAND_PATHS.ButtonXA]);

            case TouchControllerButton.ButtonYB:
                return(MappedActions[(int)hand, (int)HAND_PATHS.ButtonYB]);

            case TouchControllerButton.Grip:
                return(wantMode == INPUT_DESIRED.CLICK ? MappedActions[(int)hand, (int)HAND_PATHS.GripClick] : MappedActions[(int)hand, (int)HAND_PATHS.GripValue]);

            case TouchControllerButton.Menu:
                return(MappedActions[(int)hand, (int)HAND_PATHS.Menu]);

            case TouchControllerButton.System:
                return(MappedActions[(int)hand, (int)HAND_PATHS.System]);

            case TouchControllerButton.Trigger:
                return(wantMode == INPUT_DESIRED.CLICK ? MappedActions[(int)hand, (int)HAND_PATHS.TriggerClick] : MappedActions[(int)hand, (int)HAND_PATHS.TriggerValue]);

            case TouchControllerButton.Thumbstick:
                switch (wantMode)
                {
                default:
                case INPUT_DESIRED.CLICK:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.ThumbstickClick]);

                case INPUT_DESIRED.XAXIS:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.ThumbstickX]);

                case INPUT_DESIRED.YAXIS:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.ThumbstickY]);
                }

            case TouchControllerButton.Touchpad:
                switch (wantMode)
                {
                default:
                case INPUT_DESIRED.CLICK:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadClick]);

                case INPUT_DESIRED.XAXIS:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadX]);

                case INPUT_DESIRED.YAXIS:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadY]);

                case INPUT_DESIRED.VALUE:
                    return(MappedActions[(int)hand, (int)HAND_PATHS.TrackpadForce]);
                }

            default:
                throw new ArgumentException("Don't know button: " + button);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Shortcut to getting VR hands
        /// </summary>
        /// <param name="hand">Which hand?</param>
        /// <returns>TouchController object, otherwise null</returns>
        public TouchController GetController(TouchControllerHand hand)
        {
            switch (hand)
            {
            case TouchControllerHand.Left:
                return(Device?.LeftHand);

            case TouchControllerHand.Right:
                return(Device?.RightHand);

            default:
                return(null);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Shortcut to getting VR hands
        /// </summary>
        /// <param name="hand">Which hand?</param>
        /// <returns>TouchController object, otherwise null</returns>
        public TouchController GetController(TouchControllerHand hand)
        {
            if (Device == null)
            {
                return(null);
            }

            switch (hand)
            {
            case TouchControllerHand.Left:
                return(SwapControllerHands ? Device.RightHand : Device.LeftHand);

            case TouchControllerHand.Right:
                return(SwapControllerHands ? Device.LeftHand : Device.RightHand);

            default:
                return(null);
            }
        }
Exemplo n.º 8
0
 public OculusTouchController(TouchControllerHand hand)
 {
     this.hand    = hand;
     currentState = DeviceState.Invalid;
 }
Exemplo n.º 9
0
 internal OpenVRTouchController(TouchControllerHand hand)
 {
     this.hand = (OpenVR.Controller.Hand)hand;
 }