using System; using System.Collections.Generic; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.Razer.Native; namespace RGB.NET.Devices.Razer { /// /// Represents the update-queue performing updates for razer keyboard devices. /// public class RazerKeyboardUpdateQueue : RazerUpdateQueue { #region Constructors /// /// Initializes a new instance of the class. /// /// The update trigger used to update this queue. /// The id of the device updated by this queue. public RazerKeyboardUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId) : base(updateTrigger, deviceId) { } #endregion #region Methods /// protected override IntPtr CreateEffectParams(Dictionary dataSet) { _Color[] colors = new _Color[_Defines.KEYBOARD_MAX_LEDS]; foreach (KeyValuePair data in dataSet) colors[(int)data.Key] = new _Color(data.Value); _KeyboardCustomEffect effectParams = new _KeyboardCustomEffect { Color = colors }; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } #endregion } }