/// <summary>
        /// Creates a Corsair device
        /// </summary>
        /// <param name="device">The device index</param>
        internal CorsairDevice(int deviceIndex)
        {
            _deviceIndex = deviceIndex;
            _device      = CorsairLightingSDK.GetDeviceInfo(_deviceIndex);
            _lights      = new List <CorsairDeviceLight>();

            var positions = CorsairLightingSDK.GetLedPositionsByDeviceIndex(_deviceIndex);

            foreach (var position in positions.LedPosition)
            {
                _lights.Add(new CorsairDeviceLight(new CorsairLedColor()
                {
                    LedId = position.LedId
                }));
            }
        }
示例#2
0
        /// <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]);
        }
示例#3
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);
            }
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Device"/> class.
 /// </summary>
 /// <param name="corsairDevice">The corsair device.</param>
 /// <param name="deviceIndex">Index of the device.</param>
 /// <param name="leds">The leds.</param>
 internal Device(CorsairDeviceInfo corsairDevice, int deviceIndex, List <Led> leds)
 {
     this.CorsairDevice = corsairDevice;
     this.DeviceIndex   = deviceIndex;
     this.Leds          = leds;
 }