diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2013-05-06 14:44:47 +1000 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2013-05-06 14:44:47 +1000 |
commit | 3374aa25c6e4e118df670c18eaeefa0f6f29377f (patch) | |
tree | 99bdea0be61386bd3ae70c8516198dd857e4db13 /include/ginput | |
parent | bbfeec2dd7b312745856236214c91fce6b9ec22c (diff) | |
download | uGFX-3374aa25c6e4e118df670c18eaeefa0f6f29377f.tar.gz uGFX-3374aa25c6e4e118df670c18eaeefa0f6f29377f.tar.bz2 uGFX-3374aa25c6e4e118df670c18eaeefa0f6f29377f.zip |
Reinsertion of doxygen headers
Reinsertion of doxygen headers that got lost in license change
Diffstat (limited to 'include/ginput')
-rw-r--r-- | include/ginput/dial.h | 16 | ||||
-rw-r--r-- | include/ginput/ginput.h | 72 | ||||
-rw-r--r-- | include/ginput/keyboard.h | 235 | ||||
-rw-r--r-- | include/ginput/lld/dial.h | 9 | ||||
-rw-r--r-- | include/ginput/lld/mouse.h | 9 | ||||
-rw-r--r-- | include/ginput/lld/toggle.h | 101 | ||||
-rw-r--r-- | include/ginput/mouse.h | 290 | ||||
-rw-r--r-- | include/ginput/toggle.h | 172 |
8 files changed, 501 insertions, 403 deletions
diff --git a/include/ginput/dial.h b/include/ginput/dial.h index 5f565a4d..af54952a 100644 --- a/include/ginput/dial.h +++ b/include/ginput/dial.h @@ -4,6 +4,22 @@ * * http://chibios-gfx.com/license.html */ + +/** + * @file include/ginput/dial.h + * @brief GINPUT GFX User Input subsystem header file. + * + * @defgroup Dial Dial + * @ingroup GINPUT + * + * @details A dial provides a powerful way to navigate through menus + * on a display. + * + * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h + * @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h + * + * @{ + */ #ifndef _GINPUT_DIAL_H #define _GINPUT_DIAL_H diff --git a/include/ginput/ginput.h b/include/ginput/ginput.h index 07a5e0b7..be998c4e 100644 --- a/include/ginput/ginput.h +++ b/include/ginput/ginput.h @@ -4,32 +4,46 @@ * * http://chibios-gfx.com/license.html */ -#ifndef _GINPUT_H
-#define _GINPUT_H
-
-#include "gfx.h"
-
-#if GFX_USE_GINPUT || defined(__DOXYGEN__)
-
-/* How to use...
-
- 1. Get source handles for all the inputs you are interested in.
- - Attempting to get a handle for one instance of an input more than once will return the same handle
- 2. Create a listener
- 3. Assign inputs to your listener.
- - Inputs can be assigned or released from a listener at any time.
- - An input can be assigned to more than one listener.
- 4. Loop on getting listener events
- 5. When complete destroy the listener
-*/
-
-// Include various ginput types
-#include "ginput/mouse.h"
-#include "ginput/keyboard.h"
-#include "ginput/toggle.h"
-#include "ginput/dial.h"
-
-#endif /* GFX_USE_GINPUT */
-
-#endif /* _GINPUT_H */
-/** @} */
+ +/** + * @file include/ginput/ginput.h + * @brief GINPUT GFX User Input subsystem header file. + * + * @addtogroup GINPUT + * + * @details GINPUT provides an easy and common interface to use different input devices + * such as touchscreens and mices. + * + * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h + * + * @{ + */ +#ifndef _GINPUT_H +#define _GINPUT_H + +#include "gfx.h" + +#if GFX_USE_GINPUT || defined(__DOXYGEN__) + +/* How to use... + + 1. Get source handles for all the inputs you are interested in. + - Attempting to get a handle for one instance of an input more than once will return the same handle + 2. Create a listener + 3. Assign inputs to your listener. + - Inputs can be assigned or released from a listener at any time. + - An input can be assigned to more than one listener. + 4. Loop on getting listener events + 5. When complete destroy the listener +*/ + +// Include various ginput types +#include "ginput/mouse.h" +#include "ginput/keyboard.h" +#include "ginput/toggle.h" +#include "ginput/dial.h" + +#endif /* GFX_USE_GINPUT */ + +#endif /* _GINPUT_H */ +/** @} */ diff --git a/include/ginput/keyboard.h b/include/ginput/keyboard.h index 2c00a6c6..add2eff7 100644 --- a/include/ginput/keyboard.h +++ b/include/ginput/keyboard.h @@ -4,116 +4,125 @@ * * http://chibios-gfx.com/license.html */ -
-#ifndef _GINPUT_KEYBOARD_H
-#define _GINPUT_KEYBOARD_H
-
-#if GINPUT_NEED_KEYBOARD || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-#define GINPUT_KEYBOARD_NUM_PORTS 1 // The total number of keyboard inputs
-
-// Event types for various ginput sources
-#define GEVENT_KEYBOARD (GEVENT_GINPUT_FIRST+2)
-
-typedef struct GEventKeyboard_t {
- GEventType type; // The type of this event (GEVENT_KEYBOARD)
- uint16_t instance; // The keyboard instance
- char c; // The Ascii code for the current key press.
- // The only possible values are 0(NUL), 8(BS), 9(TAB), 13(CR), 27(ESC), 32(SPACE) to 126(~), 127(DEL)
- // 0 indicates an extended only key.
- uint16_t code; // An extended keyboard code. Codes less than 128 match their ascii equivelent.
- #define GKEY_NULL 0
- #define GKEY_BACKSPACE 8
- #define GKEY_TAB 9
- #define GKEY_CR 13
- #define GKEY_ESC 27
- #define GKEY_SPACE 32
- #define GKEY_DEL 127
- #define GKEY_UP 0x0101
- #define GKEY_DOWN 0x0102
- #define GKEY_LEFT 0x0103
- #define GKEY_RIGHT 0x0104
- #define GKEY_HOME 0x0105
- #define GKEY_END 0x0106
- #define GKEY_PAGEUP 0x0107
- #define GKEY_PAGEDOWN 0x0108
- #define GKEY_INSERT 0x0109
- #define GKEY_DELETE 0x010A
- #define GKEY_SHIFT 0x0201
- #define GKEY_CNTRL 0x0202
- #define GKEY_ALT 0x0203
- #define GKEY_WINKEY 0x0204
- #define GKEY_RCLKEY 0x0205
- #define GKEY_FNKEY 0x0206
- #define GKEY_FN1 0x0301
- #define GKEY_FN2 0x0302
- #define GKEY_FN3 0x0303
- #define GKEY_FN4 0x0304
- #define GKEY_FN5 0x0305
- #define GKEY_FN6 0x0306
- #define GKEY_FN7 0x0307
- #define GKEY_FN8 0x0308
- #define GKEY_FN9 0x0309
- #define GKEY_FN10 0x030A
- #define GKEY_FN11 0x030B
- #define GKEY_FN12 0x030C
- uint16_t current_buttons; // A bit is set to indicate various meta status.
- #define GMETA_KEY_DOWN 0x0001
- #define GMETA_KEY_SHIFT 0x0002
- #define GMETA_KEY_CNTRL 0x0004
- #define GMETA_KEY_ALT 0x0008
- #define GMETA_KEY_WINKEY 0x0010
- #define GMETA_KEY_RCLKKEY 0x0020
- #define GMETA_KEY_FN 0x0040
- #define GMETA_KEY_MISSED_EVENT 0x8000
- uint16_t last_buttons; // The value of current_buttons on the last event
-} GEventKeyboard;
-
-// Keyboard Listen Flags - passed to geventAddSourceToListener()
-#define GLISTEN_KEYREPEATS 0x0001 // Return key repeats (where the key is held down to get a repeat character)
-#define GLISTEN_KEYCODES 0x0002 // Return all key presses including extended code key presses (not just ascii codes)
-#define GLISTEN_KEYALL 0x0004 // Return keyup's, keydown's and everything in between (but not repeats unless GLISTEN_KEYREPEATS is set).
-#define GLISTEN_KEYSINGLE 0x8000 // Return only when one particular extended code key is pressed or released. The particular extended code is OR'd into this value
- // eg. (GLISTEN_KEYSINGLE | GKEY_CR)
- // No other flags may be set with this flag.
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /**
- * @brief Create a keyboard input instance
- *
- * @param[in] instance The ID of the keyboard input instance (from 0 to 9999)
- *
- * @return The source handle of the created input instance
- */
- GSourceHandle ginputGetKeyboard(uint16_t instance);
-
- /**
- * @brief Get the current keyboard status
- *
- * @param[in] instance The ID of the keyboard input instance
- * @param[in] pkeyboard The keyboard event struct
- *
- * @return Returns FALSE on an error (eg invalid instance)
- */
- bool_t ginputGetKeyboardStatus(uint16_t instance, GEventKeyboard *pkeyboard);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GINPUT_NEED_KEYBOARD */
-
-#endif /* _GINPUT_KEYBOARD_H */
-/** @} */
-
+ +/** + * @file include/ginput/keyboard.h + * @brief GINPUT GFX User Input subsystem header file. + * + * @defgroup Keyboard Keyboard + * @ingroup GINPUT + * @{ + */ + +#ifndef _GINPUT_KEYBOARD_H +#define _GINPUT_KEYBOARD_H + +#if GINPUT_NEED_KEYBOARD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +#define GINPUT_KEYBOARD_NUM_PORTS 1 // The total number of keyboard inputs + +// Event types for various ginput sources +#define GEVENT_KEYBOARD (GEVENT_GINPUT_FIRST+2) + +typedef struct GEventKeyboard_t { + GEventType type; // The type of this event (GEVENT_KEYBOARD) + uint16_t instance; // The keyboard instance + char c; // The Ascii code for the current key press. + // The only possible values are 0(NUL), 8(BS), 9(TAB), 13(CR), 27(ESC), 32(SPACE) to 126(~), 127(DEL) + // 0 indicates an extended only key. + uint16_t code; // An extended keyboard code. Codes less than 128 match their ascii equivelent. + #define GKEY_NULL 0 + #define GKEY_BACKSPACE 8 + #define GKEY_TAB 9 + #define GKEY_CR 13 + #define GKEY_ESC 27 + #define GKEY_SPACE 32 + #define GKEY_DEL 127 + #define GKEY_UP 0x0101 + #define GKEY_DOWN 0x0102 + #define GKEY_LEFT 0x0103 + #define GKEY_RIGHT 0x0104 + #define GKEY_HOME 0x0105 + #define GKEY_END 0x0106 + #define GKEY_PAGEUP 0x0107 + #define GKEY_PAGEDOWN 0x0108 + #define GKEY_INSERT 0x0109 + #define GKEY_DELETE 0x010A + #define GKEY_SHIFT 0x0201 + #define GKEY_CNTRL 0x0202 + #define GKEY_ALT 0x0203 + #define GKEY_WINKEY 0x0204 + #define GKEY_RCLKEY 0x0205 + #define GKEY_FNKEY 0x0206 + #define GKEY_FN1 0x0301 + #define GKEY_FN2 0x0302 + #define GKEY_FN3 0x0303 + #define GKEY_FN4 0x0304 + #define GKEY_FN5 0x0305 + #define GKEY_FN6 0x0306 + #define GKEY_FN7 0x0307 + #define GKEY_FN8 0x0308 + #define GKEY_FN9 0x0309 + #define GKEY_FN10 0x030A + #define GKEY_FN11 0x030B + #define GKEY_FN12 0x030C + uint16_t current_buttons; // A bit is set to indicate various meta status. + #define GMETA_KEY_DOWN 0x0001 + #define GMETA_KEY_SHIFT 0x0002 + #define GMETA_KEY_CNTRL 0x0004 + #define GMETA_KEY_ALT 0x0008 + #define GMETA_KEY_WINKEY 0x0010 + #define GMETA_KEY_RCLKKEY 0x0020 + #define GMETA_KEY_FN 0x0040 + #define GMETA_KEY_MISSED_EVENT 0x8000 + uint16_t last_buttons; // The value of current_buttons on the last event +} GEventKeyboard; + +// Keyboard Listen Flags - passed to geventAddSourceToListener() +#define GLISTEN_KEYREPEATS 0x0001 // Return key repeats (where the key is held down to get a repeat character) +#define GLISTEN_KEYCODES 0x0002 // Return all key presses including extended code key presses (not just ascii codes) +#define GLISTEN_KEYALL 0x0004 // Return keyup's, keydown's and everything in between (but not repeats unless GLISTEN_KEYREPEATS is set). +#define GLISTEN_KEYSINGLE 0x8000 // Return only when one particular extended code key is pressed or released. The particular extended code is OR'd into this value + // eg. (GLISTEN_KEYSINGLE | GKEY_CR) + // No other flags may be set with this flag. + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief Create a keyboard input instance + * + * @param[in] instance The ID of the keyboard input instance (from 0 to 9999) + * + * @return The source handle of the created input instance + */ + GSourceHandle ginputGetKeyboard(uint16_t instance); + + /** + * @brief Get the current keyboard status + * + * @param[in] instance The ID of the keyboard input instance + * @param[in] pkeyboard The keyboard event struct + * + * @return Returns FALSE on an error (eg invalid instance) + */ + bool_t ginputGetKeyboardStatus(uint16_t instance, GEventKeyboard *pkeyboard); + +#ifdef __cplusplus +} +#endif + +#endif /* GINPUT_NEED_KEYBOARD */ + +#endif /* _GINPUT_KEYBOARD_H */ +/** @} */ + diff --git a/include/ginput/lld/dial.h b/include/ginput/lld/dial.h index bdcd2c3b..7c16851f 100644 --- a/include/ginput/lld/dial.h +++ b/include/ginput/lld/dial.h @@ -5,6 +5,15 @@ * http://chibios-gfx.com/license.html */ +/** + * @file include/ginput/lld/dial.h + * @brief GINPUT header file for dial drivers. + * + * @defgroup Dial Dial + * @ingroup GINPUT + * @{ + */ + #ifndef _LLD_GINPUT_DIAL_H #define _LLD_GINPUT_DIAL_H diff --git a/include/ginput/lld/mouse.h b/include/ginput/lld/mouse.h index 111e8263..a9e755c4 100644 --- a/include/ginput/lld/mouse.h +++ b/include/ginput/lld/mouse.h @@ -5,6 +5,15 @@ * http://chibios-gfx.com/license.html */ +/** + * @file include/ginput/lld/mouse.h + * @brief GINPUT LLD header file for mouse/touch drivers. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * @{ + */ + #ifndef _LLD_GINPUT_MOUSE_H #define _LLD_GINPUT_MOUSE_H diff --git a/include/ginput/lld/toggle.h b/include/ginput/lld/toggle.h index 34aafe32..869b92f8 100644 --- a/include/ginput/lld/toggle.h +++ b/include/ginput/lld/toggle.h @@ -4,49 +4,58 @@ * * http://chibios-gfx.com/license.html */ -
-#ifndef _LLD_GINPUT_TOGGLE_H
-#define _LLD_GINPUT_TOGGLE_H
-
-#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
-
-// Describes how the toggle bits are obtained
-typedef struct GToggleConfig_t {
- void *id;
- unsigned mask;
- unsigned invert;
- iomode_t mode;
-} GToggleConfig;
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
-
- void ginput_lld_toggle_init(const GToggleConfig *ptc);
- unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
-
- /* This routine is provided to low level drivers to wakeup a value read from a thread context.
- * Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
- */
- void ginputToggleWakeup(void);
-
- /* This routine is provided to low level drivers to wakeup a value read from an ISR
- * Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
- */
- void ginputToggleWakeupI(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
-
-#endif /* _LLD_GINPUT_TOGGLE_H */
-/** @} */
-
+ +/** + * @file include/ginput/lld/toggle.h + * @brief GINPUT header file for toggle drivers. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ + +#ifndef _LLD_GINPUT_TOGGLE_H +#define _LLD_GINPUT_TOGGLE_H + +#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__) + +// Describes how the toggle bits are obtained +typedef struct GToggleConfig_t { + void *id; + unsigned mask; + unsigned invert; + iomode_t mode; +} GToggleConfig; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES]; + + void ginput_lld_toggle_init(const GToggleConfig *ptc); + unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc); + + /* This routine is provided to low level drivers to wakeup a value read from a thread context. + * Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE + */ + void ginputToggleWakeup(void); + + /* This routine is provided to low level drivers to wakeup a value read from an ISR + * Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE + */ + void ginputToggleWakeupI(void); + +#ifdef __cplusplus +} +#endif + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ + +#endif /* _LLD_GINPUT_TOGGLE_H */ +/** @} */ + diff --git a/include/ginput/mouse.h b/include/ginput/mouse.h index d49a7a97..011372c4 100644 --- a/include/ginput/mouse.h +++ b/include/ginput/mouse.h @@ -4,140 +4,156 @@ * * http://chibios-gfx.com/license.html */ -
-#ifndef _GINPUT_MOUSE_H
-#define _GINPUT_MOUSE_H
-
-#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-/* This type definition is also used by touch */
-typedef struct GEventMouse_t {
- GEventType type; // The type of this event (GEVENT_MOUSE or GEVENT_TOUCH)
- uint16_t instance; // The mouse/touch instance
- coord_t x, y, z; // The position of the mouse.
- // - For touch devices, Z is the current pressure if supported (otherwise 0)
- // - For mice, Z is the 3rd dimension if supported (otherwise 0)
- uint16_t current_buttons; // A bit is set if the button is down.
- // - For touch only bit 0 is relevant
- // - For mice the order of the buttons is (from 0 to n) left, right, middle, any other buttons
- // - Bit 15 being set indicates that an important mouse event has been missed.
- #define GINPUT_MOUSE_BTN_LEFT 0x0001
- #define GINPUT_MOUSE_BTN_RIGHT 0x0002
- #define GINPUT_MOUSE_BTN_MIDDLE 0x0004
- #define GINPUT_MOUSE_BTN_4 0x0008
- #define GINPUT_MISSED_MOUSE_EVENT 0x8000
- #define GINPUT_TOUCH_PRESSED GINPUT_MOUSE_BTN_LEFT
- uint16_t last_buttons; // The value of current_buttons on the last event
- enum GMouseMeta_e {
- GMETA_NONE = 0, // There is no meta event currently happening
- GMETA_MOUSE_DOWN = 1, // Button 0 has just gone down
- GMETA_MOUSE_UP = 2, // Button 0 has just gone up
- GMETA_MOUSE_CLICK = 4, // Button 0 has just gone through a short down - up cycle
- GMETA_MOUSE_CXTCLICK = 8 // For mice - The right button has just been depressed
- // For touch - a long press has just occurred
- } meta;
- } GEventMouse;
-
-// Mouse/Touch Listen Flags - passed to geventAddSourceToListener()
-#define GLISTEN_MOUSEMETA 0x0001 // Create events for meta events such as CLICK and CXTCLICK
-#define GLISTEN_MOUSEDOWNMOVES 0x0002 // Creates mouse move events when the primary mouse button is down (touch is on the surface)
-#define GLISTEN_MOUSEUPMOVES 0x0004 // Creates mouse move events when the primary mouse button is up (touch is off the surface - if the hardware allows).
-#define GLISTEN_MOUSENOFILTER 0x0008 // Don't filter out mouse moves where the position hasn't changed.
-#define GLISTEN_TOUCHMETA GLISTEN_MOUSEMETA
-#define GLISTEN_TOUCHDOWNMOVES GLISTEN_MOUSEDOWNMOVES
-#define GLISTEN_TOUCHUPMOVES GLISTEN_MOUSEUPMOVES
-#define GLISTEN_TOUCHNOFILTER GLISTEN_MOUSENOFILTER
-
-#define GINPUT_MOUSE_NUM_PORTS 1 // The total number of mouse/touch inputs supported
-
-// Event types for the mouse ginput source
-#define GEVENT_MOUSE (GEVENT_GINPUT_FIRST+0)
-#define GEVENT_TOUCH (GEVENT_GINPUT_FIRST+1)
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /**
- * @brief Creates an instance of a mouse and returns the Source handler
- * @note hack: if the instance is 9999, no calibration will be performed!
- *
- * @param[in] instance The ID of the mouse input instance (from 0 to 9999)
- *
- * @return The source handle of the created instance
- */
- GSourceHandle ginputGetMouse(uint16_t instance);
-
- /**
- * @brief Get the current mouse position and button status
- * @note Unlinke a listener event, this status cannot record meta events such as
- * "CLICK".
- *
- * @param[in] instance The ID of the mouse input instance
- * @param[in] pmouse The mouse event
- *
- * @return FALSE on an error (eg. invalid instance)
- */
- bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pmouse);
-
- /**
- * @brief Performs a calibration
- *
- * @param[in] instance The ID of the mouse input instance
- *
- * @return FALSE if the driver dosen't support a calibration of if the handle is invalid
- */
- bool_t ginputCalibrateMouse(uint16_t instance);
-
- /* Set the routines to save and fetch calibration data.
- * This function should be called before first calling ginputGetMouse() for a particular instance
- * as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
- * If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the data is has already obtained.
- * The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
- */
- typedef void (*GMouseCalibrationSaveRoutine)(uint16_t instance, const uint8_t *calbuf, size_t sz); // Save calibration data
- typedef const char * (*GMouseCalibrationLoadRoutine)(uint16_t instance); // Load calibration data (returns NULL if not data saved)
-
- /**
- * @brief Set the routines to store and restore calibration data
- *
- * @details This function should be called before first calling ginputGetMouse() for a particular instance
- * as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
- * If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the
- * data is has already obtained.
- * The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
- *
- * @param[in] instance The ID of the mouse input instance
- * @param[in] fnsave The routine to save the data
- * @param[in] fnload The routine to restore the data
- * @param[in] requireFree ToDo
- */
- void ginputSetMouseCalibrationRoutines(uint16_t instance, GMouseCalibrationSaveRoutine fnsave, GMouseCalibrationLoadRoutine fnload, bool_t requireFree);
-
- /**
- * @brief Test if a particular mouse/touch instance requires routines to save it's alibration data
- * @note Not implemented yet
- *
- * @param[in] instance The ID of the mouse input instance
- *
- * @return TRUE if needed
- */
- bool_t ginputRequireMouseCalibrationStorage(uint16_t instance);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GINPUT_NEED_MOUSE */
-
-#endif /* _GINPUT_MOUSE_H */
-/** @} */
-
+ +/** + * @file include/ginput/mouse.h + * @brief GINPUT GFX User Input subsystem header file for mouse and touch. + * + * @defgroup Mouse Mouse + * @ingroup GINPUT + * + * @details GINPUT allows it to easily interface touchscreens and mices to + * your application. + * + * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h + * @pre GINPUT_NEED_MOUSE must be set to TRUE in your gfxconf.h + * + * @{ + */ + +#ifndef _GINPUT_MOUSE_H +#define _GINPUT_MOUSE_H + +#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +/* This type definition is also used by touch */ +typedef struct GEventMouse_t { + GEventType type; // The type of this event (GEVENT_MOUSE or GEVENT_TOUCH) + uint16_t instance; // The mouse/touch instance + coord_t x, y, z; // The position of the mouse. + // - For touch devices, Z is the current pressure if supported (otherwise 0) + // - For mice, Z is the 3rd dimension if supported (otherwise 0) + uint16_t current_buttons; // A bit is set if the button is down. + // - For touch only bit 0 is relevant + // - For mice the order of the buttons is (from 0 to n) left, right, middle, any other buttons + // - Bit 15 being set indicates that an important mouse event has been missed. + #define GINPUT_MOUSE_BTN_LEFT 0x0001 + #define GINPUT_MOUSE_BTN_RIGHT 0x0002 + #define GINPUT_MOUSE_BTN_MIDDLE 0x0004 + #define GINPUT_MOUSE_BTN_4 0x0008 + #define GINPUT_MISSED_MOUSE_EVENT 0x8000 + #define GINPUT_TOUCH_PRESSED GINPUT_MOUSE_BTN_LEFT + uint16_t last_buttons; // The value of current_buttons on the last event + enum GMouseMeta_e { + GMETA_NONE = 0, // There is no meta event currently happening + GMETA_MOUSE_DOWN = 1, // Button 0 has just gone down + GMETA_MOUSE_UP = 2, // Button 0 has just gone up + GMETA_MOUSE_CLICK = 4, // Button 0 has just gone through a short down - up cycle + GMETA_MOUSE_CXTCLICK = 8 // For mice - The right button has just been depressed + // For touch - a long press has just occurred + } meta; + } GEventMouse; + +// Mouse/Touch Listen Flags - passed to geventAddSourceToListener() +#define GLISTEN_MOUSEMETA 0x0001 // Create events for meta events such as CLICK and CXTCLICK +#define GLISTEN_MOUSEDOWNMOVES 0x0002 // Creates mouse move events when the primary mouse button is down (touch is on the surface) +#define GLISTEN_MOUSEUPMOVES 0x0004 // Creates mouse move events when the primary mouse button is up (touch is off the surface - if the hardware allows). +#define GLISTEN_MOUSENOFILTER 0x0008 // Don't filter out mouse moves where the position hasn't changed. +#define GLISTEN_TOUCHMETA GLISTEN_MOUSEMETA +#define GLISTEN_TOUCHDOWNMOVES GLISTEN_MOUSEDOWNMOVES +#define GLISTEN_TOUCHUPMOVES GLISTEN_MOUSEUPMOVES +#define GLISTEN_TOUCHNOFILTER GLISTEN_MOUSENOFILTER + +#define GINPUT_MOUSE_NUM_PORTS 1 // The total number of mouse/touch inputs supported + +// Event types for the mouse ginput source +#define GEVENT_MOUSE (GEVENT_GINPUT_FIRST+0) +#define GEVENT_TOUCH (GEVENT_GINPUT_FIRST+1) + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief Creates an instance of a mouse and returns the Source handler + * @note hack: if the instance is 9999, no calibration will be performed! + * + * @param[in] instance The ID of the mouse input instance (from 0 to 9999) + * + * @return The source handle of the created instance + */ + GSourceHandle ginputGetMouse(uint16_t instance); + + /** + * @brief Get the current mouse position and button status + * @note Unlinke a listener event, this status cannot record meta events such as + * "CLICK". + * + * @param[in] instance The ID of the mouse input instance + * @param[in] pmouse The mouse event + * + * @return FALSE on an error (eg. invalid instance) + */ + bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pmouse); + + /** + * @brief Performs a calibration + * + * @param[in] instance The ID of the mouse input instance + * + * @return FALSE if the driver dosen't support a calibration of if the handle is invalid + */ + bool_t ginputCalibrateMouse(uint16_t instance); + + /* Set the routines to save and fetch calibration data. + * This function should be called before first calling ginputGetMouse() for a particular instance + * as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it. + * If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the data is has already obtained. + * The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine. + */ + typedef void (*GMouseCalibrationSaveRoutine)(uint16_t instance, const uint8_t *calbuf, size_t sz); // Save calibration data + typedef const char * (*GMouseCalibrationLoadRoutine)(uint16_t instance); // Load calibration data (returns NULL if not data saved) + + /** + * @brief Set the routines to store and restore calibration data + * + * @details This function should be called before first calling ginputGetMouse() for a particular instance + * as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it. + * If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the + * data is has already obtained. + * The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine. + * + * @param[in] instance The ID of the mouse input instance + * @param[in] fnsave The routine to save the data + * @param[in] fnload The routine to restore the data + * @param[in] requireFree ToDo + */ + void ginputSetMouseCalibrationRoutines(uint16_t instance, GMouseCalibrationSaveRoutine fnsave, GMouseCalibrationLoadRoutine fnload, bool_t requireFree); + + /** + * @brief Test if a particular mouse/touch instance requires routines to save it's alibration data + * @note Not implemented yet + * + * @param[in] instance The ID of the mouse input instance + * + * @return TRUE if needed + */ + bool_t ginputRequireMouseCalibrationStorage(uint16_t instance); + +#ifdef __cplusplus +} +#endif + +#endif /* GINPUT_NEED_MOUSE */ + +#endif /* _GINPUT_MOUSE_H */ +/** @} */ + diff --git a/include/ginput/toggle.h b/include/ginput/toggle.h index 0910433b..ee3d8420 100644 --- a/include/ginput/toggle.h +++ b/include/ginput/toggle.h @@ -4,81 +4,97 @@ * * http://chibios-gfx.com/license.html */ -
-#ifndef _GINPUT_TOGGLE_H
-#define _GINPUT_TOGGLE_H
-
-#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Low Level Driver details and error checks. */
-/*===========================================================================*/
-
-// Get the hardware definitions - Number of instances etc.
-#include "ginput_lld_toggle_config.h"
-
-#ifndef GINPUT_TOGGLE_POLL_PERIOD
- #define GINPUT_TOGGLE_POLL_PERIOD 200
-#endif
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-// Event types for various ginput sources
-#define GEVENT_TOGGLE (GEVENT_GINPUT_FIRST+3)
-
-typedef struct GEventToggle_t {
- GEventType type; // The type of this event (GEVENT_TOGGLE)
- uint16_t instance; // The toggle instance
- bool_t on; // True if the toggle/button is on
- } GEventToggle;
-
-// Toggle Listen Flags - passed to geventAddSourceToListener()
-#define GLISTEN_TOGGLE_ON 0x0001 // Return an event when the toggle turns on
-#define GLISTEN_TOGGLE_OFF 0x0002 // Return an event when the toggle turns off
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /**
- * @brief Create a toggle input instance
- *
- * @param[in] instance The ID of the toggle input instance (from 0 to 9999)
- *
- * @return The source handle of the created instance
- */
- GSourceHandle ginputGetToggle(uint16_t instance);
-
- /**
- * @brief Can be used to invert the sense of a toggle
- *
- * @param[in] instance The ID of the toggle input instance
- * @param[in] invert If TRUE, will be inverted
- */
- void ginputInvertToggle(uint16_t instance, bool_t invert);
-
- /**
- * @brief Get the current toggle status
- *
- * @param[in] instance The ID of the toggle input instance
- * @param[in] ptoggle The toggle event struct
- *
- * @return Returns FALSE on an error (eg invalid instance)
- */
- bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GINPUT_NEED_TOGGLE */
-
-#endif /* _GINPUT_TOGGLE_H */
-/** @} */
-
+ +/** + * @file include/ginput/toggle.h + * @brief GINPUT GFX User Input subsystem header file. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * + * @details GINPUT allows it to interface toggle buttons easily to your + * application. + * + * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h + * @pre GINPUT_NEED_TOGGLE must be set to TRUE in your gfxconf.h + * + * @{ + */ + +#ifndef _GINPUT_TOGGLE_H +#define _GINPUT_TOGGLE_H + +#if GINPUT_NEED_TOGGLE || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Low Level Driver details and error checks. */ +/*===========================================================================*/ + +// Get the hardware definitions - Number of instances etc. +#include "ginput_lld_toggle_config.h" + +#ifndef GINPUT_TOGGLE_POLL_PERIOD + #define GINPUT_TOGGLE_POLL_PERIOD 200 +#endif + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +// Event types for various ginput sources +#define GEVENT_TOGGLE (GEVENT_GINPUT_FIRST+3) + +typedef struct GEventToggle_t { + GEventType type; // The type of this event (GEVENT_TOGGLE) + uint16_t instance; // The toggle instance + bool_t on; // True if the toggle/button is on + } GEventToggle; + +// Toggle Listen Flags - passed to geventAddSourceToListener() +#define GLISTEN_TOGGLE_ON 0x0001 // Return an event when the toggle turns on +#define GLISTEN_TOGGLE_OFF 0x0002 // Return an event when the toggle turns off + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief Create a toggle input instance + * + * @param[in] instance The ID of the toggle input instance (from 0 to 9999) + * + * @return The source handle of the created instance + */ + GSourceHandle ginputGetToggle(uint16_t instance); + + /** + * @brief Can be used to invert the sense of a toggle + * + * @param[in] instance The ID of the toggle input instance + * @param[in] invert If TRUE, will be inverted + */ + void ginputInvertToggle(uint16_t instance, bool_t invert); + + /** + * @brief Get the current toggle status + * + * @param[in] instance The ID of the toggle input instance + * @param[in] ptoggle The toggle event struct + * + * @return Returns FALSE on an error (eg invalid instance) + */ + bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle); + +#ifdef __cplusplus +} +#endif + +#endif /* GINPUT_NEED_TOGGLE */ + +#endif /* _GINPUT_TOGGLE_H */ +/** @} */ + |