Allow desktop and web games to use the second mouse button. The right-click is a common input method for some games. Think deselecting in a city builder, issuing commands in an RTS, or secondary weapon fire in a top-down shooter.
Flame is currently in transition from the TapDetector
-Tappable
API to the newer HasTappableComponents
-TapCallbacks
API. The old TapDetector
API doesn't seem to work with the new CameraComponent
API (at least I can't make it work - I always get screen coords, never game coords). The new API is better in every way, except that its callbacks don't give info about the button (primary / secondary / tertiary).
The new API's main workhorse class is HasTappableComponents
(a mixin on Game
). This class implements MultiTapListener
, and that class is a facade to Flutter framework's MultiTapGestureRecognizer
(code here).
The problem: Flutter's MultiTapGestureRecognizer
doesn't have a concept of the right click. If Flame uses MultiTapGestureRecognizer
as the underlying API, it cannot support secondary mouse button action.
I'm not sure where the new API is heading, so I can only offer a newcomer's view. I'm guessing I would add a new class, SingleTapListener
, that closely follows MultiTapListener
in functionality. This class would be "the new TapDetector" β it would forward events from Flutter's TapGestureRecognizer
, but in the new way that respects the CameraComponent
.
The old TapDetector
and the new SingleTapListener
would likely have to be exclusive (you either implement from one or the other).
HasTappableComponents
would then implement the new SingleTapListener
alongside the MultiTapListener
, and would send the event down (like so).
The TapDownEvent
class would gain a new member, pointerEvent
, which would just copy Flutter's PointerEvent
. This const class has everything anyone could need, including pressure, tilt, kind, buttons, etc. The primary / secondary / tertiary button is easily extracted from PointerEvent.buttons
.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too