示例#1
0
        /// <summary>
        /// Returns the current Nintendo Controller state.
        /// </summary>
        /// <returns></returns>
        public NintendoControllerState GetState()
        {
            var state = this._previousState;

            if (--this._debounce <= 0)
            {
                if (this._controller.QueryDevice())
                {
                    state = new NintendoControllerState(this._controller.ControllerInput);
                }
                else
                {
                    state = NintendoControllerState.Disconnected;
                }

                this._debounce      = DEBOUNCE_PERIOD;
                this._previousState = state;
            }

            return(state);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NintendoController"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public NintendoController(Game game)
 {
     this._controller    = new UsbSingleNintendoController(game.Window.Handle);
     this._previousState = NintendoControllerState.Disconnected;
 }