mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Compare commits
14 Commits
4a0ae1a185
...
79252d5b31
| Author | SHA1 | Date | |
|---|---|---|---|
| 79252d5b31 | |||
| 27018b34e3 | |||
| 0aca2d84b1 | |||
| 020f249f9a | |||
| 1532e31a33 | |||
|
|
d53801117b | ||
| a196d2a0a4 | |||
| 73b7f1f24f | |||
| 124f76b382 | |||
| acddfed2b1 | |||
|
|
184a5823e8 | ||
|
|
e9cd657eac | ||
|
|
0c8f48ea44 | ||
| 93cd8055a2 |
@ -27,9 +27,9 @@ public abstract class AbstractBindable : IBindable
|
||||
/// <typeparam name="T">Type of the property.</typeparam>
|
||||
/// <param name="storage">Reference to the backing-filed.</param>
|
||||
/// <param name="value">Value to apply.</param>
|
||||
/// <returns><c>true</c> if the value needs to be updated; otherweise <c>false</c>.</returns>
|
||||
/// <returns><c>true</c> if the value needs to be updated; otherwise <c>false</c>.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected virtual bool RequiresUpdate<T>(ref T storage, T value) => !EqualityComparer<T>.Default.Equals(storage, value);
|
||||
protected bool RequiresUpdate<T>(ref T storage, T value) => !EqualityComparer<T>.Default.Equals(storage, value);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the property already matches the desired value and updates it if not.
|
||||
@ -40,7 +40,7 @@ public abstract class AbstractBindable : IBindable
|
||||
/// <param name="propertyName">Name of the property used to notify listeners. This value is optional
|
||||
/// and can be provided automatically when invoked from compilers that support <see cref="CallerMemberNameAttribute"/>.</param>
|
||||
/// <returns><c>true</c> if the value was changed, <c>false</c> if the existing value matched the desired value.</returns>
|
||||
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string? propertyName = null)
|
||||
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
if (!RequiresUpdate(ref storage, value)) return false;
|
||||
|
||||
@ -55,7 +55,7 @@ public abstract class AbstractBindable : IBindable
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property used to notify listeners. This value is optional
|
||||
/// and can be provided automatically when invoked from compilers that support <see cref="CallerMemberNameAttribute"/>.</param>
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
||||
#endregion
|
||||
|
||||
@ -74,9 +74,13 @@ public abstract class AbstractBrush : AbstractDecoratable<IBrushDecorator>, IBru
|
||||
if (Decorators.Count == 0) return;
|
||||
|
||||
lock (Decorators)
|
||||
foreach (IBrushDecorator decorator in Decorators)
|
||||
// ReSharper disable once ForCanBeConvertedToForeach - Sadly this does not get optimized reliably and causes allocations if foreached
|
||||
for (int i = 0; i < Decorators.Count; i++)
|
||||
{
|
||||
IBrushDecorator decorator = Decorators[i];
|
||||
if (decorator.IsEnabled)
|
||||
decorator.ManipulateColor(rectangle, renderTarget, ref color);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -32,6 +32,8 @@ public sealed class SolidColorBrush : AbstractBrush
|
||||
public SolidColorBrush(Color color)
|
||||
{
|
||||
this.Color = color;
|
||||
|
||||
CalculationMode = RenderMode.Absolute;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RGB.NET.Core;
|
||||
|
||||
@ -41,7 +40,7 @@ public sealed class AverageColorSampler : ISampler<Color>
|
||||
{
|
||||
ReadOnlySpan<Color> data = info[y];
|
||||
|
||||
fixed (Color* colorPtr = &MemoryMarshal.GetReference(data))
|
||||
fixed (Color* colorPtr = data)
|
||||
{
|
||||
Color* current = colorPtr;
|
||||
for (int i = 0; i < chunks; i++)
|
||||
|
||||
@ -133,7 +133,7 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
|
||||
/// <summary>
|
||||
/// Stops the trigger.
|
||||
/// </summary>
|
||||
public async void Stop()
|
||||
public virtual async void Stop()
|
||||
{
|
||||
if (!IsRunning) return;
|
||||
|
||||
@ -141,7 +141,9 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
|
||||
|
||||
UpdateTokenSource?.Cancel();
|
||||
if (UpdateTask != null)
|
||||
await UpdateTask;
|
||||
try { await UpdateTask.ConfigureAwait(false); }
|
||||
catch (TaskCanceledException) { }
|
||||
catch (OperationCanceledException) { }
|
||||
|
||||
UpdateTask?.Dispose();
|
||||
UpdateTask = null;
|
||||
|
||||
@ -69,6 +69,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
AsusDeviceType.HEADSET_RGB => new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device), GetUpdateTrigger()),
|
||||
AsusDeviceType.DRAM_RGB => new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device), GetUpdateTrigger()),
|
||||
AsusDeviceType.KEYBOARD_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()),
|
||||
AsusDeviceType.KEYBOARD_5ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()),
|
||||
AsusDeviceType.NB_KB_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), LedMappings.KeyboardMapping, GetUpdateTrigger()),
|
||||
AsusDeviceType.NB_KB_4ZONE_RGB => new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device), null, GetUpdateTrigger()),
|
||||
AsusDeviceType.MOUSE_RGB => new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device), GetUpdateTrigger()),
|
||||
|
||||
@ -16,10 +16,12 @@ internal enum AsusDeviceType : uint
|
||||
EXTERNAL_BLUE_RAY_RGB = 0x61000,
|
||||
DRAM_RGB = 0x70000,
|
||||
KEYBOARD_RGB = 0x80000,
|
||||
KEYBOARD_5ZONE_RGB = 0x80001,
|
||||
NB_KB_RGB = 0x81000,
|
||||
NB_KB_4ZONE_RGB = 0x81001,
|
||||
MOUSE_RGB = 0x90000,
|
||||
CHASSIS_RGB = 0xB0000,
|
||||
PROJECTOR_RGB = 0xC0000,
|
||||
WATERCOOLER_RGB = 0xD1000,
|
||||
TERMINAL_RGB = 0xE0000
|
||||
}
|
||||
@ -4,7 +4,7 @@ namespace RGB.NET.Devices.Asus;
|
||||
|
||||
/// <inheritdoc cref="AsusRGBDevice{TDeviceInfo}" />
|
||||
/// <summary>
|
||||
/// Represents a Asus headset.
|
||||
/// Represents a Asus device that is otherwise not handled by a more specific helper.
|
||||
/// </summary>
|
||||
public sealed class AsusUnspecifiedRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IUnknownDevice
|
||||
{
|
||||
@ -18,9 +18,9 @@ public sealed class AsusUnspecifiedRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>,
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Asus.AsusHeadsetRGBDevice" /> class.
|
||||
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Asus.AsusUnspecifiedRGBDevice" /> class.
|
||||
/// </summary>
|
||||
/// <param name="info">The specific information provided by Asus for the headset.</param>
|
||||
/// <param name="info">The specific information provided by Asus for the device.</param>
|
||||
/// <param name="baseLedId">The ledId of the first led of this device. All other leds are created by incrementing this base-id by 1.</param>
|
||||
/// <param name="updateTrigger">The update trigger used to update this device.</param>
|
||||
internal AsusUnspecifiedRGBDevice(AsusRGBDeviceInfo info, LedId baseLedId, IDeviceUpdateTrigger updateTrigger)
|
||||
|
||||
@ -188,4 +188,49 @@ public static class LedMappings
|
||||
{ LedId.Keyboard_Custom59, 131 },
|
||||
{ LedId.Keyboard_Custom60, 133 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A LED mapping containing extra lights for the ROG Strix G15 (2021)
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// ASUS notebooks have extra lights under wide keys like space and backspace, these do not appear as keys on the device.
|
||||
/// Instead they only appear in the Lights enumerable, this mapping maps the matching keys to the index of these lights.
|
||||
/// There are also some keys which do not use the default key scan code mappings for LEDs, and instead rely on lights.
|
||||
/// </para>
|
||||
/// <para>You may add more of these by further populating <see cref="AsusKeyboardRGBDevice.ExtraLedMappings"/>.</para>
|
||||
/// </remarks>
|
||||
public static LedMapping<int> ROGStrixG15 { get; } = new()
|
||||
{
|
||||
{ LedId.Keyboard_Custom71, 4 }, //Mic Mute
|
||||
{ LedId.Keyboard_Custom72, 5 }, //Fan
|
||||
{ LedId.Keyboard_Custom73, 6 }, //ROG Logo
|
||||
//{ LedId.Keyboard_Function, 127 }, //commented out because adding a mapping fails if a mapping already exists for a key, even if it is incorrect for this device
|
||||
//use Keyboard_Custom36 in the default mapping to get the Fn key on this laptop
|
||||
|
||||
{ LedId.Keyboard_Custom52, 55 }, //backspace extra LEDs (x2) - these are named to match the appropriate LEDs in the previous ROG Zephyrus mapping
|
||||
{ LedId.Keyboard_Custom53, 57 },
|
||||
{ LedId.Keyboard_Custom54, 97 }, //enter extra LEDs (x2)
|
||||
{ LedId.Keyboard_Custom55, 99 },
|
||||
{ LedId.Keyboard_Custom56, 118 }, //right shift extra LEDs (x2)
|
||||
{ LedId.Keyboard_Custom57, 120 },
|
||||
{ LedId.Keyboard_Custom58, 130 }, //space bar extra LEDs (x3)
|
||||
{ LedId.Keyboard_Custom59, 131 }, //this one specifically is also exposed as Custom7 (AsusLedID.KEY_NOCONVERT) in the main map
|
||||
{ LedId.Keyboard_Custom60, 133 },
|
||||
|
||||
{ LedId.Keyboard_MediaVolumeDown, 2 },
|
||||
{ LedId.Keyboard_MediaVolumeUp, 3 },
|
||||
{ LedId.Keyboard_MediaPlay, 58 },
|
||||
{ LedId.Keyboard_MediaStop, 79 },
|
||||
{ LedId.Keyboard_MediaPreviousTrack, 100 },
|
||||
{ LedId.Keyboard_MediaNextTrack, 121 },
|
||||
|
||||
{ LedId.LedStripe1, 174 }, //front LED strip; yes, these are in reverse order, since the SDK exposes them from right to left
|
||||
{ LedId.LedStripe2, 173 },
|
||||
{ LedId.LedStripe3, 172 },
|
||||
{ LedId.LedStripe4, 171 },
|
||||
{ LedId.LedStripe5, 170 },
|
||||
{ LedId.LedStripe6, 169 },
|
||||
|
||||
};
|
||||
}
|
||||
@ -37,7 +37,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static readonly List<AsusKeyboardExtraMapping> ExtraLedMappings = new()
|
||||
{
|
||||
new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15)
|
||||
new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15),
|
||||
new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15)
|
||||
};
|
||||
|
||||
#endregion
|
||||
@ -65,7 +66,7 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
|
||||
|
||||
private void InitializeLayout()
|
||||
{
|
||||
if (DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB)
|
||||
if (DeviceInfo.Device.Type != (uint)AsusDeviceType.NB_KB_4ZONE_RGB && DeviceInfo.Device.Type !=(uint)AsusDeviceType.KEYBOARD_5ZONE_RGB)
|
||||
{
|
||||
int pos = 0;
|
||||
int unknownLed = (int)LedId.Unknown1;
|
||||
|
||||
@ -109,6 +109,28 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{ 0x026C, RGBDeviceType.Keyboard, "Huntsman V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028D, RGBDeviceType.Keyboard, "BlackWidow V4", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x02A1, RGBDeviceType.Keyboard, "Ornata V3", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0A24, RGBDeviceType.Keyboard, "BlackWidow V3 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0295, RGBDeviceType.Keyboard, "DeathStalker V2", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0292, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired
|
||||
{ 0x0290, RGBDeviceType.Keyboard, "DeathStalker V2 Pro", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless
|
||||
{ 0x0298, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wired
|
||||
{ 0x0296, RGBDeviceType.Keyboard, "DeathStalker V2 Pro TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard }, // Wireless
|
||||
{ 0x0294, RGBDeviceType.Keyboard, "Ornata V3 X", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028C, RGBDeviceType.Keyboard, "Blade 14 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028B, RGBDeviceType.Keyboard, "Blade 17 (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x028A, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x027A, RGBDeviceType.Keyboard, "Blade 15 Base (2022)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0279, RGBDeviceType.Keyboard, "Blade 17 Pro (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0276, RGBDeviceType.Keyboard, "Blade 15 Advanced (Mid 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0270, RGBDeviceType.Keyboard, "Blade 14 (2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026F, RGBDeviceType.Keyboard, "Blade 15 Base (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026E, RGBDeviceType.Keyboard, "Blade 17 Pro (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026D, RGBDeviceType.Keyboard, "Blade 15 Advanced (Early 2021)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026A, RGBDeviceType.Keyboard, "Book 13 (2020)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0282, RGBDeviceType.Keyboard, "Huntsman Mini Analog", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0271, RGBDeviceType.Keyboard, "BlackWidow V3 Mini Hyperspeed", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x026B, RGBDeviceType.Keyboard, "Huntsman V2 TKL", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
{ 0x0269, RGBDeviceType.Keyboard, "Huntsman Mini (JP)", LedMappings.Keyboard, RazerEndpointType.Keyboard },
|
||||
|
||||
// Mice
|
||||
{ 0x0013, RGBDeviceType.Mouse, "Orochi 2011", LedMappings.Mouse, RazerEndpointType.Mouse },
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Presets.Textures.Sampler;
|
||||
@ -42,7 +41,7 @@ public sealed class AverageByteSampler : ISampler<byte>
|
||||
{
|
||||
ReadOnlySpan<byte> data = info[y];
|
||||
|
||||
fixed (byte* colorPtr = &MemoryMarshal.GetReference(data))
|
||||
fixed (byte* colorPtr = data)
|
||||
{
|
||||
byte* current = colorPtr;
|
||||
for (int i = 0; i < chunks; i++)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Presets.Textures.Sampler;
|
||||
@ -33,7 +32,7 @@ public sealed class AverageFloatSampler : ISampler<float>
|
||||
{
|
||||
ReadOnlySpan<float> data = info[y];
|
||||
|
||||
fixed (float* colorPtr = &MemoryMarshal.GetReference(data))
|
||||
fixed (float* colorPtr = data)
|
||||
{
|
||||
float* current = colorPtr;
|
||||
for (int i = 0; i < chunks; i++)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user