From e6f910ec2761bedd0515721b156acbe93668acda Mon Sep 17 00:00:00 2001 From: Sacha Date: Thu, 7 Nov 2013 16:10:46 +1000 Subject: [PATCH] Coords fix: toFullscreenCoord should return float, not int. --- UI/TouchControlLayoutScreen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 4e4fcb32d2..b12a3b3972 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -30,12 +30,12 @@ static const int leftMargin = 140; -// convert from screen coordinates (leftMargin to dp_xres) to actual fullscreen coordinates (0 to dp_xres) -static inline int toFullscreenCoord(int screenx) { - return ((float)1.0 / (dp_xres - leftMargin)) * (screenx - leftMargin); +// convert from screen coordinates (leftMargin to dp_xres) to actual fullscreen coordinates (0 to 1.0) +static inline float toFullscreenCoord(int screenx) { + return (float)(screenx - leftMargin) / (dp_xres - leftMargin); } -// convert from external fullscreen coordinates(0 to dp_xres) to the current partial coordinates (leftMargin to dp_xres) +// convert from external fullscreen coordinates(0 to 1.0) to the current partial coordinates (leftMargin to dp_xres) static inline int fromFullscreenCoord(float controllerX) { return leftMargin + (dp_xres - leftMargin) * controllerX; };