mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Added properties to change the search-paths for native-libaries (sdks)
This commit is contained in:
parent
1345b50a8f
commit
7264731eb1
@ -27,7 +27,7 @@ namespace RGB.NET.Core
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="IRGBDeviceProvider"/> if not already happened or reloads it if it is already initialized.
|
||||
/// </summary>
|
||||
|
||||
@ -21,6 +21,18 @@ namespace RGB.NET.Devices.CoolerMaster
|
||||
/// </summary>
|
||||
public static CoolerMasterDeviceProvider Instance { get; } = new CoolerMasterDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX86NativePaths { get; } = new List<string> { "x86/CMSDK.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX64NativePaths { get; } = new List<string> { "x64/CMSDK.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the SDK is initialized and ready to use.
|
||||
/// </summary>
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core.Exceptions;
|
||||
|
||||
@ -34,9 +36,9 @@ namespace RGB.NET.Devices.CoolerMaster.Native
|
||||
if (_dllHandle != IntPtr.Zero) return;
|
||||
|
||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||
string dllPath = (LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/CMSDK.dll";
|
||||
if (!File.Exists(dllPath))
|
||||
throw new RGBDeviceException($"Can't find the CoolerMaster-SDK at the expected location '{Path.GetFullPath(dllPath)}'");
|
||||
List<string> possiblePathList = Environment.Is64BitProcess ? CoolerMasterDeviceProvider.PossibleX64NativePaths : CoolerMasterDeviceProvider.PossibleX86NativePaths;
|
||||
string dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CoolerMaster-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
|
||||
|
||||
@ -22,6 +22,18 @@ namespace RGB.NET.Devices.Corsair
|
||||
/// </summary>
|
||||
public static CorsairDeviceProvider Instance { get; } = new CorsairDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX86NativePaths { get; } = new List<string> { "x86/CUESDK.dll", "x86/CUESDK_2015.dll", "x86/CUESDK_2013.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX64NativePaths { get; } = new List<string> { "x64/CUESDK.dll", "x64/CUESDK_2015.dll", "x64/CUESDK_2013.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the SDK is initialized and ready to use.
|
||||
/// </summary>
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core.Exceptions;
|
||||
|
||||
@ -34,9 +36,9 @@ namespace RGB.NET.Devices.Corsair.Native
|
||||
if (_dllHandle != IntPtr.Zero) return;
|
||||
|
||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||
string dllPath = (LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/CUESDK.dll";
|
||||
if (!File.Exists(dllPath))
|
||||
throw new RGBDeviceException($"Can't find the CUE-SDK at the expected location '{Path.GetFullPath(dllPath)}'");
|
||||
List<string> possiblePathList = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
|
||||
string dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
|
||||
|
||||
@ -20,6 +20,18 @@ namespace RGB.NET.Devices.Logitech
|
||||
/// </summary>
|
||||
public static LogitechDeviceProvider Instance { get; } = new LogitechDeviceProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX86NativePaths { get; } = new List<string> { "x86/LogitechLedEnginesWrapper.dll" };
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
|
||||
/// The first match will be used.
|
||||
/// </summary>
|
||||
public static List<string> PossibleX64NativePaths { get; } = new List<string> { "x64/LogitechLedEnginesWrapper.dll" };
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RGB.NET.Core.Exceptions;
|
||||
|
||||
@ -35,9 +37,9 @@ namespace RGB.NET.Devices.Logitech.Native
|
||||
if (_dllHandle != IntPtr.Zero) return;
|
||||
|
||||
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll
|
||||
string dllPath = (LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/LogitechLedEnginesWrapper.dll";
|
||||
if (!File.Exists(dllPath))
|
||||
throw new RGBDeviceException($"Can't find the Logitech-SDK at the expected location '{Path.GetFullPath(dllPath)}'");
|
||||
List<string> possiblePathList = Environment.Is64BitProcess ? LogitechDeviceProvider.PossibleX64NativePaths : LogitechDeviceProvider.PossibleX86NativePaths;
|
||||
string dllPath = possiblePathList.FirstOrDefault(File.Exists);
|
||||
if (dllPath == null) throw new RGBDeviceException($"Can't find the Logitech-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
|
||||
|
||||
_dllHandle = LoadLibrary(dllPath);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user