mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Merge pull request #140 from DarthAffe/SDK/SteelSeries
Lisp-handler rewrite
This commit is contained in:
commit
8b0c7ea75b
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -16,16 +17,21 @@ namespace RGB.NET.Devices.SteelSeries.API
|
|||||||
private const string GAME_NAME = "RGBNET";
|
private const string GAME_NAME = "RGBNET";
|
||||||
private const string GAME_DISPLAYNAME = "RGB.NET";
|
private const string GAME_DISPLAYNAME = "RGB.NET";
|
||||||
private const string EVENT_NAME = "UPDATELEDS";
|
private const string EVENT_NAME = "UPDATELEDS";
|
||||||
private static readonly string HANDLER = $@"(handler ""{EVENT_NAME}""
|
private static readonly string HANDLER = $@"(define (getZone x)
|
||||||
|
(case x
|
||||||
|
{string.Join(Environment.NewLine, Enum.GetValues(typeof(SteelSeriesLedId))
|
||||||
|
.Cast<SteelSeriesLedId>()
|
||||||
|
.Select(x => x.GetAPIName())
|
||||||
|
.Select(ledId => $" ((\"{ledId}\") {ledId}:)"))}
|
||||||
|
))
|
||||||
|
|
||||||
|
(handler ""{EVENT_NAME}""
|
||||||
(lambda (data)
|
(lambda (data)
|
||||||
(let* ((device (value: data))
|
(let* ((device (value: data))
|
||||||
(zoneData (frame: data))
|
(zones (zones: data))
|
||||||
(zones (frame-keys zoneData)))
|
(colors (colors: data)))
|
||||||
(do ((zoneDo zones (cdr zoneDo)))
|
(on-device device show-on-zones: colors (map (lambda (x) (getZone x)) zones)))))
|
||||||
((nil? zoneDo))
|
|
||||||
(let* ((zone (car zoneDo))
|
|
||||||
(color (get-slot zoneData zone)))
|
|
||||||
(on-device device show-on-zone: color zone))))))
|
|
||||||
(add-event-per-key-zone-use ""{EVENT_NAME}"" ""all"")
|
(add-event-per-key-zone-use ""{EVENT_NAME}"" ""all"")
|
||||||
(add-event-zone-use-with-specifier ""{EVENT_NAME}"" ""all"" ""rgb-1-zone"")
|
(add-event-zone-use-with-specifier ""{EVENT_NAME}"" ""all"" ""rgb-1-zone"")
|
||||||
(add-event-zone-use-with-specifier ""{EVENT_NAME}"" ""all"" ""rgb-2-zone"")
|
(add-event-zone-use-with-specifier ""{EVENT_NAME}"" ""all"" ""rgb-2-zone"")
|
||||||
@ -87,7 +93,8 @@ namespace RGB.NET.Devices.SteelSeries.API
|
|||||||
{
|
{
|
||||||
_event.Data.Clear();
|
_event.Data.Clear();
|
||||||
_event.Data.Add("value", device);
|
_event.Data.Add("value", device);
|
||||||
_event.Data.Add("frame", data);
|
_event.Data.Add("colors", data.Values.ToList());
|
||||||
|
_event.Data.Add("zones", data.Keys.ToList());
|
||||||
|
|
||||||
TriggerEvent(_event);
|
TriggerEvent(_event);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ namespace RGB.NET.Devices.SteelSeries
|
|||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private string _deviceType;
|
private string _deviceType;
|
||||||
private Dictionary<object, Color> _lastDataSet;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -39,20 +38,14 @@ namespace RGB.NET.Devices.SteelSeries
|
|||||||
protected override void OnUpdate(object sender, CustomUpdateData customData)
|
protected override void OnUpdate(object sender, CustomUpdateData customData)
|
||||||
{
|
{
|
||||||
if ((customData != null) && (customData["refresh"] as bool? ?? false))
|
if ((customData != null) && (customData["refresh"] as bool? ?? false))
|
||||||
{
|
SteelSeriesSDK.SendHeartbeat();
|
||||||
if ((_lastDataSet != null) && (_lastDataSet.Count != 0))
|
|
||||||
Update(_lastDataSet);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
base.OnUpdate(sender, customData);
|
base.OnUpdate(sender, customData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Update(Dictionary<object, Color> dataSet)
|
protected override void Update(Dictionary<object, Color> dataSet)
|
||||||
{
|
=> SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToDictionary(x => ((SteelSeriesLedId)x.Key).GetAPIName(), x => x.Value.ToIntArray()));
|
||||||
_lastDataSet = dataSet;
|
|
||||||
SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToDictionary(x => ((SteelSeriesLedId)x.Key).GetAPIName(), x => x.Value.ToIntArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user