Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Touch Identifier on iOS doesn't behave like expected #135

Open
MathieuLoutre opened this issue Aug 24, 2016 · 2 comments
Open

Touch Identifier on iOS doesn't behave like expected #135

MathieuLoutre opened this issue Aug 24, 2016 · 2 comments

Comments

@MathieuLoutre
Copy link
Contributor

Hi there,

I've tried my prototype on iOS (emulator and physical) and I've had some problems. It seems like the touch handlers are using the touch.identifier (https://developer.mozilla.org/en-US/docs/Web/API/Touch/identifier) as the index for touches, however identifier only guarantees to have a unique ID per touch/finger and doesn't stay between 0-10 (see also: http://stackoverflow.com/questions/25008690/javascript-ipad-touch-event-identifier-is-continually-incrementing).

Because of this, this line https://github.com/superpowers/superpowers-game/blob/master/SupEngine/src/Input.ts#L377 completely kills the Input loop on iOS.

Ideally, the touches array shouldn't be pre-populated like it is now. It should probably be an object where you add a key using the identifier and create the object on touchstart, update it using the identifier on touchmove and then deleted it on touchend.

I'm happy to have a stab at a PR if that's of interest (I understand the code is getting migrated so I'm not sure which bit to work on).

@MathieuLoutre
Copy link
Contributor Author

Having a closer look at it, it messes up the current state of things quite a bit, particularly auto-generated methods which won't work if using a dictionary/object (and if they do, they'll expect the identifier, which isn't a number you can calculate).

However I believe I have an implementation with a dictionary which covers the lifecycle of the touch events (inc. mouseDown simulation). It's just that Sup.Input.isTouchDown(0) won't work (in the current state of things). It might be worth looking at because the current implementation is entirely broken anyway.

@AgileJoshua
Copy link
Contributor

See #174 for a fix that should work.

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

No branches or pull requests

2 participants