Beispiel #1
0
 private void Awake()
 {
     if (!VR_Object.activeSelf)
     {
         Trackpad = SteamVR_Input.GetVector2Action("TrackPad");
     }
 }
    // Update is called once per frame
    void Update()
    {
        MenuDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Menu").GetStateDown(InputSource);
        Menu     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Menu").GetState(InputSource);
        MenuUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Menu").GetStateUp(InputSource);

        TriggerDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabPinch").GetStateDown(InputSource);
        Trigger     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabPinch").GetState(InputSource);
        TriggerUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabPinch").GetStateUp(InputSource);

        TouchPadDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("TouchPad").GetStateDown(InputSource);
        TouchPad     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("TouchPad").GetState(InputSource);
        TouchPadUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("TouchPad").GetStateUp(InputSource);

        TouchClicDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetStateDown(InputSource);
        TouchClic     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetState(InputSource);
        TouchClicUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetStateUp(InputSource);

        GripDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabGrip").GetStateDown(InputSource);
        Grip     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabGrip").GetState(InputSource);
        GripUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabGrip").GetStateUp(InputSource);



        Squeeze = SteamVR_Input.GetSingleAction("Squeeze").GetAxis(InputSource);
        //Squeeze = (float)System.Math.Round(Squeeze , 2);
        if (Squeeze <= 0.05f)
        {
            Squeeze = 0;
        }

        TouchPos = SteamVR_Input.GetVector2Action("TouchPos").GetAxis(InputSource);
        //TouchPos = new Vector2 ((float)System.Math.Round(TouchPos.x , 2) , (float)System.Math.Round(TouchPos.y , 2) );

        /*
         * if (Menu) print("Menu");
         * if (MenuUp) print("MenuUp");
         * if (MenuDown) print("MenuDown");
         * if (Trigger) print("Trigger");
         * if (TriggerUp) print("TriggerUp");
         * if (TriggerDown) print("TriggerDown");
         * if (TouchPad) print("TouchPad");
         * if (TouchPadUp) print("TouchPadUp");
         * if (TouchPadDown) print("TouchPadDown");
         * if (TouchClic) print("TouchClic");
         * if (TouchClicUp) print("TouchClicUp");
         * if (TouchClicDown) print("TouchClicDown");
         * if (Grip) print("Grip");
         * if (GripUp) print("GripUp");
         * if (GripDown) print("GripDown");
         */
    }
        private static void InitializeActionMapping()
        {
            hapticAction              = SteamVR_Input.GetAction <SteamVR_Action_Vibration>("Haptic", false);
            m_weaponSwitchLeftAction  = SteamVR_Input.GetBooleanAction("WeaponSwitchLeft", false);
            m_weaponSwitchRightAction = SteamVR_Input.GetBooleanAction("WeaponSwitchRight", false);
            m_reloadAction            = SteamVR_Input.GetBooleanAction("Reload", false);
            m_flashlightAction        = SteamVR_Input.GetBooleanAction("ToggleFlashlight", false);
            m_shootAction             = SteamVR_Input.GetBooleanAction("Shoot", false);
            m_movementAxisAction      = SteamVR_Input.GetVector2Action("Movement", false);
            m_interactAction          = SteamVR_Input.GetBooleanAction("interact", false);
            m_crouchAction            = SteamVR_Input.GetBooleanAction("Crouch", false);
            m_sprintAction            = SteamVR_Input.GetBooleanAction("Sprint", false);
            m_jumpAction              = SteamVR_Input.GetBooleanAction("Jump", false);
            m_openMapAction           = SteamVR_Input.GetBooleanAction("OpenMap", false);
            m_openMenuAction          = SteamVR_Input.GetBooleanAction("OpenMenu", false);
            m_pingAction              = SteamVR_Input.GetBooleanAction("Ping", false);
            m_openObjectivesAction    = SteamVR_Input.GetBooleanAction("OpenObjectives", false);
            m_aimOrShoveAction        = SteamVR_Input.GetBooleanAction("AimOrShove", false);
            m_pushToTalkAction        = SteamVR_Input.GetBooleanActionFromPath("/actions/default/in/PushToTalk");


            boolActions = new Dictionary <InputAction, SteamVR_Action_Boolean>
            {
                { InputAction.Jump, m_jumpAction },
                { InputAction.Use, m_interactAction },
                { InputAction.Aim, m_aimOrShoveAction },
                { InputAction.ToggleObjectives, m_openObjectivesAction },
                { InputAction.Fire, m_shootAction },
                { InputAction.Run, m_sprintAction },
                { InputAction.Crouch, m_crouchAction },
                { InputAction.Reload, m_reloadAction },
                { InputAction.VoiceChatPushToTalk, m_pushToTalkAction },
                { InputAction.NavMarkerPing, m_pingAction },
                { InputAction.TerminalUp, m_weaponSwitchLeftAction },
                { InputAction.TerminalDown, m_weaponSwitchRightAction },
                { InputAction.TerminalExit, m_reloadAction },
                { InputAction.MenuClick, m_shootAction },
                //{ InputAction.MenuClickAlternate, interactAction },
                { InputAction.MenuExit, m_reloadAction },
                { InputAction.MenuToggle, m_openMenuAction },
                { InputAction.ToggleMap, m_openMapAction },
                { InputAction.Flashlight, m_flashlightAction },
            };
        }
Beispiel #4
0
        private void InitializeActionMapping()
        {
            hapticAction            = SteamVR_Input.GetAction <SteamVR_Action_Vibration>("Haptic", false);
            weaponSwitchLeftAction  = SteamVR_Input.GetBooleanAction("WeaponSwitchLeft", false);
            weaponSwitchRightAction = SteamVR_Input.GetBooleanAction("WeaponSwitchRight", false);
            reloadAction            = SteamVR_Input.GetBooleanAction("Reload", false);
            flashlightAction        = SteamVR_Input.GetBooleanAction("ToggleFlashlight", false);
            snapLeftAction          = SteamVR_Input.GetBooleanAction("SnapTurnLeft", false);
            snapRightAction         = SteamVR_Input.GetBooleanAction("SnapTurnRight", false);
            shootAction             = SteamVR_Input.GetBooleanAction("Shoot", false);
            toggleWatchAction       = SteamVR_Input.GetBooleanAction("ToggleWatchMode", false);
            movementAxisAction      = SteamVR_Input.GetVector2Action("Movement", false);
            interactAction          = SteamVR_Input.GetBooleanAction("interact", false);
            crouchAction            = SteamVR_Input.GetBooleanAction("Crouch", false);
            sprintAction            = SteamVR_Input.GetBooleanAction("Sprint", false);
            jumpAction     = SteamVR_Input.GetBooleanAction("Jump", false);
            openMapAction  = SteamVR_Input.GetBooleanAction("OpenMap", false);
            openMenuAction = SteamVR_Input.GetBooleanAction("OpenMenu", false);
            pingAction     = SteamVR_Input.GetBooleanAction("Ping", false);


            VRInput.boolActions = new Dictionary <InputAction, SteamVR_Action_Boolean>
            {
                { InputAction.Jump, jumpAction },
                { InputAction.Use, interactAction },
                { InputAction.Aim, toggleWatchAction },
                { InputAction.Fire, shootAction },
                { InputAction.Run, sprintAction },
                { InputAction.Crouch, crouchAction },
                { InputAction.Reload, reloadAction },
                //{ InputAction.Melee, aimAction },
                { InputAction.NavMarkerPing, pingAction },
                { InputAction.TerminalUp, weaponSwitchLeftAction },
                { InputAction.TerminalDown, weaponSwitchRightAction },
                { InputAction.TerminalExit, reloadAction },
                { InputAction.MenuClick, shootAction },
                { InputAction.MenuClickAlternate, interactAction },
                { InputAction.MenuExit, reloadAction },
                { InputAction.MenuToggle, openMenuAction },
                { InputAction.ToggleMap, openMapAction },
                { InputAction.Flashlight, flashlightAction }
            };
        }
    protected override void FillMetadata(HandAnchor anchor, ref XRNodeState xRNode)
    {
        //base.UpdateHandNodeState(hand, ref xRNode);
        float thumb = 0f, index = 0f, middle = 0f;

        //psotion && rotation
        xRNode.TryGetPosition(out anchor.position);
        xRNode.TryGetRotation(out anchor.rotation);

        var    inputSource      = SteamVR_Input_Sources.LeftHand;
        string skeletonHandName = "SkeletonLeftHand";

        if (anchor.type == NodeType.RightHand)
        {
            inputSource      = SteamVR_Input_Sources.RightHand;
            skeletonHandName = "skeletonRightHand";
        }

        //SteamVR_Action_Boolean key_MenuKey = SteamVR_Input.GetBooleanAction("MenuKey");
        //SteamVR_Action_Boolean key_SystemKey = SteamVR_Input.GetBooleanAction("SystemKey");

        //trigger
        SteamVR_Action_Boolean triggerPressed = SteamVR_Input.GetBooleanAction("Trigger");

        //SteamVR_Action_Single triggerTouchValue = SteamVR_Input.GetSingleAction("triggerTouchValue");
        anchor.triggerPressed    = triggerPressed.GetState(inputSource);
        anchor.triggerTouchValue = Mathf.Lerp(anchor.triggerTouchValue, anchor.triggerPressed ? 1f : 0f, Time.deltaTime * 5);
        index = anchor.triggerTouchValue;

        //grip
        SteamVR_Action_Boolean gripPressed = SteamVR_Input.GetBooleanAction("SideTrigger");

        //SteamVR_Action_Single gripTouchValue = SteamVR_Input.GetSingleAction("gripTouchValue");
        anchor.gripPressed    = gripPressed.GetState(inputSource);
        anchor.gripTouchValue = Mathf.Lerp(anchor.gripTouchValue, anchor.gripPressed ? 1f : 0f, Time.deltaTime * 5);
        middle = anchor.gripTouchValue;

        //primary2DAxis
        SteamVR_Action_Vector2 primary2DAxis      = SteamVR_Input.GetVector2Action("ThumbStick");
        SteamVR_Action_Boolean primary2DAxisClick = SteamVR_Input.GetBooleanAction("PadDown");

        anchor.primary2DAxis        = primary2DAxis.GetAxis(inputSource);
        anchor.primary2DAxisTouch   = anchor.primary2DAxis.sqrMagnitude > 0.02f;
        anchor.primary2DAxisPressed = primary2DAxisClick.GetState(inputSource);
        thumb = Mathf.Max(thumb, (anchor.primary2DAxisPressed || anchor.primary2DAxisTouch) ? 1f : 0f);
        thumb = Mathf.Max(thumb, anchor.primary2DAxis.sqrMagnitude > 0.1f ? 1f : 0f);

        //primary
        SteamVR_Action_Boolean primaryPressed = SteamVR_Input.GetBooleanAction("BKey");

        anchor.primaryPressed    = primaryPressed.GetState(inputSource);
        anchor.primaryTouchValue = (anchor.primaryPressed) ? 1f : 0f;
        thumb = Mathf.Max(thumb, anchor.primaryTouchValue);

        //secondary
        SteamVR_Action_Boolean secondaryPressed = SteamVR_Input.GetBooleanAction("AKey");

        anchor.secondaryPressed    = secondaryPressed.GetState(inputSource);
        anchor.secondaryTouchValue = (anchor.secondaryPressed) ? 1f : 0f;
        thumb = Mathf.Max(thumb, anchor.secondaryTouchValue);

        //fingers
        var skeletonHand = SteamVR_Input.GetAction <SteamVR_Action_Skeleton>(skeletonHandName);

        if (skeletonHand.poseIsValid)
        {
            anchor.handPoseChanged = skeletonHand.poseChanged;
            anchor.fingerCurls[0]  = skeletonHand.thumbCurl;
            anchor.fingerCurls[1]  = skeletonHand.indexCurl;
            anchor.fingerCurls[2]  = skeletonHand.middleCurl;
            anchor.fingerCurls[3]  = skeletonHand.ringCurl;
            anchor.fingerCurls[4]  = skeletonHand.pinkyCurl;
        }
        else
        {
            anchor.handPoseChanged = true;
            anchor.fingerCurls[0]  = thumb;
            anchor.fingerCurls[1]  = index;
            anchor.fingerCurls[2]  = middle;
            anchor.fingerCurls[3]  = middle;
            anchor.fingerCurls[4]  = middle;
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     m_LeftThumbstick = SteamVR_Input.GetVector2Action("thumbstickleftmove");
 }
Beispiel #7
0
        private void Awake()
        {
            Log.Info("Snapturn init");

            smoothTurn = SteamVR_Input.GetVector2Action("SnapTurn");
        }