PCSX2Bonus.Gamepad.Gamepad C# (CSharp) Method

Gamepad() public method

public Gamepad ( Window wnd ) : Microsoft.DirectX.DirectInput
wnd System.Windows.Window
return Microsoft.DirectX.DirectInput
        public Gamepad(Window wnd)
        {
            foreach (DeviceInstance instance in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
            {
                this._joystick = new Device(instance.InstanceGuid);
                break;
            }
            if (this._joystick == null)
            {
                Tools.ShowMessage("No gamepad found!", MessageType.Error);
            }
            else
            {
                WindowInteropHelper helper = new WindowInteropHelper(wnd);
                this._joystick.SetCooperativeLevel(helper.Handle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
                this._joystick.Properties.BufferSize = 0x80;
                this._joystick.Acquire();
                this.IsValid = true;
            }
        }