mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 01:42:02 +00:00
Small fixes
No longer taking exclusive CUE access, seems to work well with latest CUE this way Removed LUA stack trace logging, just refers to MoonSharp code anyway Artemis disables and re-enables itself after system wake for #204
This commit is contained in:
parent
ef69c39cf5
commit
97281e24df
@ -22,7 +22,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
{
|
{
|
||||||
CanUse = CanInitializeSdk();
|
CanUse = CanInitializeSdk();
|
||||||
if (CanUse && !CueSDK.IsInitialized)
|
if (CanUse && !CueSDK.IsInitialized)
|
||||||
CueSDK.Initialize(true);
|
CueSDK.Initialize();
|
||||||
|
|
||||||
Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse);
|
Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse);
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using CUE.NET;
|
|||||||
using CUE.NET.Brushes;
|
using CUE.NET.Brushes;
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
|
using CUE.NET.Exceptions;
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
using Ninject.Extensions.Logging;
|
using Ninject.Extensions.Logging;
|
||||||
using Point = System.Drawing.Point;
|
using Point = System.Drawing.Point;
|
||||||
@ -44,7 +45,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
if (!CueSDK.IsInitialized)
|
if (!CueSDK.IsInitialized)
|
||||||
CueSDK.Initialize(true);
|
CueSDK.Initialize();
|
||||||
|
|
||||||
CueSDK.UpdateMode = UpdateMode.Manual;
|
CueSDK.UpdateMode = UpdateMode.Manual;
|
||||||
_keyboard = CueSDK.KeyboardSDK;
|
_keyboard = CueSDK.KeyboardSDK;
|
||||||
@ -87,8 +88,17 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
|
|
||||||
public override void Disable()
|
public override void Disable()
|
||||||
{
|
{
|
||||||
if (CueSDK.IsInitialized)
|
try
|
||||||
CueSDK.Reinitialize();
|
{
|
||||||
|
if (CueSDK.IsInitialized)
|
||||||
|
CueSDK.Reinitialize();
|
||||||
|
}
|
||||||
|
catch (WrapperException e)
|
||||||
|
{
|
||||||
|
// This occurs when releasing the SDK after sleep, ignore it
|
||||||
|
if (e.Message != "The previously loaded Keyboard got disconnected.")
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
{
|
{
|
||||||
CanUse = CanInitializeSdk();
|
CanUse = CanInitializeSdk();
|
||||||
if (CanUse && !CueSDK.IsInitialized)
|
if (CanUse && !CueSDK.IsInitialized)
|
||||||
CueSDK.Initialize(true);
|
CueSDK.Initialize();
|
||||||
|
|
||||||
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
|
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
{
|
{
|
||||||
CanUse = CanInitializeSdk();
|
CanUse = CanInitializeSdk();
|
||||||
if (CanUse && !CueSDK.IsInitialized)
|
if (CanUse && !CueSDK.IsInitialized)
|
||||||
CueSDK.Initialize(true);
|
CueSDK.Initialize();
|
||||||
|
|
||||||
Logger.Debug("Attempted to enable Corsair mousemat. CanUse: {0}", CanUse);
|
Logger.Debug("Attempted to enable Corsair mousemat. CanUse: {0}", CanUse);
|
||||||
|
|
||||||
|
|||||||
@ -80,15 +80,15 @@ namespace Artemis.Managers
|
|||||||
}
|
}
|
||||||
catch (InternalErrorException e)
|
catch (InternalErrorException e)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||||
}
|
}
|
||||||
catch (SyntaxErrorException e)
|
catch (SyntaxErrorException e)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||||
}
|
}
|
||||||
catch (ScriptRuntimeException e)
|
catch (ScriptRuntimeException e)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -10,6 +9,7 @@ using Artemis.Utilities;
|
|||||||
using Artemis.Utilities.DataReaders;
|
using Artemis.Utilities.DataReaders;
|
||||||
using Artemis.Utilities.GameState;
|
using Artemis.Utilities.GameState;
|
||||||
using Artemis.ViewModels;
|
using Artemis.ViewModels;
|
||||||
|
using Microsoft.Win32;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Extensions.Logging;
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
@ -51,6 +51,9 @@ namespace Artemis.Managers
|
|||||||
var updateTask = new Task(Updater.UpdateApp);
|
var updateTask = new Task(Updater.UpdateApp);
|
||||||
updateTask.Start();
|
updateTask.Start();
|
||||||
|
|
||||||
|
// Listen for power mode changes
|
||||||
|
SystemEvents.PowerModeChanged += OnPowerChange;
|
||||||
|
|
||||||
Logger.Info("Intialized MainManager");
|
Logger.Info("Intialized MainManager");
|
||||||
Logger.Info($"Artemis version {Assembly.GetExecutingAssembly().GetName().Version} is ready!");
|
Logger.Info($"Artemis version {Assembly.GetExecutingAssembly().GetName().Version} is ready!");
|
||||||
}
|
}
|
||||||
@ -83,6 +86,23 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
public event EventHandler<EnabledChangedEventArgs> OnEnabledChangedEvent;
|
public event EventHandler<EnabledChangedEventArgs> OnEnabledChangedEvent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restarts the loop manager when the system resumes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private async void OnPowerChange(object sender, PowerModeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Mode != PowerModes.Resume)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger.Debug("Restarting for OnPowerChange");
|
||||||
|
DisableProgram();
|
||||||
|
// Wait an extra while for device providers to be fully ready
|
||||||
|
await Task.Delay(2000);
|
||||||
|
EnableProgram();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the last active effect and starts the program
|
/// Loads the last active effect and starts the program
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -124,13 +144,11 @@ namespace Artemis.Managers
|
|||||||
// If the currently active effect is a no longer running game, get rid of it.
|
// If the currently active effect is a no longer running game, get rid of it.
|
||||||
var activeGame = EffectManager.ActiveEffect as GameModel;
|
var activeGame = EffectManager.ActiveEffect as GameModel;
|
||||||
if (activeGame != null)
|
if (activeGame != null)
|
||||||
{
|
|
||||||
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
|
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
|
||||||
{
|
{
|
||||||
Logger.Info("Disabling game: {0}", activeGame.Name);
|
Logger.Info("Disabling game: {0}", activeGame.Name);
|
||||||
EffectManager.DisableGame(activeGame);
|
EffectManager.DisableGame(activeGame);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Look for running games, stopping on the first one that's found.
|
// Look for running games, stopping on the first one that's found.
|
||||||
var newGame = EffectManager.EnabledGames
|
var newGame = EffectManager.EnabledGames
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user