diff options
author | Tectu <joel@unormal.org> | 2013-04-07 02:59:42 -0700 |
---|---|---|
committer | Tectu <joel@unormal.org> | 2013-04-07 02:59:42 -0700 |
commit | 1d24b6977dd86d7fa68e5ddd451722430b371b78 (patch) | |
tree | 393c6669e4d683c84f53749e6ab189044d00f265 /include | |
parent | 05aebebb8bcaa6213076ebf5e191974bb5741d46 (diff) | |
parent | 5412fa559673f46cdec652068eaaddcbb6271779 (diff) | |
download | uGFX-1d24b6977dd86d7fa68e5ddd451722430b371b78.tar.gz uGFX-1d24b6977dd86d7fa68e5ddd451722430b371b78.tar.bz2 uGFX-1d24b6977dd86d7fa68e5ddd451722430b371b78.zip |
Merge pull request #63 from inmarket/master
GINPUT Dial. Simplify input -> GWIN widget assignment
Diffstat (limited to 'include')
-rw-r--r-- | include/ginput/dial.h | 245 | ||||
-rw-r--r-- | include/ginput/lld/dial.h | 57 | ||||
-rw-r--r-- | include/ginput/lld/mouse.h | 302 | ||||
-rw-r--r-- | include/gwin/button.h | 22 | ||||
-rw-r--r-- | include/gwin/slider.h | 23 |
5 files changed, 388 insertions, 261 deletions
diff --git a/include/ginput/dial.h b/include/ginput/dial.h index c395f1da..358e36cf 100644 --- a/include/ginput/dial.h +++ b/include/ginput/dial.h @@ -1,123 +1,122 @@ -/*
- ChibiOS/GFX - Copyright (C) 2012, 2013
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS/GFX.
-
- ChibiOS/GFX is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/GFX is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @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
-
-#if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-// Event types for various ginput sources
-#define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4)
-
-typedef struct GEventDial_t {
- GEventType type; // The type of this event (GEVENT_DIAL)
- uint16_t instance; // The dial instance
- uint16_t value; // The dial value
- } GEventDial;
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /**
- * @brief Create a dial input instance
- *
- * @param[in] instance The ID of the dial input instance (from 0 to 9999)
- *
- * @return The soure handle of the created dial instance
- */
- GSourceHandle ginputGetDial(uint16_t instance);
-
- /**
- * @brief Reset the value back to the hardware default
- *
- * @param[in] instance The ID of the dial input instance
- */
- void ginputResetDialRange(uint16_t instance);
-
- /**
- * @brief Get the maximum value
- * @details The readings are scaled to be 0 ... max-1.
- * 0 means over the full uint16_t range.
- *
- * @param[in] instance The ID of the dial input instance
- *
- * @return The maximum value
- */
- uint16_t ginputGetDialRange(uint16_t instance);
-
- /**
- * @brief Set the maximum value
- * @note This shouldn't be set higher that the hardwares possible maximum value
- *
- * @param[in] instance The ID of the dial input instance
- * @param[in] max The maximum value to be set
- */
- void ginputSetDialRange(uint16_t instance, uint16_t max);
-
- /**
- * @brief Set the level change required before a dial even is generated (threshold)
- * @note This is done after range scaling
- *
- * @param[in] instance The ID of the dial input instance
- * @param[in] diff The amount of level changes
- */
- void ginputSetDialSensitivity(uint16_t instance, uint16_t diff);
-
- /**
- * @brief Get the current dial status
- *
- * @param[in] instance The ID of the dial input instance
- * @param[in] pdial The dial event struct
- *
- * @return Returns FALSE on an error (eg invalid instance)
- */
- bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GINPUT_NEED_DIAL */
-
-#endif /* _GINPUT_DIAL_H */
-/** @} */
+/* + ChibiOS/GFX - Copyright (C) 2012, 2013 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +/** + * @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 + +#if GINPUT_NEED_DIAL || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +// Event types for various ginput sources +#define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4) + +typedef struct GEventDial_t { + GEventType type; // The type of this event (GEVENT_DIAL) + uint16_t instance; // The dial instance + uint16_t value; // The dial value + } GEventDial; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief Create a dial input instance + * + * @param[in] instance The ID of the dial input instance (from 0 to 9999) + * + * @return The soure handle of the created dial instance + */ + GSourceHandle ginputGetDial(uint16_t instance); + + /** + * @brief Reset the value back to the hardware default + * + * @param[in] instance The ID of the dial input instance + */ + void ginputResetDialRange(uint16_t instance); + + /** + * @brief Get the maximum value + * @details The readings are scaled to be 0 ... max. + * + * @param[in] instance The ID of the dial input instance + * + * @return The maximum value + */ + uint16_t ginputGetDialRange(uint16_t instance); + + /** + * @brief Set the maximum value + * @details The readings are scaled to be 0 ... max. + * + * @param[in] instance The ID of the dial input instance + * @param[in] max The maximum value to be set + */ + void ginputSetDialRange(uint16_t instance, uint16_t max); + + /** + * @brief Set the level change required before a dial even is generated (threshold) + * @note This is done after range scaling + * + * @param[in] instance The ID of the dial input instance + * @param[in] diff The amount of level changes + */ + void ginputSetDialSensitivity(uint16_t instance, uint16_t diff); + + /** + * @brief Get the current dial status + * + * @param[in] instance The ID of the dial input instance + * @param[in] pdial The dial event struct + * + * @return Returns FALSE on an error (eg invalid instance) + */ + bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial); + +#ifdef __cplusplus +} +#endif + +#endif /* GINPUT_NEED_DIAL */ + +#endif /* _GINPUT_DIAL_H */ +/** @} */ diff --git a/include/ginput/lld/dial.h b/include/ginput/lld/dial.h new file mode 100644 index 00000000..3efae04f --- /dev/null +++ b/include/ginput/lld/dial.h @@ -0,0 +1,57 @@ +/* + ChibiOS/GFX - Copyright (C) 2012, 2013 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +/** + * @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 + +#if GINPUT_NEED_DIAL || defined(__DOXYGEN__) + +#include "ginput_lld_dial_config.h" + +typedef void (*DialCallbackFn)(uint16_t instance, uint16_t rawvalue); + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + void ginput_lld_dial_init(void); + void ginput_lld_dial_poll(DialCallbackFn fn); + +#ifdef __cplusplus +} +#endif + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ + +#endif /* _LLD_GINPUT_TOGGLE_H */ +/** @} */ + diff --git a/include/ginput/lld/mouse.h b/include/ginput/lld/mouse.h index 48e47bde..05de28bf 100644 --- a/include/ginput/lld/mouse.h +++ b/include/ginput/lld/mouse.h @@ -1,121 +1,181 @@ -/*
- ChibiOS/GFX - Copyright (C) 2012, 2013
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS/GFX.
-
- ChibiOS/GFX is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/GFX is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @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
-
-#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__)
-
-#include "ginput_lld_mouse_config.h"
-
-// GEVENT_MOUSE or GEVENT_TOUCH - What type of device is this.
-#ifndef GINPUT_MOUSE_EVENT_TYPE
- #define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE
-#endif
-
-// TRUE/FALSE - Does the mouse/touch driver require calibration?
-#ifndef GINPUT_MOUSE_NEED_CALIBRATION
- #define GINPUT_MOUSE_NEED_CALIBRATION FALSE
-#endif
-
-// TRUE/FALSE - Can the mouse/touch driver itself save calibration data?
-#ifndef GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE
- #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
-#endif
-
-// n or -1 - n means to test calibration result (+/- pixels), -1 means not to.
-#ifndef GINPUT_MOUSE_MAX_CALIBRATION_ERROR
- #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1
-#endif
-
-// n - How many times to read (and average) per poll
-#ifndef GINPUT_MOUSE_READ_CYCLES
- #define GINPUT_MOUSE_READ_CYCLES 1
-#endif
-
-// n - Millisecs between poll's
-#ifndef GINPUT_MOUSE_POLL_PERIOD
- #define GINPUT_MOUSE_POLL_PERIOD 25
-#endif
-
-// n - Movement allowed without discarding the CLICK or CLICKCXT event (+/- pixels)
-#ifndef GINPUT_MOUSE_MAX_CLICK_JITTER
- #define GINPUT_MOUSE_MAX_CLICK_JITTER 1
-#endif
-
-// n - Movement allowed without discarding the MOVE event (+/- pixels)
-#ifndef GINPUT_MOUSE_MAX_MOVE_JITTER
- #define GINPUT_MOUSE_MAX_MOVE_JITTER 0
-#endif
-
-// ms - Millisecs seperating a CLICK from a CXTCLICK
-#ifndef GINPUT_MOUSE_CLICK_TIME
- #define GINPUT_MOUSE_CLICK_TIME 700
-#endif
-
-
-typedef struct MouseReading_t {
- coord_t x, y, z;
- uint16_t buttons;
- } MouseReading;
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- void ginput_lld_mouse_init(void);
- void ginput_lld_mouse_get_reading(MouseReading *pt);
-
- #if GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE
- const char *ginput_lld_mouse_calibration_load(uint16_t instance);
- void ginput_lld_mouse_calibration_save(uint16_t instance, const uint8_t *calbuf, size_t sz);
- #endif
-
- /* This routine is provided to low level drivers to wakeup a value read from a thread context.
- * Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE
- */
- void ginputMouseWakeup(void);
-
- /* This routine is provided to low level drivers to wakeup a value read from an ISR
- * Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE
- */
- void ginputMouseWakeupI(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GINPUT_NEED_MOUSE || GINPUT_NEED_TOUCH */
-
-#endif /* _LLD_GINPUT_MOUSE_H */
-/** @} */
-
+/* + ChibiOS/GFX - Copyright (C) 2012, 2013 + Joel Bodenmann aka Tectu <joel@unormal.org> + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/GFX is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +/** + * @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 + +#if GINPUT_NEED_MOUSE || defined(__DOXYGEN__) + +#include "ginput_lld_mouse_config.h" + +// GEVENT_MOUSE or GEVENT_TOUCH - What type of device is this. +#ifndef GINPUT_MOUSE_EVENT_TYPE + #define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE +#endif + +// TRUE/FALSE - Does the mouse/touch driver require calibration? +#ifndef GINPUT_MOUSE_NEED_CALIBRATION + #define GINPUT_MOUSE_NEED_CALIBRATION FALSE +#endif + +// TRUE/FALSE - Can the mouse/touch driver itself save calibration data? +#ifndef GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE + #define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE +#endif + +// n or -1 - n means to test calibration result (+/- pixels), -1 means not to. +#ifndef GINPUT_MOUSE_MAX_CALIBRATION_ERROR + #define GINPUT_MOUSE_MAX_CALIBRATION_ERROR -1 +#endif + +// n - How many times to read (and average) per poll +#ifndef GINPUT_MOUSE_READ_CYCLES + #define GINPUT_MOUSE_READ_CYCLES 1 +#endif + +// n - Millisecs between poll's +#ifndef GINPUT_MOUSE_POLL_PERIOD + #define GINPUT_MOUSE_POLL_PERIOD 25 +#endif + +// n - Movement allowed without discarding the CLICK or CLICKCXT event (+/- pixels) +#ifndef GINPUT_MOUSE_MAX_CLICK_JITTER + #define GINPUT_MOUSE_MAX_CLICK_JITTER 1 +#endif + +// n - Movement allowed without discarding the MOVE event (+/- pixels) +#ifndef GINPUT_MOUSE_MAX_MOVE_JITTER + #define GINPUT_MOUSE_MAX_MOVE_JITTER 0 +#endif + +// ms - Millisecs seperating a CLICK from a CXTCLICK +#ifndef GINPUT_MOUSE_CLICK_TIME + #define GINPUT_MOUSE_CLICK_TIME 700 +#endif + + +typedef struct MouseReading_t { + coord_t x, y, z; + uint16_t buttons; + } MouseReading; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief Initialise the mouse/touch. + * + * @notapi + */ + void ginput_lld_mouse_init(void); + + /** + * @brief Read the mouse/touch position. + * + * @param[in] pt A pointer to the structure to fill + * + * @note For drivers that don't support returning a position + * when the touch is up (most touch devices), it should + * return the previous position with the new Z value. + * The z value is the pressure for those touch devices + * that support it (-100 to 100 where > 0 is touched) + * or, 0 or 100 for those drivers that don't. + * + * @notapi + */ + void ginput_lld_mouse_get_reading(MouseReading *pt); + + #if GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE + /** + * @brief Load calibration data from a storage area on the touch controller. + * + * @param[in] instance The mouse instance number + * + * @note The instance parameter is currently always 0 as we only support + * one mouse/touch device at a time. + * @note This routine should only be provided if the driver has its own + * storage area where calibration data can be stored. The drivers + * option.h file should define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE = TRUE + * if it supports this. + * + * @notapi + */ + const char *ginput_lld_mouse_calibration_load(uint16_t instance); + /** + * @brief Save calibration data to a storage area on the touch controller. + * + * @param[in] instance The mouse instance number + * @param[in] calbuf The calibration data to be saved + * @param[in] sz The size of the calibration data + * + * @note The instance parameter is currently always 0 as we only support + * one mouse/touch device at a time. + * @note This routine should only be provided if the driver has its own + * storage area where calibration data can be stored. The drivers + * option.h file should define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE = TRUE + * if it supports this. + * + * @notapi + */ + void ginput_lld_mouse_calibration_save(uint16_t instance, const uint8_t *calbuf, size_t sz); + #endif + + /** + * @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 + * @note Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE + * + * @notapi + */ + void ginputMouseWakeup(void); + + /** + * @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 + * @note Particularly useful if GINPUT_MOUSE_POLL_PERIOD = TIME_INFINITE + * + * @icode + * @notapi + */ + void ginputMouseWakeupI(void); + +#ifdef __cplusplus +} +#endif + +#endif /* GINPUT_NEED_MOUSE || GINPUT_NEED_TOUCH */ + +#endif /* _LLD_GINPUT_MOUSE_H */ +/** @} */ diff --git a/include/gwin/button.h b/include/gwin/button.h index 2df540da..3d54afbb 100644 --- a/include/gwin/button.h +++ b/include/gwin/button.h @@ -180,30 +180,28 @@ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param); */ #define gwinGetButtonSource(gh) ((GSourceHandle)(gh)) -#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE +#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE /** - * @brief Attach a mouse source - * @details Attach a mouse source to a given button + * @brief Attach a mouse to a button * - * @param[in] gh The button handle - * @param[in] gsh The source handle + * @param[in] gh The button handle + * @param[in] instance The mouse instance * * @api */ - bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh); + bool_t gwinAttachButtonMouse(GHandle gh, uint16_t instance); #endif -#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE +#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE /** - * @brief Attach a toggle source - * @details Attach a toggle source to this button + * @brief Attach a toggle to a button * - * @param[in] gh The button handle - * @param[in] gsh The source handle + * @param[in] gh The button handle + * @param[in] instance The toggle instance * * @api */ - bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh); + bool_t gwinAttachButtonToggle(GHandle gh, uint16_t instance); #endif /** diff --git a/include/gwin/slider.h b/include/gwin/slider.h index 412900a5..1943729f 100644 --- a/include/gwin/slider.h +++ b/include/gwin/slider.h @@ -187,17 +187,30 @@ void gwinSetSliderCustom(GHandle gh, GSliderDrawFunction fn, void *param); */ #define gwinGetSliderSource(gh) ((GSourceHandle)(gh)) -#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE +#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE /** * @brief Attach a mouse source - * @details Attach a mouse source to a slider + * @details Attach a mouse to a slider * - * @param[in] gh The slider handle - * @param[in] gsh The source handle + * @param[in] gh The slider handle + * @param[in] instance The mouse instance * * @api */ - bool_t gwinAttachSliderMouseSource(GHandle gh, GSourceHandle gsh); + bool_t gwinAttachSliderMouse(GHandle gh, uint16_t instance); +#endif + +#if GFX_USE_GINPUT && GINPUT_NEED_DIAL + /** + * @brief Attach a dial source + * @details Attach a dial to a slider + * + * @param[in] gh The dial handle + * @param[in] instance The dial instance + * + * @api + */ + bool_t gwinAttachSliderDial(GHandle gh, uint16_t instance); #endif /** |