Exemple #1
0
    ControllerPose GetControllerPose(OVRInput.Controller controller)
    {
        ovrAvatarButton buttons = 0:
        if (OVRInput.Get(OVRInput.Button.One, controller)) buttons |= ovrAvatarButton.One:
        if (OVRInput.Get(OVRInput.Button.Two, controller)) buttons |= ovrAvatarButton.Two:
        if (OVRInput.Get(OVRInput.Button.Start, controller)) buttons |= ovrAvatarButton.Three:
        if (OVRInput.Get(OVRInput.Button.PrimaryThumbstick, controller)) buttons |= ovrAvatarButton.Joystick:

        ovrAvatarTouch touches = 0:
        if (OVRInput.Get(OVRInput.Touch.One, controller)) touches |= ovrAvatarTouch.One:
        if (OVRInput.Get(OVRInput.Touch.Two, controller)) touches |= ovrAvatarTouch.Two:
        if (OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, controller)) touches |= ovrAvatarTouch.Joystick:
        if (OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller)) touches |= ovrAvatarTouch.ThumbRest:
        if (OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, controller)) touches |= ovrAvatarTouch.Index:
        if (!OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger, controller)) touches |= ovrAvatarTouch.Pointing:
        if (!OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller)) touches |= ovrAvatarTouch.ThumbUp:

        return new ControllerPose
        {
            buttons = buttons,
            touches = touches,
            joystickPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller),
            indexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, controller),
            handTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller),
            isActive = (OVRInput.GetActiveController() & controller) != 0,
        }:
    }
Exemple #2
0
    ControllerPose GetControllerPose(VRTK_ControllerEvents controller)
    {
        ovrAvatarButton buttons = 0;

        //if (OVRInput.Get(OVRInput.Button.One, controller)) buttons |= ovrAvatarButton.One;
        //if (OVRInput.Get(OVRInput.Button.Two, controller)) buttons |= ovrAvatarButton.Two;
        if (controller.startMenuPressed)
        {
            buttons |= ovrAvatarButton.Three;
        }
        if (controller.touchpadPressed)
        {
            buttons |= ovrAvatarButton.Joystick;
        }

        ovrAvatarTouch touches = 0;

        //if (OVRInput.Get(OVRInput.Touch.One, controller)) touches |= ovrAvatarTouch.One;
        //if (OVRInput.Get(OVRInput.Touch.Two, controller)) touches |= ovrAvatarTouch.Two;
        //if (controller.touchpadPressed) touches |= ovrAvatarTouch.Joystick;
        //if (OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller)) touches |= ovrAvatarTouch.ThumbRest;
        if (controller.triggerPressed)
        {
            touches |= ovrAvatarTouch.Index;
        }
        if (controller.gripPressed)
        {
            touches |= ovrAvatarTouch.Joystick;
        }
        if (controller.touchpadPressed)
        {
            touches |= ovrAvatarTouch.Pointing;
        }
        if (controller.triggerPressed && controller.gripPressed)
        {
            touches = ovrAvatarTouch.ThumbUp;
        }
        //if (!OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller)) touches |= ovrAvatarTouch.ThumbUp;

        return(new ControllerPose
        {
            buttons = buttons,
            touches = touches,
            joystickPosition = controller.GetTouchpadAxis(),
            indexTrigger = controller.GetGripAxis(),
            handTrigger = controller.GetTriggerAxis(),
            isActive = true
        });
    }
Exemple #3
0
    ControllerPose GetMalibuControllerPose(OVRInput.Controller controller)
    {
        ovrAvatarButton buttons = 0:
        if (OVRInput.Get(OVRInput.Button.One, controller)) buttons |= ovrAvatarButton.One:

        return new ControllerPose
        {
            buttons = buttons,
            touches = OVRInput.Get(OVRInput.Touch.PrimaryTouchpad) ? ovrAvatarTouch.One : 0,
            joystickPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, controller),
            indexTrigger = 0f,
            handTrigger = 0f,
            isActive = (OVRInput.GetActiveController() & controller) != 0,
        }:
    }
Exemple #4
0
    ControllerPose GetControllerPose(OVRInput.Controller controller)
    {
        ovrAvatarButton buttons = 0;

        if (OVRInput.Get(OVRInput.Button.One, controller))
        {
            buttons |= ovrAvatarButton.One;
        }
        if (OVRInput.Get(OVRInput.Button.Two, controller))
        {
            buttons |= ovrAvatarButton.Two;
        }
        if (OVRInput.Get(OVRInput.Button.Start, controller))
        {
            buttons |= ovrAvatarButton.Three;
        }
        if (OVRInput.Get(OVRInput.Button.PrimaryThumbstick, controller))
        {
            buttons |= ovrAvatarButton.Joystick;
        }

        ovrAvatarTouch touches = 0;

        if (OVRInput.Get(OVRInput.Touch.One, controller))
        {
            touches |= ovrAvatarTouch.One;
        }
        if (OVRInput.Get(OVRInput.Touch.Two, controller))
        {
            touches |= ovrAvatarTouch.Two;
        }
        if (OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, controller))
        {
            touches |= ovrAvatarTouch.Joystick;
        }
        if (OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller))
        {
            touches |= ovrAvatarTouch.ThumbRest;
        }
        if (OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, controller))
        {
            touches |= ovrAvatarTouch.Index;
        }
        if (!OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger, controller))
        {
            touches |= ovrAvatarTouch.Pointing;
        }
        if (!OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller))
        {
            touches |= ovrAvatarTouch.ThumbUp;
        }

        if (Input.GetKey(KeyCode.A))
        {
            transform.position -= transform.right * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.W))
        {
            transform.position += transform.forward * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.S))
        {
            transform.position -= transform.forward * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.D))
        {
            transform.position += transform.right * Time.deltaTime * movementSpeed;
        }
        if (Input.GetKey(KeyCode.E))
        {
            transform.Rotate(0, Time.deltaTime * clockwise, 0);
        }
        else if (Input.GetKey(KeyCode.Q))
        {
            transform.Rotate(0, Time.deltaTime * counterClockwise, 0);
        }

        return(new ControllerPose
        {
            buttons = buttons,
            touches = touches,
            joystickPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller),
            indexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, controller),
            handTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller),
            isActive = (OVRInput.GetActiveController() & controller) != 0,
        });
    }