示例#1
0
        public static GamepadState GetState(Index controlIndex, bool raw = false)
        {
            state.LeftStickAxis  = MyInputManager.GetAxis(MyInputManager.Axis.LeftStick, controlIndex);
            state.rightStickAxis = MyInputManager.GetAxis(MyInputManager.Axis.RightStick, controlIndex);

            state.LeftTrigger  = MyInputManager.GetTrigger(MyInputManager.Trigger.LeftTrigger, controlIndex);
            state.RightTrigger = MyInputManager.GetTrigger(MyInputManager.Trigger.RightTrigger, controlIndex);

            return(state);
        }
    void Update()
    {
        for (int i = 0; i < buttonLength; i++)
        {
            buttonName = (MyInputManager.Button)i;
            if (MyInputManager.GetButtonDown(buttonName))
            {
                Debug.Log("push " + buttonName + " button");
            }
        }

        for (int i = 0; i < stickButtonLength; i++)
        {
            stickButtonName = (MyInputManager.StickDirection)i;
            if (MyInputManager.IsJustStickDown(stickButtonName))
            {
                Debug.Log("push " + stickButtonName);
            }
        }

        if (MyInputManager.IsJustTriggerDown(MyInputManager.Trigger.LeftTrigger))
        {
            Debug.Log("push LeftTrigger");
        }
        if (MyInputManager.IsJustTriggerDown(MyInputManager.Trigger.RightTrigger))
        {
            Debug.Log("push RightTrigger");
        }

        float leftTrigger = MyInputManager.GetTrigger(MyInputManager.Trigger.LeftTrigger);

        if (leftTrigger != 0.0f)
        {
            Debug.Log("leftTrigger = " + leftTrigger);
        }
        float rightTrigger = MyInputManager.GetTrigger(MyInputManager.Trigger.RightTrigger);

        if (rightTrigger != 0.0f)
        {
            Debug.Log("leftTrigger = " + rightTrigger);
        }

        Vector2 leftStick = MyInputManager.GetAxis(MyInputManager.Axis.LeftStick);

        if (leftStick != Vector2.zero)
        {
            Debug.Log("leftStick = " + leftStick);
        }
        Vector2 rightStick = MyInputManager.GetAxis(MyInputManager.Axis.RightStick);

        if (rightStick != Vector2.zero)
        {
            Debug.Log("rightStick = " + rightStick);
        }
        Vector2 dPad = MyInputManager.GetAxis(MyInputManager.Axis.Dpad);

        if (dPad != Vector2.zero)
        {
            Debug.Log("dPad = " + dPad);
        }
    }