Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Add Touch Support #93

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Add Touch Support #93

wants to merge 7 commits into from

Conversation

Sigmoidle
Copy link

@Sigmoidle Sigmoidle commented Mar 1, 2024

I have exposed the following function to the user:

get_touch_locations() -> Vec<Vec2>

Things to check:

  • Currently the Vec2 is in screen position and not world position. Which should be default?
  • When no fingers are on the screen, this function returns an empty Vec<>, is this ok?
  • How can we make this function more "comfy" for the game developer?

Example usage:

let touch_locations = get_touch_locations();
for touch_location in touch_locations{
    // do something with Vec2 touch location
}

Compiles with:

  • OS: macOS Sonoma
  • CPU: M2

Works with:

  • OS: IOS, Android
  • Browser: Safari, Chrome

Please try my test game at: https://sigmoidle.itch.io/comfy-touch-support-cat-ball-wow
The itch.io page includes the repository for the test game.

PLEASE NOTE: The changes to devices.rs may not work for all users and should be reviewed.

Currently broken:

  • No multi-touch support out-of-the-box - fixed
  • Touch position doesn't reset (to none?) when no fingers are on the screen. - fixed
  • Cargo format pipeline doesn't pass? Could a more experienced rust dev help me with this one?

@juh9870
Copy link

juh9870 commented Mar 1, 2024

Seems to be broken on android (using the example game https://sigmoidle.itch.io/comfy-touch-support-cat-ball-wow)

2024-03-01-15-26-09.mp4

@Sigmoidle
Copy link
Author

To add to @juh9870's message, this behaviour also happens on IOS.

The function get_touch_position() returns a position even when no fingers are on the screen.

Also, it seemingly only returns one finger at a time.

I'm not sure how to fix this, I'll need some help from some more experience rust developers.

@Sigmoidle Sigmoidle marked this pull request as draft March 1, 2024 13:37
@juh9870
Copy link

juh9870 commented Mar 1, 2024

Also, I believe that the touch API should have some level of interoperability with the mouse API. Even on the actual mobile devices, mouse pointers are not that uncommon, even as an accessibility feature: https://stackoverflow.com/a/54862570

Putting the burden of supporting both touch and mouse on the game developers is asking a bit too much, especially since developers coming from other languages would expect that they can just target one input method, and have the other work automatically, even if in a limited fashion.

@Sigmoidle
Copy link
Author

Sigmoidle commented Mar 1, 2024

I've updated this pull request to fix the multi-touch bug and the lingering touch bug.
Please try the itch.io game to preview the changes.

@Sigmoidle Sigmoidle mentioned this pull request Mar 1, 2024
@Sigmoidle Sigmoidle changed the title Add Touch Support - DRAFT Add Touch Support Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants