Skip to content

emscripten touch support is intented? #2694

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

Closed
krmbn0576 opened this issue Nov 15, 2021 · 9 comments · Fixed by #2924
Closed

emscripten touch support is intented? #2694

krmbn0576 opened this issue Nov 15, 2021 · 9 comments · Fixed by #2924
Assignees
Labels
Emscripten WebAssembly/JavaScript port for web browsers Input Input related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter Patch available
Milestone

Comments

@krmbn0576
Copy link
Contributor

In 0.7.0, Key Input Proc (Maniac Patch) for mouse is supported, and emscripten build supports touches.

Player/src/system.h

Lines 58 to 60 in dfbad20

#elif defined(EMSCRIPTEN)
# define SUPPORT_MOUSE
# define SUPPORT_TOUCH

#if defined(USE_TOUCH) && defined(SUPPORT_TOUCH)
{DECISION, Keys::ONE_FINGER},
{CANCEL, Keys::TWO_FINGERS},
#endif

However, I tested this and did not work.

fingers touch input is intented? or not implemented yet?

@Ghabry
Copy link
Member

Ghabry commented Nov 15, 2021

Touch instead of Mouse is not implemented but I totally see that this would be the expected behaviour (at least for Left & Right Touch, Cursor position is a different topic...)

One Touch: Left click
Two Touch: Right click
Three Touch: Middle Click

Converting it to a mouse cursor is more tricky, maybe just use the last touch position and when the finger moves on the screen the cursor moves?

The code you found is "Touch for decision & cancel".

This can be enabled with the option --enable-touch or ?enable-touch in emscripten. With this option you can e.g. continue messages boxes with a touch (the same applies to --enable-mouse for click to continue).

Note that these options could conflict with the KeyInput support because One Finger Touch is then detected as both Decision and Left-Click. (when I fix this issue)

@Ghabry
Copy link
Member

Ghabry commented Nov 15, 2021

Hmm, short term solution is checking for ONE_FINGER, TWO_FINGERS and THREE_FINGERS in Ineluki and Maniac when mouse buttons are checked.

This will not help with mouse cursor movement via touch but at least makes the finger working 🤔

(Long term solution would be a better integration in the normal Input class)

@krmbn0576
Copy link
Contributor Author

However, the strange thing is that the touched coordinates can be obtained by the GetMousePosition command, even though it does not appear to be implemented yet. In other words, mouse_pos already supports finger touch!

Why don't MouseButtons support finger touch?

@Ghabry
Copy link
Member

Ghabry commented Nov 15, 2021

I checked the documentation:

which may be SDL_TOUCH_MOUSEID, for events that were generated by a touch input device,
and not a real mouse. You might want to ignore such events, if your application already handles
SDL_TouchFingerEvent.

So mouse motion and touch motion is sent through the same event and we do not check the which. Meaning this works already by accident 😅

@krmbn0576
Copy link
Contributor Author

I see, it was an accident after all 😆 I understood that key input proc for touch is not yet supported. thx

@Ghabry Ghabry added the Input Input related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter label Nov 16, 2021
@Ghabry Ghabry added this to the 0.7.1 milestone Nov 16, 2021
@Ghabry
Copy link
Member

Ghabry commented Nov 18, 2021

@krmbn0576
You should be able to "fix" it by deleting these lines here and recompiling the Player:

For Scroll (no idea how this behaves, needs testing):
https://github.com/EasyRPG/Player/blob/master/src/sdl2_ui.cpp#L622-L623

For Finger press (I guess 1 finger = Left and 2 finger = Right, untested!):
https://github.com/EasyRPG/Player/blob/master/src/sdl2_ui.cpp#L642-L643


This will not be changed upstream. I work on a better fix instead but this takes longer :)

@krmbn0576
Copy link
Contributor Author

thx, I tested it.

Key Input Proc 1005 (Left Click) was activated when the screen was touched, but other events seem to be unsupported.

I can't think of a way to implement the wheel event, but 2 Fingers = Right Click should be supported.
Therefore, I will not adopt this fix :->

@Ghabry
Copy link
Member

Ghabry commented Nov 19, 2021

Okay so the mouse emulation is junk. Good to know. :D

@fdelapena fdelapena added the Emscripten WebAssembly/JavaScript port for web browsers label Nov 23, 2021
@Ghabry Ghabry modified the milestones: 0.7.1, 0.7.2 Oct 9, 2022
@Ghabry Ghabry modified the milestones: 0.7.2, 0.7.1 Dec 8, 2022
@Ghabry
Copy link
Member

Ghabry commented Dec 9, 2022

I found a way to properly detect N fingers, making this fully compatible with the mouse input. (only gestures for "scrolling" won't work)

Will be part of 0.8.0 (when its done 😅 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Emscripten WebAssembly/JavaScript port for web browsers Input Input related (gamepads, keyboard mappings, mouse support). For KeyInputProc, add event/interpreter Patch available
Development

Successfully merging a pull request may close this issue.

3 participants