1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00
RGB.NET/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs

51 lines
1.7 KiB
C#

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
{
/// <summary>
/// Represents the update-queue performing updates for razer mousepad devices.
/// </summary>
public class RazerMousepadUpdateQueue : RazerUpdateQueue
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="RazerMousepadUpdateQueue" /> class.
/// </summary>
/// <param name="updateTrigger">The update trigger used to update this queue.</param>
/// <param name="deviceId">The id of the device updated by this queue.</param>
public RazerMousepadUpdateQueue(IDeviceUpdateTrigger updateTrigger, Guid deviceId)
: base(updateTrigger, deviceId)
{ }
#endregion
#region Methods
/// <inheritdoc />
protected override IntPtr CreateEffectParams(Dictionary<object, Color> dataSet)
{
_Color[] colors = new _Color[_Defines.MOUSEPAD_MAX_LEDS];
foreach (KeyValuePair<object, Color> data in dataSet)
colors[(int)data.Key] = new _Color(data.Value);
_MousepadCustomEffect effectParams = new _MousepadCustomEffect { Color = colors };
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams));
Marshal.StructureToPtr(effectParams, ptr, false);
return ptr;
}
/// <inheritdoc />
protected override void CreateEffect(IntPtr effectParams, ref Guid effectId) => _RazerSDK.CreateMousepadEffect(_Defines.MOUSEPAD_EFFECT_ID, effectParams, ref effectId);
#endregion
}
}