refactor: Removed non-windows calls as I don't support other OS APIs

This commit is contained in:
Gerard Gascón 2024-06-15 13:01:51 +02:00
parent 0c2ff64639
commit e8996a382d

View file

@ -60,37 +60,9 @@ public class JoyConRead : IGamepadReader {
private static HidDevice? GetHidDevice() { private static HidDevice? GetHidDevice() {
DeviceList list = DeviceList.Local; DeviceList list = DeviceList.Local;
HidDevice? device = null; IEnumerable<HidDevice>? nintendos = list.GetHidDevices(0x057e);
if (OperatingSystem.IsWindows()) { return nintendos.FirstOrDefault();
var nintendos = list.GetHidDevices(0x057e);
device = nintendos.FirstOrDefault();
} else {
var hidDevices = list.GetHidDevices();
foreach (var d in hidDevices) {
var rd = d.GetReportDescriptor();
if (rd != null) {
if (
rd.OutputReports.Count() == 4
&& rd.OutputReports.Count(r => r.ReportID == 0x01) == 1
&& rd.OutputReports.Count(r => r.ReportID == 0x10) == 1
&& rd.OutputReports.Count(r => r.ReportID == 0x11) == 1
&& rd.OutputReports.Count(r => r.ReportID == 0x12) == 1
&& rd.InputReports.Count() == 6
&& rd.InputReports.Count(r => r.ReportID == 0x21) == 1
&& rd.InputReports.Count(r => r.ReportID == 0x30) == 1
&& rd.InputReports.Count(r => r.ReportID == 0x31) == 1
&& rd.InputReports.Count(r => r.ReportID == 0x32) == 1
&& rd.InputReports.Count(r => r.ReportID == 0x33) == 1
&& rd.InputReports.Count(r => r.ReportID == 0x3F) == 1
) {
device = d;
break;
}
}
}
}
return device;
} }
private Task OnJoyConOnReportReceived(JoyCon _, IJoyConReport input) { private Task OnJoyConOnReportReceived(JoyCon _, IJoyConReport input) {