Maelstrom: Fixed touch coordinate scaling with the new logical resolution code

https://github.com/libsdl-org/Maelstrom/commit/6e9f3058c65b04b954c9aff2ce50b8c470fff4e0

From 6e9f3058c65b04b954c9aff2ce50b8c470fff4e0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 2 Oct 2012 22:36:19 -0700
Subject: [PATCH] Fixed touch coordinate scaling with the new logical
 resolution code

---
 screenlib/SDL_FrameBuf.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 2a678369..af2c28e4 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -119,13 +119,18 @@ FrameBuf::ProcessEvent(SDL_Event *event)
 bool
 FrameBuf::ConvertTouchCoordinates(const SDL_TouchFingerEvent &finger, int *x, int *y)
 {
+	int window_w, window_h;
+	float scale_x, scale_y;
+
 	SDL_Touch* inTouch = SDL_GetTouch(finger.touchId);
 	if (inTouch == NULL) {
 		return false;
 	}
-
-	*x = (int)((((float)finger.x)/inTouch->xres)*output.w) - output.x;
-	*y = (int)((((float)finger.y)/inTouch->yres)*output.h) - output.y;
+    
+	SDL_GetWindowSize(window, &window_w, &window_h);
+	SDL_RenderGetScale(renderer, &scale_x, &scale_y);
+	*x = (int)((((float)finger.x)/inTouch->xres)*window_w/scale_x) - output.x;
+	*y = (int)((((float)finger.y)/inTouch->yres)*window_h/scale_y) - output.y;
 	*x = (*x * rect.w) / output.w;
 	*y = (*y * rect.h) / output.h;
 	return true;