gamepads icon indicating copy to clipboard operation
gamepads copied to clipboard

Update gamepads_windows to use a newer API

Open markvideon opened this issue 1 year ago • 7 comments

gamepads_windows currently appears to use the Joysticks API. As per its documentation, it has now been superseded by Windows.Gaming.Input, which provides some functionality comparable to the Game Controller Library provided by Apple.

There is a larger project to make Windows APIs accessible as Dart packages via FFI. One such package is windows_gaming. https://github.com/halildurmus/dartwinrt/tree/main/packages/windows_gaming

It may be worth exploring making use of this package.

EDIT: I've come to understand that migrating to this API may affect compatibility with controllers that don't support XInput.

markvideon avatar May 21 '24 08:05 markvideon

After some experimentation, I have some comments about this.

Windows.Gaming.Input manages input devices and events. It seems like we would need to look at other Windows APIs for other features.

The two 'core' classes representing devices of concern are:

A particular device may be recognised as a RawGameController and it may also be recognised as a Gamepad. For instance, I found the Switch Pro Controller was recognised as a Gamepad and a RawGameController when connected via Bluetooth, and only as a RawGameController when connected via USB.

RawGameController has a number of properties such as device name and hardware device ID that can also vary depending on the connection type. E.g. I observed RawGameController.DisplayName with a value of "HID-compliant game controller" for most controller and connection type combinations, but notably when an Xbox Series S/X controller was connected via USB it was reported as "Xbox One Game Controller".

markvideon avatar May 31 '24 08:05 markvideon

Win10 has been unable to operate in the past two weeks, is this the reason?

chengwei88888 avatar Jun 07 '24 08:06 chengwei88888

Win10 has been unable to operate in the past two weeks, is this the reason?

This GitHub issue describes rewriting the Windows plugin to use a new API, it is not directly related to any problems people may be facing with the current implementation of gamepads_windows.

markvideon avatar Jun 07 '24 08:06 markvideon

This sounds promising:

GameInput is a functional superset of all legacy input APIs—XInput, DirectInput, Raw Input, Human Interface Device (HID), and WinRT APIs—in addition to adding new features of its own.

However it is distributed via NuGet, which does not play well with CMake according to this issue.

markvideon avatar Jun 09 '24 07:06 markvideon

Win10 has been unable to operate in the past two weeks, is this the reason?

This GitHub issue describes rewriting the Windows plugin to use a new API, it is not directly related to any problems people may be facing with the current implementation of gamepads_windows.

Is there a specific plan for this? Where can I see the answer? Please provide me with a link, thank you

chengwei88888 avatar Jun 11 '24 02:06 chengwei88888

Any progress on this? I added support for web on this package but I don't like the old windows implementation so I had to remove/ reimplement the windows package. How xinput_gamepad is implemented is perfect for me.

zhuhaichao518 avatar Sep 09 '24 18:09 zhuhaichao518

Still a work in progress. A number of Windows specific issues seem to be popping up (i.e. #34 and #42), I will try to find more time to spend on this.

markvideon avatar Sep 22 '24 03:09 markvideon