protected override IEnumerable <IRGBDevice> LoadDevices() { Dictionary <string, int>?modelCounter = new Dictionary <string, int>(); foreach (OpenRGBClient?openRgb in _clients) { int deviceCount = openRgb.GetControllerCount(); for (int i = 0; i < deviceCount; i++) { Device?device = openRgb.GetControllerData(i); //if the device doesn't have a direct mode, don't add it if (!device.Modes.Any(m => m.Name == "Direct") && !ForceAddAllDevices) { continue; } OpenRGBUpdateQueue?updateQueue = new OpenRGBUpdateQueue(GetUpdateTrigger(), i, openRgb, device); RGBDeviceType type = Helper.GetRgbNetDeviceType(device.Type); if (PerZoneDeviceFlag.HasFlag(type)) { int totalLedCount = 0; for (int zoneIndex = 0; zoneIndex < device.Zones.Length; zoneIndex++) { Zone zone = device.Zones[zoneIndex]; if (zone.LedCount == 0) { continue; } yield return(new OpenRGBZoneDevice(new OpenRGBZoneDeviceInfo(i, type, device, modelCounter, zoneIndex), totalLedCount, zone, updateQueue)); totalLedCount += (int)zone.LedCount; } } else { yield return(new OpenRGBGenericDevice(new OpenRGBDeviceInfo(i, type, device, modelCounter), updateQueue)); } } } }
/// <inheritdoc /> public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false) { IsInitialized = false; try { UpdateTrigger?.Stop(); openRgb = new OpenRGBClient(port: 1337, name: "JackNet RGBSync"); openRgb.Connect(); int controllerCount = openRgb.GetControllerCount(); var devices = new List <OpenRGBDevice>(); //IOpenRGBDevice _device = null; IList <IRGBDevice> _devices = new List <IRGBDevice>(); for (int i = 0; i < controllerCount; i++) { devices.Add(openRgb.GetControllerData(i)); } for (int i = 0; i < devices.Count; i++) { OpenRGBUpdateQueue updateQueue = new OpenRGBUpdateQueue(UpdateTrigger, i, openRgb, devices[i].leds.Length); IOpenRGBDevice _device = new OpenRGBUnspecifiedRGBDevice(new OpenRGBDeviceInfo(RGBDeviceType.Unknown, i + " " + devices[i].name, "OpenRGB")); _device.Initialize(updateQueue, devices[i].leds.Length); _devices.Add(_device); /* * var list = new OpenRGBColor[devices[i].leds.Length]; * for (int j = 0; j < devices[i].leds.Length; j++) * { * list[j] = new OpenRGBColor(0, 255, 0); * } * openRgb.UpdateLeds(i, list); */ } UpdateTrigger?.Start(); Devices = new ReadOnlyCollection <IRGBDevice>(_devices); IsInitialized = true; } catch (Exception ex) { throw; } return(true); }