Example #1
0
        private void fireInputBegan(InputDeviceType inputType, GamePadState gpdState, KeyboardState keyState, MouseState mosState, Keys keyBtn, GamepadCode gpdBtn, MouseCode mosBtn)
        {
            InputObject input = new InputObject(inputType, gpdState, mosState, keyBtn, gpdBtn, mosBtn);

            //General
            for (int i = 0; i < generalListeners.Count; i++)
            {
                GeneralInputListener listener = generalListeners[i];
                listener.InputBegan(input);
                switch (inputType)
                {
                case (InputDeviceType.Gamepad):
                    listener.GamepadInputBegan(input);
                    break;

                case (InputDeviceType.Keyboard):
                    listener.KeyboardInputBegan(input);
                    break;

                case (InputDeviceType.Mouse):
                    listener.MouseInputBegan(input);
                    break;
                }
            }
            //Others
            switch (inputType)
            {
            case (InputDeviceType.Gamepad):
                for (int i = 0; i < gamepadListeners.Count; i++)
                {
                    GamepadListener listener = gamepadListeners[i];
                    listener.InputBegan(input);
                }
                break;

            case (InputDeviceType.Keyboard):
                for (int i = 0; i < keyboardListeners.Count; i++)
                {
                    KeyboardListener listener = keyboardListeners[i];
                    listener.InputBegan(input);
                }
                if (keyboardBinds.ContainsKey(keyBtn))
                {
                    keyboardBinds[keyBtn].Began();
                }
                break;

            case (InputDeviceType.Mouse):
                for (int i = 0; i < mouseListeners.Count; i++)
                {
                    MouseListener listener = mouseListeners[i];
                    listener.InputBegan(input);
                }
                break;

            default:
                break;
            }
        }