public static async Task InitializeAsync() { var hidFactory = new FilterDeviceDefinition( LogitechVid, LogitechPowerPlayPid, LogitechPowerPlayUsagePage, LogitechPowerPlaFriendlyName) .CreateWindowsHidDeviceFactory(); // The correct device var powerPlayDeviceDefinition = (await hidFactory.GetConnectedDeviceDefinitionsAsync().ConfigureAwait(false)).FirstOrDefault(d => d.Usage == LogitechPowerPlayPage); var powerPlayDevice = await hidFactory.GetDeviceAsync(powerPlayDeviceDefinition).ConfigureAwait(false); if (powerPlayDeviceDefinition == null || powerPlayDevice == null) { IsInitialized = false; return; } powerPlayDevice.InitializeAsync().Wait(); MouseController = new PowerPlayController(powerPlayDevice, 0x01, 0x07); MatController = new PowerPlayController(powerPlayDevice, 0x07, 0x0B); // We assume the mouse exists because there is no way of know if there is a paired device. IsInitialized = true; }
internal static async Task <Scxi> Create(AppConfig config) { var hidFactory = new FilterDeviceDefinition(vendorId: 10462, productId: 4418, label: "Steam Controller") .CreateWindowsHidDeviceFactory(); var deviceDefinitions = await hidFactory.GetConnectedDeviceDefinitionsAsync(); var device = await hidFactory.GetDeviceAsync(deviceDefinitions.Single(d => d.DeviceId.Contains("mi_01"))); await device.InitializeAsync(); return(new Scxi((IHidDevice)device, XboxControllerAdapter.Create(), config)); }