Пример #1
0
        private void AddState(InputStateBase inputState)
        {
            m_inputStates.Add(inputState);

            // Register first MouseOrPointer state as default
            if (this.DefaultMouseOrPointer == MouseOrPointerState.Dummy)
            {
                MouseOrPointerState mouseOrPointer = inputState as MouseOrPointerState;
                if (mouseOrPointer != null)
                {
                    this.DefaultMouseOrPointer = mouseOrPointer;
                }
            }

            // Register first Gamepad state as default
            if (this.DefaultGamepad == GamepadState.Dummy)
            {
                GamepadState gamepadState = inputState as GamepadState;
                if (gamepadState != null)
                {
                    this.DefaultGamepad = gamepadState;
                }
            }

            // Register first keyboard state as default
            if (this.DefaultKeyboard == KeyboardState.Dummy)
            {
                KeyboardState keyboardState = inputState as KeyboardState;
                if (keyboardState != null)
                {
                    this.DefaultKeyboard = keyboardState;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericGamepadHandler"/> class.
        /// </summary>
        public GenericGamepadHandler()
        {
            m_gamepads = new Gamepad[MAX_GAMEPAD_COUNT];

            m_states = new GamepadState[m_gamepads.Length];
            for (int loop = 0; loop < m_gamepads.Length; loop++)
            {
                m_states[loop] = new GamepadState(loop);
            }
        }
Пример #3
0
        /// <summary>
        /// Copies this object and then resets it
        /// in preparation of the next update pass.
        /// Called by update-render loop.
        /// </summary>
        protected override void CopyAndResetForUpdatePassInternal(InputStateBase targetState)
        {
            GamepadState targetStateCasted = targetState as GamepadState;

            targetStateCasted.EnsureNotNull(nameof(targetStateCasted));

            targetStateCasted.m_controllerIndex = this.m_controllerIndex;
            targetStateCasted.m_isConnected     = this.m_isConnected;
            targetStateCasted.m_prevState       = this.m_prevState;
            targetStateCasted.m_currentState    = this.m_currentState;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericXInputHandler"/> class.
        /// </summary>
        public GenericXInputHandler()
        {
            m_controllers    = new XI.Controller[4];
            m_controllers[0] = new XI.Controller(XI.UserIndex.One);
            m_controllers[1] = new XI.Controller(XI.UserIndex.Two);
            m_controllers[2] = new XI.Controller(XI.UserIndex.Three);
            m_controllers[3] = new XI.Controller(XI.UserIndex.Four);

            m_states = new GamepadState[m_controllers.Length];
            for (int loop = 0; loop < m_controllers.Length; loop++)
            {
                m_states[loop] = new GamepadState(loop);
            }
        }