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:
parent
30acda3005
commit
f273407f97
3 changed files with 212 additions and 0 deletions
49
BeefLibs/Beefy2D/src/input/InputManager.bf
Normal file
49
BeefLibs/Beefy2D/src/input/InputManager.bf
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue