This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GloriousModelODeviceProvider.cs
90 lines (72 loc) · 3.11 KB
/
GloriousModelODeviceProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using RGB.NET.Core;
using RGB.NET.Devices.GloriousModelO.Native;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace RGB.NET.Devices.GloriousModelO
{
public class GloriousModelODeviceProvider : IRGBDeviceProvider
{
#region Properties & Fields
private static GloriousModelODeviceProvider _instance;
/// <summary>
/// Gets the singleton <see cref="CorsarLinkDeviceProvider"/> instance.
/// </summary>
public static GloriousModelODeviceProvider Instance => _instance ?? new GloriousModelODeviceProvider();
/// <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/GloriousModelO.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/GloriousModelO.dll" };
public bool HasExclusiveAccess => false; // we don't really need this
public bool IsInitialized { get; private set; }
public IEnumerable<IRGBDevice> Devices { get; private set; }
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="GloriousModelODeviceProvider"/> class.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
public GloriousModelODeviceProvider()
{
if (_instance != null) throw new InvalidOperationException($"There can be only one instanc of type {nameof(GloriousModelODeviceProvider)}");
_instance = this;
}
public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
{
IsInitialized = false;
try
{
_GloriousModelO.Reload();
IList<IRGBDevice> devices = new List<IRGBDevice>();
IGloriousModelORGBDevice device = new GloriousModelORGBDevice(new GloriousModelORGBDeviceInfo());
device.Initialize();
devices.Add(device);
Devices = new ReadOnlyCollection<IRGBDevice>(devices);
if (_GloriousModelO.DetectDevice() == 1)
{
IsInitialized = true;
}
}
catch
{
if (throwExceptions)
throw;
else
return false;
}
return true;
}
public void ResetDevices()
{
// we don't really need this
}
public void Dispose()
{
}
}
}