예제 #1
0
        public override float GetValue(InputManager manager)
        {
            TouchController tc = VRDeviceSystem.GetSystem?.GetController((Index & (1 << 16)) != 0 ? TouchControllerHand.Right : TouchControllerHand.Left);

            if (tc == null)
            {
                return(0f);
            }
            TouchControllerButton button = (TouchControllerButton)(Index & 0xFF);

            switch (button)
            {
            case TouchControllerButton.Grip:
                return(tc.Grip);

            case TouchControllerButton.Thumbstick:
                return((Index & (1 << 17)) != 0 ? tc.ThumbstickAxis.Y : tc.ThumbstickAxis.X);

            case TouchControllerButton.Touchpad:
                return((Index & (1 << 17)) != 0 ? tc.ThumbAxis.Y : tc.ThumbAxis.X);

            case TouchControllerButton.Trigger:
                return(tc.Trigger);

            default:
                return(tc.IsPressed(button) ? 1f : 0f);
            }
        }
예제 #2
0
        public override bool IsReleased(InputManager manager)
        {
            TouchController tc = VRDeviceSystem.GetSystem?.GetController((Index & (1 << 16)) != 0 ? TouchControllerHand.Right : TouchControllerHand.Left);

            if (tc == null)
            {
                return(false);
            }
            return(tc.IsPressReleased((TouchControllerButton)(Index & 0xFF)));
        }
예제 #3
0
        public override bool IsReleased()
        {
            TouchController tc = VRDeviceSystem.GetSystem?.GetController((Index & (1 << 16)) != 0 ? TouchControllerHand.Right : TouchControllerHand.Left);

            if (tc == null)
            {
                return(false);
            }
            TouchControllerButton strippedButton = (TouchControllerButton)(Index & 0xFF);

            if (tc.IsPressReleased(strippedButton) == false)
            {
                return(false);
            }
            Vector2 axis;

            switch (strippedButton)
            {
            default:
                return(true);

            case TouchControllerButton.Thumbstick:
                axis = tc.ThumbstickAxis;
                break;

            case TouchControllerButton.Touchpad:
                axis = tc.TouchpadAxis;
                break;
            }
            switch (Index >> 17)
            {
            case 0:     // up
                return(axis.Y > 0.5f);

            case 1:     // down
                return(axis.Y < -0.5f);

            case 2:     // left
                return(axis.X < -0.5f);

            case 3:     // right
                return(axis.X > 0.5f);

            case 4:     // center
                return(axis.X > -0.5f && axis.X < 0.5f && axis.Y < 0.5f && axis.Y > -0.5f);
            }
            return(false);
        }