diff --git a/src/panda_sdl/frontend_sdl.cpp b/src/panda_sdl/frontend_sdl.cpp index 3c7ccc1d..b503dc42 100644 --- a/src/panda_sdl/frontend_sdl.cpp +++ b/src/panda_sdl/frontend_sdl.cpp @@ -162,8 +162,13 @@ void FrontendSDL::run() { if (emu.romType == ROMType::None) break; if (event.button.button == SDL_BUTTON_LEFT) { - const s32 x = event.button.x; - const s32 y = event.button.y; + // Get current window dimensions + int windowWidth, windowHeight; + SDL_GetWindowSize(window, &windowWidth, &windowHeight); + + // Go from window positions to [0, 400) for x and [0, 480) for y + const s32 x = (s32)std::round(event.button.x * 400.f / windowWidth); + const s32 y = (s32)std::round(event.button.y * 480.f / windowHeight); // Check if touch falls in the touch screen area if (y >= 240 && y <= 480 && x >= 40 && x < 40 + 320) {