Add support for mouse drivers that do their own orientation mapping as the display rotation changes.

ugfx_release_2.6
inmarket 2013-11-16 01:58:37 +10:00
parent a3935c653e
commit 3c3bab5d82
2 changed files with 17 additions and 13 deletions

View File

@ -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;

View File

@ -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
}