/// <summary> /// Creates a new instance of the InputManager component and adds itself to the game's component collection as well as Service /// </summary> /// <param name = "application">The game instance</param> public InputManager(Application application) : base(application) { if (application == null) { throw new ArgumentNullException("application", "InputManager requires a valid application instance"); } if (Application.Input != null) { throw new CoreException("There already is an InputManager instance."); } application.Components.Add(this); application.Services.AddService(typeof(InputManager), this); Player1 = new PlayerInput(PlayerIndex.One); Player1.Connected += OnPlayerConnected; Player1.Disconnected += OnPlayerDisconnected; Player2 = new PlayerInput(PlayerIndex.Two); Player2.Connected += OnPlayerConnected; Player2.Disconnected += OnPlayerDisconnected; Player3 = new PlayerInput(PlayerIndex.Three); Player3.Connected += OnPlayerConnected; Player3.Disconnected += OnPlayerDisconnected; Player4 = new PlayerInput(PlayerIndex.Four); Player4.Connected += OnPlayerConnected; Player4.Disconnected += OnPlayerDisconnected; _noInputDeviceConnectedPlayer1 = new NoPlayerInput(PlayerIndex.One); _noInputDeviceConnectedPlayer2 = new NoPlayerInput(PlayerIndex.Two); _noInputDeviceConnectedPlayer3 = new NoPlayerInput(PlayerIndex.Three); _noInputDeviceConnectedPlayer4 = new NoPlayerInput(PlayerIndex.Four); _connectedPlayers = new Dictionary <PlayerIndex, PlayerInput>(); Player1.CheckConnectionStatus(); Player2.CheckConnectionStatus(); Player3.CheckConnectionStatus(); Player4.CheckConnectionStatus(); #if WINDOWS Game.Activated += delegate { _windowFocused = true; }; Game.Deactivated += delegate { _windowFocused = false; }; _windowFocused = true; #elif WINDOWS_PHONE VirtualGamePadSkin = new VirtualGamePadSkin(); #endif }
/// <summary> /// Creates a new instance of the InputManager component and adds itself to the game's component collection as well as Service /// </summary> /// <param name = "application">The game instance</param> public InputManager(Application application) : base(application) { if (application == null) throw new ArgumentNullException("application", "InputManager requires a valid application instance"); if (Application.Input != null) throw new CoreException("There already is an InputManager instance."); application.Components.Add(this); application.Services.AddService(typeof (InputManager), this); Player1 = new PlayerInput(PlayerIndex.One); Player1.Connected += OnPlayerConnected; Player1.Disconnected += OnPlayerDisconnected; Player2 = new PlayerInput(PlayerIndex.Two); Player2.Connected += OnPlayerConnected; Player2.Disconnected += OnPlayerDisconnected; Player3 = new PlayerInput(PlayerIndex.Three); Player3.Connected += OnPlayerConnected; Player3.Disconnected += OnPlayerDisconnected; Player4 = new PlayerInput(PlayerIndex.Four); Player4.Connected += OnPlayerConnected; Player4.Disconnected += OnPlayerDisconnected; _noInputDeviceConnectedPlayer1 = new NoPlayerInput(PlayerIndex.One); _noInputDeviceConnectedPlayer2 = new NoPlayerInput(PlayerIndex.Two); _noInputDeviceConnectedPlayer3 = new NoPlayerInput(PlayerIndex.Three); _noInputDeviceConnectedPlayer4 = new NoPlayerInput(PlayerIndex.Four); _connectedPlayers = new Dictionary<PlayerIndex, PlayerInput>(); Player1.CheckConnectionStatus(); Player2.CheckConnectionStatus(); Player3.CheckConnectionStatus(); Player4.CheckConnectionStatus(); #if WINDOWS Game.Activated += delegate { _windowFocused = true; }; Game.Deactivated += delegate { _windowFocused = false; }; _windowFocused = true; #elif WINDOWS_PHONE VirtualGamePadSkin = new VirtualGamePadSkin(); #endif }