mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Dispose of each keyboard properly
This commit is contained in:
parent
819e6ef1df
commit
f3d63f09a9
@ -37,6 +37,8 @@ public class WootingRGBDeviceInfo : IRGBDeviceInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public WootingLayoutType WootingLayoutType { get; }
|
public WootingLayoutType WootingLayoutType { get; }
|
||||||
|
|
||||||
|
public byte WootingDeviceIndex { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@ -46,11 +48,12 @@ public class WootingRGBDeviceInfo : IRGBDeviceInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
|
||||||
/// <param name="deviceInfo">The <see cref="_WootingDeviceInfo"/> of the <see cref="IRGBDevice"/>.</param>
|
/// <param name="deviceInfo">The <see cref="_WootingDeviceInfo"/> of the <see cref="IRGBDevice"/>.</param>
|
||||||
internal WootingRGBDeviceInfo(RGBDeviceType deviceType, _WootingDeviceInfo deviceInfo)
|
internal WootingRGBDeviceInfo(RGBDeviceType deviceType, _WootingDeviceInfo deviceInfo, byte deviceIndex)
|
||||||
{
|
{
|
||||||
this.DeviceType = deviceType;
|
this.DeviceType = deviceType;
|
||||||
this.WootingDeviceType = deviceInfo.DeviceType;
|
this.WootingDeviceType = deviceInfo.DeviceType;
|
||||||
this.WootingLayoutType = deviceInfo.LayoutType;
|
this.WootingLayoutType = deviceInfo.LayoutType;
|
||||||
|
this.WootingDeviceIndex = deviceIndex;
|
||||||
|
|
||||||
Model = deviceInfo.Model;
|
Model = deviceInfo.Model;
|
||||||
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.Wooting.Generic;
|
using RGB.NET.Devices.Wooting.Generic;
|
||||||
|
using RGB.NET.Devices.Wooting.Native;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.Wooting.Keyboard;
|
namespace RGB.NET.Devices.Wooting.Keyboard;
|
||||||
|
|
||||||
@ -48,5 +49,12 @@ public class WootingKeyboardRGBDevice : WootingRGBDevice<WootingKeyboardRGBDevic
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate));
|
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate));
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
_WootingSDK.SelectDevice(DeviceInfo.WootingDeviceIndex);
|
||||||
|
_WootingSDK.Reset();
|
||||||
|
|
||||||
|
base.Dispose();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -24,8 +24,8 @@ public class WootingKeyboardRGBDeviceInfo : WootingRGBDeviceInfo, IKeyboardDevic
|
|||||||
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDeviceInfo" />.
|
/// Internal constructor of managed <see cref="T:RGB.NET.Devices.Wooting.WootingKeyboardRGBDeviceInfo" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceInfo">The native <see cref="T:RGB.NET.Devices.Wooting.Native._WootingDeviceInfo" />.</param>
|
/// <param name="deviceInfo">The native <see cref="T:RGB.NET.Devices.Wooting.Native._WootingDeviceInfo" />.</param>
|
||||||
internal WootingKeyboardRGBDeviceInfo(_WootingDeviceInfo deviceInfo)
|
internal WootingKeyboardRGBDeviceInfo(_WootingDeviceInfo deviceInfo, byte deviceIndex)
|
||||||
: base(RGBDeviceType.Keyboard, deviceInfo)
|
: base(RGBDeviceType.Keyboard, deviceInfo, deviceIndex)
|
||||||
{
|
{
|
||||||
Layout = WootingLayoutType switch
|
Layout = WootingLayoutType switch
|
||||||
{
|
{
|
||||||
|
|||||||
@ -58,7 +58,6 @@ internal static class _WootingSDK
|
|||||||
{
|
{
|
||||||
if (_handle == IntPtr.Zero) return;
|
if (_handle == IntPtr.Zero) return;
|
||||||
|
|
||||||
Reset();
|
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
_getDeviceInfoPointer = null;
|
_getDeviceInfoPointer = null;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class WootingDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
_WootingSDK.SelectDevice(i);
|
_WootingSDK.SelectDevice(i);
|
||||||
_WootingDeviceInfo nativeDeviceInfo = (_WootingDeviceInfo)Marshal.PtrToStructure(_WootingSDK.GetDeviceInfo(), typeof(_WootingDeviceInfo))!;
|
_WootingDeviceInfo nativeDeviceInfo = (_WootingDeviceInfo)Marshal.PtrToStructure(_WootingSDK.GetDeviceInfo(), typeof(_WootingDeviceInfo))!;
|
||||||
|
|
||||||
yield return new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(nativeDeviceInfo), updateQueue);
|
yield return new WootingKeyboardRGBDevice(new WootingKeyboardRGBDeviceInfo(nativeDeviceInfo, i), updateQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user