public ControllerMapping(IController controller, ControllerType type) { MappedType = type; UUID = Guid.NewGuid(); if (controller is XInputController xi) { Source = SourceType.XInput; DeviceIndex = xi.Index; } else if (controller is RawInputController ri) { Source = SourceType.RawInput; VendorID = ri.HidDevice.VendorID; ProductID = ri.HidDevice.ProductID; DeviceIndex = ri.DeviceItemIndex; ReportHash = CRC32.Calc(ri.HidDevice.GetRawReportDescriptor()); } else if (controller is MuniaController mc) { Source = SourceType.MUNIA; DevicePath = mc.DevicePath; } else if (controller is ArduinoController ac) { Source = SourceType.Arduino; ArduinoPort = ac.PortInfo; ArduinoSource = ac.Type; } }
public bool AppliesTo(IController controller) { if (controller is MappedController) { return(false); // prevent mapping over mapping constructs } if (Source == SourceType.RawInput && controller is RawInputController ri) { return(ri.HidDevice.ProductID == ProductID && ri.HidDevice.VendorID == VendorID && CRC32.Calc(ri.HidDevice.GetRawReportDescriptor()) == ReportHash); } else if (Source == SourceType.XInput && controller is XInputController xi) { // xinput devices are always compatible return(true); } else if (Source == SourceType.MUNIA && controller is MuniaController mc) { return(DevicePath == mc.DevicePath); } else if (Source == SourceType.Arduino && controller is ArduinoController ac) { return(Equals(ArduinoPort, ac.PortInfo) && ArduinoSource == ac.Type); } return(false); }
public bool AppliesTo(GenericController controller) { if (Source == SourceType.RawInput && controller is RawInputController ri) { return(ri.HidDevice.ProductID == ProductID && ri.HidDevice.VendorID == VendorID && CRC32.Calc(ri.HidDevice.GetRawReportDescriptor()) == ReportHash); } else if (Source == SourceType.XInput && controller is XInputController xi) { // xinput devices are always compatible return(true); } return(false); }
public ControllerMapping(GenericController controller, ControllerType type) { MappedType = type; UUID = Guid.NewGuid(); if (controller is XInputController xi) { Source = SourceType.XInput; DeviceIndex = xi.Index; } else if (controller is RawInputController ri) { Source = SourceType.RawInput; VendorID = ri.HidDevice.VendorID; ProductID = ri.HidDevice.ProductID; DeviceIndex = ri.DeviceItemIndex; ReportHash = CRC32.Calc(ri.HidDevice.GetRawReportDescriptor()); } }