/// <summary>Initializes a new DirectInput-based game pad</summary> /// <param name="joystick">The DirectInput joystick this instance will query</param> /// <param name="checkAttachedDelegate"> /// Delegate through which the instance can check if the device is attached /// </param> public DirectInputGamePad( Joystick joystick, CheckAttachedDelegate checkAttachedDelegate ) { this.joystick = joystick; this.checkAttachedDelegate = checkAttachedDelegate; this.states = new LeakyQueue <JoystickState>(); this.converter = new DirectInputConverter(this.joystick); // Ensure the leaky queue has created its array ensureSlotAvailable(); }
/// <summary>Initializes a new DirectInput-based game pad</summary> /// <param name="joystick">The DirectInput joystick this instance will query</param> /// <param name="checkAttachedDelegate"> /// Delegate through which the instance can check if the device is attached /// </param> public DirectInputGamePad( Joystick joystick, CheckAttachedDelegate checkAttachedDelegate ) { this.joystick = joystick; this.checkAttachedDelegate = checkAttachedDelegate; this.states = new LeakyQueue<JoystickState>(); this.converter = new DirectInputConverter(this.joystick); // Ensure the leaky queue has created its array ensureSlotAvailable(); }
/// <summary>Initializes a new DirectInput-based game pad</summary> /// <param name="joystick">The DirectInput joystick this instance will query</param> /// <param name="checkAttachedDelegate"> /// Delegate through which the instance can check if the device is attached /// </param> public DirectInputGamePad( Joystick joystick, CheckAttachedDelegate checkAttachedDelegate ) { this.joystick = joystick; this.checkAttachedDelegate = checkAttachedDelegate; this.states = new Queue<GamePadState>(); this.currentJoystickState = new JoystickState(); this.current = new GamePadState(); this.converter = new GamePadConverter(this.joystick); }
/// <summary>Initializes a new DirectInput-based game pad</summary> /// <param name="joystick">The DirectInput joystick this instance will query</param> /// <param name="checkAttachedDelegate"> /// Delegate through which the instance can check if the device is attached /// </param> public DirectInputGamePad( Joystick joystick, CheckAttachedDelegate checkAttachedDelegate ) { this.joystick = joystick; this.checkAttachedDelegate = checkAttachedDelegate; this.states = new Queue <GamePadState>(); this.currentJoystickState = new JoystickState(); this.current = new GamePadState(); this.converter = new GamePadConverter(this.joystick); }
/// <summary>Creates game pad wrappers for all DirectInput game pads</summary> /// <returns>An array with wrappers for all DirectInput game pads</returns> public DirectInputGamePad[] CreateGamePads() { IList <DeviceInstance> devices = this.directInput.GetDevices( DeviceClass.GameController, DeviceEnumerationFlags.AllDevices ); var checkAttachedDelegate = new CheckAttachedDelegate(IsDeviceAttached); var gamePads = new List <DirectInputGamePad>(); for (int index = 0; index < Math.Min(devices.Count, 4); ++index) { // Do not enumerate XINPUT-enabled controllers. There are handled by // XNA (which is based on XINPUT) itself. if (!isXInputDevice(devices[index])) { var joystick = new Joystick(this.directInput, devices[index].InstanceGuid); gamePads.Add(new DirectInputGamePad(joystick, checkAttachedDelegate)); } } return(gamePads.ToArray()); }
/// <summary>Creates game pad wrappers for all DirectInput game pads</summary> /// <returns>An array with wrappers for all DirectInput game pads</returns> public DirectInputGamePad[] CreateGamePads() { IList<DeviceInstance> devices = this.directInput.GetDevices( DeviceClass.GameController, DeviceEnumerationFlags.AllDevices ); var checkAttachedDelegate = new CheckAttachedDelegate(IsDeviceAttached); var gamePads = new List<DirectInputGamePad>(); for (int index = 0; index < Math.Min(devices.Count, 4); ++index) { // Do not enumerate XINPUT-enabled controllers. There are handled by // XNA (which is based on XINPUT) itself. if (!isXInputDevice(devices[index])) { var joystick = new Joystick(this.directInput, devices[index].InstanceGuid); gamePads.Add(new DirectInputGamePad(joystick, checkAttachedDelegate)); } } return gamePads.ToArray(); }