Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GestureDetector / ActorGestureListener depend on absolute amount of touch points #7373

Open
2 tasks done
LobbyDivinus opened this issue Mar 31, 2024 · 1 comment
Open
2 tasks done

Comments

@LobbyDivinus
Copy link

LobbyDivinus commented Mar 31, 2024

The GestureDetector - and therefore also ActorGestureListener which is a wrapper for use in Stages - does not consider actually recevied touch events to determine multi-touch input.

Issue details

My use-case is the following: I want to offer touchpad input controls to control some entity in the game world. If the player touches outside of the touchpad he can control the game camera. Ie. panning, pinching and zooming. I use an ActorGestureListener on the underlying panel to catch camera related events. I asserted that other events consumed by the touchpad are not propagated to the ActorGestureListener.

What I noticed: Even without the GestureListener receiving events from multiple fingers (ie because other active fingers are controlling the touchpad) it fires somewhat abitrary pinch and zoom events. It turns out, that the GestureListener uses

Gdx.input.isTouched(1)

to determine if there are already two touch sources present. So it thinks it's processing multiple touch points while in realtiy it only receives events from a single one.

Reproduction steps/code

It can be reproduced by using a GestureListener that only receives touch events from a single point while there are multiple touch points present. A way to reproduce this without a real device would be to somehow mock the result of Gdx.input.isTouched(pointer).

Version of libGDX and/or relevant dependencies

1.12.1

Please select the affected platforms

  • Android
  • iOS
@NathanSweet
Copy link
Member

Looks like GestureDetector should not use isTouched, it should instead track the touched state of pointers 0 and 1 itself and use that. This way a touch down the GestureDetector never sees will not cause it to consider that pointer as touched.

The code is complex enough I'm not comfortable making the changes without being able to test. A well tested PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants