[SDL] iOS: need help de-hardcoding SDL 2.0.3 changes in Exult-iOS

ollika olli.kallioinen at iki.fi
Thu Sep 29 08:33:45 PDT 2016


Sounds like the the wrong coordinates could be caused by the resolution being scaled by iOS. If You are not using the SDL_WINDOW_ALLOW_HIGHDPI flag, the app will not use the full native resolution on many iOS devices. I.e. it will only render only a quarter of the pixels and scale width and height with 2 (or something else depending on device).

I'm not sure but SDL_MOUSEBUTTONDOWN etc. might give the coordinates as actual screen pixels and not as the rendered "logical" pixels. So maybe you need to scale them to get the pixel locations you want. What I do on iOS instead, is use the actual SDL_FINGERDOWN etc. events and ignore any mouse events where (event.button.which == SDL_TOUCH_MOUSEID). Those events are generated for compatibility to fake mouse events on touch devices. At least that way I'm getting correct coordinates also on touch devices.

However, when using SDL_FINGERDOWN etc. you will get coordinates as values that range from 0.0 to 1.0 (if I remember correctly). If you need the value in "logical" pixels, you need to scale with width and height values you get from SDL_GL_GetDrawableSize.

Disclaimer: I haven't looked at your code and probably don't remember all the details from the top of my head.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20160929/24d01c25/attachment.htm>


More information about the SDL mailing list