-
Notifications
You must be signed in to change notification settings - Fork 501
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
iOS touch events scale issue #658
Comments
First: Are you using the GL or Metal backend? The GL backend on iOS may suffer from problems because GL has been deprecated, so this probably won't see much fixes in the future. If it's the Metal backend, it might be a bug though. Second, are you properly communicating the dpi scale from sokol_app.h to sokol_imgui.h (via (e.g. see the entry for This part of the code (reporting the dpi scale each frame instead of just at startup also had changed quite recently, but this was mainly for macOS to deal with multi-monitor scenarios, might be that the iOS sokol_app.h backend doesn't handle this correctly for some reason). Third: what combination of iOS version and Xcode version are you using? I'll try to look at the touch position problem in the evening on my iPad Mini4. As for the crash on rotation, I recently fixed a similar problem (for Metal), see this ticket: Are you on sokol_app.h version which contains this fix? Cheers! |
Thanks for the quick reply! Here's how I set the dpi for ImGui:
I'm at latest Xcode (13.3.1) and latest iOS (15.4.1). Regarding crash - I have updated the repo and the issue is indeed gone, thanks! |
Oki doki, then I shall try to look into the touch pos issue in the evening :) |
Ah damn, I had already forgotten the sort of trouble I had with on-device development :D
I'll see if I can reproduce the problem on the simulator, and I'll try to get a adapter tomorrow. Btw, Dear ImGui has some known problems with touch input: some widget types (for instance the menu) requires hover-information in the frame before a "click" happens. A touch interface doesn't provide such hover information so some of the UI elements are broken. |
Just for me understanding the problem correctly: pressing a button or similar in the Dear ImGui UI works, right? Because that's what I see on the simulator. Some operations like dragging windows doesn't work great, but the touch coordinates that ImGui uses for its own "hit tests" seem to be alright. However, now that I read your bug description carefully again, I noticed that you mention E.g. look here, the position that's reported to Dear ImGui is the sokol_app.h mouse- or touch-position divided by the dpi_scale value (see the call to Lines 2197 to 2200 in 9a6237f
(the same is true for any touch-input positions). ...so if you get the mouse/touch position via A better alternative to Please let me know if this cleans up the confusion, or if there's still an actual bug on a real device (as I said I can't test on a real device until tomorrow or so). Cheers! |
Ohhhh, you are absolutely right. Thanks for the explanation! While we are at it - in Xcode I am getting this message in the debugger window at startup:
and the app crashes when I close the simulator in |
Yes I'm seeing those too, I'm not too concerned. The debug console warnings seem to change with each new macOS/iOS or SDK version, some of those are deep in the callstack of OS functions, so it's sometimes hard to make sense of them or figure out if they are caused by the application code or something else inside the OS. The crash seems to be because the simulator doesn't seem to properly stop applications before it shuts down. PS: closing the ticket now :) |
Hi,
I just tried to use sokol in iOS (iPad) and I am noticing that touch events (ImGui::GetMousePos()) returns values scaled by 0.5f. As if the DPI scaling is not properly calculated between the screen size and the input position. When I scale the width/height passed to the simgui_frame_desc_t then it's correct, but obviously it renders just the quarter of the screen.
What am I missing?
Also, there's a crash when I try to change the orientation of the screen, but this seems to be only a problem in the simulator, not on the real device.
Tom
The text was updated successfully, but these errors were encountered: