Пример #1
0
    string GetButtonLabel(int btnIndex)
    {
        PlayerControlsGamepad.E_Input actionID = s_GActions[btnIndex].actionID;
        JoyInput command = GamepadInputManager.Instance.GetActionButton(actionID);

        return(GetButtonLabel(command));
    }
Пример #2
0
    void saveInputs(int Slot, string gamepadName = null)
    {
        // *** save input configuration ***
        // ********************************
        // temporary string to hold the KeyCodes
        string KeyCodes_TempString = "";
        string Joystick_TempString = "";

        // go through all keycodes
        for (int sn = 0; sn < GetActionCount(); sn++)
        {
            // add every key to our temp. keycode string,also add "*" seperators
            PlayerControlsGamepad.E_Input inp = (PlayerControlsGamepad.E_Input)(sn);
            JoyInput btn = GamepadInputManager.Instance.GetActionButton(inp);
            KeyCodes_TempString += (int)btn.key + "*";
            // add joystick data to our temp. Joystick string,also add "*" seperators
            Joystick_TempString += (int)btn.joyAxis + "*";
        }

        PlayerPrefs.SetInt(sKeyLastSaveSlot, Slot);
        Save(Slot,
             gamepadName == null ? Game.CurrentJoystickName() : gamepadName,
             KeyCodes_TempString,
             Joystick_TempString,
             GetActionCount());
        // ********************************
    }
Пример #3
0
    string GetUseKeyString(PlayerControlsGamepad.E_Input command)
    {
        string keyString = null;

        GamepadInputManager.Instance.SetConfig(Game.CurrentJoystickName());
        JoyInput inputButton = GamepadInputManager.Instance.GetActionButton(command);

        if (inputButton.key != KeyCode.None || inputButton.joyAxis != E_JoystickAxis.NONE)
        {
            keyString = GuiPopupGamepadConfig.GetButtonLabel(inputButton);
        }

#if MADFINGER_KEYBOARD_MOUSE
        GamepadInputManager.Instance.SetConfig("Keyboard");
        JoyInput inputKey = GamepadInputManager.Instance.GetActionButton(command);
        if (inputKey.key != KeyCode.None || inputKey.joyAxis != E_JoystickAxis.NONE)
        {
            if (string.IsNullOrEmpty(keyString))
            {
                keyString = GuiPopupGamepadConfig.GetButtonLabel(inputKey);
            }
            else
            {
                keyString = GuiPopupGamepadConfig.GetButtonLabel(inputKey) + ", " + keyString;
            }
        }
#endif
        return(keyString);
    }
Пример #4
0
    void ChecDupliciteAxis(E_JoystickAxis testAxis, int btnIndex)
    {
        for (int m = 0; m < s_GActions.Length; m++)
        {
            PlayerControlsGamepad.E_Input actionID = s_GActions[m].actionID;
            // check if we allready have testkey in our list and make sure we dont compare with itself
            JoyInput button = GamepadInputManager.Instance.GetActionButton(actionID);
            if (testAxis == button.joyAxis && m != btnIndex)
            {
                // reset the double key
                GamepadInputManager.Instance.SetActionButton(actionID, new JoyInput(KeyCode.None, E_JoystickAxis.NONE));

                //update label
                GUIBase_Button updateBtn = m_ActionButtons[m];
                UpdateButtonLabel(updateBtn.Widget);
            }
        }
    }
Пример #5
0
    public PlayerControlsGamepad.E_Input GetInputTableAction(KeyCode keyCode)
    {
        if (m_InputTable == null)
        {
            return(PlayerControlsGamepad.E_Input.COUNT);
        }

        for (PlayerControlsGamepad.E_Input action = PlayerControlsGamepad.E_Input.Fire;
             action < PlayerControlsGamepad.E_Input.COUNT;
             action++)
        {
            if (m_InputTable[(int)action].key == keyCode)
            {
                return(action);
            }
        }
        return(PlayerControlsGamepad.E_Input.COUNT);
    }
Пример #6
0
//----------------------------------------------
//	interface
//----------------------------------------------

    //is button fopr this action currently pressed
    public bool ControlPressed(PlayerControlsGamepad.E_Input inpAction)
    {
        if ((int)inpAction >= GetActionCount())
        {
            return(false);
        }

        JoyInput btn = m_InputK[(int)inpAction];

        if (btn.joyAxis == E_JoystickAxis.NONE)
        {
            return(Input.GetKey(btn.key));
        }
        else
        {
            return(Input.GetAxis(GamepadAxis.GetAxis(btn.joyAxis)) > 0.95f);
        }
    }
Пример #7
0
    public bool ControlUp(PlayerControlsGamepad.E_Input inpAction)
    {
        if ((int)inpAction >= GetActionCount())
        {
            return(false);
        }

        JoyInput btn = m_InputK[(int)inpAction];

        if (btn.joyAxis == E_JoystickAxis.NONE)
        {
            return(Input.GetKeyUp(btn.key));
        }
        else
        {
            return(m_AxisUp[(int)btn.joyAxis]);
        }
    }
Пример #8
0
    //--------------------------------------------------

    void DetectInputSetup()
    {
        if (m_InputIndex != -1)
        {
            JoyInput pi;

            if (m_IsForKeyboard)
            {
                pi = GetKeyboardPressedInput();
            }
            else
            {
                pi = GetPressedInput();
            }
            if (pi != null)
            {
                m_TimeOfLastChange = Time.timeSinceLevelLoad;
                PlayerControlsGamepad.E_Input actionID = s_GActions[m_InputIndex].actionID;
                GamepadInputManager.Instance.SetActionButton(actionID, pi);

                //currently we do not allow duplicite keys
                if (pi.joyAxis == E_JoystickAxis.NONE)
                {
                    ChecDupliciteKey(pi.key, m_InputIndex);
                }
                else
                {
                    ChecDupliciteAxis(pi.joyAxis, m_InputIndex);
                }

                GUIBase_Button updateBtn = m_ActionButtons[m_InputIndex];
                m_InputIndex = -1;
                UpdateButtonLabel(updateBtn.Widget);
            }
        }
    }
Пример #9
0
    bool Load(string KeyCodes_loadstring, string Joystick_loadstring)
    {
        if (KeyCodes_loadstring == "" || Joystick_loadstring == "")
        {
            Debug.LogError("Load failed - empty strings");
            return(false);
        }

        // split them up and put them in an array
        string[] KeyCode_prefs = KeyCodes_loadstring.Split('*');
        string[] JoyAxis_prefs = Joystick_loadstring.Split('*');

        int len = GetActionCount();

        if (KeyCode_prefs.Length < len || JoyAxis_prefs.Length < len)
        {
            //Debug.Log(KeyCodes_loadstring + " " + Joystick_loadstring + " " + Names_loadstring);
            Debug.LogError("Load failed - lengt of parset strings do not match: " + len + ", " + KeyCode_prefs.Length + ", " + JoyAxis_prefs.Length);
            return(false);
        }

        for (int sn = 0; sn < len; sn++)
        {
            // convert the strings -> ints -> KeyCodes array
            int KeyCode_prefs_temp;
            int.TryParse(KeyCode_prefs[sn], out KeyCode_prefs_temp);
            int joyAxis_temp;
            int.TryParse(JoyAxis_prefs[sn], out joyAxis_temp);

            JoyInput btn = new JoyInput((KeyCode)KeyCode_prefs_temp, (E_JoystickAxis)joyAxis_temp);
            PlayerControlsGamepad.E_Input inp = (PlayerControlsGamepad.E_Input)(sn);
            GamepadInputManager.Instance.SetActionButton(inp, btn);
        }

        return(true);
    }
Пример #10
0
    bool ProcessKey(ref IInputEvent evt)
    {
        if (States.ActionsEnabled == false)
        {
            return(false);
        }

        if (Player.LocalInstance == null)
        {
            return(false);
        }

        KeyEvent key = (KeyEvent)evt;

        PlayerControlsGamepad.E_Input action = GetInputTableAction(key.Code);

        if (key.State == E_KeyState.Released)
        {
            // Escape and Tab are always hardcoded and can't be set by user
            switch (key.Code)
            {
            case KeyCode.Escape:
                if (MFGuiFader.Fading == false && GuiFrontendIngame.PauseMenuCooldown() == false)
                {
                    GuiFrontendIngame.ShowPauseMenu();
                }
                return(true);

            case KeyCode.Tab:
                GuiFrontendIngame.HideScoreMenu();
                return(true);
            }

            if (m_InputTable != null)
            {
                switch (action)
                {
                case PlayerControlsGamepad.E_Input.Fire:
                    Fire(false);
                    return(true);

                case PlayerControlsGamepad.E_Input.Sprint:
                    States.SprintUpDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Pause:
                    if (GuiHUD.Instance.CommandMenu != null && GuiHUD.Instance.CommandMenu.IsShown)
                    {
                        GuiHUD.Instance.CommandMenu.Hide();
                    }
                    return(true);
                }
                return(false);
            }

            switch (key.Code)
            {
            case KeyCode.RightControl:
            case KeyCode.LeftControl:
                Fire(false);
                return(true);

            case KeyCode.RightShift:
            case KeyCode.LeftShift:
                States.SprintUpDelegate();
                return(true);

            default:
                break;
            }
        }
        else if (key.State == E_KeyState.Pressed)
        {
            switch (key.Code)
            {
            case KeyCode.Return:
                //check for mouse lock unlock
                MouseCameraCtrl.SwitchCursor();
                return(true);

            case KeyCode.Tab:
                //E_MPGameType gameType = Client.Instance.GameState.GameType;
                GuiFrontendIngame.ShowScoreMenu(/*gameType, false*/);
                return(true);
            }

            if (m_InputTable != null)
            {
                switch (action)
                {
                case PlayerControlsGamepad.E_Input.Fire:
                    Fire(true);
                    return(true);

                case PlayerControlsGamepad.E_Input.Sprint:
                    States.SprintDownDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Roll:
                    States.RollDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Reload:
                    States.ReloadDelegate();
                    return(true);

                case PlayerControlsGamepad.E_Input.Weapon1:
                    ChangeWeapon(0);
                    return(true);

                case PlayerControlsGamepad.E_Input.Weapon2:
                    ChangeWeapon(1);
                    return(true);

                case PlayerControlsGamepad.E_Input.Weapon3:
                    ChangeWeapon(2);
                    return(true);

                case PlayerControlsGamepad.E_Input.Item1:
                    UseGadget(0);
                    return(true);

                case PlayerControlsGamepad.E_Input.Item2:
                    UseGadget(1);
                    return(true);

                case PlayerControlsGamepad.E_Input.Item3:
                    UseGadget(2);
                    return(true);

                case PlayerControlsGamepad.E_Input.WeaponNext:
                    ChangeWeaponNext();
                    return(true);

                case PlayerControlsGamepad.E_Input.WeaponPrev:
                    ChangeWeaponPrev();
                    return(true);

                case PlayerControlsGamepad.E_Input.Pause:
                    if (GuiHUD.Instance.CommandMenu != null && !m_IsFiring)
                    {
                        GuiHUD.Instance.CommandMenu.Show();
                        GuiHUD.Instance.CommandMenu.OpenMenu();
                    }
                    return(true);
                }
                return(false);
            }

            switch (key.Code)
            {
            case KeyCode.RightControl:
            case KeyCode.LeftControl:
                Fire(true);
                return(true);

            case KeyCode.RightShift:
            case KeyCode.LeftShift:
                States.SprintDownDelegate();
                return(true);

            case KeyCode.Space:
                States.RollDelegate();
                return(true);

            case KeyCode.R:
                States.ReloadDelegate();
                return(true);

            case KeyCode.Alpha1:
            case KeyCode.Keypad1:
                ChangeWeapon(0);
                return(true);

            case KeyCode.Alpha2:
            case KeyCode.Keypad2:
                ChangeWeapon(1);
                return(true);

            case KeyCode.Alpha3:
            case KeyCode.Keypad3:
                ChangeWeapon(2);
                return(true);

            case KeyCode.Alpha4:
            case KeyCode.Keypad4:
                ChangeWeapon(3);
                return(true);

            case KeyCode.Alpha7:
            case KeyCode.Keypad7:
                UseGadget(3);
                return(true);

            case KeyCode.Alpha8:
            case KeyCode.Keypad8:
            case KeyCode.H:
            case KeyCode.Q:
                UseGadget(2);
                return(true);

            case KeyCode.Alpha9:
            case KeyCode.Keypad9:
            case KeyCode.G:
            case KeyCode.E:
                UseGadget(1);
                return(true);

            case KeyCode.Alpha0:
            case KeyCode.Keypad0:
            case KeyCode.F:
                UseGadget(0);
                return(true);

            case KeyCode.O:
                SelectNextGadget();
                return(true);

            case KeyCode.I:
            case KeyCode.L:
                SelectPrevGadget();
                return(true);

            case KeyCode.P:
                UseSelectedGadget();
                return(true);

            default:
                break;
            }
        }

        return(false);
    }
Пример #11
0
 public void SetActionButton(PlayerControlsGamepad.E_Input inpAction, JoyInput btn)
 {
     m_InputK[(int)inpAction] = btn;
 }
Пример #12
0
 public JoyInput GetActionButton(PlayerControlsGamepad.E_Input inpAction)
 {
     return(m_InputK[(int)inpAction]);
 }