diff options
author | inmarket <andrewh@inmarket.com.au> | 2013-05-25 01:26:52 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2013-05-25 01:26:52 +1000 |
commit | 7fbfde42aabbcd30cffba2fba35158236c0a6c6c (patch) | |
tree | e85c90a4f21974b706315d64209021e0b2bde764 /src/ginput | |
parent | 42006a67b5ccfd86f30d8a91cc474681c437eaf6 (diff) | |
download | uGFX-7fbfde42aabbcd30cffba2fba35158236c0a6c6c.tar.gz uGFX-7fbfde42aabbcd30cffba2fba35158236c0a6c6c.tar.bz2 uGFX-7fbfde42aabbcd30cffba2fba35158236c0a6c6c.zip |
GOS module, for operating system independance
GMISC fast floating point trig
GMISC fast fixed point trig
Diffstat (limited to 'src/ginput')
-rw-r--r-- | src/ginput/dial.c | 2 | ||||
-rw-r--r-- | src/ginput/ginput.c | 26 | ||||
-rw-r--r-- | src/ginput/ginput.mk | 3 | ||||
-rw-r--r-- | src/ginput/keyboard.c | 14 | ||||
-rw-r--r-- | src/ginput/mouse.c | 20 | ||||
-rw-r--r-- | src/ginput/toggle.c | 16 |
6 files changed, 50 insertions, 31 deletions
diff --git a/src/ginput/dial.c b/src/ginput/dial.c index c8bc7d0f..24836910 100644 --- a/src/ginput/dial.c +++ b/src/ginput/dial.c @@ -13,8 +13,6 @@ * @ingroup GINPUT * @{ */ -#include "ch.h" -#include "hal.h" #include "gfx.h" #if GFX_USE_GINPUT && GINPUT_NEED_DIAL diff --git a/src/ginput/ginput.c b/src/ginput/ginput.c new file mode 100644 index 00000000..96fa1449 --- /dev/null +++ b/src/ginput/ginput.c @@ -0,0 +1,26 @@ +/* + * This file is subject to the terms of the GFX License, v1.0. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://chibios-gfx.com/license.html + */ + +/** + * @file src/ginput/ginput.c + * @brief GINPUT subsystem common code. + * + * @addtogroup GINPUT + * @{ + */ +#include "gfx.h" + +#if GFX_USE_GINPUT + +/** + * This should really call an init routine for each ginput sub-system. + * Maybe we'll do this later. + */ +void _ginputInit(void) {} + +#endif /* GFX_USE_GINPUT */ +/** @} */ diff --git a/src/ginput/ginput.mk b/src/ginput/ginput.mk index 06bcfc07..ed34d46d 100644 --- a/src/ginput/ginput.mk +++ b/src/ginput/ginput.mk @@ -1,4 +1,5 @@ -GFXSRC += $(GFXLIB)/src/ginput/mouse.c \
+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
diff --git a/src/ginput/keyboard.c b/src/ginput/keyboard.c index 26d90ba9..99aa90e8 100644 --- a/src/ginput/keyboard.c +++ b/src/ginput/keyboard.c @@ -1,9 +1,9 @@ -/* - * This file is subject to the terms of the GFX License, v1.0. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://chibios-gfx.com/license.html - */ +/*
+ * This file is subject to the terms of the GFX License, v1.0. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://chibios-gfx.com/license.html
+ */
/**
* @file src/ginput/keyboard.c
@@ -15,8 +15,6 @@ * @{
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD) || defined(__DOXYGEN__)
diff --git a/src/ginput/mouse.c b/src/ginput/mouse.c index 7320cf2d..334fdb6c 100644 --- a/src/ginput/mouse.c +++ b/src/ginput/mouse.c @@ -13,8 +13,6 @@ * @ingroup GINPUT * @{ */ -#include "ch.h" -#include "hal.h" #include "gfx.h" #if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) || defined(__DOXYGEN__) @@ -58,7 +56,7 @@ static struct MouseConfig_t { MouseReading t; MousePoint movepos; MousePoint clickpos; - systime_t clicktime; + systemticks_t clicktime; uint16_t last_buttons; uint16_t flags; #define FLG_INIT_DONE 0x8000 @@ -253,7 +251,7 @@ static void MousePoll(void *param) { if ((tbtns & (GINPUT_MOUSE_BTN_LEFT|GINPUT_MOUSE_BTN_RIGHT))) { MouseConfig.clickpos.x = MouseConfig.t.x; MouseConfig.clickpos.y = MouseConfig.t.y; - MouseConfig.clicktime = chTimeNow(); + MouseConfig.clicktime = gfxSystemTicks(); MouseConfig.flags |= FLG_CLICK_TIMER; } @@ -265,7 +263,7 @@ static void MousePoll(void *param) { if ((MouseConfig.flags & FLG_CLICK_TIMER)) { if ((tbtns & GINPUT_MOUSE_BTN_LEFT) #if GINPUT_MOUSE_CLICK_TIME != TIME_INFINITE - && chTimeNow() - MouseConfig.clicktime < MS2ST(GINPUT_MOUSE_CLICK_TIME) + && gfxSystemTicks() - MouseConfig.clicktime < gfxMillisecondsToTicks(GINPUT_MOUSE_CLICK_TIME) #endif ) meta |= GMETA_MOUSE_CLICK; @@ -338,7 +336,7 @@ GSourceHandle ginputGetMouse(uint16_t instance) { MouseConfig.caldata = pc[0]; MouseConfig.flags |= (FLG_CAL_OK|FLG_CAL_SAVED); if ((MouseConfig.flags & FLG_CAL_FREE)) - chHeapFree((void *)pc); + gfxFree((void *)pc); } else if (instance == 9999) { MouseConfig.caldata.ax = 1; MouseConfig.caldata.bx = 0; @@ -367,7 +365,7 @@ GSourceHandle ginputGetMouse(uint16_t instance) { bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pe) { // 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. - chThdSleepMilliseconds(1); + gfxSleepMilliseconds(1); if (instance || (MouseConfig.flags & (FLG_INIT_DONE|FLG_IN_CAL)) != FLG_INIT_DONE) return FALSE; @@ -443,11 +441,11 @@ bool_t ginputCalibrateMouse(uint16_t instance) { /* Wait for the mouse to be pressed */ while(get_raw_reading(&MouseConfig.t), !(MouseConfig.t.buttons & GINPUT_MOUSE_BTN_LEFT)) - chThdSleepMilliseconds(20); + gfxSleepMilliseconds(20); /* Average all the samples while the mouse is down */ for(px = py = 0, j = 0; - chThdSleepMilliseconds(20), /* Settling time between readings */ + gfxSleepMilliseconds(20), /* Settling time between readings */ get_raw_reading(&MouseConfig.t), (MouseConfig.t.buttons & GINPUT_MOUSE_BTN_LEFT); j++) { @@ -464,7 +462,7 @@ bool_t ginputCalibrateMouse(uint16_t instance) { if (i >= 1 && pt->x == (pt-1)->x && pt->y == (pt-1)->y) { gdispFillStringBox(0, 35, width, 40, GINPUT_MOUSE_CALIBRATION_SAME_TEXT, font2, Red, Yellow, justifyCenter); - chThdSleepMilliseconds(5000); + gfxSleepMilliseconds(5000); gdispFillArea(0, 35, width, 40, Blue); } @@ -492,7 +490,7 @@ bool_t ginputCalibrateMouse(uint16_t instance) { break; gdispFillStringBox(0, 35, width, 40, GINPUT_MOUSE_CALIBRATION_ERROR_TEXT, font2, Red, Yellow, justifyCenter); - chThdSleepMilliseconds(5000); + gfxSleepMilliseconds(5000); } #endif diff --git a/src/ginput/toggle.c b/src/ginput/toggle.c index a2474c3e..2784a6ef 100644 --- a/src/ginput/toggle.c +++ b/src/ginput/toggle.c @@ -1,9 +1,9 @@ -/* - * This file is subject to the terms of the GFX License, v1.0. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://chibios-gfx.com/license.html - */ +/*
+ * This file is subject to the terms of the GFX License, v1.0. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://chibios-gfx.com/license.html
+ */
/**
* @file src/ginput/toggle.c
@@ -13,8 +13,6 @@ * @ingroup GINPUT
* @{
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__)
@@ -134,7 +132,7 @@ void ginputInvertToggle(uint16_t instance, bool_t invert) { 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.
- chThdSleepMilliseconds(1);
+ gfxSleepMilliseconds(1);
if (instance >= GINPUT_TOGGLE_NUM_PORTS)
return FALSE;
|