コード例 #1
0
ファイル: VRControllerState.cs プロジェクト: klukule/FlaxAPI
        /// <summary>
        /// Updates the controller.
        /// </summary>
        /// <param name="role">The role.</param>
        /// <param name="state">The state.</param>
        /// <param name="pose">The pose.</param>
        internal void Update(VRControllerRole role, ref VRControllerState_t state, ref VRPose pose)
        {
            IsConnected = true;
            Pose        = pose;
            Role        = role;

            // Trackpad
            Trackpad.X     = state.rAxis0.x;
            Trackpad.Y     = state.rAxis0.y;
            TrackpadTouch  = state.GetButtonTouched(EVRButtonId.k_EButton_Axis0);
            TrackpadButton = state.GetButtonPressed(EVRButtonId.k_EButton_Axis0).ToButtonState();

            // Trigger
            Trigger       = state.rAxis1.x;
            TriggerButton = state.GetButtonPressed(EVRButtonId.k_EButton_Axis1).ToButtonState();

            // Buttons
            ApplicationMenu = state.GetButtonPressed(EVRButtonId.k_EButton_ApplicationMenu).ToButtonState();
            A    = state.GetButtonPressed(EVRButtonId.k_EButton_A).ToButtonState();
            Grip = state.GetButtonPressed(EVRButtonId.k_EButton_Grip).ToButtonState();

            // DPad
            DPad.Up    = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Up).ToButtonState();
            DPad.Down  = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Down).ToButtonState();
            DPad.Left  = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Left).ToButtonState();
            DPad.Right = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Right).ToButtonState();
        }
コード例 #2
0
        internal void Update(int id, VRControllerRole role, ref VRControllerState_t state, ref VRPose pose)
        {
            this.Update(id, pose);

            this.Role = role;

            // Axies
            this.Trackpad.X = state.rAxis0.x;
            this.Trackpad.Y = state.rAxis0.y;
            this.Trigger    = state.rAxis1.x;

            // Buttons
            this.TrackpadButton  = state.GetButtonPressed(EVRButtonId.k_EButton_SteamVR_Touchpad).ToButtonState();
            this.TriggerButton   = state.GetButtonPressed(EVRButtonId.k_EButton_SteamVR_Trigger).ToButtonState();
            this.ApplicationMenu = state.GetButtonPressed(EVRButtonId.k_EButton_ApplicationMenu).ToButtonState();
            this.A    = state.GetButtonPressed(EVRButtonId.k_EButton_A).ToButtonState();
            this.Grip = state.GetButtonPressed(EVRButtonId.k_EButton_Grip).ToButtonState();

            this.TrackpadTouch = state.GetButtonTouched(EVRButtonId.k_EButton_SteamVR_Touchpad);

            // DPad
            this.DPad.Up    = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Up).ToButtonState();
            this.DPad.Right = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Right).ToButtonState();
            this.DPad.Left  = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Left).ToButtonState();
            this.DPad.Down  = state.GetButtonPressed(EVRButtonId.k_EButton_DPad_Down).ToButtonState();
        }