Kha
Kha copied to clipboard
Don't duplicate touch events to mouse
I have a HTML5 game that runs both on desktop and mobile. On mobile I need multi-touch support for controlling both a virtual joystick and buttons. In Javascript you handle mouse and touch events separately, and so you implement both and all works on all devices.
Kha conveniently forwards all touch events to mouse events. This is handy when it should work the same on both desktop and mobile, but very annoying when you need to handle multi-touch separately, since you will get duplicate events coming in at the mouse.
HTML5 doesn't allow detecting if you are working with a touch device, so you cannot just block mouse events on those devices.
My proposed solution is to forward touch events to mouse by default, but once you set touch listeners, Kha assumes you are handling touch yourself and so disables the forwarding.
I will implement this myself and will send a pull request, but just want to check if this is the solution we want or not?
I like that, me wants it.
Hm, that sounds complicated, how about a simpler static bool kha.System.forwardTouchEvents = true;
or something that you can manually override?
I prefer dewitter's solution here, it doesn't sound complicated to me.
I thought about the bool too, but in my solution the bool is basically touchListener != null.
@dewitters any progress on this?
No pressuring of our beautiful contributors, please. Instead ask how you can help 😇 (and thereby build pressure indirectly).
It was more like if you aren't working on this anymore I'll give it a try than work, work!! :sweat_smile:
That's what I hoped 👍