Merge remote-tracking branch 'origin/master'

This commit is contained in:
Robert committed 2021-01-19 19:58:26 +01:00
commit 281c18200a
11 files changed
+308 -57

No files matched your search

@@ -2,6 +2,9 @@
using System.Threading.Tasks;
using System.Timers;
using Artemis.Core.Modules;
using Artemis.Core.Services;
using Ninject;
using Serilog;
namespace Artemis.Core
{
@@ -14,9 +17,12 @@ namespace Artemis.Core
private Timer? _timer;
private bool _disposed;
private readonly object _lock = new();
private ILogger _logger;
internal TimedUpdateRegistration(PluginFeature feature, TimeSpan interval, Action<double> action)
{
_logger = CoreService.Kernel.Get<ILogger>();
Feature = feature;
Interval = interval;
Action = action;
@@ -29,6 +35,8 @@ namespace Artemis.Core
internal TimedUpdateRegistration(PluginFeature feature, TimeSpan interval, Func<double, Task> asyncAction)
{
_logger = CoreService.Kernel.Get<ILogger>();
Feature = feature;
Interval = interval;
AsyncAction = asyncAction;
@@ -119,12 +127,19 @@ namespace Artemis.Core
if (Feature is Module module && !module.IsUpdateAllowed)
return;
if (Action != null)
Action(interval.TotalSeconds);
else if (AsyncAction != null)
try
{
Task task = AsyncAction(interval.TotalSeconds);
task.Wait();
if (Action != null)
Action(interval.TotalSeconds);
else if (AsyncAction != null)
{
Task task = AsyncAction(interval.TotalSeconds);
task.Wait();
}
}
catch (Exception exception)
{
_logger.Error(exception, "Timed update uncaught exception in plugin {plugin}", Feature.Plugin);
}
}
}
@@ -47,7 +47,7 @@ namespace Artemis.Core.Services
inputProvider.MouseScrollDataReceived += InputProviderOnMouseScrollDataReceived;
inputProvider.MouseMoveDataReceived += InputProviderOnMouseMoveDataReceived;
_inputProviders.Add(inputProvider);
inputProvider.OnKeyboardToggleStatusRequested();
}
@@ -296,6 +296,17 @@ namespace Artemis.Core.Services
return modifiers;
}
public void ReleaseAll()
{
foreach (var (device, keys) in _pressedKeys.ToList())
{
foreach (KeyboardKey keyboardKey in keys)
{
InputProviderOnKeyboardDataReceived(this, new InputProviderKeyboardEventArgs(device, keyboardKey, false));
}
}
}
#endregion
#region Mouse
@@ -35,6 +35,11 @@ namespace Artemis.Core.Services
/// </summary>
void StopIdentify();
/// <summary>
/// Flush all currently pressed buttons/keys
/// </summary>
void ReleaseAll();
#region Events
/// <summary>