mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Refactored LedIds
Everything is now based on the same ids for all devices
This commit is contained in:
1 parent
200e471e4d
commit
c5a1825f50
80 files changed
+2923
-3657
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <summary>
|
||||
/// Contains list of all LEDs available for all logitech devices.
|
||||
/// </summary>
|
||||
public enum LogitechLedIds
|
||||
public enum LogitechLedId
|
||||
{
|
||||
Invalid = 0,
|
||||
ESC = 0x01,
|
||||
@@ -1,108 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Logitech
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Represents a Id of a <see cref="T:RGB.NET.Core.Led" /> on a <see cref="T:RGB.NET.Devices.Logitech.LogitechRGBDevice" />.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{" + nameof(LedId) + "}")]
|
||||
public class LogitechLedId : ILedId
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
internal readonly LogitechLedIds LedId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRGBDevice Device { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsValid => LedId != LogitechLedIds.Invalid;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LogitechLedId"/> class.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="IRGBDevice"/> the <see cref="ILedId"/> belongs to.</param>
|
||||
/// <param name="ledId">The <see cref="LogitechLedId"/> of the represented <see cref="Led"/>.</param>
|
||||
public LogitechLedId(IRGBDevice device, LogitechLedIds ledId)
|
||||
{
|
||||
this.Device = device;
|
||||
this.LedId = ledId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Converts the Id of this <see cref="LogitechLedId"/> to a human-readable string.
|
||||
/// </summary>
|
||||
/// <returns>A string that contains the Id of this <see cref="LogitechLedId"/>. For example "Enter".</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return LedId.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the specified object is a <see cref="LogitechLedId" /> and is equivalent to this <see cref="LogitechLedId" />.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to test.</param>
|
||||
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="LogitechLedId" /> equivalent to this <see cref="LogitechLedId" />; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
LogitechLedId compareLedId = obj as LogitechLedId;
|
||||
if (ReferenceEquals(compareLedId, null))
|
||||
return false;
|
||||
|
||||
if (ReferenceEquals(this, compareLedId))
|
||||
return true;
|
||||
|
||||
if (GetType() != compareLedId.GetType())
|
||||
return false;
|
||||
|
||||
return compareLedId.LedId == LedId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code for this <see cref="LogitechLedId" />.
|
||||
/// </summary>
|
||||
/// <returns>An integer value that specifies the hash code for this <see cref="LogitechLedId" />.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return LedId.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Operators
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="LogitechLedId" /> are equal.
|
||||
/// </summary>
|
||||
/// <param name="ledId1">The first <see cref="LogitechLedId" /> to compare.</param>
|
||||
/// <param name="ledId2">The second <see cref="LogitechLedId" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId1" /> and <paramref name="ledId2" /> are equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator ==(LogitechLedId ledId1, LogitechLedId ledId2)
|
||||
{
|
||||
return ReferenceEquals(ledId1, null) ? ReferenceEquals(ledId2, null) : ledId1.Equals(ledId2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a value that indicates whether two specified <see cref="LogitechLedId" /> are equal.
|
||||
/// </summary>
|
||||
/// <param name="ledId1">The first <see cref="LogitechLedId" /> to compare.</param>
|
||||
/// <param name="ledId2">The second <see cref="LogitechLedId" /> to compare.</param>
|
||||
/// <returns><c>true</c> if <paramref name="ledId1" /> and <paramref name="ledId2" /> are not equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool operator !=(LogitechLedId ledId1, LogitechLedId ledId2)
|
||||
{
|
||||
return !(ledId1 == ledId2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core.Layout;
|
||||
|
||||
namespace RGB.NET.Devices.Logitech
|
||||
{
|
||||
@@ -62,46 +59,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
string basePath = info.ImageBasePath;
|
||||
string layout = info.ImageLayout;
|
||||
string layoutPath = info.LayoutPath;
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, PathHelper.GetAbsolutePath($@"Images\Logitech\{basePath}"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the given layout.
|
||||
/// </summary>
|
||||
/// <param name="layoutPath">The file containing the layout.</param>
|
||||
/// <param name="imageLayout">The name of the layout used to get the images of the leds.</param>
|
||||
/// <param name="imageBasePath">The path images for this device are collected in.</param>
|
||||
protected void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath)
|
||||
{
|
||||
DeviceLayout layout = DeviceLayout.Load(layoutPath);
|
||||
if (layout != null)
|
||||
{
|
||||
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
Size = new Size(layout.Width, layout.Height);
|
||||
|
||||
if (layout.Leds != null)
|
||||
foreach (LedLayout layoutLed in layout.Leds)
|
||||
{
|
||||
if (Enum.TryParse(layoutLed.Id, true, out LogitechLedIds ledId))
|
||||
{
|
||||
LogitechLedId id = new LogitechLedId(this, ledId);
|
||||
if (!LedMapping.TryGetValue(id, out Led led))
|
||||
led = InitializeLed(id, new Rectangle());
|
||||
|
||||
led.LedRectangle.Location = new Point(layoutLed.X, layoutLed.Y);
|
||||
led.LedRectangle.Size = new Size(layoutLed.Width, layoutLed.Height);
|
||||
|
||||
led.Shape = layoutLed.Shape;
|
||||
led.ShapeData = layoutLed.ShapeData;
|
||||
|
||||
LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id);
|
||||
led.Image = (!string.IsNullOrEmpty(image?.Image))
|
||||
? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute)
|
||||
: new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute);
|
||||
}
|
||||
}
|
||||
}
|
||||
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, PathHelper.GetAbsolutePath($@"Images\Logitech\{basePath}"), true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Logitech
|
||||
{
|
||||
internal static class BitmapMapping
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const int BITMAP_SIZE = 21 * 6 * 4;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
internal static Dictionary<LogitechLedIds, int> BitmapOffset { get; } = new Dictionary<LogitechLedIds, int>
|
||||
{
|
||||
{ LogitechLedIds.ESC, 0 },
|
||||
{ LogitechLedIds.F1, 4 },
|
||||
{ LogitechLedIds.F2, 8 },
|
||||
{ LogitechLedIds.F3, 12 },
|
||||
{ LogitechLedIds.F4, 16 },
|
||||
{ LogitechLedIds.F5, 20 },
|
||||
{ LogitechLedIds.F6, 24 },
|
||||
{ LogitechLedIds.F7, 28 },
|
||||
{ LogitechLedIds.F8, 32 },
|
||||
{ LogitechLedIds.F9, 36 },
|
||||
{ LogitechLedIds.F10, 40 },
|
||||
{ LogitechLedIds.F11, 44 },
|
||||
{ LogitechLedIds.F12, 48 },
|
||||
{ LogitechLedIds.PRINT_SCREEN, 52 },
|
||||
{ LogitechLedIds.SCROLL_LOCK, 56 },
|
||||
{ LogitechLedIds.PAUSE_BREAK, 60 },
|
||||
// { LogitechLedIds.?, 64 },
|
||||
// { LogitechLedIds.?, 68 },
|
||||
// { LogitechLedIds.?, 72 },
|
||||
// { LogitechLedIds.?, 76 },
|
||||
// { LogitechLedIds.?, 80 },
|
||||
|
||||
{ LogitechLedIds.TILDE, 84 },
|
||||
{ LogitechLedIds.ONE, 88 },
|
||||
{ LogitechLedIds.TWO, 92 },
|
||||
{ LogitechLedIds.THREE, 96 },
|
||||
{ LogitechLedIds.FOUR, 100 },
|
||||
{ LogitechLedIds.FIVE, 104 },
|
||||
{ LogitechLedIds.SIX, 108 },
|
||||
{ LogitechLedIds.SEVEN, 112 },
|
||||
{ LogitechLedIds.EIGHT, 116 },
|
||||
{ LogitechLedIds.NINE, 120 },
|
||||
{ LogitechLedIds.ZERO, 124 },
|
||||
{ LogitechLedIds.MINUS, 128 },
|
||||
{ LogitechLedIds.EQUALS, 132 },
|
||||
{ LogitechLedIds.BACKSPACE, 136 },
|
||||
{ LogitechLedIds.INSERT, 140 },
|
||||
{ LogitechLedIds.HOME, 144 },
|
||||
{ LogitechLedIds.PAGE_UP, 148 },
|
||||
{ LogitechLedIds.NUM_LOCK, 152 },
|
||||
{ LogitechLedIds.NUM_SLASH, 156 },
|
||||
{ LogitechLedIds.NUM_ASTERISK, 160 },
|
||||
{ LogitechLedIds.NUM_MINUS, 164 },
|
||||
|
||||
{ LogitechLedIds.TAB, 168 },
|
||||
{ LogitechLedIds.Q, 172 },
|
||||
{ LogitechLedIds.W, 176 },
|
||||
{ LogitechLedIds.E, 180 },
|
||||
{ LogitechLedIds.R, 184 },
|
||||
{ LogitechLedIds.T, 188 },
|
||||
{ LogitechLedIds.Y, 192 },
|
||||
{ LogitechLedIds.U, 196 },
|
||||
{ LogitechLedIds.I, 200 },
|
||||
{ LogitechLedIds.O, 204 },
|
||||
{ LogitechLedIds.P, 208 },
|
||||
{ LogitechLedIds.OPEN_BRACKET, 212 },
|
||||
{ LogitechLedIds.CLOSE_BRACKET, 216 },
|
||||
// { LogitechLedIds.?, 220 },
|
||||
{ LogitechLedIds.KEYBOARD_DELETE, 224 },
|
||||
{ LogitechLedIds.END, 228 },
|
||||
{ LogitechLedIds.PAGE_DOWN, 232 },
|
||||
{ LogitechLedIds.NUM_SEVEN, 236 },
|
||||
{ LogitechLedIds.NUM_EIGHT, 240 },
|
||||
{ LogitechLedIds.NUM_NINE, 244 },
|
||||
{ LogitechLedIds.NUM_PLUS, 248 },
|
||||
|
||||
{ LogitechLedIds.CAPS_LOCK, 252 },
|
||||
{ LogitechLedIds.A, 256 },
|
||||
{ LogitechLedIds.S, 260 },
|
||||
{ LogitechLedIds.D, 264 },
|
||||
{ LogitechLedIds.F, 268 },
|
||||
{ LogitechLedIds.G, 272 },
|
||||
{ LogitechLedIds.H, 276 },
|
||||
{ LogitechLedIds.J, 280 },
|
||||
{ LogitechLedIds.K, 284 },
|
||||
{ LogitechLedIds.L, 288 },
|
||||
{ LogitechLedIds.SEMICOLON, 292 },
|
||||
{ LogitechLedIds.APOSTROPHE, 296 },
|
||||
{ LogitechLedIds.NonUsTilde, 300 }, //TODO DarthAffe 26.03.2017: Find the real ID/Name of this key - it's not documented ...
|
||||
{ LogitechLedIds.ENTER, 304 },
|
||||
// { LogitechLedIds.?, 308 },
|
||||
// { LogitechLedIds.?, 312 },
|
||||
// { LogitechLedIds.?, 316 },
|
||||
{ LogitechLedIds.NUM_FOUR, 320 },
|
||||
{ LogitechLedIds.NUM_FIVE, 324 },
|
||||
{ LogitechLedIds.NUM_SIX, 328 },
|
||||
// { LogitechLedIds.?, 332 },
|
||||
|
||||
{ LogitechLedIds.LEFT_SHIFT, 336 },
|
||||
{ LogitechLedIds.BACKSLASH, 340 },
|
||||
{ LogitechLedIds.Z, 344 },
|
||||
{ LogitechLedIds.X, 348 },
|
||||
{ LogitechLedIds.C, 352 },
|
||||
{ LogitechLedIds.V, 356 },
|
||||
{ LogitechLedIds.B, 360 },
|
||||
{ LogitechLedIds.N, 364 },
|
||||
{ LogitechLedIds.M, 368 },
|
||||
{ LogitechLedIds.COMMA, 372 },
|
||||
{ LogitechLedIds.PERIOD, 376 },
|
||||
{ LogitechLedIds.FORWARD_SLASH, 380 },
|
||||
{ LogitechLedIds.RIGHT_SHIFT, 388 },
|
||||
// { LogitechLedIds.?, 392 },
|
||||
{ LogitechLedIds.ARROW_UP, 396 },
|
||||
// { LogitechLedIds.?, 400 },
|
||||
{ LogitechLedIds.NUM_ONE, 404 },
|
||||
{ LogitechLedIds.NUM_TWO, 408 },
|
||||
{ LogitechLedIds.NUM_THREE, 412 },
|
||||
{ LogitechLedIds.NUM_ENTER, 416 },
|
||||
|
||||
{ LogitechLedIds.LEFT_CONTROL, 420 },
|
||||
{ LogitechLedIds.LEFT_WINDOWS, 424 },
|
||||
{ LogitechLedIds.LEFT_ALT, 428 },
|
||||
// { LogitechLedIds.?, 432 },
|
||||
// { LogitechLedIds.?, 436 },
|
||||
{ LogitechLedIds.SPACE, 440 },
|
||||
// { LogitechLedIds.?, 444 },
|
||||
// { LogitechLedIds.?, 448 },
|
||||
// { LogitechLedIds.?, 452 },
|
||||
// { LogitechLedIds.?, 456 },
|
||||
// { LogitechLedIds.?, 460 },
|
||||
{ LogitechLedIds.RIGHT_ALT, 464 },
|
||||
{ LogitechLedIds.RIGHT_WINDOWS, 468 },
|
||||
{ LogitechLedIds.APPLICATION_SELECT, 472 },
|
||||
{ LogitechLedIds.RIGHT_CONTROL, 476 },
|
||||
{ LogitechLedIds.ARROW_LEFT, 480 },
|
||||
{ LogitechLedIds.ARROW_DOWN, 484 },
|
||||
{ LogitechLedIds.ARROW_RIGHT, 488 },
|
||||
{ LogitechLedIds.NUM_ZERO, 492 },
|
||||
{ LogitechLedIds.NUM_PERIOD, 496 },
|
||||
// { LogitechLedIds.?, 500 },
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static byte[] CreateBitmap() => new byte[BITMAP_SIZE];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static void SetColor(ref byte[] bitmap, int offset, Color color)
|
||||
{
|
||||
bitmap[offset] = color.B;
|
||||
bitmap[offset + 1] = color.G;
|
||||
bitmap[offset + 2] = color.R;
|
||||
bitmap[offset + 3] = color.A;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,12 @@ namespace RGB.NET.Devices.Logitech
|
||||
base.InitializeLayout();
|
||||
|
||||
if (LedMapping.Count == 0)
|
||||
InitializeLed(new LogitechLedId(this, LogitechLedIds.DEVICE), new Rectangle(0, 0, 10, 10));
|
||||
InitializeLed(LedId.Custom1, new Rectangle(0, 0, 10, 10));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object CreateLedCustomData(LedId ledId) => LogitechLedId.DEVICE;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Logitech
|
||||
{
|
||||
internal static class BitmapMapping
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const int BITMAP_SIZE = 21 * 6 * 4;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
internal static Dictionary<LedId, int> BitmapOffset { get; } = new Dictionary<LedId, int>
|
||||
{
|
||||
{ LedId.Keyboard_Escape, 0 },
|
||||
{ LedId.Keyboard_F1, 4 },
|
||||
{ LedId.Keyboard_F2, 8 },
|
||||
{ LedId.Keyboard_F3, 12 },
|
||||
{ LedId.Keyboard_F4, 16 },
|
||||
{ LedId.Keyboard_F5, 20 },
|
||||
{ LedId.Keyboard_F6, 24 },
|
||||
{ LedId.Keyboard_F7, 28 },
|
||||
{ LedId.Keyboard_F8, 32 },
|
||||
{ LedId.Keyboard_F9, 36 },
|
||||
{ LedId.Keyboard_F10, 40 },
|
||||
{ LedId.Keyboard_F11, 44 },
|
||||
{ LedId.Keyboard_F12, 48 },
|
||||
{ LedId.Keyboard_PrintScreen, 52 },
|
||||
{ LedId.Keyboard_ScrollLock, 56 },
|
||||
{ LedId.Keyboard_PauseBreak, 60 },
|
||||
// { LedId.Keyboard_?, 64 },
|
||||
// { LedId.Keyboard_?, 68 },
|
||||
// { LedId.Keyboard_?, 72 },
|
||||
// { LedId.Keyboard_?, 76 },
|
||||
// { LedId.Keyboard_?, 80 },
|
||||
|
||||
{ LedId.Keyboard_GraveAccentAndTilde, 84 },
|
||||
{ LedId.Keyboard_1, 88 },
|
||||
{ LedId.Keyboard_2, 92 },
|
||||
{ LedId.Keyboard_3, 96 },
|
||||
{ LedId.Keyboard_4, 100 },
|
||||
{ LedId.Keyboard_5, 104 },
|
||||
{ LedId.Keyboard_6, 108 },
|
||||
{ LedId.Keyboard_7, 112 },
|
||||
{ LedId.Keyboard_8, 116 },
|
||||
{ LedId.Keyboard_9, 120 },
|
||||
{ LedId.Keyboard_0, 124 },
|
||||
{ LedId.Keyboard_MinusAndUnderscore, 128 },
|
||||
{ LedId.Keyboard_EqualsAndPlus, 132 },
|
||||
{ LedId.Keyboard_Backspace, 136 },
|
||||
{ LedId.Keyboard_Insert, 140 },
|
||||
{ LedId.Keyboard_Home, 144 },
|
||||
{ LedId.Keyboard_PageUp, 148 },
|
||||
{ LedId.Keyboard_NumLock, 152 },
|
||||
{ LedId.Keyboard_NumSlash, 156 },
|
||||
{ LedId.Keyboard_NumAsterisk, 160 },
|
||||
{ LedId.Keyboard_NumMinus, 164 },
|
||||
|
||||
{ LedId.Keyboard_Tab, 168 },
|
||||
{ LedId.Keyboard_Q, 172 },
|
||||
{ LedId.Keyboard_W, 176 },
|
||||
{ LedId.Keyboard_E, 180 },
|
||||
{ LedId.Keyboard_R, 184 },
|
||||
{ LedId.Keyboard_T, 188 },
|
||||
{ LedId.Keyboard_Y, 192 },
|
||||
{ LedId.Keyboard_U, 196 },
|
||||
{ LedId.Keyboard_I, 200 },
|
||||
{ LedId.Keyboard_O, 204 },
|
||||
{ LedId.Keyboard_P, 208 },
|
||||
{ LedId.Keyboard_BracketLeft, 212 },
|
||||
{ LedId.Keyboard_BracketRight, 216 },
|
||||
// { LedId.Keyboard_?, 220 },
|
||||
{ LedId.Keyboard_Delete, 224 },
|
||||
{ LedId.Keyboard_End, 228 },
|
||||
{ LedId.Keyboard_PageDown, 232 },
|
||||
{ LedId.Keyboard_Num7, 236 },
|
||||
{ LedId.Keyboard_Num8, 240 },
|
||||
{ LedId.Keyboard_Num9, 244 },
|
||||
{ LedId.Keyboard_NumPlus, 248 },
|
||||
|
||||
{ LedId.Keyboard_CapsLock, 252 },
|
||||
{ LedId.Keyboard_A, 256 },
|
||||
{ LedId.Keyboard_S, 260 },
|
||||
{ LedId.Keyboard_D, 264 },
|
||||
{ LedId.Keyboard_F, 268 },
|
||||
{ LedId.Keyboard_G, 272 },
|
||||
{ LedId.Keyboard_H, 276 },
|
||||
{ LedId.Keyboard_J, 280 },
|
||||
{ LedId.Keyboard_K, 284 },
|
||||
{ LedId.Keyboard_L, 288 },
|
||||
{ LedId.Keyboard_SemicolonAndColon, 292 },
|
||||
{ LedId.Keyboard_ApostropheAndDoubleQuote, 296 },
|
||||
{ LedId.Keyboard_NonUsTilde, 300 }, //TODO DarthAffe 26.03.2017: Find the real ID/Name of this key - it's not documented ...
|
||||
{ LedId.Keyboard_Enter, 304 },
|
||||
// { LedId.Keyboard_?, 308 },
|
||||
// { LedId.Keyboard_?, 312 },
|
||||
// { LedId.Keyboard_?, 316 },
|
||||
{ LedId.Keyboard_Num4, 320 },
|
||||
{ LedId.Keyboard_Num5, 324 },
|
||||
{ LedId.Keyboard_Num6, 328 },
|
||||
// { LedId.Keyboard_?, 332 },
|
||||
|
||||
{ LedId.Keyboard_LeftShift, 336 },
|
||||
{ LedId.Keyboard_Backslash, 340 },
|
||||
{ LedId.Keyboard_Z, 344 },
|
||||
{ LedId.Keyboard_X, 348 },
|
||||
{ LedId.Keyboard_C, 352 },
|
||||
{ LedId.Keyboard_V, 356 },
|
||||
{ LedId.Keyboard_B, 360 },
|
||||
{ LedId.Keyboard_N, 364 },
|
||||
{ LedId.Keyboard_M, 368 },
|
||||
{ LedId.Keyboard_CommaAndLessThan, 372 },
|
||||
{ LedId.Keyboard_PeriodAndBiggerThan, 376 },
|
||||
{ LedId.Keyboard_SlashAndQuestionMark, 380 },
|
||||
{ LedId.Keyboard_RightShift, 388 },
|
||||
// { LedId.Keyboard_?, 392 },
|
||||
{ LedId.Keyboard_ArrowUp, 396 },
|
||||
// { LedId.Keyboard_?, 400 },
|
||||
{ LedId.Keyboard_Num1, 404 },
|
||||
{ LedId.Keyboard_Num2, 408 },
|
||||
{ LedId.Keyboard_Num3, 412 },
|
||||
{ LedId.Keyboard_NumEnter, 416 },
|
||||
|
||||
{ LedId.Keyboard_LeftCtrl, 420 },
|
||||
{ LedId.Keyboard_LeftGui, 424 },
|
||||
{ LedId.Keyboard_LeftAlt, 428 },
|
||||
// { LedId.Keyboard_?, 432 },
|
||||
// { LedId.Keyboard_?, 436 },
|
||||
{ LedId.Keyboard_Space, 440 },
|
||||
// { LedId.Keyboard_?, 444 },
|
||||
// { LedId.Keyboard_?, 448 },
|
||||
// { LedId.Keyboard_?, 452 },
|
||||
// { LedId.Keyboard_?, 456 },
|
||||
// { LedId.Keyboard_?, 460 },
|
||||
{ LedId.Keyboard_RightAlt, 464 },
|
||||
{ LedId.Keyboard_RightGui, 468 },
|
||||
{ LedId.Keyboard_Application, 472 },
|
||||
{ LedId.Keyboard_RightCtrl, 476 },
|
||||
{ LedId.Keyboard_ArrowLeft, 480 },
|
||||
{ LedId.Keyboard_ArrowDown, 484 },
|
||||
{ LedId.Keyboard_ArrowRight, 488 },
|
||||
{ LedId.Keyboard_Num0, 492 },
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, 496 },
|
||||
// { LedId.Keyboard_?, 500 },
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static byte[] CreateBitmap() => new byte[BITMAP_SIZE];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static void SetColor(ref byte[] bitmap, int offset, Color color)
|
||||
{
|
||||
bitmap[offset] = color.B;
|
||||
bitmap[offset + 1] = color.G;
|
||||
bitmap[offset + 2] = color.R;
|
||||
bitmap[offset + 3] = color.A;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,9 @@ namespace RGB.NET.Devices.Logitech
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object CreateLedCustomData(LedId ledId) => PerKeyIdMapping.DEFAULT[ledId];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||
{
|
||||
@@ -39,7 +42,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
foreach (Led led in leds)
|
||||
{
|
||||
// DarthAffe 26.03.2017: This is only needed since update by name doesn't work as expected for all keys ...
|
||||
if (BitmapMapping.BitmapOffset.TryGetValue(((LogitechLedId)led.Id).LedId, out int bitmapOffset))
|
||||
if (BitmapMapping.BitmapOffset.TryGetValue(led.Id, out int bitmapOffset))
|
||||
{
|
||||
if (bitmap == null)
|
||||
bitmap = BitmapMapping.CreateBitmap();
|
||||
@@ -47,7 +50,7 @@ namespace RGB.NET.Devices.Logitech
|
||||
BitmapMapping.SetColor(ref bitmap, bitmapOffset, led.Color);
|
||||
}
|
||||
else
|
||||
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)((LogitechLedId)led.Id).LedId,
|
||||
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)led.CustomData,
|
||||
(int)Math.Round(led.Color.RPercent * 100),
|
||||
(int)Math.Round(led.Color.GPercent * 100),
|
||||
(int)Math.Round(led.Color.BPercent * 100));
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
using System.Collections.Generic;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Devices.Logitech
|
||||
{
|
||||
internal static class PerKeyIdMapping
|
||||
{
|
||||
internal static readonly Dictionary<LedId, LogitechLedId> DEFAULT = new Dictionary<LedId, LogitechLedId>
|
||||
{
|
||||
{ LedId.Invalid, LogitechLedId.Invalid },
|
||||
{ LedId.Keyboard_Escape, LogitechLedId.ESC },
|
||||
{ LedId.Keyboard_F1, LogitechLedId.F1 },
|
||||
{ LedId.Keyboard_F2, LogitechLedId.F2 },
|
||||
{ LedId.Keyboard_F3, LogitechLedId.F3 },
|
||||
{ LedId.Keyboard_F4, LogitechLedId.F4 },
|
||||
{ LedId.Keyboard_F5, LogitechLedId.F5 },
|
||||
{ LedId.Keyboard_F6, LogitechLedId.F6 },
|
||||
{ LedId.Keyboard_F7, LogitechLedId.F7 },
|
||||
{ LedId.Keyboard_F8, LogitechLedId.F8 },
|
||||
{ LedId.Keyboard_F9, LogitechLedId.F9 },
|
||||
{ LedId.Keyboard_F10, LogitechLedId.F10 },
|
||||
{ LedId.Keyboard_F11, LogitechLedId.F11 },
|
||||
{ LedId.Keyboard_GraveAccentAndTilde, LogitechLedId.TILDE },
|
||||
{ LedId.Keyboard_1, LogitechLedId.ONE },
|
||||
{ LedId.Keyboard_2, LogitechLedId.TWO },
|
||||
{ LedId.Keyboard_3, LogitechLedId.THREE },
|
||||
{ LedId.Keyboard_4, LogitechLedId.FOUR },
|
||||
{ LedId.Keyboard_5, LogitechLedId.FIVE },
|
||||
{ LedId.Keyboard_6, LogitechLedId.SIX },
|
||||
{ LedId.Keyboard_7, LogitechLedId.SEVEN },
|
||||
{ LedId.Keyboard_8, LogitechLedId.EIGHT },
|
||||
{ LedId.Keyboard_9, LogitechLedId.NINE },
|
||||
{ LedId.Keyboard_0, LogitechLedId.ZERO },
|
||||
{ LedId.Keyboard_MinusAndUnderscore, LogitechLedId.MINUS },
|
||||
{ LedId.Keyboard_Tab, LogitechLedId.TAB },
|
||||
{ LedId.Keyboard_Q, LogitechLedId.Q },
|
||||
{ LedId.Keyboard_W, LogitechLedId.W },
|
||||
{ LedId.Keyboard_E, LogitechLedId.E },
|
||||
{ LedId.Keyboard_R, LogitechLedId.R },
|
||||
{ LedId.Keyboard_T, LogitechLedId.T },
|
||||
{ LedId.Keyboard_Y, LogitechLedId.Y },
|
||||
{ LedId.Keyboard_U, LogitechLedId.U },
|
||||
{ LedId.Keyboard_I, LogitechLedId.I },
|
||||
{ LedId.Keyboard_O, LogitechLedId.O },
|
||||
{ LedId.Keyboard_P, LogitechLedId.P },
|
||||
{ LedId.Keyboard_BracketLeft, LogitechLedId.OPEN_BRACKET },
|
||||
{ LedId.Keyboard_CapsLock, LogitechLedId.CAPS_LOCK },
|
||||
{ LedId.Keyboard_A, LogitechLedId.A },
|
||||
{ LedId.Keyboard_S, LogitechLedId.S },
|
||||
{ LedId.Keyboard_D, LogitechLedId.D },
|
||||
{ LedId.Keyboard_F, LogitechLedId.F },
|
||||
{ LedId.Keyboard_G, LogitechLedId.G },
|
||||
{ LedId.Keyboard_H, LogitechLedId.H },
|
||||
{ LedId.Keyboard_J, LogitechLedId.J },
|
||||
{ LedId.Keyboard_K, LogitechLedId.K },
|
||||
{ LedId.Keyboard_L, LogitechLedId.L },
|
||||
{ LedId.Keyboard_SemicolonAndColon, LogitechLedId.SEMICOLON },
|
||||
{ LedId.Keyboard_ApostropheAndDoubleQuote, LogitechLedId.APOSTROPHE },
|
||||
{ LedId.Keyboard_LeftShift, LogitechLedId.LEFT_SHIFT },
|
||||
{ LedId.Keyboard_Z, LogitechLedId.Z },
|
||||
{ LedId.Keyboard_X, LogitechLedId.X },
|
||||
{ LedId.Keyboard_C, LogitechLedId.C },
|
||||
{ LedId.Keyboard_V, LogitechLedId.V },
|
||||
{ LedId.Keyboard_B, LogitechLedId.B },
|
||||
{ LedId.Keyboard_N, LogitechLedId.N },
|
||||
{ LedId.Keyboard_M, LogitechLedId.M },
|
||||
{ LedId.Keyboard_CommaAndLessThan, LogitechLedId.COMMA },
|
||||
{ LedId.Keyboard_PeriodAndBiggerThan, LogitechLedId.PERIOD },
|
||||
{ LedId.Keyboard_SlashAndQuestionMark, LogitechLedId.FORWARD_SLASH },
|
||||
{ LedId.Keyboard_LeftCtrl, LogitechLedId.LEFT_CONTROL },
|
||||
{ LedId.Keyboard_LeftGui, LogitechLedId.LEFT_WINDOWS },
|
||||
{ LedId.Keyboard_LeftAlt, LogitechLedId.LEFT_ALT },
|
||||
{ LedId.Keyboard_Space, LogitechLedId.SPACE },
|
||||
{ LedId.Keyboard_RightAlt, LogitechLedId.RIGHT_ALT },
|
||||
{ LedId.Keyboard_RightGui, LogitechLedId.RIGHT_WINDOWS },
|
||||
{ LedId.Keyboard_Application, LogitechLedId.APPLICATION_SELECT },
|
||||
{ LedId.Keyboard_F12, LogitechLedId.F12 },
|
||||
{ LedId.Keyboard_PrintScreen, LogitechLedId.PRINT_SCREEN },
|
||||
{ LedId.Keyboard_ScrollLock, LogitechLedId.SCROLL_LOCK },
|
||||
{ LedId.Keyboard_PauseBreak, LogitechLedId.PAUSE_BREAK },
|
||||
{ LedId.Keyboard_Insert, LogitechLedId.INSERT },
|
||||
{ LedId.Keyboard_Home, LogitechLedId.HOME },
|
||||
{ LedId.Keyboard_PageUp, LogitechLedId.PAGE_UP },
|
||||
{ LedId.Keyboard_BracketRight, LogitechLedId.CLOSE_BRACKET },
|
||||
{ LedId.Keyboard_Backslash, LogitechLedId.BACKSLASH },
|
||||
{ LedId.Keyboard_NonUsTilde, LogitechLedId.NonUsTilde },
|
||||
{ LedId.Keyboard_Enter, LogitechLedId.ENTER },
|
||||
{ LedId.Keyboard_EqualsAndPlus, LogitechLedId.EQUALS },
|
||||
{ LedId.Keyboard_Backspace, LogitechLedId.BACKSPACE },
|
||||
{ LedId.Keyboard_Delete, LogitechLedId.KEYBOARD_DELETE },
|
||||
{ LedId.Keyboard_End, LogitechLedId.END },
|
||||
{ LedId.Keyboard_PageDown, LogitechLedId.PAGE_DOWN },
|
||||
{ LedId.Keyboard_RightShift, LogitechLedId.RIGHT_SHIFT },
|
||||
{ LedId.Keyboard_RightCtrl, LogitechLedId.RIGHT_CONTROL },
|
||||
{ LedId.Keyboard_ArrowUp, LogitechLedId.ARROW_UP },
|
||||
{ LedId.Keyboard_ArrowLeft, LogitechLedId.ARROW_LEFT },
|
||||
{ LedId.Keyboard_ArrowDown, LogitechLedId.ARROW_DOWN },
|
||||
{ LedId.Keyboard_ArrowRight, LogitechLedId.ARROW_RIGHT },
|
||||
{ LedId.Keyboard_NumLock, LogitechLedId.NUM_LOCK },
|
||||
{ LedId.Keyboard_NumSlash, LogitechLedId.NUM_SLASH },
|
||||
{ LedId.Keyboard_NumAsterisk, LogitechLedId.NUM_ASTERISK },
|
||||
{ LedId.Keyboard_NumMinus, LogitechLedId.NUM_MINUS },
|
||||
{ LedId.Keyboard_NumPlus, LogitechLedId.NUM_PLUS },
|
||||
{ LedId.Keyboard_NumEnter, LogitechLedId.NUM_ENTER },
|
||||
{ LedId.Keyboard_Num7, LogitechLedId.NUM_SEVEN },
|
||||
{ LedId.Keyboard_Num8, LogitechLedId.NUM_EIGHT },
|
||||
{ LedId.Keyboard_Num9, LogitechLedId.NUM_NINE },
|
||||
{ LedId.Keyboard_Num4, LogitechLedId.NUM_FOUR },
|
||||
{ LedId.Keyboard_Num5, LogitechLedId.NUM_FIVE },
|
||||
{ LedId.Keyboard_Num6, LogitechLedId.NUM_SIX },
|
||||
{ LedId.Keyboard_Num1, LogitechLedId.NUM_ONE },
|
||||
{ LedId.Keyboard_Num2, LogitechLedId.NUM_TWO },
|
||||
{ LedId.Keyboard_Num3, LogitechLedId.NUM_THREE },
|
||||
{ LedId.Keyboard_Num0, LogitechLedId.NUM_ZERO },
|
||||
{ LedId.Keyboard_NumPeriodAndDelete, LogitechLedId.NUM_PERIOD },
|
||||
{ LedId.Keyboard_Programmable1, LogitechLedId.G_1 },
|
||||
{ LedId.Keyboard_Programmable2, LogitechLedId.G_2 },
|
||||
{ LedId.Keyboard_Programmable3, LogitechLedId.G_3 },
|
||||
{ LedId.Keyboard_Programmable4, LogitechLedId.G_4 },
|
||||
{ LedId.Keyboard_Programmable5, LogitechLedId.G_5 },
|
||||
{ LedId.Keyboard_Programmable6, LogitechLedId.G_6 },
|
||||
{ LedId.Keyboard_Programmable7, LogitechLedId.G_7 },
|
||||
{ LedId.Keyboard_Programmable8, LogitechLedId.G_8 },
|
||||
{ LedId.Keyboard_Programmable9, LogitechLedId.G_9 },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -52,16 +52,16 @@
|
||||
<Compile Include="Enum\LogitechLogicalKeyboardLayout.cs" />
|
||||
<Compile Include="Enum\LogitechPhysicalKeyboardLayout.cs" />
|
||||
<Compile Include="Enum\LogitechDeviceCaps.cs" />
|
||||
<Compile Include="Enum\LogitechLedIds.cs" />
|
||||
<Compile Include="Enum\LogitechLedId.cs" />
|
||||
<Compile Include="Generic\ILogitechRGBDevice.cs" />
|
||||
<Compile Include="Generic\LogitechLedId.cs" />
|
||||
<Compile Include="Generic\LogitechRGBDevice.cs" />
|
||||
<Compile Include="Generic\LogitechRGBDeviceInfo.cs" />
|
||||
<Compile Include="Helper\BitmapMapping.cs" />
|
||||
<Compile Include="PerKey\BitmapMapping.cs" />
|
||||
<Compile Include="HID\DeviceChecker.cs" />
|
||||
<Compile Include="LogitechDeviceProvider.cs" />
|
||||
<Compile Include="Native\_LogitechGSDK.cs" />
|
||||
<Compile Include="PerDevice\LogitechPerDeviceRGBDevice.cs" />
|
||||
<Compile Include="PerKey\PerKeyIdMapping.cs" />
|
||||
<Compile Include="PerKey\LogitechPerKeyRGBDevice.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in new issue
Block a user