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;
}
}