mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +00:00
Implemented corsair devices
This commit is contained in:
1 parent
89194c4cb4
commit
f3128a3dd0
31 files changed
+1731
No files matched your search
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a corsair mousemat.
|
||||
/// </summary>
|
||||
public class CorsairMousematRGBDevice : CorsairRGBDevice
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
/// <summary>
|
||||
/// Gets information about the <see cref="CorsairMousematRGBDevice"/>.
|
||||
/// </summary>
|
||||
public CorsairMousematRGBDeviceInfo MousematDeviceInfo { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CorsairMousematRGBDevice"/> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by CUE for the mousemat</param>
|
||||
internal CorsairMousematRGBDevice(CorsairMousematRGBDeviceInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.MousematDeviceInfo = info;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="Led"/> of the mousemat.
|
||||
/// </summary>
|
||||
protected override void InitializeLeds()
|
||||
{
|
||||
_CorsairLedPositions nativeLedPositions =
|
||||
(_CorsairLedPositions)
|
||||
Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(MousematDeviceInfo.CorsairDeviceIndex),
|
||||
typeof(_CorsairLedPositions));
|
||||
|
||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||
IntPtr ptr = nativeLedPositions.pLedPosition;
|
||||
|
||||
List<_CorsairLedPosition> positions = new List<_CorsairLedPosition>();
|
||||
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
||||
{
|
||||
_CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition));
|
||||
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||
positions.Add(ledPosition);
|
||||
}
|
||||
|
||||
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId))
|
||||
InitializeLed(new CorsairLedId(ledPosition.ledId),
|
||||
new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using RGB.NET.Devices.Corsair.Native;
|
||||
|
||||
namespace RGB.NET.Devices.Corsair
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a generic information for a <see cref="CorsairMousematRGBDevice"/>.
|
||||
/// </summary>
|
||||
public class CorsairMousematRGBDeviceInfo : CorsairRGBDeviceInfo
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Internal constructor of managed <see cref="CorsairMousematRGBDeviceInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">The index if the <see cref="CorsairMousematRGBDevice"/>.</param>
|
||||
/// <param name="nativeInfo">The native <see cref="_CorsairDeviceInfo" />-struct</param>
|
||||
internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
|
||||
: base(deviceIndex, Core.DeviceType.Mousemat, nativeInfo)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user