Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ which is statically linked.

## Bridge packages

- [flame_gamepads](https://github.com/flame-engine/flame/tree/main/packages/flame_gamepads) -
- [flame_gamepads](https://pub.dev/packages/flame_gamepads) -
Provides a GamepadCallbacks component mixin for your Flame games
- [flutter_gamepads](./packages/flutter_gamepads/) - Provides a widget that maps gamepad input
to UI interaction with your Flutter widgets. In regular Flutter apps as well as for Flame
overlays.
- [flutter_gamepads](https://pub.dev/packages/flutter_gamepads) - Provides a widget that
maps gamepad input to UI interaction with your Flutter widgets. In regular Flutter apps
as well as for Flame overlays.


## Support
Expand Down
38 changes: 19 additions & 19 deletions packages/flutter_gamepads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ within a Tick-tac-toe game is in [TicTacToe widget](https://github.com/flame-eng
There are four ways to block gamepad input from invoking intents:

1. Omitting the `GamepadControl` widget from your widget tree
- Fully unregisters `gamepad` event handles, axis activation memory, repeat timers etc.
- Fully unregisters *gamepads* event handles, axis activation memory, repeat timers etc.
2. `GamepadControl.ignoreEvents == true`
- Early check on each *gamepads* event, axis activation memory is reset and repeat timers are
reset.
Expand All @@ -133,24 +133,6 @@ use `onBeforeIntent` to block intents from all but one of the `GamepadControl` w
The `GamepadControl` widget does not check if primaryFocus is a descendant of itself.


### How it works

`GamepadControl` listens on `NormalizedGamepadEvent` from *gamepads* package and maps those
to a `GamepadActivator` and its related `Intent`.

Input repetition is conceptually started on activation of a GamepadActivator and stopped
once the activator has been canceled (eg. button up or axis below minimum threshold).

`GamepadControl` will lookup the closest ancestor `GamepadInterceptor` from `primaryFocus`
and call its `onBeforeIntent` first (if there is one), and then proceed to `onBeforeIntent` on
`GamepadControl`. Calling is lazy so if the local `onBeforeIntent` returns fall, the one on
`GamepadControl` is not called.

If no onBeforeIntent has rejected, the Intent will be invoked on the primary focus context.

[Diagram of the callbacks and intent emit chain](https://raw.githubusercontent.com/flame-engine/gamepads/refs/heads/main/packages/flutter_gamepads/doc/input_diagram.svg)


### Defaults

By default `GamepadControl` comes with these bindings:
Expand Down Expand Up @@ -195,6 +177,24 @@ Flame game that you want users to be able to navigate with their gamepad.
`ignoreEvents = true` on it.


## How it works

`GamepadControl` listens on `NormalizedGamepadEvent` from *gamepads* package and maps those
to a `GamepadActivator` and its related `Intent`.

Input repetition is conceptually started on activation of a GamepadActivator and stopped
once the activator has been canceled (eg. button up or axis below minimum threshold).

`GamepadControl` will lookup the closest ancestor `GamepadInterceptor` from `primaryFocus`
and call its `onBeforeIntent` first (if there is one), and then proceed to `onBeforeIntent` on
`GamepadControl`. Calling is lazy so if the local `onBeforeIntent` returns fall, the one on
`GamepadControl` is not called.

If no onBeforeIntent has rejected, the Intent will be invoked on the primary focus context.

[Diagram of the callbacks and intent emit chain](https://raw.githubusercontent.com/flame-engine/gamepads/refs/heads/main/packages/flutter_gamepads/doc/input_diagram.svg)


## Code example

In the example folder there is both a full Flutter app and a full Flame game example showing
Expand Down
Loading