Beispiel #1
0
    void ToolControllerAction()
    {
        toolTrackUp    = Input.GetKeyDown(KeyCode.UpArrow);
        toolTrackDown  = Input.GetKeyDown(KeyCode.DownArrow);
        toolTrackLeft  = Input.GetKeyDown(KeyCode.LeftArrow);
        toolTrackRight = Input.GetKeyDown(KeyCode.RightArrow);

        toolEnter = Input.GetKeyDown(KeyCode.Return);

        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow))
        {
            toolLeftRightDown = true;
        }
        else
        {
            toolLeftRightDown = false;
        }

        if (toolEnter)
        {
            toolSet.TriggerDown();
        }
        else if (toolTrackLeft)
        {
            toolSet.PadRight(ViveControllerInput.Button.release);
            toolSet.PadLeft(ViveControllerInput.Button.press);
            toolPressed = true;
        }
        else if (toolTrackRight)
        {
            toolSet.PadLeft(ViveControllerInput.Button.release);
            toolSet.PadRight(ViveControllerInput.Button.press);
            toolPressed = true;
        }
        else if (toolTrackDown)
        {
            toolSet.PadDown();
        }
        else if (toolTrackUp)
        {
            toolSet.PadUp();
        }


        if (!toolLeftRightDown && toolPressed)
        {
            toolSet.PadLeft(ViveControllerInput.Button.release);
            toolSet.PadRight(ViveControllerInput.Button.release);
            toolPressed = false;
        }
    }
Beispiel #2
0
    //Controller actions
    #region
    void ToolControllerAction()
    {
        toolTrackPos  = SteamVR_Input.GetVector2(trackPadPos_tool, SteamVR_Input_Sources.Any, true);
        toolTrackDown = SteamVR_Input.GetStateDown(trackPadClick_tool, SteamVR_Input_Sources.Any, true);
        toolTrack     = SteamVR_Input.GetState(trackPadClick_tool, SteamVR_Input_Sources.Any, true);

        if (SteamVR_Input.GetStateDown(triggerClick_tool, SteamVR_Input_Sources.Any, true))
        {
            toolSet.TriggerDown();
        }
        else if (toolTrackDown && toolTrackPos.y < 0.5f && toolTrackPos.y > -0.5f)
        {
            if (toolTrackPos.x < -0.5f)
            {
                toolSet.PadRight(Button.release);
                toolSet.PadLeft(Button.press);
                toolPressed = true;
            }
            else if (toolTrackPos.x > 0.5f)
            {
                toolSet.PadLeft(Button.release);
                toolSet.PadRight(Button.press);
                toolPressed = true;
            }
        }
        else if (toolTrackDown && toolTrackPos.x < 0.5f && toolTrackPos.x > -0.5f)
        {
            if (toolTrackPos.y < -0.5f)
            {
                toolSet.PadDown();
            }
            else if (toolTrackPos.y > 0.5f)
            {
                toolSet.PadUp();
            }
        }

        if (!toolTrack && toolPressed)
        {
            toolSet.PadLeft(Button.release);
            toolSet.PadRight(Button.release);
            toolPressed = false;
        }
    }