1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Simple DirectInput support

This commit is contained in:
Brian Fiete 2020-11-27 06:24:47 -08:00
parent 30acda3005
commit f273407f97
3 changed files with 212 additions and 0 deletions

View file

@ -0,0 +1,49 @@
using System;
namespace Beefy.input
{
class InputDevice
{
[CallingConvention(.Stdcall), CLink]
public static extern void BFInput_Destroy(void* nativeInputDevice);
[CallingConvention(.Stdcall), CLink]
public static extern char8* BFInput_GetState(void* nativeInputDevice);
void* mNativeInputDevice;
public ~this()
{
BFInput_Destroy(mNativeInputDevice);
}
public void GetState(String outStr)
{
outStr.Append(BFInput_GetState(mNativeInputDevice));
}
}
class InputManager
{
[CallingConvention(.Stdcall), CLink]
public static extern char8* BFApp_EnumerateInputDevices();
[CallingConvention(.Stdcall), CLink]
public static extern void* BFApp_CreateInputDevice(char8* guid);
public void EnumerateInputDevices(String outData)
{
outData.Append(BFApp_EnumerateInputDevices());
}
public InputDevice CreateInputDevice(StringView guid)
{
void* nativeInputDevice = BFApp_CreateInputDevice(guid.ToScopeCStr!());
if (nativeInputDevice == null)
return null;
InputDevice inputDevice = new .();
inputDevice.[Friend]mNativeInputDevice = nativeInputDevice;
return inputDevice;
}
}
}