mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-11 04:57:15 +00:00
Added a device filter to LoadDevices and device Initialize
This commit is contained in:
1 parent
b700c84b8d
commit
11ca959328
9 files changed
+142
-114
No files matched your search
@@ -58,7 +58,7 @@ namespace RGB.NET.Devices.Novation
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Initialize(bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
|
||||
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
|
||||
{
|
||||
IsInitialized = false;
|
||||
|
||||
@@ -66,25 +66,26 @@ namespace RGB.NET.Devices.Novation
|
||||
{
|
||||
IList<IRGBDevice> devices = new List<IRGBDevice>();
|
||||
|
||||
for (int index = 0; index < OutputDeviceBase.DeviceCount; index++)
|
||||
{
|
||||
try
|
||||
if (loadFilter.HasFlag(RGBDeviceType.LedMatrix))
|
||||
for (int index = 0; index < OutputDeviceBase.DeviceCount; index++)
|
||||
{
|
||||
MidiOutCaps outCaps = OutputDeviceBase.GetDeviceCapabilities(index);
|
||||
if (outCaps.name == null) continue;
|
||||
try
|
||||
{
|
||||
MidiOutCaps outCaps = OutputDeviceBase.GetDeviceCapabilities(index);
|
||||
if (outCaps.name == null) continue;
|
||||
|
||||
NovationDevices? deviceId = (NovationDevices?)Enum.GetValues(typeof(NovationDevices))
|
||||
.Cast<Enum>()
|
||||
.FirstOrDefault(x => string.Equals(x.GetDeviceId(), outCaps.name, StringComparison.OrdinalIgnoreCase));
|
||||
NovationDevices? deviceId = (NovationDevices?)Enum.GetValues(typeof(NovationDevices))
|
||||
.Cast<Enum>()
|
||||
.FirstOrDefault(x => string.Equals(x.GetDeviceId(), outCaps.name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (deviceId == null) continue;
|
||||
if (deviceId == null) continue;
|
||||
|
||||
INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability()));
|
||||
device.Initialize();
|
||||
devices.Add(device);
|
||||
}
|
||||
catch { if (throwExceptions) throw; }
|
||||
}
|
||||
catch { if (throwExceptions) throw; }
|
||||
}
|
||||
|
||||
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
|
||||
IsInitialized = true;
|
||||
|
||||
Reference in new issue
Block a user