Пример #1
0
 /// <summary>
 /// Buttons the pressed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="button">The button.</param>
 private void ButtonPressed(GamepadDevice sender, GamepadButton button)
 {
     this.strings.AppendLine(String.Format("Pressed: {0}", button.Button));
 }
Пример #2
0
 /// <summary>
 /// Get the specified GamepadDevice or create a new one if possible
 /// </summary>
 /// <param name="index">The index of the controller.</param>
 /// <returns>
 /// A GamepadDevice instance or null if the controller could not be created
 /// </returns>
 public GamepadDevice GetController(PlayerIndex index)
 {
     GamepadDevice gamepad = null;
     foreach (IInputDevice device in this.devices)
     {
         gamepad = device as GamepadDevice;
         if (gamepad != null)
         {
             if (gamepad.PlayerIndex == index)
             {
                 return gamepad;
             }
         }
     }
     if (GamePad.GetState(index).IsConnected)
     {
         gamepad = new GamepadDevice(index);
         this.devices.Add(gamepad);
     }
     return gamepad;
 }