mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2026-11-11 04:56:44 +00:00
Improved key-access on keyboard, implemented single "batch update" method
This commit is contained in:
1 parent
575804c8bf
commit
7efdb9ca7d
9 files changed
+124
-29
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using CUE.NET.Enums.Keyboard;
|
||||
|
||||
namespace CUE.NET.Wrapper.Keyboard
|
||||
{
|
||||
public class CorsairKey
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public CorsairKeyboardKeyId KeyId { get; }
|
||||
public CorsairLed Led { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led)
|
||||
{
|
||||
this.KeyId = keyId;
|
||||
this.Led = led;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Drawing;
|
||||
using CUE.NET.Native;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CUE.NET.Enums.Keyboard;
|
||||
|
||||
namespace CUE.NET.Wrapper.Keyboard
|
||||
{
|
||||
@@ -9,6 +10,13 @@ namespace CUE.NET.Wrapper.Keyboard
|
||||
|
||||
public CorsairKeyboardDeviceInfo KeyboardDeviceInfo { get; }
|
||||
|
||||
private Dictionary<CorsairKeyboardKeyId, CorsairKey> _keys = new Dictionary<CorsairKeyboardKeyId, CorsairKey>();
|
||||
public CorsairKey this[CorsairKeyboardKeyId keyId]
|
||||
{
|
||||
get { return _keys[keyId]; }
|
||||
private set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@@ -17,28 +25,18 @@ namespace CUE.NET.Wrapper.Keyboard
|
||||
: base(info)
|
||||
{
|
||||
this.KeyboardDeviceInfo = info;
|
||||
|
||||
InitializeKeys();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public void SetKeyColor(char key, Color color)
|
||||
private void InitializeKeys()
|
||||
{
|
||||
int id = _CUESDK.CorsairGetLedIdForKeyName(key);
|
||||
_CorsairLedColor ledColor = new _CorsairLedColor { ledId = id, r = color.R, g = color.G, b = color.B };
|
||||
SetKeyColors(ledColor);
|
||||
}
|
||||
|
||||
public void SetKeyColors(char[] keys, Color color)
|
||||
{
|
||||
_CorsairLedColor[] ledColors = new _CorsairLedColor[keys.Length];
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
int id = _CUESDK.CorsairGetLedIdForKeyName(keys[i]);
|
||||
ledColors[i] = new _CorsairLedColor { ledId = id, r = color.R, g = color.G, b = color.B };
|
||||
}
|
||||
SetKeyColors(ledColors);
|
||||
foreach (CorsairKeyboardKeyId keyId in Enum.GetValues(typeof(CorsairKeyboardKeyId)))
|
||||
_keys.Add(keyId, new CorsairKey(keyId, GetLed((int)keyId)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user