internal static string GetAPIName(this SteelSeriesLedId ledId) { if (!_ledIdNames.TryGetValue(ledId, out string apiName)) { _ledIdNames.Add(ledId, apiName = GetAPIName(typeof(SteelSeriesLedId), ledId)); } return(apiName); }
public void AddDevice(int PID) { var supportedDevice = HIDDevices.First(x => x.PID == PID); SteelSeriesControlDevice device = new SteelSeriesControlDevice { LEDs = new ControlDevice.LedUnit[supportedDevice.NumberOfLeds], Driver = this, Name = supportedDevice.Name, DeviceType = supportedDevice.DeviceClass, ProductImage = supportedDevice.Image, HID = PID, SSDeviceType = supportedDevice.SteelSeriesDeviceType }; List <KeyValuePair <LedId, SteelSeriesLedId> > mp = supportedDevice.Mapping.ToList(); for (int i = 0; i < supportedDevice.NumberOfLeds; i++) { int ln = i; int kc = 2; SteelSeriesLedId tp = SteelSeriesLedId.ZoneOne; if (i < mp.Count) { ln = (int)mp[i].Key; kc = (int)mp[i].Value; tp = mp[i].Value; } device.LEDs[i] = new ControlDevice.LedUnit { LEDName = "LED " + i, Data = new SteelSeriesLedData { LEDNumber = ln, KeyCode = kc, ZoneName = tp.GetAPIName() } }; } DeviceAdded?.Invoke(this, new Events.DeviceChangeEventArgs(device)); foundDevices.Add(device); }