Ryujinx-SDL/src/render
Sam Lantinga 9dbe5a9686 Fixed bug 3311 - Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS
Eric wing

Hi, I think I found a bug when using SDL_WINDOW_ALLOW_HIGHDPI with SDL_RenderSetLogicalSize on iOS. I use SDL_RenderSetLogicalSize for all my stuff. I just tried turning on SDL_WINDOW_ALLOW_HIGHDPI on iOS and suddenly all my touch/mouse positions are really broken/far-off-the-mark.

I actually don't have a real retina device (still) so I'm seeing this using the iOS simulator with a 6plus template.

Attached is a simple test program that can reproduce the problem. It uses RenderSetLogicalSize and draws some moving happy faces (to show the boundaries/space of the LogicalSize and that it is working correctly for that part).

When you click/touch, it will draw one more happy face where your button point is.

If you comment out SDL_WINDOW_ALLOW_HIGHDPI, everything works as expected. But if you compile with it in, the mouse coordinates seem really far off the mark. (Face appears far up and to the left.)


Alex Szpakowski on the mailing list suggests the problem is
"I believe this is a bug in SDL_Render?s platform-agnostic mouse coordinate scaling code. It assumes the units of the mouse coordinates are always in pixels, which isn?t the case where high-DPI is involved (regardless of whether iOS is used) ? they?re actually in ?DPI independent? coordinates (which matches the window size, but not the renderer output size)."

Additionally, if this is correct, the Mac under Retina is also probably affected too and "as well as any other platform SDL adds high-dpi support for in the future".
2017-08-02 13:38:46 -07:00
..
direct3d Updated copyright for 2017 2017-01-01 18:33:28 -08:00
direct3d11 WinRT: removed buildbot debug code, pending further research 2017-02-24 20:49:14 -05:00
opengl render: GL_DestroyRender() should activate first. 2017-05-18 21:00:11 -04:00
opengles Removed newlines from error messages. 2017-03-26 21:00:19 +02:00
opengles2 Corrected names of header file guards. 2017-06-03 23:00:15 +02:00
psp Updated copyright for 2017 2017-01-01 18:33:28 -08:00
software Updated copyright for 2017 2017-01-01 18:33:28 -08:00
mmx.h Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
SDL_d3dmath.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_d3dmath.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_render.c Fixed bug 3311 - Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS 2017-08-02 13:38:46 -07:00
SDL_sysrender.h Fixed bug 3311 - Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS 2017-08-02 13:38:46 -07:00
SDL_yuv_mmx.c Disable MMX inline assembly on Clang for now. 2017-07-26 13:43:25 -04:00
SDL_yuv_sw_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_yuv_sw.c Whoops, forgot to commit the actual fix. :) 2017-07-26 13:54:11 -04:00