using System.Runtime.InteropServices; using System.Text.RegularExpressions; using RGB.NET.Core; using RGB.NET.Devices.CorsairLegacy.Native; namespace RGB.NET.Devices.CorsairLegacy; /// /// /// Represents a generic information for a Corsair-. /// public class CorsairRGBDeviceInfo : IRGBDeviceInfo { #region Properties & Fields /// /// Gets the corsair specific device type. /// public CorsairDeviceType CorsairDeviceType { get; } /// /// Gets the index of the . /// public int CorsairDeviceIndex { get; } /// public RGBDeviceType DeviceType { get; } /// public string DeviceName { get; } /// public string Manufacturer => "Corsair"; /// public string Model { get; } /// /// Returns the unique ID provided by the Corsair-SDK. /// Returns string.Empty for Custom devices. /// public string DeviceId { get; } /// public object? LayoutMetadata { get; set; } /// /// Gets a flag that describes device capabilities. () /// public CorsairDeviceCaps CapsMask { get; } #endregion #region Constructors /// /// Internal constructor of managed . /// /// The index of the . /// The type of the . /// The native -struct internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo) { this.CorsairDeviceIndex = deviceIndex; this.DeviceType = deviceType; this.CorsairDeviceType = nativeInfo.type; this.Model = nativeInfo.model == 0 ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase); this.DeviceId = nativeInfo.deviceId ?? string.Empty; this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } /// /// Internal constructor of managed . /// /// The index of the . /// The type of the . /// The native -struct /// The name of the device-model (overwrites the one provided with the device info). internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, string modelName) { this.CorsairDeviceIndex = deviceIndex; this.DeviceType = deviceType; this.CorsairDeviceType = nativeInfo.type; this.Model = modelName; this.DeviceId = nativeInfo.deviceId ?? string.Empty; this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); } #endregion }