I'm creating a little game to be used on the raspberry pi using mouse and keyboard, but i also own an official raspberry pi touchscreen and noticed when using the touchscreen that sdl did not generate mousebutton down events. instead it seems i need to use SDL_TouchFingerEvent for it to work. I implemented it in my game but i'm having problems when letterboxing occurs. I'm using a logical size of 320x240 for my game but a (default) window size of 640x480 so sdl scales the rendering. I also let my window be resizeable. Unlike the mousebuttondown events where the x and y position is relative to the window and it adheres to letterboxing occuring and scaling (so i can use calculations based on 320x240 perspective) SDL_Touchfingerevent seems to be using a normalized value for the positions between 0 and 1. When i don't resize my window i can get the the 320x240 coordinates by multiplying the x & y values with the window size however this starts to fail when letterboxing (to keep aspect ratio during scaling) occurs when i have resized my window and i can not seem to calculate the values for 320x240 perspective anymore. I also seem to be getting negative values while the docs said it was normalized between 0 & 1 when letterboxing happens.
i mean this with letterboxing (the black borders getting added above and under left and right but in screenshot i only resized on x axis)
to me it seems i need to substract the black sizes from the calculations but i can't seem to be able to calculate this and it probably won't not work as the touchfingerevent values don't start from 0 anymore when letterboxing occurs. Does anyone know how to correctly calculate the position relative to 320x240 when this occurs ?
Maybe someone already used sdl2 and the official touchscreen and came accros a similar problem ?