diff options
Diffstat (limited to 'src/ginput')
-rw-r--r-- | src/ginput/ginput_dial.c (renamed from src/ginput/dial.c) | 4 | ||||
-rw-r--r-- | src/ginput/ginput_dial.h (renamed from src/ginput/dial.h) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_ginput.c (renamed from src/ginput/ginput.c) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_keyboard.c (renamed from src/ginput/keyboard.c) | 46 | ||||
-rw-r--r-- | src/ginput/ginput_keyboard.h (renamed from src/ginput/keyboard.h) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_mouse.c (renamed from src/ginput/mouse.c) | 4 | ||||
-rw-r--r-- | src/ginput/ginput_mouse.h (renamed from src/ginput/mouse.h) | 2 | ||||
-rw-r--r-- | src/ginput/ginput_toggle.c (renamed from src/ginput/toggle.c) | 312 | ||||
-rw-r--r-- | src/ginput/ginput_toggle.h (renamed from src/ginput/toggle.h) | 2 | ||||
-rw-r--r-- | src/ginput/sys_defs.h | 8 | ||||
-rw-r--r-- | src/ginput/sys_make.mk | 10 |
11 files changed, 197 insertions, 197 deletions
diff --git a/src/ginput/dial.c b/src/ginput/ginput_dial.c index 410efc1a..6af89b31 100644 --- a/src/ginput/dial.c +++ b/src/ginput/ginput_dial.c @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/dial.c + * @file src/ginput/ginput_dial.c * @brief GINPUT dial code. * * @defgroup Dial Dial @@ -17,7 +17,7 @@ #if GFX_USE_GINPUT && GINPUT_NEED_DIAL -#include "src/ginput/driver_dial.h" +#include "driver_dial.h" static GTIMER_DECL(DialTimer); static struct DialStatus_t { diff --git a/src/ginput/dial.h b/src/ginput/ginput_dial.h index f2d3fb58..88a2e165 100644 --- a/src/ginput/dial.h +++ b/src/ginput/ginput_dial.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/dial.h + * @file src/ginput/ginput_dial.h * @brief GINPUT GFX User Input subsystem header file. * * @defgroup Dial Dial diff --git a/src/ginput/ginput.c b/src/ginput/ginput_ginput.c index abd16cd8..4197fa25 100644 --- a/src/ginput/ginput.c +++ b/src/ginput/ginput_ginput.c @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/ginput.c + * @file src/ginput/ginput_ginput.c * @brief GINPUT subsystem common code. * * @addtogroup GINPUT diff --git a/src/ginput/keyboard.c b/src/ginput/ginput_keyboard.c index 98fad414..5443572b 100644 --- a/src/ginput/keyboard.c +++ b/src/ginput/ginput_keyboard.c @@ -1,23 +1,23 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/ginput/keyboard.c
- * @brief GINPUT keyboard code.
- *
- * @defgroup Keyboard Keyboard
- * @ingroup GINPUT
- *
- * @{
- */
-
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD) || defined(__DOXYGEN__)
- #error "GINPUT: GINPUT_NEED_KEYBOARD - Not Implemented Yet"
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD */
-/** @} */
+/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/ginput/ginput_keyboard.c + * @brief GINPUT keyboard code. + * + * @defgroup Keyboard Keyboard + * @ingroup GINPUT + * + * @{ + */ + +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD) || defined(__DOXYGEN__) + #error "GINPUT: GINPUT_NEED_KEYBOARD - Not Implemented Yet" +#endif /* GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD */ +/** @} */ diff --git a/src/ginput/keyboard.h b/src/ginput/ginput_keyboard.h index eff5cc6f..f5737255 100644 --- a/src/ginput/keyboard.h +++ b/src/ginput/ginput_keyboard.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/keyboard.h + * @file src/ginput/ginput_keyboard.h * @brief GINPUT GFX User Input subsystem header file. * * @defgroup Keyboard Keyboard diff --git a/src/ginput/mouse.c b/src/ginput/ginput_mouse.c index 1f1a18fe..772e300b 100644 --- a/src/ginput/mouse.c +++ b/src/ginput/ginput_mouse.c @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/mouse.c + * @file src/ginput/ginput_mouse.c * @brief GINPUT mouse/touch code. * * @defgroup Mouse Mouse @@ -17,7 +17,7 @@ #if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) || defined(__DOXYGEN__) -#include "src/ginput/driver_mouse.h" +#include "driver_mouse.h" #if !GINPUT_TOUCH_NOCALIBRATE #if !defined(GFX_USE_GDISP) || !GFX_USE_GDISP diff --git a/src/ginput/mouse.h b/src/ginput/ginput_mouse.h index 79ad1f08..61ad35e0 100644 --- a/src/ginput/mouse.h +++ b/src/ginput/ginput_mouse.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/mouse.h + * @file src/ginput/ginput_mouse.h * @brief GINPUT GFX User Input subsystem header file for mouse and touch. * * @defgroup Mouse Mouse diff --git a/src/ginput/toggle.c b/src/ginput/ginput_toggle.c index aad9c862..4c6dc9ae 100644 --- a/src/ginput/toggle.c +++ b/src/ginput/ginput_toggle.c @@ -1,156 +1,156 @@ -/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/ginput/toggle.c
- * @brief GINPUT toggle code.
- *
- * @defgroup Toggle Toggle
- * @ingroup GINPUT
- * @{
- */
-#include "gfx.h"
-
-#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__)
-
-#include "src/ginput/driver_toggle.h"
-
-#define GINPUT_TOGGLE_ISON 0x01
-#define GINPUT_TOGGLE_INVERT 0x02
-
-static GTIMER_DECL(ToggleTimer);
-static struct GEventToggleStatus_t {
- uint8_t status;
-} ToggleStatus[GINPUT_TOGGLE_NUM_PORTS];
-
-// Our polling function
-static void TogglePoll(void *param) {
- (void) param;
-
- const GToggleConfig *ptc;
- GSourceListener *psl;
- GEventToggle *pe;
- unsigned i, bits, mask;
- uint8_t state;
-
- // Loop while there are bits to get
- for(ptc = GInputToggleConfigTable, i=0; i < GINPUT_TOGGLE_NUM_PORTS; ptc++) {
-
- // Get the next block of bits
- bits = ginput_lld_toggle_getbits(ptc) ^ ptc->invert;
-
- // Extract the bits of use
- for(mask = ptc->mask; i < GINPUT_TOGGLE_NUM_PORTS && mask; mask >>= 1, bits >>= 1) {
- // Ignore bits not in our mask
- if (!(mask & 1))
- continue;
-
- // Calculate our new state
- state = ToggleStatus[i].status & ~GINPUT_TOGGLE_ISON;
- if (state & GINPUT_TOGGLE_INVERT)
- bits ^= 1;
- if (bits & 1)
- state |= GINPUT_TOGGLE_ISON;
-
- // Has it changed?
- if ((state ^ ToggleStatus[i].status) & GINPUT_TOGGLE_ISON) {
-
- // Save the new state
- ToggleStatus[i].status = state;
-
- // Send the event to the listeners that are interested.
- psl = 0;
- while ((psl = geventGetSourceListener((GSourceHandle)(ToggleStatus+i), psl))) {
- if (!(pe = (GEventToggle *)geventGetEventBuffer(psl)))
- continue;
- if ((state & GINPUT_TOGGLE_ISON)) {
- if ((psl->listenflags & GLISTEN_TOGGLE_ON)) {
- pe->type = GEVENT_TOGGLE;
- pe->instance = i;
- pe->on = TRUE;
- geventSendEvent(psl);
- }
- } else {
- if ((psl->listenflags & GLISTEN_TOGGLE_OFF)) {
- pe->type = GEVENT_TOGGLE;
- pe->instance = i;
- pe->on = FALSE;
- geventSendEvent(psl);
- }
- }
- }
- }
-
- // Next toggle switch
- i++;
- }
- }
-}
-
-/* Hardware Toggle/Switch/Button Functions */
-GSourceHandle ginputGetToggle(uint16_t instance) {
- const GToggleConfig *ptc;
-
- if (instance >= GINPUT_TOGGLE_NUM_PORTS)
- return 0;
-
- // Do we need to initialise the toggle subsystem?
- if (!gtimerIsActive(&ToggleTimer)) {
- for(ptc = GInputToggleConfigTable; ptc < GInputToggleConfigTable+sizeof(GInputToggleConfigTable)/sizeof(GInputToggleConfigTable[0]); ptc++)
- ginput_lld_toggle_init(ptc);
- gtimerStart(&ToggleTimer, TogglePoll, 0, TRUE, GINPUT_TOGGLE_POLL_PERIOD);
- }
-
- // OK - return this input
- return (GSourceHandle)(ToggleStatus+instance);
-}
-
-// If invert is true, invert the on/off sense for the toggle
-void ginputInvertToggle(uint16_t instance, bool_t invert) {
- if (instance >= GINPUT_TOGGLE_NUM_PORTS)
- return;
- if (invert) {
- if (!(ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) {
- ToggleStatus[instance].status |= GINPUT_TOGGLE_INVERT;
- ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON;
- }
- } else {
- if ((ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) {
- ToggleStatus[instance].status &= ~GINPUT_TOGGLE_INVERT;
- ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON;
- }
- }
-}
-
-/* Get the current toggle status.
- * Returns FALSE on error (eg invalid instance)
- */
-bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) {
- // Win32 threads don't seem to recognise priority and/or pre-emption
- // so we add a sleep here to prevent 100% polled applications from locking up.
- gfxSleepMilliseconds(1);
-
- if (instance >= GINPUT_TOGGLE_NUM_PORTS)
- return FALSE;
- ptoggle->type = GEVENT_TOGGLE;
- ptoggle->instance = instance;
- ptoggle->on = (ToggleStatus[instance].status & GINPUT_TOGGLE_ISON) ? TRUE : FALSE;
- return TRUE;
-}
-
-/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */
-void ginputToggleWakeup(void) {
- gtimerJab(&ToggleTimer);
-}
-
-/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */
-void ginputToggleWakeupI(void) {
- gtimerJabI(&ToggleTimer);
-}
-
-#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
-/** @} */
+/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file src/ginput/ginput_toggle.c + * @brief GINPUT toggle code. + * + * @defgroup Toggle Toggle + * @ingroup GINPUT + * @{ + */ +#include "gfx.h" + +#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__) + +#include "driver_toggle.h" + +#define GINPUT_TOGGLE_ISON 0x01 +#define GINPUT_TOGGLE_INVERT 0x02 + +static GTIMER_DECL(ToggleTimer); +static struct GEventToggleStatus_t { + uint8_t status; +} ToggleStatus[GINPUT_TOGGLE_NUM_PORTS]; + +// Our polling function +static void TogglePoll(void *param) { + (void) param; + + const GToggleConfig *ptc; + GSourceListener *psl; + GEventToggle *pe; + unsigned i, bits, mask; + uint8_t state; + + // Loop while there are bits to get + for(ptc = GInputToggleConfigTable, i=0; i < GINPUT_TOGGLE_NUM_PORTS; ptc++) { + + // Get the next block of bits + bits = ginput_lld_toggle_getbits(ptc) ^ ptc->invert; + + // Extract the bits of use + for(mask = ptc->mask; i < GINPUT_TOGGLE_NUM_PORTS && mask; mask >>= 1, bits >>= 1) { + // Ignore bits not in our mask + if (!(mask & 1)) + continue; + + // Calculate our new state + state = ToggleStatus[i].status & ~GINPUT_TOGGLE_ISON; + if (state & GINPUT_TOGGLE_INVERT) + bits ^= 1; + if (bits & 1) + state |= GINPUT_TOGGLE_ISON; + + // Has it changed? + if ((state ^ ToggleStatus[i].status) & GINPUT_TOGGLE_ISON) { + + // Save the new state + ToggleStatus[i].status = state; + + // Send the event to the listeners that are interested. + psl = 0; + while ((psl = geventGetSourceListener((GSourceHandle)(ToggleStatus+i), psl))) { + if (!(pe = (GEventToggle *)geventGetEventBuffer(psl))) + continue; + if ((state & GINPUT_TOGGLE_ISON)) { + if ((psl->listenflags & GLISTEN_TOGGLE_ON)) { + pe->type = GEVENT_TOGGLE; + pe->instance = i; + pe->on = TRUE; + geventSendEvent(psl); + } + } else { + if ((psl->listenflags & GLISTEN_TOGGLE_OFF)) { + pe->type = GEVENT_TOGGLE; + pe->instance = i; + pe->on = FALSE; + geventSendEvent(psl); + } + } + } + } + + // Next toggle switch + i++; + } + } +} + +/* Hardware Toggle/Switch/Button Functions */ +GSourceHandle ginputGetToggle(uint16_t instance) { + const GToggleConfig *ptc; + + if (instance >= GINPUT_TOGGLE_NUM_PORTS) + return 0; + + // Do we need to initialise the toggle subsystem? + if (!gtimerIsActive(&ToggleTimer)) { + for(ptc = GInputToggleConfigTable; ptc < GInputToggleConfigTable+sizeof(GInputToggleConfigTable)/sizeof(GInputToggleConfigTable[0]); ptc++) + ginput_lld_toggle_init(ptc); + gtimerStart(&ToggleTimer, TogglePoll, 0, TRUE, GINPUT_TOGGLE_POLL_PERIOD); + } + + // OK - return this input + return (GSourceHandle)(ToggleStatus+instance); +} + +// If invert is true, invert the on/off sense for the toggle +void ginputInvertToggle(uint16_t instance, bool_t invert) { + if (instance >= GINPUT_TOGGLE_NUM_PORTS) + return; + if (invert) { + if (!(ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) { + ToggleStatus[instance].status |= GINPUT_TOGGLE_INVERT; + ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON; + } + } else { + if ((ToggleStatus[instance].status & GINPUT_TOGGLE_INVERT)) { + ToggleStatus[instance].status &= ~GINPUT_TOGGLE_INVERT; + ToggleStatus[instance].status ^= GINPUT_TOGGLE_ISON; + } + } +} + +/* Get the current toggle status. + * Returns FALSE on error (eg invalid instance) + */ +bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) { + // Win32 threads don't seem to recognise priority and/or pre-emption + // so we add a sleep here to prevent 100% polled applications from locking up. + gfxSleepMilliseconds(1); + + if (instance >= GINPUT_TOGGLE_NUM_PORTS) + return FALSE; + ptoggle->type = GEVENT_TOGGLE; + ptoggle->instance = instance; + ptoggle->on = (ToggleStatus[instance].status & GINPUT_TOGGLE_ISON) ? TRUE : FALSE; + return TRUE; +} + +/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */ +void ginputToggleWakeup(void) { + gtimerJab(&ToggleTimer); +} + +/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */ +void ginputToggleWakeupI(void) { + gtimerJabI(&ToggleTimer); +} + +#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */ +/** @} */ diff --git a/src/ginput/toggle.h b/src/ginput/ginput_toggle.h index 40149754..7fc075d6 100644 --- a/src/ginput/toggle.h +++ b/src/ginput/ginput_toggle.h @@ -6,7 +6,7 @@ */ /** - * @file src/ginput/toggle.h + * @file src/ginput/ginput_toggle.h * @brief GINPUT GFX User Input subsystem header file. * * @defgroup Toggle Toggle diff --git a/src/ginput/sys_defs.h b/src/ginput/sys_defs.h index 33259da4..cab1e15d 100644 --- a/src/ginput/sys_defs.h +++ b/src/ginput/sys_defs.h @@ -39,10 +39,10 @@ */ // Include various ginput types -#include "src/ginput/mouse.h" -#include "src/ginput/keyboard.h" -#include "src/ginput/toggle.h" -#include "src/ginput/dial.h" +#include "ginput_mouse.h" +#include "ginput_keyboard.h" +#include "ginput_toggle.h" +#include "ginput_dial.h" #endif /* GFX_USE_GINPUT */ diff --git a/src/ginput/sys_make.mk b/src/ginput/sys_make.mk index 34ac4a55..9abe1645 100644 --- a/src/ginput/sys_make.mk +++ b/src/ginput/sys_make.mk @@ -1,5 +1,5 @@ -GFXSRC += $(GFXLIB)/src/ginput/ginput.c \ - $(GFXLIB)/src/ginput/mouse.c \ - $(GFXLIB)/src/ginput/keyboard.c \ - $(GFXLIB)/src/ginput/toggle.c \ - $(GFXLIB)/src/ginput/dial.c +GFXSRC += $(GFXLIB)/src/ginput/ginput_ginput.c \ + $(GFXLIB)/src/ginput/ginput_mouse.c \ + $(GFXLIB)/src/ginput/ginput_keyboard.c \ + $(GFXLIB)/src/ginput/ginput_toggle.c \ + $(GFXLIB)/src/ginput/ginput_dial.c |