mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-07 08:45:59 +02:00
CachedEnumerateInputDevices
This commit is contained in:
parent
f34424a61d
commit
9e3248fb4f
2 changed files with 36 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Beefy.input
|
||||
{
|
||||
|
@ -33,6 +34,33 @@ namespace Beefy.input
|
|||
[CallingConvention(.Stdcall), CLink]
|
||||
public static extern void* BFApp_CreateInputDevice(char8* guid);
|
||||
|
||||
public Monitor mMonitor = new .() ~ delete _;
|
||||
public String mEnumerateString = new .() ~ delete _;
|
||||
public bool mEnumerating;
|
||||
|
||||
public void CachedEnumerateInputDevices(String outData)
|
||||
{
|
||||
using (mMonitor.Enter())
|
||||
{
|
||||
outData.Append(mEnumerateString);
|
||||
|
||||
if (!mEnumerating)
|
||||
{
|
||||
mEnumerating = true;
|
||||
ThreadPool.QueueUserWorkItem(new () =>
|
||||
{
|
||||
String data = scope .();
|
||||
data.Append(BFApp_EnumerateInputDevices());
|
||||
using (mMonitor.Enter())
|
||||
{
|
||||
mEnumerateString.Set(data);
|
||||
mEnumerating = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void EnumerateInputDevices(String outData)
|
||||
{
|
||||
outData.Append(BFApp_EnumerateInputDevices());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue