mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 01:58:30 +00:00
Razer - Added all OpenRazer provided PIDs Razer - Use device-specific SDK endpoints, allowing access to all Razer devices
89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using RGB.NET.Core;
|
|
|
|
namespace RGB.NET.Devices.Razer
|
|
{
|
|
/// <inheritdoc cref="AbstractRGBDevice{RazerRGBDeviceInfo}" />
|
|
/// <inheritdoc cref="IRazerRGBDevice" />
|
|
/// <summary>
|
|
/// Represents a generic razer-device. (keyboard, mouse, headset, mousepad).
|
|
/// </summary>
|
|
public abstract class RazerRGBDevice : AbstractRGBDevice<RazerRGBDeviceInfo>, IRazerRGBDevice
|
|
{
|
|
#region Properties & Fields
|
|
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// Gets information about the <see cref="T:RGB.NET.Devices.Razer.RazerRGBDevice" />.
|
|
/// </summary>
|
|
public override RazerRGBDeviceInfo DeviceInfo { get; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the update queue performing updates for this device.
|
|
/// </summary>
|
|
// ReSharper disable once MemberCanBePrivate.Global
|
|
protected RazerUpdateQueue? UpdateQueue { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RazerRGBDevice"/> class.
|
|
/// </summary>
|
|
/// <param name="info">The generic information provided by razer for the device.</param>
|
|
protected RazerRGBDevice(RazerRGBDeviceInfo info)
|
|
{
|
|
this.DeviceInfo = info;
|
|
|
|
RequiresFlush = true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Initializes the device.
|
|
/// </summary>
|
|
public void Initialize(IDeviceUpdateTrigger updateTrigger)
|
|
{
|
|
InitializeLayout();
|
|
|
|
UpdateQueue = CreateUpdateQueue(updateTrigger);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a specific <see cref="RazerUpdateQueue"/> for this device.
|
|
/// </summary>
|
|
/// <param name="updateTrigger">The trigger used to update the queue.</param>
|
|
/// <returns>The <see cref="RazerUpdateQueue"/> for this device.</returns>
|
|
protected abstract RazerUpdateQueue CreateUpdateQueue(IDeviceUpdateTrigger updateTrigger);
|
|
|
|
/// <summary>
|
|
/// Initializes the <see cref="Led"/> and <see cref="Size"/> of the device.
|
|
/// </summary>
|
|
protected abstract void InitializeLayout();
|
|
|
|
/// <inheritdoc />
|
|
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue?.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
|
|
|
/// <summary>
|
|
/// Resets the device.
|
|
/// </summary>
|
|
public void Reset() => UpdateQueue?.Reset();
|
|
|
|
/// <inheritdoc />
|
|
public override void Dispose()
|
|
{
|
|
try { UpdateQueue?.Dispose(); }
|
|
catch { /* at least we tried */ }
|
|
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|