mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 09:08:34 +00:00
Added key-position, initialized keyboard with available keys
This commit is contained in:
parent
0167828a19
commit
64e0902046
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Enums;
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
using CUE.NET.Devices.Keyboard.Keys;
|
using CUE.NET.Devices.Keyboard.Keys;
|
||||||
|
using CUE.NET.Native;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard
|
namespace CUE.NET.Devices.Keyboard
|
||||||
{
|
{
|
||||||
@ -41,8 +44,17 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
|
|
||||||
private void InitializeKeys()
|
private void InitializeKeys()
|
||||||
{
|
{
|
||||||
foreach (CorsairKeyboardKeyId keyId in Enum.GetValues(typeof(CorsairKeyboardKeyId)))
|
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions));
|
||||||
_keys.Add(keyId, new CorsairKey(keyId, GetLed((int)keyId)));
|
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||||
|
IntPtr ptr = nativeLedPositions.pLedPosition;
|
||||||
|
for (int i = 0; i < nativeLedPositions.numberOfLed; i++)
|
||||||
|
{
|
||||||
|
_CorsairLedPosition ledPosition = Marshal.PtrToStructure<_CorsairLedPosition>(ptr);
|
||||||
|
_keys.Add(ledPosition.ledId, new CorsairKey(ledPosition.ledId, GetLed((int)ledPosition.ledId),
|
||||||
|
//TODO DarthAffe 19.09.2015: Is something like RectangleD needed? I don't think so ...
|
||||||
|
new RectangleF((float)ledPosition.top, (float)ledPosition.left, (float)ledPosition.width, (float)ledPosition.height)));
|
||||||
|
ptr = new IntPtr(ptr.ToInt64() + structSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using CUE.NET.Devices.Generic;
|
using System.Drawing;
|
||||||
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Keyboard.Enums;
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Devices.Keyboard.Keys
|
namespace CUE.NET.Devices.Keyboard.Keys
|
||||||
@ -9,15 +10,17 @@ namespace CUE.NET.Devices.Keyboard.Keys
|
|||||||
|
|
||||||
public CorsairKeyboardKeyId KeyId { get; }
|
public CorsairKeyboardKeyId KeyId { get; }
|
||||||
public CorsairLed Led { get; }
|
public CorsairLed Led { get; }
|
||||||
|
public RectangleF KeyRectangle { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led)
|
internal CorsairKey(CorsairKeyboardKeyId keyId, CorsairLed led, RectangleF keyRectangle)
|
||||||
{
|
{
|
||||||
this.KeyId = keyId;
|
this.KeyId = keyId;
|
||||||
this.Led = led;
|
this.Led = led;
|
||||||
|
this.KeyRectangle = keyRectangle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Native
|
namespace CUE.NET.Native
|
||||||
{
|
{
|
||||||
@ -52,7 +53,7 @@ namespace CUE.NET.Native
|
|||||||
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("CUESDK_2013.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
#endif
|
#endif
|
||||||
// retrieves led id for key name taking logical layout into account.
|
// retrieves led id for key name taking logical layout into account.
|
||||||
internal static extern int CorsairGetLedIdForKeyName(char keyName);
|
internal static extern CorsairKeyboardKeyId CorsairGetLedIdForKeyName(char keyName);
|
||||||
|
|
||||||
#if WIN64
|
#if WIN64
|
||||||
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("CUESDK.x64_2013.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
#pragma warning disable 649 // Field 'x' is never assigned
|
#pragma warning disable 649 // Field 'x' is never assigned
|
||||||
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using CUE.NET.Devices.Keyboard.Enums;
|
||||||
|
|
||||||
namespace CUE.NET.Native
|
namespace CUE.NET.Native
|
||||||
{
|
{
|
||||||
@ -10,7 +11,7 @@ namespace CUE.NET.Native
|
|||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
internal class _CorsairLedPosition // contains led id and position of led rectangle.Most of the keys are rectangular. In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key
|
internal class _CorsairLedPosition // contains led id and position of led rectangle.Most of the keys are rectangular. In case if key is not rectangular(like Enter in ISO / UK layout) it returns the smallest rectangle that fully contains the key
|
||||||
{
|
{
|
||||||
internal int ledId; // identifier of led
|
internal CorsairKeyboardKeyId ledId; // identifier of led
|
||||||
internal double top;
|
internal double top;
|
||||||
internal double left;
|
internal double left;
|
||||||
internal double height;
|
internal double height;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user