mirror of
https://github.com/Ellpeck/Illumilib.git
synced 2024-11-23 12:18:36 +01:00
changed Initialize to be synchronous
This commit is contained in:
parent
3ee8c4deca
commit
92e8a8e6f5
5 changed files with 14 additions and 14 deletions
|
@ -6,8 +6,8 @@ using Illumilib;
|
||||||
namespace Demo {
|
namespace Demo {
|
||||||
internal static class Program {
|
internal static class Program {
|
||||||
|
|
||||||
private static async Task Main(string[] args) {
|
private static void Main(string[] args) {
|
||||||
await IllumilibLighting.Initialize();
|
IllumilibLighting.Initialize();
|
||||||
|
|
||||||
Console.WriteLine("Setting specific positions");
|
Console.WriteLine("Setting specific positions");
|
||||||
IllumilibLighting.SetKeyboardLighting(0, 1, 0);
|
IllumilibLighting.SetKeyboardLighting(0, 1, 0);
|
||||||
|
|
|
@ -28,18 +28,18 @@ namespace Illumilib {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes Illumilib, starting all of the supported lighting systems.
|
/// Initializes Illumilib, starting all of the supported lighting systems.
|
||||||
/// Any lighting systems that are not supported, or for which devices are not present, will be ignored.
|
/// Any lighting systems that are not supported, or for which devices are not present, will be ignored.
|
||||||
/// This function runs asynchronously.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <returns>Whether at least one lighting system was successfully initialized</returns>
|
||||||
/// <exception cref="InvalidOperationException">Thrown if Illumilib has already been <see cref="Initialized"/></exception>
|
/// <exception cref="InvalidOperationException">Thrown if Illumilib has already been <see cref="Initialized"/></exception>
|
||||||
public static async Task Initialize() {
|
public static bool Initialize() {
|
||||||
if (Initialized)
|
if (Initialized)
|
||||||
throw new InvalidOperationException("Illumilib has already been initialized");
|
throw new InvalidOperationException("Illumilib has already been initialized");
|
||||||
var ret = new List<LightingSystem>();
|
systems = new List<LightingSystem>();
|
||||||
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting()}) {
|
foreach (var system in new LightingSystem[] {new LogitechLighting(), new RazerLighting()}) {
|
||||||
if (await system.Initialize())
|
if (system.Initialize())
|
||||||
ret.Add(system);
|
systems.Add(system);
|
||||||
}
|
}
|
||||||
systems = ret;
|
return systems.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Threading.Tasks;
|
||||||
namespace Illumilib.System {
|
namespace Illumilib.System {
|
||||||
internal abstract class LightingSystem : IDisposable {
|
internal abstract class LightingSystem : IDisposable {
|
||||||
|
|
||||||
public abstract Task<bool> Initialize();
|
public abstract bool Initialize();
|
||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ namespace Illumilib.System {
|
||||||
private readonly byte[] bitmap = new byte[LogitechGsdk.LogiLedBitmapSize];
|
private readonly byte[] bitmap = new byte[LogitechGsdk.LogiLedBitmapSize];
|
||||||
private bool bitmapDirty;
|
private bool bitmapDirty;
|
||||||
|
|
||||||
public override Task<bool> Initialize() {
|
public override bool Initialize() {
|
||||||
try {
|
try {
|
||||||
LogitechGsdk.LogiLedInit();
|
LogitechGsdk.LogiLedInit();
|
||||||
return Task.FromResult(true);
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return Task.FromResult(false);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace Illumilib.System {
|
||||||
private CustomKeyboardEffect effect = new CustomKeyboardEffect(Color.Black);
|
private CustomKeyboardEffect effect = new CustomKeyboardEffect(Color.Black);
|
||||||
private bool effectOutdated;
|
private bool effectOutdated;
|
||||||
|
|
||||||
public override async Task<bool> Initialize() {
|
public override bool Initialize() {
|
||||||
try {
|
try {
|
||||||
this.chroma = await ColoreProvider.CreateNativeAsync();
|
this.chroma = ColoreProvider.CreateNativeAsync().Result;
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue