aboutsummaryrefslogtreecommitdiffstats
path: root/src/ginput/driver_mouse.h
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-09-16 10:06:59 +1000
committerinmarket <andrewh@inmarket.com.au>2014-09-16 10:06:59 +1000
commit6f8845e86c31fa8f5076950d46d80aae53bef21a (patch)
treee262d204dc39122fe5bbae24f2f32a7ec009bf49 /src/ginput/driver_mouse.h
parenteaf1909c5601fe510f5a51a6b4aef6c1d82121b4 (diff)
downloaduGFX-6f8845e86c31fa8f5076950d46d80aae53bef21a.tar.gz
uGFX-6f8845e86c31fa8f5076950d46d80aae53bef21a.tar.bz2
uGFX-6f8845e86c31fa8f5076950d46d80aae53bef21a.zip
More mouse updates - not working yet.
Diffstat (limited to 'src/ginput/driver_mouse.h')
-rw-r--r--src/ginput/driver_mouse.h90
1 files changed, 34 insertions, 56 deletions
diff --git a/src/ginput/driver_mouse.h b/src/ginput/driver_mouse.h
index c60b9a0e..dbd327d9 100644
--- a/src/ginput/driver_mouse.h
+++ b/src/ginput/driver_mouse.h
@@ -19,55 +19,57 @@
#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__)
-typedef struct MouseReading {
+// Include the GDRIVER infrastructure
+#include "src/gdriver/sys_defs.h"
+
+typedef struct GMouseReading {
coord_t x, y, z;
uint16_t buttons;
- } MouseReading;
+ } GMouseReading;
#if !GINPUT_TOUCH_NOCALIBRATE
- typedef struct MouseCalibration {
+ typedef struct GMouseCalibration {
float ax;
float bx;
float cx;
float ay;
float by;
float cy;
- } MouseCalibration;
+ } GMouseCalibration;
#endif
-typedef struct MouseInstance {
- struct MouseInstance * next; // The next mouse instance
- const struct MOUSEVMT * vmt; // The mouse VMT
- MouseReading r; // The current position and state
+typedef struct GMouse {
+ GDriver d; // The driver overheads and vmt
+ GMouseReading r; // The current position and state
uint16_t flags; // Flags
#define GMOUSE_FLG_ACTIVE 0x0001 // Mouse is currently active
- #define GMOUSE_FLG_DYNAMIC 0x0002 // Mouse is dynamically allocated
- #define GMOUSE_FLG_CLICK_TIMER 0x0004 // Currently timing a click event
- #define GMOUSE_FLG_INDELTA 0x0008 // Currently in a up/down transition test
- #define GMOUSE_FLG_CLIP 0x0010 // Clip reading to the display
- #define GMOUSE_FLG_CALIBRATE 0x0020 // Calibrate readings
- #define GMOUSE_FLG_CAL_INPROGRESS 0x0040 // Calibrate is currently in progress
- #define GMOUSE_FLG_CAL_SAVED 0x0080 // Calibration has been saved
- #define GMOUSE_FLG_FINGERMODE 0x0100 // Mouse is currently in finger mode
+ #define GMOUSE_FLG_CLICK_TIMER 0x0002 // Currently timing a click event
+ #define GMOUSE_FLG_INDELTA 0x0004 // Currently in a up/down transition test
+ #define GMOUSE_FLG_CLIP 0x0008 // Clip reading to the display
+ #define GMOUSE_FLG_CALIBRATE 0x0010 // Calibrate readings
+ #define GMOUSE_FLG_CAL_INPROGRESS 0x0020 // Calibrate is currently in progress
+ #define GMOUSE_FLG_CAL_SAVED 0x0040 // Calibration has been saved
+ #define GMOUSE_FLG_FINGERMODE 0x0080 // Mouse is currently in finger mode
+ #define GMOUSE_FLG_NEEDREAD 0x0100 // The mouse needs reading
point clickpos; // The position of the last click event
systemticks_t clicktime; // The time of the last click event
GDisplay * display; // The display the mouse is associated with
- void * param; // A variable for private driver use
#if !GINPUT_TOUCH_NOCALIBRATE
GMouseCalibrationSaveRoutine fnsavecal; // The calibration load routine
GMouseCalibrationLoadRoutine fnloadcal; // The calibration save routine
MouseCalibration caldata; // The calibration data
#endif
-} MouseInstance;
+ // Other driver specific fields may follow.
+} GMouse;
-typedef struct MouseJitter {
+typedef struct GMouseJitter {
coord_t calibrate; // Maximum error for a calibration to succeed
coord_t click; // Movement allowed without discarding the CLICK or CLICKCXT event
coord_t move; // Movement allowed without discarding the MOVE event
-} MouseJitter;
+} GMouseJitter;
-typedef struct MOUSEVMT {
- uint16_t flags; // Device flags
+typedef struct GMouseVMT {
+ GDriverVMT d; // Device flags are part of the general vmt
#define GMOUSE_VFLG_TOUCH 0x0001 // This is a touch device (rather than a mouse). Button 1 is calculated from z value.
#define GMOUSE_VFLG_NOPOLL 0x0002 // Do not poll this device - it is purely interrupt driven
#define GMOUSE_VFLG_SELFROTATION 0x0004 // This device returns readings that are aligned with the display orientation
@@ -82,17 +84,16 @@ typedef struct MOUSEVMT {
coord_t z_touchon; // TOUCH: z values between z_max and this are a solid touch on
coord_t z_touchoff; // TOUCH: z values between z_min and this are a solid touch off
- MouseJitter pen_jitter; // PEN MODE: Jitter settings
- MouseJitter finger_jitter; // FINGER MODE: Jitter settings
+ GMouseJitter pen_jitter; // PEN MODE: Jitter settings
+ GMouseJitter finger_jitter; // FINGER MODE: Jitter settings
- void (*init)((MouseInstance *pmouse); // Required
- void (*get)(MouseInstance *pmouse, MouseReading *prd); // Required
- void (*cal_save)(MouseInstance *pmouse, void *buf, size_t sz); // Optional
- const char *(*cal_load)(MouseInstance *pmouse); // Optional: Can return NULL if no data is saved.
- // Buffer is gfxFree()'d afterwards.
-} MOUSEVMT;
+ bool_t (*init)(GMouse *m); // Required
+ void (*get)(GMouse *m, GMouseReading *prd); // Required
+ void (*calsave)(GMouse *m, void *buf, size_t sz); // Optional
+ const char *(*calload)(GMouse *m); // Optional: Can return NULL if no data is saved. Buffer is automatically gfxFree()'d afterwards.
+} GMouseVMT;
-#include "ginput_lld_mouse_config.h"
+#define gmvmt(m) ((const GMouseVMT const *)((m)->d.vmt))
/*===========================================================================*/
/* External declarations. */
@@ -102,36 +103,13 @@ typedef struct MOUSEVMT {
extern "C" {
#endif
/**
- * @brief Get a new empty mouse instance and assign it this VMT and display
- * @note This routine is provided to low level drivers by the high level code.
- * @note This routine is designed for displays that have their own dedicated mouse
- * eg. Win32, X, uGFXnet.
- * The display driver will during initialisation call this routine to associate
- * itself with a mouse.
- *
- * @notapi
- */
- MouseInstance *ginputMouseGetNewMouseForDisplay(const MOUSEVMT *vmt, GDisplay *g);
-
- /**
- * @brief Release a mouse
- * @note This routine is provided to low level drivers by the high level code.
- * @note This routine is designed for displays that have their own dedicated mouse
- * eg. Win32, X, uGFXnet.
- * When the display has finished with the mouse it can release it.
- *
- * @notapi
- */
- void ginputMouseGetNewMouseForDisplay(MouseIntance *pmouse);
-
- /**
* @brief Wakeup the high level code so that it attempts another read
*
* @note This routine is provided to low level drivers by the high level code
*
* @notapi
*/
- void ginputMouseWakeup(void);
+ void ginputMouseWakeup(GMouse *m);
/**
* @brief Wakeup the high level code so that it attempts another read
@@ -141,7 +119,7 @@ extern "C" {
* @iclass
* @notapi
*/
- void ginputMouseWakeupI(void);
+ void ginputMouseWakeupI(GMouse *m);
#ifdef __cplusplus
}