Exemplo n.º 1
0
        public static AxisValue GetAxisValue(uint controller, Axis axis)
        {
            //var state = new Valve.VR.VRControllerState_t();
            var success = OpenVR.GetControllerState(controller, ref state, (uint)Marshal.SizeOf(typeof(Valve.VR.VRControllerState_t)));

            switch (axis)
            {
            case Axis.Joystick:
                return(new AxisValue(state.rAxis0));

            case Axis.Trigger:
                return(new AxisValue(state.rAxis1));

            case Axis.Grip:
                return(new AxisValue(state.rAxis2));

            case Axis.Axis3:
                return(new AxisValue(state.rAxis3));

            case Axis.Axis4:
                return(new AxisValue(state.rAxis4));

            default:
                return(new AxisValue(0, 0));
            }
        }
Exemplo n.º 2
0
        public static bool GetIsPressed(uint controller, ulong button)
        {
            if (controller == 0)
            {
                return(false);
            }
            //var state = new Valve.VR.VRControllerState_t();
            var success = OpenVR.GetControllerState(controller, ref state, (uint)Marshal.SizeOf(typeof(Valve.VR.VRControllerState_t)));

            if (!success)
            {
                return(false);
            }
            return((state.ulButtonPressed & button) != 0);
        }