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
sokol_app.h: add a tool_type
field to the sapp_touchpoint
struct (valid on Android)
#717
Conversation
I think it might make more sense to emit mouse events so that Android matches other platforms, and we don't have to use two different APIs to handle mouse input. |
No, I don't think so. Afaik, mouses on Android already emit a mouse event, but touch should remain touch. |
I've noticed my previous implementation (a field in the event struct) didn't make much sense in the multi-touch architecture of |
Actually, android has a single API for both mouse and touch, and calls them "pointers". Currently sokol creates touch events, but not mouse events for android. |
Oh, okay, I didn't know that. Well, on one hand, it makes sense, but on the other hand, you normally have only 1 mouse, but multiple fingers, so it maybe makes sense to separate it. |
touch_tool_type
field (valid on Android)tool_type
field to the sapp_touchpoint
struct (valid on Android)
See floooh/sokol#717 for the associated sokol PR
I'll start looking into this PR now. @billzez: I'm not a big fan of unified mouse and and touch events, for instance UWP also only has this sort of "pointer events", and it's quite a mess. It's better if the application decides to explicitely support touch vs mouse input, and if it wants to unify those two. |
@Wertzui123: Do you know if there's a documentation somewhere what the integer return value from AMotionEvent_getToolType() actually means? I have a hard time finding any useful documentation. Also, I'll rename the field to PS: nevermind, found it: https://developer.android.com/reference/android/view/MotionEvent#TOOL_TYPE_FINGER I'll add an |
I think you are looking for this: https://developer.android.com/ndk/reference/group/input#anonymous-enum-38
I used a generic name since we may want to add iOS support in the future too (if that's possible), but I'm fine with adding an
Good idea. |
Please ignore the Github Actions error, this seems to be a regression in Nim. |
I did some quick googling too but haven't found anything (neither iOS nor web APIs). If iOS provides that sort of information then we should go back from the |
Ok, merged, I did the following changes on top: (argh, extra whitespace line, I'll remove that too...) |
Thanks for merging! |
This makes it possible to differentiate between different types of touch input.
See: https://developer.android.com/ndk/reference/group/input#amotionevent_gettooltype for the documentation of this function
I've tested it and it successfully showed 1 for finger input and 2 for S-Pen input.
I'm unsure if adding a new field to the event struct is the way to go; maybe we should provide the user directly with the
AMotionEvent
and thepointer_index
(e
andidx
variables) instead so that they can then use arbitrary NDK functions in their callbacks.