1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00
RGB.NET/RGB.NET.Devices.Razer/Mousepad/RazerMousepadUpdateQueue.cs
Robert 587ae8f6e2 Razer - Moved to HID-based device detection
Razer - Added all OpenRazer provided PIDs
Razer - Use device-specific SDK endpoints, allowing access to all Razer devices
2021-02-27 12:00:12 +01:00

51 lines
1.6 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>
public RazerMousepadUpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger)
{ }
#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()
{ 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
}
}