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

Touch input: improve double click emulation #1781

Closed
jotaen4tinypilot opened this issue Apr 11, 2024 · 0 comments · Fixed by #1787
Closed

Touch input: improve double click emulation #1781

jotaen4tinypilot opened this issue Apr 11, 2024 · 0 comments · Fixed by #1787
Assignees
Labels
enhancement New feature or request

Comments

@jotaen4tinypilot
Copy link
Contributor

Related #270, see also our initial proof-of-concept.

When the TinyPilot web UI is used via a touch device (e.g., a tablet), you might not be able to issue double clicks by tapping twice on the remote screen.

That’s because when tapping twice with a finger, it’s quite hard to make the second tap so that it matches the position of the first tap exactly. Depending on the operating system of the target machine, the two taps (clicks) won’t be recognised as true and proper double-click, due to the position mismatch. Instead, the target machine treats both clicks as independent.

One way of solving this could be via some sort of timing logic, where we re-use the position of the first tap in case the second tap happens (a) within a certain time threshold and (b) within a certain distance limit.

@jotaen4tinypilot jotaen4tinypilot added the enhancement New feature or request label Apr 11, 2024
@jotaen4tinypilot jotaen4tinypilot self-assigned this Apr 11, 2024
jotaen4tinypilot added a commit that referenced this issue Apr 18, 2024
Resolves #1781.

This PR improves double-click emulation so that both of the consecutive
mouse (touch) events have the exact same location. On a touch device,
you might otherwise accidentally direct the second click to a slightly
different location, or the target operating system might not even
recognise both clicks as proper double click.

## Notes

- I’ve slightly re-ordered the commentary, which I thought was sensible
due to the increased complexity in the file.
- The parameters for detecting a double-click are heuristic at best –
the 500ms delay is from [this
article](https://en.wikipedia.org/wiki/Double-click#:~:text=rely%20upon%20it.-,Speed%20and%20timing,basis%20for%20other%20timed%20actions.),
and the 500px distance just felt okay when trying from an iPad.

I’ve tested with this on an iPad, so from my side a pure code review
would suffice.

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1787"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>

---------

Co-authored-by: Jan Heuermann <jan@jotaen.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant