LuanRoger / xinput_gamepad

🎮 Add support to XInput controllers with Win32 API.
https://pub.dev/packages/xinput_gamepad
MIT License
6 stars 2 forks source link

Controller Disconnected Event #11

Closed xanmankey closed 1 year ago

xanmankey commented 1 year ago

First of all, I want to say that this is awesome. I'd been wanting to work with XInput for a flutter app, but I couldn't figure out how, so this makes that process a lot easier and could be useful for guidance for working with the win32 and ffi libraries.

That aside, I cloned this repo to try out a couple examples, but when I disconnected my controller while running the flutter_windows example either the XInput disconnected event wasn't handled or the GUI didn't update, as the color didn't change back from green to red. I'm using an Xbox one controller; I've tested it with gamepad tester and I believe it to be fully functional. Let me know if you need any more information.

Thanks for the package!

LuanRoger commented 1 year ago

Thanks for use the package. Unfortunately, the XInput does't have a event or callback to be called when you plug/unplug an controller, to check the controller's state you could call ControllersManager.getIndexConnectedControllers() from time to time, and check what is connected or not. I will close this for now, but if you found some other odd behavior let me know.

xanmankey commented 1 year ago

I see, I didn't realize that the example code was checking for a controller input of some kind rather than a connection/disconnection event. Thanks for clearing that up!