1
0
mirror of synced 2024-11-30 18:24:32 +01:00

Fix joystick support (#543)

This commit is contained in:
ivan k 2024-01-12 10:44:25 -08:00 committed by GitHub
parent 42951e20fb
commit d2cc907b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,11 @@ namespace FDK
{
// コンストラクタ
private IJoystick Joystick {get; set;}
public CInputJoystick(IJoystick joystick)
{
Joystick = joystick;
this.CurrentType = InputDeviceType.Joystick;
this.GUID = joystick.Index.ToString();
this.ID = joystick.Index;
@ -64,6 +67,14 @@ namespace FDK
{
InputEvents.Clear();
// BUG: In Silk.NET, GLFW input does not fire events, so we have to poll
// them instead.
// https://github.com/dotnet/Silk.NET/issues/1889
foreach (var button in Joystick.Buttons) {
// also, in GLFW the buttons don't have names, so the indices are the names
ButtonStates[button.Index].Item1 = button.Pressed;
}
for (int i = 0; i < ButtonStates.Length; i++)
{
if (ButtonStates[i].Item1)
@ -153,7 +164,7 @@ namespace FDK
#region [ private ]
//-----------------
private (bool, int)[] ButtonStates = new (bool, int)[15];
private (bool, int)[] ButtonStates = new (bool, int)[18];
private bool IsDisposed;
private void Joystick_ButtonDown(IJoystick joystick, Button button)