Change the definition of the calibration load and save routines as per steved suggestion.

ugfx_release_2.6
inmarket 2014-11-15 15:22:09 +10:00
parent a8d6aa0790
commit fe00d3e090
4 changed files with 11 additions and 31 deletions

View File

@ -74,7 +74,6 @@ typedef struct GMouseVMT {
#define GMOUSE_VFLG_CALIBRATE 0x0010 // This device requires calibration
#define GMOUSE_VFLG_CAL_EXTREMES 0x0020 // Use edge to edge calibration
#define GMOUSE_VFLG_CAL_TEST 0x0040 // Test the results of the calibration
#define GMOUSE_VFLG_CAL_LOADFREE 0x0080 // Call gfxFree on the buffer returned by the VMT calload() routine.
#define GMOUSE_VFLG_ONLY_DOWN 0x0100 // This device returns a valid position only when the mouse is down
#define GMOUSE_VFLG_POORUPDOWN 0x0200 // Position readings during up/down are unreliable
#define GMOUSE_VFLG_DYNAMICONLY 0x8000 // This mouse driver should not be statically initialized eg Win32
@ -89,8 +88,8 @@ typedef struct GMouseVMT {
bool_t (*init)(GMouse *m, unsigned driverinstance); // Required
void (*deinit)(GMouse *m); // Optional
bool_t (*get)(GMouse *m, GMouseReading *prd); // Required
void (*calsave)(GMouse *m, void *buf, size_t sz); // Optional
const char *(*calload)(GMouse *m, size_t sz); // Optional: Can return NULL if no data is saved.
void (*calsave)(GMouse *m, const void *buf, size_t sz); // Optional
bool_t (*calload)(GMouse *m, void *buf, size_t sz); // Optional
} GMouseVMT;
#define gmvmt(m) ((const GMouseVMT const *)((m)->d.vmt))

View File

@ -462,7 +462,7 @@ static void MousePoll(void *param) {
gdispGSetClip(m->display, 0, 0, w, h);
#endif
// Ensure we get minimaly processed readings for the calibration
// Ensure we get minimally processed readings for the calibration
m->flags |= GMOUSE_FLG_IN_CAL;
// Set up our calibration locations
@ -519,7 +519,7 @@ static void MousePoll(void *param) {
gfxSleepMilliseconds(CALIBRATION_POLL_PERIOD);
}
// Ignore presses less than CALIBRATION_MAXPRESS_PERIOD milliseconds
// Ignore presses less than CALIBRATION_MINPRESS_PERIOD milliseconds
} while(j < CALIBRATION_MINPRESS_PERIOD/CALIBRATION_POLL_PERIOD);
points[i].x = px / j;
points[i].y = py / j;
@ -689,23 +689,13 @@ void _gmousePostInitDriver(GDriver *g) {
#if !GINPUT_TOUCH_NOCALIBRATE && !GINPUT_TOUCH_STARTRAW
if ((gmvmt(m)->d.flags & GMOUSE_VFLG_CALIBRATE)) {
GMouseCalibration *pc;
#if GINPUT_TOUCH_USER_CALIBRATION_LOAD
if ((pc = (GMouseCalibration *)LoadMouseCalibration(gdriverGetDriverInstanceNumber((GDriver *)m), sizeof(GMouseCalibration)))) {
memcpy(&m->caldata, pc, sizeof(GMouseCalibration));
#if GINPUT_TOUCH_USER_CALIBRATION_FREE
gfxFree(pc);
#endif
if (LoadMouseCalibration(gdriverGetDriverInstanceNumber((GDriver *)m), &m->caldata, sizeof(GMouseCalibration))))
m->flags |= GMOUSE_FLG_CALIBRATE;
} else
else
#endif
if (gmvmt(m)->calload && (pc = (GMouseCalibration *)gmvmt(m)->calload(m, sizeof(GMouseCalibration)))) {
memcpy(&m->caldata, pc, sizeof(GMouseCalibration));
if ((gmvmt(m)->d.flags & GMOUSE_VFLG_CAL_LOADFREE))
gfxFree(pc);
if (gmvmt(m)->calload && gmvmt(m)->calload(m, &m->caldata, sizeof(GMouseCalibration))))
m->flags |= GMOUSE_FLG_CALIBRATE;
}
#if !GINPUT_TOUCH_NOCALIBRATE_GUI
else
while (CalibrateMouse(m));

View File

@ -156,15 +156,14 @@ extern "C" {
* @return A pointer to the data or NULL on failure
*
* @param[in] instance The mouse input instance number
* @param[in] data Where the data should be placed
* @param[in] sz The size in bytes of the data to retrieve.
*
* @note This routine is provided by the user application. It is only
* called if GINPUT_TOUCH_USER_CALIBRATION_LOAD has been set to TRUE in the
* users gfxconf.h file.
* @note If GINPUT_TOUCH_USER_CALIBRATION_FREE has been set to TRUE in the users
* gfxconf.h file then the buffer returned will be free'd using gfxFree().
*/
void *LoadMouseCalibration(unsigned instance, size_t sz);
bool_t LoadMouseCalibration(unsigned instance, void *data, size_t sz);
/**
* @brief Save a set of mouse calibration data

View File

@ -134,12 +134,12 @@
#endif
/**
* @brief Milliseconds to generate a CXTCLICK on a touch device.
* @details Defaults to 700 millseconds
* @details Defaults to 500 millseconds
* @note If you hold the touch down for longer than this a CXTCLICK is generated
* but only on a touch device.
*/
#ifndef GINPUT_TOUCH_CXTCLICK_TIME
#define GINPUT_TOUCH_CXTCLICK_TIME 700
#define GINPUT_TOUCH_CXTCLICK_TIME 500
#endif
/**
* @brief There is a user supplied routine to load mouse calibration data
@ -149,14 +149,6 @@
#ifndef GINPUT_TOUCH_USER_CALIBRATION_LOAD
#define GINPUT_TOUCH_USER_CALIBRATION_LOAD FALSE
#endif
/**
* @brief The buffer returned by the users @p LoadMouseCalibration() routine must be gfxFree()'d
* by the mouse code.
* @details Defaults to FALSE
*/
#ifndef GINPUT_TOUCH_USER_CALIBRATION_FREE
#define GINPUT_TOUCH_USER_CALIBRATION_FREE FALSE
#endif
/**
* @brief There is a user supplied routine to save mouse calibration data
* @details Defaults to FALSE