This commit is contained in:
TinyHerm committed 2026-11-24 23:40:08 +03:00
commit 1c7a8cf25f
579 files changed
+83196

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
namespace VibranceHud.Hotkeys;
public sealed class HotkeyCaptureGate
{
public static readonly HotkeyCaptureGate Shared = new HotkeyCaptureGate();
private readonly object _lock = new object();
private readonly HashSet<object> _listening = new HashSet<object>();
public bool IsCapturing
{
get
{
lock (_lock)
{
return _listening.Count > 0;
}
}
}
public event Action? Began;
public event Action? Ended;
internal void Enter(object picker)
{
bool flag;
lock (_lock)
{
flag = _listening.Count == 0;
_listening.Add(picker);
}
if (flag)
{
Began?.Invoke();
}
}
internal void Leave(object picker)
{
bool flag;
lock (_lock)
{
if (!_listening.Remove(picker))
{
return;
}
flag = _listening.Count == 0;
}
if (flag)
{
Ended?.Invoke();
}
}
}