From f3d3a5835cc791eaf23cd2014a7d1be1fff5ce93 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 14 Oct 2017 15:47:19 +0200 Subject: [PATCH] Use the OS Touchscreen Calibration instead of hardcoded values --- src/gui/VPadController.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/VPadController.h b/src/gui/VPadController.h index b9b4506..3426938 100644 --- a/src/gui/VPadController.h +++ b/src/gui/VPadController.h @@ -40,16 +40,18 @@ public: s32 vpadError = -1; VPADRead(0, &vpad, 1, &vpadError); - if(vpadError == 0) - { + if(vpadError == 0){ data.buttons_r = vpad.btns_r; data.buttons_h = vpad.btns_h; data.buttons_d = vpad.btns_d; data.validPointer = !vpad.tpdata.invalid; data.touched = vpad.tpdata.touched; + + VPADGetTPCalibratedPoint(0, &tpCalib, &vpad.tpdata1); + //! calculate the screen offsets - data.x = -(width >> 1) + ((s32)(vpad.tpdata1.x * ((width)/1211.0f)*width) >> 12)-30; - data.y = -(height >> 1) + ((s32)(vpad.tpdata1.y * ((height)/653.0f)*height) >> 12)-35; + data.x = -(width >> 1) + (s32)(((float)tpCalib.x / 1280.0f) * (float)width); + data.y = -(height >> 1) + (s32)(float)height - (((float)tpCalib.y / 720.0f) * (float)height); return true; } @@ -58,6 +60,7 @@ public: private: VPADData vpad; + VPADTPData tpCalib; }; #endif