// ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global // ReSharper disable UnusedMember.Global using System; using System.Drawing; using System.Runtime.InteropServices; using CUE.NET.Devices.Generic; using CUE.NET.Native; namespace CUE.NET.Devices.Keyboard { /// /// Represents the SDK for a corsair keyboard. /// public class CorsairKeyboard : AbstractCueDevice { #region Properties & Fields /// /// Gets specific information provided by CUE for the keyboard. /// public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the keyboard internal CorsairKeyboard(CorsairKeyboardDeviceInfo info) : base(info) { this.KeyboardDeviceInfo = info; } #endregion #region Methods /// /// Initializes the LEDs of the device. /// protected override void InitializeLeds() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); } } #endregion } }