/// <summary> /// Lists the devices. /// </summary> /// <returns></returns> public Device[] ListDevices() { int deviceCount = CorsairLightingSDK.GetDeviceCount(); if (deviceCount > 0) { Device[] devices = new Device[deviceCount]; for (int i = 0; i < deviceCount; i++) { CorsairDeviceInfo deviceInfo = CorsairLightingSDK.GetDeviceInfo(i); CorsairLedPositions positions = GetLedPositions(i); List <Led> leds = new List <Led>(); for (int j = 0; j < positions.LedPosition.Length; j++) { leds.Add(new Led(positions.LedPosition[j])); } devices[i] = new Device(deviceInfo, i, leds); RefreshDeviceColor(devices[i]); } return(devices); } return(new Device[0]); }
public ICueBridge() { CUESDK.LoadCUESDK(); CorsairProtocolDetails details = CUESDK.CorsairPerformProtocolHandshake(); CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl); int devCount = CUESDK.CorsairGetDeviceCount(); Debug.WriteLine("CorsairGetDeviceCount: {1}", "", devCount); for (int deviceIndex = 0; deviceIndex < devCount; deviceIndex++) { IntPtr deviceInfoPointer = CUESDK.CorsairGetDeviceInfo(deviceIndex); CorsairDeviceInfo DeviceInfo = (CorsairDeviceInfo)Marshal.PtrToStructure(deviceInfoPointer, typeof(CorsairDeviceInfo)); IntPtr ledPositionPointer = CUESDK.CorsairGetLedPositionsByDeviceIndex(deviceIndex); CorsairLedPositions LedPositions = (CorsairLedPositions)Marshal.PtrToStructure(ledPositionPointer, typeof(CorsairLedPositions)); switch (DeviceInfo.type) { case CorsairDeviceType.Keyboard: Debug.WriteLine("Keyboard LedPosition: {1}", "", LedPositions.numberOfLed); Keyboard = new Keyboard(); Keyboard.LedPositions = LedPositions; Keyboard.DeviceInfo = DeviceInfo; Keyboard.CorsairDeviceIndex = deviceIndex; break; case CorsairDeviceType.LightningNodePro: Debug.WriteLine("LightningNodePro LedPosition: {1}", "", LedPositions.numberOfLed); LedStrip = new LedStrip(); LedStrip.LedPositions = LedPositions; LedStrip.DeviceInfo = DeviceInfo; LedStrip.CorsairDeviceIndex = deviceIndex; break; } Debug.WriteLine("DeviceInfo: {1}", "", DeviceInfo.type); } }