// ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global using System; using System.Collections.Generic; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.Razer.Native; namespace RGB.NET.Devices.Razer { /// /// /// Represents a razer headset. /// public class RazerHeadsetRGBDevice : RazerRGBDevice { #region Constructors /// /// /// Initializes a new instance of the class. /// /// The specific information provided by CUE for the headset. internal RazerHeadsetRGBDevice(RazerHeadsetRGBDeviceInfo info) : base(info) { } #endregion #region Methods /// protected override void InitializeLayout() { string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( $@"Layouts\Razer\Headset\{model}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Razer\Headset")); if (LedMapping.Count == 0) for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++) InitializeLed(new RazerLedId(this, i), new Rectangle(i * 11, 0, 10, 10)); } /// protected override IntPtr CreateEffectParams(IEnumerable leds) { _Color[] colors = new _Color[_Defines.HEADSET_MAX_LEDS]; foreach (Led led in leds) colors[((RazerLedId)led.Id).Index] = new _Color(led.Color.R, led.Color.G, led.Color.B); _HeadsetCustomEffect effectParams = new _HeadsetCustomEffect { Color = colors }; IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(effectParams)); Marshal.StructureToPtr(effectParams, ptr, false); return ptr; } #endregion } }