コード例 #1
0
        public bool GetReleasedThisFrame(MRWSAInput.InteractionSourceHandedness handedness, Button btn)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            return(!IsPressed(state, btn) && IsPressed(lastState, btn));
        }
コード例 #2
0
        private void SetPressedPointerState(MRWSAInput.InteractionSourceHandedness handedness)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            var hand = (SourceHandedness)Enum.ToObject(typeof(SourceHandedness), state.Value.source.handedness);


            var isPressedThisFrame = IsPressed(state, selectionButton);
            var isPressedLastFrame = IsPressed(lastState, selectionButton);

            if (isPressedThisFrame && !isPressedLastFrame)
            {
                if (activeSelectionHand != hand)
                {
                    activeSelectionHand = hand;
                }
            }

            if (state.HasValue && activeSelectionHand == hand)
            {
                PressedThisFrame  = (isPressedThisFrame && !isPressedLastFrame);
                ReleasedThisFrame = (!isPressedThisFrame && isPressedLastFrame);
            }
        }
コード例 #3
0
        public Quaternion GetRotationDelta(MRWSAInput.InteractionSourceHandedness handedness, MRWSAInput.InteractionSourceNode node)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            var rotation     = GetRotation(state, node);
            var lastRotation = GetRotation(lastState, node);

            Quaternion delta = Quaternion.identity;

            if (rotation.HasValue && lastRotation.HasValue)
            {
                delta = rotation.Value * Quaternion.Inverse(lastRotation.Value);
            }

            return(delta);
        }
コード例 #4
0
        public Vector3 GetPositionDelta(MRWSAInput.InteractionSourceHandedness handedness, MRWSAInput.InteractionSourceNode node)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            var position     = GetPosition(state, node);
            var lastPosition = GetPosition(lastState, node);

            Vector3 delta = Vector3.zero;

            if (position.HasValue && lastPosition.HasValue)
            {
                delta = position.Value - lastPosition.Value;
            }

            return(delta);
        }
コード例 #5
0
        public Vector2 ThumbStickPosition(MRWSAInput.InteractionSourceHandedness handedness, bool getPreviousValue = false)
        {
            var state = GetState(handedness, getPreviousValue);

            var position = Vector2.zero;

            if (state.HasValue)
            {
#if UNITY_5
                position = new Vector2((float)state.Value.controllerProperties.thumbstickX, (float)state.Value.controllerProperties.thumbstickY);
#else
                position = state.Value.thumbstickPosition;
#endif
            }

            return(position);
        }
コード例 #6
0
        // special states
        public double SelectAmount(MRWSAInput.InteractionSourceHandedness handedness, bool getPreviousValue = false)
        {
            var state = GetState(handedness, getPreviousValue);

            double amount = 0.0;

            if (state.HasValue)
            {
#if UNITY_5
                amount = state.Value.selectPressedValue;
#else
                amount = state.Value.selectPressedAmount;
#endif
            }

            return(amount);
        }
コード例 #7
0
        public Vector2 ThumbStickDelta(MRWSAInput.InteractionSourceHandedness handedness)
        {
            var state     = GetState(handedness, false);
            var lastState = GetState(handedness, true);

            var delta = Vector2.zero;

            if (state.HasValue && lastState.HasValue)
            {
#if UNITY_5
                var pos     = new Vector2((float)state.Value.controllerProperties.thumbstickX, (float)state.Value.controllerProperties.thumbstickY);
                var lastPos = new Vector2((float)lastState.Value.controllerProperties.thumbstickX, (float)lastState.Value.controllerProperties.thumbstickY);
#else
                var pos     = state.Value.thumbstickPosition;
                var lastPos = lastState.Value.thumbstickPosition;
#endif
                delta = pos - lastPos;
            }

            return(delta);
        }
コード例 #8
0
        public MRWSAInput.InteractionSourceState?GetState(MRWSAInput.InteractionSourceHandedness handedness, bool getPreviousState)
        {
            MRWSAInput.InteractionSourceState?state = null;

            if (handedness == MRWSAInput.InteractionSourceHandedness.Left)
            {
                state = getPreviousState ? this.prevLeftHandState : this.leftHandState;
            }
            else if (handedness == MRWSAInput.InteractionSourceHandedness.Right)
            {
                state = getPreviousState ? this.prevRightHandState : this.rightHandState;
            }
#if UNITY_5
            else if (handedness == MRWSAInput.InteractionSourceHandedness.Unspecified)
#else
            else if (handedness == MRWSAInput.InteractionSourceHandedness.Unknown)
#endif
            {
                state = getPreviousState ? this.prevUnspecifiedHandState : this.unspecifiedHandState;
            }

            return(state);
        }
コード例 #9
0
        // rotation
        public Quaternion?GetRotation(MRWSAInput.InteractionSourceHandedness handedness, MRWSAInput.InteractionSourceNode node, bool getPreviousValue = false)
        {
            var state = GetState(handedness, getPreviousValue);

            return(GetRotation(state, node));
        }
コード例 #10
0
 public bool GetPressedOrReleased(MRWSAInput.InteractionSourceHandedness handedness, Button btn)
 {
     return(GetPressedThisFrame(handedness, btn) || GetReleasedThisFrame(handedness, btn));
 }
コード例 #11
0
        // button states
        public bool IsPressed(MRWSAInput.InteractionSourceHandedness handedness, Button btn, bool getPreviousValue = false)
        {
            var state = GetState(handedness, getPreviousValue);

            return(IsPressed(state, btn));
        }