diff --git a/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs index 4ca979a..946125d 100644 --- a/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus_Legacy/AsusDeviceProvider.cs @@ -228,7 +228,7 @@ namespace RGB.NET.Devices.Asus catch { if (throwExceptions) throw; } #endregion - + UpdateTrigger?.Start(); Devices = new ReadOnlyCollection(devices); @@ -267,7 +267,10 @@ namespace RGB.NET.Devices.Asus /// public void Dispose() - { } + { + try { _AsusSDK.UnloadAsusSDK(); } + catch { /* at least we tried */ } + } #endregion } diff --git a/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs b/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs index 830dadd..437a3ea 100644 --- a/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs +++ b/RGB.NET.Devices.Asus_Legacy/Native/_AsusSDK.cs @@ -75,7 +75,7 @@ namespace RGB.NET.Devices.Asus.Native //_getDramColorPointer = (GetDramColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetDramColor"), typeof(GetDramColorPointer)); } - private static void UnloadAsusSDK() + internal static void UnloadAsusSDK() { if (_dllHandle == IntPtr.Zero) return; diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index f091ed3..e676ca1 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -108,7 +108,7 @@ namespace RGB.NET.Devices.CoolerMaster { RGBDeviceType deviceType = index.GetDeviceType(); if (deviceType == RGBDeviceType.None) continue; - + if (_CoolerMasterSDK.IsDevicePlugged(index)) { if (!loadFilter.HasFlag(deviceType)) continue; @@ -185,6 +185,9 @@ namespace RGB.NET.Devices.CoolerMaster } catch {/* shit happens */} } + + try { _CoolerMasterSDK.UnloadCMSDK(); } + catch { /* at least we tried */ } } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs index 00e89c8..ac23587 100644 --- a/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs +++ b/RGB.NET.Devices.CoolerMaster/Native/_CoolerMasterSDK.cs @@ -52,7 +52,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native _setAllLedColorPointer = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetAllLedColor"), typeof(SetAllLedColorPointer)); } - private static void UnloadCMSDK() + internal static void UnloadCMSDK() { if (_dllHandle == IntPtr.Zero) return; diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index d048397..330be29 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -292,7 +292,10 @@ namespace RGB.NET.Devices.Corsair /// public void Dispose() - { } + { + try { _CUESDK.UnloadCUESDK(); } + catch { /* at least we tried */ } + } #endregion } diff --git a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs index 0e319ff..9b217e4 100644 --- a/RGB.NET.Devices.Corsair/Native/_CUESDK.cs +++ b/RGB.NET.Devices.Corsair/Native/_CUESDK.cs @@ -56,7 +56,7 @@ namespace RGB.NET.Devices.Corsair.Native _corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer)); } - private static void UnloadCUESDK() + internal static void UnloadCUESDK() { if (_dllHandle == IntPtr.Zero) return; @@ -136,7 +136,7 @@ namespace RGB.NET.Devices.Corsair.Native #endregion // ReSharper disable EventExceptionNotDocumented - + /// /// CUE-SDK: set specified LEDs to some colors. /// This function set LEDs colors in the buffer which is written to the devices via CorsairSetLedsColorsFlushBuffer or CorsairSetLedsColorsFlushBufferAsync. @@ -151,7 +151,7 @@ namespace RGB.NET.Devices.Corsair.Native /// This function executes synchronously, if you are concerned about delays consider using CorsairSetLedsColorsFlushBufferAsync /// internal static bool CorsairSetLedsColorsFlushBuffer() => _corsairSetLedsColorsFlushBufferPointer(); - + /// /// CUE-SDK: get current color for the list of requested LEDs. /// The color should represent the actual state of the hardware LED, which could be a combination of SDK and/or CUE input. @@ -175,7 +175,7 @@ namespace RGB.NET.Devices.Corsair.Native /// CUE-SDK: returns information about device at provided index. /// internal static IntPtr CorsairGetDeviceInfo(int deviceIndex) => _corsairGetDeviceInfoPointer(deviceIndex); - + /// /// CUE-SDK: provides list of keyboard or mousepad LEDs with their physical positions. /// diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index 991fc01..eaab179 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -182,7 +182,14 @@ namespace RGB.NET.Devices.Logitech public void ResetDevices() => _LogitechGSDK.LogiLedRestoreLighting(); /// - public void Dispose() => _LogitechGSDK.LogiLedRestoreLighting(); + public void Dispose() + { + try { _LogitechGSDK.LogiLedRestoreLighting(); } + catch { /* at least we tried */ } + + try { _LogitechGSDK.UnloadLogitechGSDK(); } + catch { /* at least we tried */ } + } #endregion } diff --git a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs index 39d0968..8f1b826 100644 --- a/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs +++ b/RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs @@ -55,7 +55,7 @@ namespace RGB.NET.Devices.Logitech.Native _logiLedSetLightingForTargetZonePointer = (LogiLedSetLightingForTargetZonePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "LogiLedSetLightingForTargetZone"), typeof(LogiLedSetLightingForTargetZonePointer)); } - private static void UnloadLogitechGSDK() + internal static void UnloadLogitechGSDK() { if (_dllHandle == IntPtr.Zero) return; diff --git a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs index 59a3980..f5bf830 100644 --- a/RGB.NET.Devices.Msi/MsiDeviceProvider.cs +++ b/RGB.NET.Devices.Msi/MsiDeviceProvider.cs @@ -163,7 +163,10 @@ namespace RGB.NET.Devices.Msi /// public void Dispose() - { } + { + try { _MsiSDK.UnloadMsiSDK(); } + catch { /* at least we tried */ } + } #endregion } diff --git a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs index a67aa94..930352f 100644 --- a/RGB.NET.Devices.Msi/Native/_MsiSDK.cs +++ b/RGB.NET.Devices.Msi/Native/_MsiSDK.cs @@ -60,7 +60,7 @@ namespace RGB.NET.Devices.Msi.Native _getErrorMessagePointer = (GetErrorMessagePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "MLAPI_GetErrorMessage"), typeof(GetErrorMessagePointer)); } - private static void UnloadMsiSDK() + internal static void UnloadMsiSDK() { if (_dllHandle == IntPtr.Zero) return; diff --git a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs index 17742b3..4802196 100644 --- a/RGB.NET.Devices.Razer/Native/_RazerSDK.cs +++ b/RGB.NET.Devices.Razer/Native/_RazerSDK.cs @@ -52,7 +52,7 @@ namespace RGB.NET.Devices.Razer.Native _deleteEffectPointer = (DeleteEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "DeleteEffect"), typeof(DeleteEffectPointer)); } - private static void UnloadRazerSDK() + internal static void UnloadRazerSDK() { if (_dllHandle == IntPtr.Zero) return; diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 5c9f88b..2172491 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -222,7 +222,13 @@ namespace RGB.NET.Devices.Razer } /// - public void Dispose() => TryUnInit(); + public void Dispose() + { + TryUnInit(); + + try { _RazerSDK.UnloadRazerSDK(); } + catch { /* at least we tried */ } + } #endregion } diff --git a/RGB.NET.Devices.Roccat/Native/_ROCCATSDK.cs b/RGB.NET.Devices.Roccat/Native/_ROCCATSDK.cs index aa59118..21e1644 100644 --- a/RGB.NET.Devices.Roccat/Native/_ROCCATSDK.cs +++ b/RGB.NET.Devices.Roccat/Native/_ROCCATSDK.cs @@ -27,11 +27,11 @@ namespace RGB.NET.Devices.Roccat.Native /// internal static void Reload() { - UnloadCUESDK(); - LoadCUESDK(); + UnloadRoccatSDK(); + LoadRoccatSDK(); } - private static void LoadCUESDK() + private static void LoadRoccatSDK() { if (_dllHandle != IntPtr.Zero) return; @@ -57,7 +57,7 @@ namespace RGB.NET.Devices.Roccat.Native _setAllLedSfxPointer = (SetAllLedSfxPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "Set_all_LEDSFX"), typeof(SetAllLedSfxPointer)); } - private static void UnloadCUESDK() + internal static void UnloadRoccatSDK() { if (_dllHandle == IntPtr.Zero) return; diff --git a/RGB.NET.Devices.Roccat/RoccatDeviceProvider.cs b/RGB.NET.Devices.Roccat/RoccatDeviceProvider.cs index 391a0da..4ad9a9e 100644 --- a/RGB.NET.Devices.Roccat/RoccatDeviceProvider.cs +++ b/RGB.NET.Devices.Roccat/RoccatDeviceProvider.cs @@ -114,6 +114,9 @@ namespace RGB.NET.Devices.Roccat try { _RoccatSDK.UnloadSDK(_sdkHandle); } catch { /* We tried our best */} } + + try { _RoccatSDK.UnloadRoccatSDK(); } + catch { /* at least we tried */ } } #endregion diff --git a/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs b/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs index be7f5ac..8b3d84d 100644 --- a/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs +++ b/RGB.NET.Devices.SteelSeries/API/SteelSeriesSDK.cs @@ -85,7 +85,9 @@ namespace RGB.NET.Devices.SteelSeries.API internal static void Dispose() { - ResetLeds(); + if (IsInitialized) + ResetLeds(); + _client.Dispose(); } diff --git a/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs b/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs index a9017f3..b90e4f7 100644 --- a/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs +++ b/RGB.NET.Devices.Wooting/Native/_WootingSDK.cs @@ -52,7 +52,7 @@ namespace RGB.NET.Devices.Wooting.Native _arraySetSinglePointer = (ArraySetSinglePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_array_set_single"), typeof(ArraySetSinglePointer)); } - private static void UnloadWootingSDK() + internal static void UnloadWootingSDK() { if (_dllHandle == IntPtr.Zero) return; @@ -91,13 +91,13 @@ namespace RGB.NET.Devices.Wooting.Native [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate IntPtr GetDeviceInfoPointer(); - + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool KeyboardConnectedPointer(); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool ResetPointer(); - + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool ArrayUpdateKeyboardPointer(); diff --git a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs index 5a1113c..4635f74 100644 --- a/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs +++ b/RGB.NET.Devices.Wooting/WootingDeviceProvider.cs @@ -28,13 +28,13 @@ namespace RGB.NET.Devices.Wooting /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// The first match will be used. /// - public static List PossibleX86NativePaths { get; } = new List {"x86/wooting-rgb-sdk.dll"}; + public static List PossibleX86NativePaths { get; } = new List { "x86/wooting-rgb-sdk.dll" }; /// /// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications. /// The first match will be used. /// - public static List PossibleX64NativePaths { get; } = new List {"x64/wooting-rgb-sdk64.dll"}; + public static List PossibleX64NativePaths { get; } = new List { "x64/wooting-rgb-sdk64.dll" }; /// /// @@ -144,9 +144,10 @@ namespace RGB.NET.Devices.Wooting public void Dispose() { try { _WootingSDK.Reset(); } - catch - { /* Unlucky.. */ - } + catch { /* Unlucky.. */ } + + try { _WootingSDK.UnloadWootingSDK(); } + catch { /* at least we tried */ } } #endregion