Пример #1
0
    public void SetupDevice(Bindings a_bindings)
    {
        LeftStickAxis = new TwoAxisInput(currentBindings.LeftXAxis + PadID,
                                         currentBindings.LeftYAxis + PadID);

        RightStickAxis = new TwoAxisInput(currentBindings.RightXAxis + PadID,
                                          currentBindings.RightYAxis + PadID);

        DPadAxis = new TwoAxisWithButtonInput(currentBindings.DPadX + PadID,
                                              currentBindings.DPadY + PadID);

        LeftTrigger  = new OneAxisWithButtonInput(currentBindings.LeftTriggerAxis + PadID);
        RightTrigger = new OneAxisWithButtonInput(currentBindings.RightTriggerAxis + PadID);

        keyLookup[InputButtonValue.LeftStickButton]  = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.LeftStickButton, PadID);
        keyLookup[InputButtonValue.RightStickButton] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.RightStickButton, PadID);

        keyLookup[InputButtonValue.Action1] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Action1, PadID);
        keyLookup[InputButtonValue.Action2] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Action2, PadID);
        keyLookup[InputButtonValue.Action3] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Action3, PadID);
        keyLookup[InputButtonValue.Action4] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Action4, PadID);

        keyLookup[InputButtonValue.LeftBumper]  = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.LeftBumper, PadID);
        keyLookup[InputButtonValue.RightBumper] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.RightBumper, PadID);

        keyLookup[InputButtonValue.Start]   = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Start, PadID);
        keyLookup[InputButtonValue.Return]  = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Return, PadID);
        keyLookup[InputButtonValue.Select]  = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Select, PadID);
        keyLookup[InputButtonValue.Pause]   = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Pause, PadID);
        keyLookup[InputButtonValue.Menu]    = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Menu, PadID);
        keyLookup[InputButtonValue.Options] = GamePadKeyCodeHelper.GetTargetPadButton(currentBindings.Options, PadID);
    }
    private bool CheckGamePadEngagement(out int a_controllerID)
    {
        for (int i = 0; i < currentEngagmentStatus.ControllersEngaged.Length; ++i)
        {
            if (currentEngagmentStatus.ControllersEngaged[i])
            {
                continue;
            }

            KeyCode padKeycode = GamePadKeyCodeHelper.GetTargetPadButton(gamePadEngagementKey, i);
            if (Input.GetKeyDown(padKeycode))
            {
                // Pad Engaged
                currentEngagmentStatus.ControllersEngaged[i] = true;
                Debug.Log("Pad " + i + " engaged!");
                a_controllerID = i;
                return(true);
            }
        }

        a_controllerID = -1;
        return(false);
    }