iOS: Using SDL_RenderSetLogicalSize & SDL_WINDOW_ALLOW_HIGHDPI, results in non-normalized tfinger values

I found that if I try to use SDL_RenderSetLogicalSize simultaneously with a window created with the flag SDL_WINDOW_ALLOW_HIGHDPI, I get the graphics rendering as I expect, but touch inputs go in the wrong locations.

According to the documentation, the SDL_FINGERDOWN event has tfinger.x and tfinger.y that are supposed to provide values between 0 and 1. I should be able to multiply those values with the value of the width and height of the screen (as retrieved earlier from SDL_GetRendererOutputSize) to get the location that I can then use in my app to figure out what to do with the touch event relative to where everything is supposed to be on the screen.

Instead, they are larger than expected. If I touch at the far right side of the screen, I find that the value of SDL_FINGERDOWN’s x approaches over 3.1, which results in my code calculating a screen location offscreen.

I saw that there was a defect in 2016 about this issue (, and that it had been addressed, but as I’m using SDL2-2.0.10, either there is a regression or there is something else going on.

SDL_MOUSEMOTION’s motion.x looks accurate, which I can use if I just want to treat touch events as a mouse, but if I want to handle touch events, it’s not enough.

If I don’t set SDL_WINDOW_ALLOW_HIGHDPI, the values for tfinger.x/y are normalized as expected, but on iOS the graphics look fuzzy and the text is hard to read in my app.

If I don’t use logical sizing, then I would need to completely redo the logic of how I render to the screen, and I would rather not do so.

Am I misunderstanding how to use allow high DPI and use logical sizing for rendering together?

I’ve come across this exact same issue with SDL-2.0.12 running on iOS. Were you able to resolve this?

I used a workaround. The project I was working on didn’t require multitouch, so if I ignored the touch presses and treated everything as a mouse event, it worked fine.

However, last month I saw this changeset is available, which might fix the issue:

1 Like

I’ll try that diff out, thanks!

The diff worked, touch events are working as they should.