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

cursorPositionCallback gives odd results on mobile safari #15

Closed
GJMontreal opened this issue Jan 16, 2025 · 10 comments
Closed

cursorPositionCallback gives odd results on mobile safari #15

GJMontreal opened this issue Jan 16, 2025 · 10 comments

Comments

@GJMontreal
Copy link

When a canvas is made resizable, at least on mobile safari, the cursorPositionCallback is no longer called and or reports incorrect values.
It's easy to see by just loading https://pongasoft.github.io/emscripten-glfw/test/demo/main.html. Zoom out so the page fits the screen and the callback ceases to be called.

@ypujante
Copy link
Member

Is there any message in the console (I don't know if you can get access to the console on Mobile safari)?

@GJMontreal
Copy link
Author

In fact I'm doing a little more experimenting and it seems the callback is only called if the canvas is larger than the device's view.
It's only when the containing page scrolls that the callback happens. I'll try and put something together to demonstrate this a bit more clearly.

If you've got a mac it's easy enough to launch a device simulator from safari and get access to the console that way. There are no messages I can see, besides what I put into the cursor callback to try and track the x and y pos.

@ypujante
Copy link
Member

I do have a mac but never use Safari. Can you explain how to "launch a device simulator from safari and get access to the console that way"?

@GJMontreal
Copy link
Author

First, this is not a bug, but a difference in behaviour between using USE_GLFW=3 and --use-port=contrib.glfw3
It's a mobile device; they're touch events not mouse events 🤦
I'll look through the old js to see how it was working. In the meantime I'll create mouseevents from touchevents.

As for safari:
Go to Settings->Advanced and enable "Show Features for Web Developers". It's at the bottom.
Now you'll have a "develop menu". From there you can open a page on a specific device: simulated or real.
Once the device is connected/running they're be a further option next to that device's name in the menu

Image

@ypujante
Copy link
Member

Thank you very much for providing the description.

It is true that I have never tried the code on a touch device because I am on mac and I wasn't writing an app. That being said, if the other implementation supports touch events I should be able to add this behavior to this library as well.

I will investigate and try to add it if I can.

@GJMontreal
Copy link
Author

GJMontreal commented Jan 16, 2025

Sure enough touches are being handled in the javascript.
It looks like listeners have been added for all the touch events that then call the equivalent mouse callback

@ypujante
Copy link
Member

ypujante commented Feb 9, 2025

I have implemented full touch support with the latest release.

@ypujante ypujante closed this as completed Feb 9, 2025
@GJMontreal
Copy link
Author

GJMontreal commented Feb 10, 2025 via email

@ypujante
Copy link
Member

The changes have been merged to Emscripten, but the latest version of Emscripten has not been released yet. It is explained in this section of the README file:

If you want to use the latest version right away without having to wait until the latest version of Emscripten is released, you can copy the file emscripten-glfw3.py in your project and use it directly: --use-port=<path_to>/emscripten_glfw3.py (instead of --use-port=contrib.glfw3)

@GJMontreal
Copy link
Author

GJMontreal commented Feb 10, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants