From 3c3bab5d8275a93e12d8b37526811f73a2283195 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 16 Nov 2013 01:58:37 +1000 Subject: [PATCH] Add support for mouse drivers that do their own orientation mapping as the display rotation changes. --- include/ginput/lld/mouse.h | 4 ++++ src/ginput/mouse.c | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/ginput/lld/mouse.h b/include/ginput/lld/mouse.h index 4da338dc..a3056519 100644 --- a/include/ginput/lld/mouse.h +++ b/include/ginput/lld/mouse.h @@ -66,6 +66,10 @@ #define GINPUT_MOUSE_CLICK_TIME 700 #endif +// true/false - Whether the mouse driver internally handles screen rotation +#ifndef GINPUT_MOUSE_NO_ROTATION + #define GINPUT_MOUSE_NO_ROTATION FALSE +#endif typedef struct MouseReading_t { coord_t x, y, z; diff --git a/src/ginput/mouse.c b/src/ginput/mouse.c index 80a4ed20..aa1d2234 100644 --- a/src/ginput/mouse.c +++ b/src/ginput/mouse.c @@ -164,22 +164,22 @@ static struct MouseConfig_t { #endif static void get_calibrated_reading(MouseReading *pt) { - #if GINPUT_MOUSE_NEED_CALIBRATION || GDISP_NEED_CONTROL + #if GINPUT_MOUSE_NEED_CALIBRATION || (GDISP_NEED_CONTROL && !GINPUT_MOUSE_NO_ROTATION) coord_t w, h; #endif get_raw_reading(pt); - #if GINPUT_MOUSE_NEED_CALIBRATION || GDISP_NEED_CONTROL - w = gdispGGetWidth(MouseConfig.display); - h = gdispGGetHeight(MouseConfig.display); - #endif - #if GINPUT_MOUSE_NEED_CALIBRATION _tsTransform(pt, &MouseConfig.caldata); #endif - #if GDISP_NEED_CONTROL + #if GINPUT_MOUSE_NEED_CALIBRATION || (GDISP_NEED_CONTROL && !GINPUT_MOUSE_NO_ROTATION) + w = gdispGGetWidth(MouseConfig.display); + h = gdispGGetHeight(MouseConfig.display); + #endif + + #if GDISP_NEED_CONTROL && !GINPUT_MOUSE_NO_ROTATION switch(gdispGGetOrientation(MouseConfig.display)) { case GDISP_ROTATE_0: break; @@ -207,12 +207,12 @@ static void get_calibrated_reading(MouseReading *pt) { #endif #if GINPUT_MOUSE_NEED_CALIBRATION - if (!(MouseConfig.flags & FLG_CAL_RAW)) { - if (pt->x < 0) pt->x = 0; - else if (pt->x >= w) pt->x = w-1; - if (pt->y < 0) pt->y = 0; - else if (pt->y >= h) pt->y = h-1; - } + if (!(MouseConfig.flags & FLG_CAL_RAW)) { + if (pt->x < 0) pt->x = 0; + else if (pt->x >= w) pt->x = w-1; + if (pt->y < 0) pt->y = 0; + else if (pt->y >= h) pt->y = h-1; + } #endif }