mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 13:06:24 +00:00
Made logitech keyboards work (Layout and Images for G910 DE-Layout)
This commit is contained in:
1 parent
9617771368
commit
726ec1443e
125 files changed
+829
-18
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Core.Layout;
|
||||
@@ -59,11 +60,15 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// Applies the given layout.
|
||||
/// </summary>
|
||||
/// <param name="layoutPath">The file containing the layout.</param>
|
||||
protected void ApplyLayoutFromFile(string layoutPath)
|
||||
/// <param name="imageLayout">The name of the layout used tp 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));
|
||||
|
||||
InternalSize = new Size(layout.Width, layout.Height);
|
||||
|
||||
if (layout.Leds != null)
|
||||
@@ -83,6 +88,12 @@ namespace RGB.NET.Devices.Logitech
|
||||
led.LedRectangle.Size.Height = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,13 +102,31 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate)
|
||||
{
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB);
|
||||
|
||||
List<Led> leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList();
|
||||
|
||||
byte[] bitmap = null;
|
||||
foreach (Led led in leds)
|
||||
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)((LogitechLedId)led.Id).LedId,
|
||||
(int)Math.Round(led.Color.RPercent * 100),
|
||||
(int)Math.Round(led.Color.GPercent * 100),
|
||||
(int)Math.Round(led.Color.BPercent * 100));
|
||||
{
|
||||
//TODO DarthAffe 26.03.2017: This is only needed since update by name doesn't work as expected for all keys ...
|
||||
int bitmapOffset;
|
||||
if (BitmapMapping.BitmapOffset.TryGetValue(((LogitechLedId)led.Id).LedId, out bitmapOffset))
|
||||
{
|
||||
if (bitmap == null)
|
||||
bitmap = BitmapMapping.CreateBitmap();
|
||||
|
||||
BitmapMapping.SetColor(ref bitmap, bitmapOffset, led.Color);
|
||||
}
|
||||
else
|
||||
_LogitechGSDK.LogiLedSetLightingForKeyWithKeyName((int)((LogitechLedId)led.Id).LedId,
|
||||
(int)Math.Round(led.Color.RPercent * 100),
|
||||
(int)Math.Round(led.Color.GPercent * 100),
|
||||
(int)Math.Round(led.Color.BPercent * 100));
|
||||
}
|
||||
|
||||
if (bitmap != null)
|
||||
_LogitechGSDK.LogiLedSetLightingFromBitmap(bitmap);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user