gamepads
gamepads copied to clipboard
feat: Added a stream to listen for connecting/disconnecting gamepads for MacOS
This Pull Request enhances the event handling functionality of the library by implementing methods to emit gamepad events and gamepad connection events for MacOS. Additionally, it defines stream controllers and streams for broadcasting these events.
Changes Made:
- Added method
emitGamepadConnectedEvent()
to emit gamepad connection events. - Defined stream controller
_gamepadConnectedStreamController
to manage stream of gamepad connection events. - Added a
GamepadConnectedEvent
. - Implemented getter
gamepadConnectedStream
to provide access to the stream of gamepad connection events. - Added to the
dispose()
method to properly close the stream controller when it is no longer needed. - Updated the README.md for usage examples.
These changes enhance the functionality of the library by providing a structured approach to emitting and broadcasting gamepad events and connection events, facilitating seamless integration of gamepad functionality into applications.
Usage:
StreamSubscription<GamepadConnectedEvent>? _connectedGamepadSubscription;
_connectedGamepadSubscription = Gamepads.isConnected.listen((GamepadConnectedEvent event) {
if (event.isConnected) {
// ...
}
});
Worth flagging explicitly that this PR makes relevant changes to the Dart interface and contains implementation code for macOS only.
Worth flagging explicitly that this PR makes relevant changes to the Dart interface and contains implementation code for macOS only.
Yeah, we should add all platforms if we're adding new features to the interface. Could you do the other implementations too @gotnull? :)