Beispiel #1
0
        public InputObject(InputDeviceType deviceType, GamePadState gpdState, MouseState mosState, Keys keyBtn, GamepadCode gpdBtn, MouseCode musBtn)
        {
            this.gamepadCode  = gpdBtn;
            this.keyboardCode = keyBtn;
            this.mouseCode    = musBtn;

            this.gpdState = gpdState;
            this.mosState = mosState;
        }
Beispiel #2
0
        private void fireInputEnd(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.InputEnded(input);
                switch (inputType)
                {
                case (InputDeviceType.Gamepad):
                    listener.GamepadInputEnded(input);
                    break;

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

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

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

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

            default:
                break;
            }
        }