Esempio n. 1
0
        /// <summary>
        /// Get the Steam VR hair trigger up state.
        /// </summary>
        /// <returns>Trigger up state.</returns>
        public bool GetHairTriggerUp()
        {
            if (CurrentInputMode == RVInputMode.Playback)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.HasCurrentFrame() ?
                                             CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, "HairTriggerUp") : null;
                return(inputInfo == null ? false : inputInfo.HairTriggerUpState);
            }
            bool stateValue = m_DeviceImpl.GetHairTriggerUp();

            if (CurrentInputMode == RVInputMode.Record)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, "HairTriggerUp");
                if (inputInfo == null)
                {
                    inputInfo = new SteamVRInputInfo();
                }
                inputInfo.HairTriggerUpState = stateValue;
                CurrentRecording.CurrentFrame.AddInputInfo(DeviceIndex, "HairTriggerUp", inputInfo);
            }
            return(stateValue);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the Steam VR button touch up state.
        /// </summary>
        /// <returns>Touch up state.</returns>
        /// <param name="buttonId">Button identifier.</param>
        public bool GetTouchUp(EVRButtonId buttonId)
        {
            if (CurrentInputMode == RVInputMode.Playback)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.HasCurrentFrame() ?
                                             CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, buttonId.ToString()) : null;
                return(inputInfo == null ? false : inputInfo.TouchUpState);
            }
            bool stateValue = m_DeviceImpl.GetTouchUp(buttonId);

            if (CurrentInputMode == RVInputMode.Record)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, buttonId.ToString());
                if (inputInfo == null)
                {
                    inputInfo = new SteamVRInputInfo();
                }
                inputInfo.TouchUpState = stateValue;
                CurrentRecording.CurrentFrame.AddInputInfo(DeviceIndex, buttonId.ToString(), inputInfo);
            }
            return(stateValue);
        }
Esempio n. 3
0
        /// <summary>
        /// Get the Steam VR axis value.
        /// </summary>
        /// <returns>The axis.</returns>
        /// <param name="buttonId">Button identifier.</param>
        public Vector2 GetAxis(EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad)
        {
            if (CurrentInputMode == RVInputMode.Playback)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.HasCurrentFrame() ?
                                             CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, buttonId.ToString()) : null;
                return(inputInfo == null ? Vector2.zero : inputInfo.AxisValue);
            }
            Vector2 axisValue = m_DeviceImpl.GetAxis(buttonId);

            if (CurrentInputMode == RVInputMode.Record)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, buttonId.ToString());
                if (inputInfo == null)
                {
                    inputInfo = new SteamVRInputInfo();
                }
                inputInfo.AxisValue = axisValue;
                CurrentRecording.CurrentFrame.AddInputInfo(DeviceIndex, buttonId.ToString(), inputInfo);
            }
            return(axisValue);
        }
Esempio n. 4
0
        /// <summary>
        /// Get the Steam VR button press down state.
        /// </summary>
        /// <param name="buttonMask">Button Mask</param>
        /// <returns>Press down state</returns>
        public bool GetPressDown(ulong buttonMask)
        {
            if (CurrentInputMode == RVInputMode.Playback)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.HasCurrentFrame() ?
                                             CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, buttonMask.ToString()) : null;
                return(inputInfo == null ? false : inputInfo.PressDownState);
            }
            bool stateValue = m_DeviceImpl.GetPressDown(buttonMask);

            if (CurrentInputMode == RVInputMode.Record)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, buttonMask.ToString());
                if (inputInfo == null)
                {
                    inputInfo = new SteamVRInputInfo();
                }
                inputInfo.PressDownState = stateValue;
                CurrentRecording.CurrentFrame.AddInputInfo(DeviceIndex, buttonMask.ToString(), inputInfo);
            }
            return(stateValue);
        }
Esempio n. 5
0
        public override void MergeInputInfo(IRecordInputInfo inputInfo)
        {
            if (inputInfo.InputMethod() != RVInputMethod.SteamVR)
            {
                throw new UnityException("Not valid input info!");
            }
            SteamVRInputInfo steamVRInputInfo = (SteamVRInputInfo)inputInfo;

            PressState     = PressState | steamVRInputInfo.PressState;
            PressDownState = PressDownState | steamVRInputInfo.PressDownState;
            PressUpState   = PressUpState | steamVRInputInfo.PressUpState;

            TouchState     = TouchState | steamVRInputInfo.TouchState;
            TouchDownState = PressDownState | steamVRInputInfo.TouchDownState;
            TouchUpState   = PressUpState | steamVRInputInfo.TouchUpState;

            AxisValue = new Vector2(
                Mathf.Max(AxisValue.x, steamVRInputInfo.AxisValue.x),
                Mathf.Max(AxisValue.y, steamVRInputInfo.AxisValue.y));

            HairTriggerState     = TouchState | steamVRInputInfo.HairTriggerState;
            HairTriggerDownState = PressDownState | steamVRInputInfo.HairTriggerDownState;
            HairTriggerUpState   = PressUpState | steamVRInputInfo.HairTriggerUpState;
        }