mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-12 16:58:29 +00:00
64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
// 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
|
|
{
|
|
/// <summary>
|
|
/// Represents the SDK for a corsair keyboard.
|
|
/// </summary>
|
|
public class CorsairKeyboard : AbstractCueDevice
|
|
{
|
|
#region Properties & Fields
|
|
|
|
/// <summary>
|
|
/// Gets specific information provided by CUE for the keyboard.
|
|
/// </summary>
|
|
public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; }
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CorsairKeyboard"/> class.
|
|
/// </summary>
|
|
/// <param name="info">The specific information provided by CUE for the keyboard</param>
|
|
internal CorsairKeyboard(CorsairKeyboardDeviceInfo info)
|
|
: base(info)
|
|
{
|
|
this.KeyboardDeviceInfo = info;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Initializes the LEDs of the device.
|
|
/// </summary>
|
|
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
|
|
}
|
|
}
|