From 78db2f1d49534998264077a6b2fc3eb7234be0df Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 23 Feb 2015 18:15:22 +1000 Subject: [PATCH] Fix to STMPE811 touch driver to fix self-calibration in other orientations --- .../ginput/touch/STMPE811/gmouse_lld_STMPE811.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c b/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c index 353539f9..56e8c98f 100644 --- a/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c +++ b/drivers/ginput/touch/STMPE811/gmouse_lld_STMPE811.c @@ -208,8 +208,21 @@ static bool_t read_xyz(GMouse* m, GMouseReading* pdr) // Rescale X,Y if we are using self-calibration #if GMOUSE_STMPE811_SELF_CALIBRATE - pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); - pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + #if GDISP_NEED_CONTROL + switch(gdispGGetOrientation(m->display)) { + case GDISP_ROTATE_0: + case GDISP_ROTATE_180: + pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); + pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + case GDISP_ROTATE_90: + case GDISP_ROTATE_270: + pdr->x = gdispGGetHeight(m->display) - pdr->x / (4096/gdispGGetHeight(m->display)); + pdr->y = pdr->y / (4096/gdispGGetWidth(m->display)); + } + #else + pdr->x = gdispGGetWidth(m->display) - pdr->x / (4096/gdispGGetWidth(m->display)); + pdr->y = pdr->y / (4096/gdispGGetHeight(m->display)); + #endif #endif return TRUE;