aboutsummaryrefslogtreecommitdiffstats
path: root/src/ginput/mouse.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-05-25 01:26:52 +1000
committerinmarket <andrewh@inmarket.com.au>2013-05-25 01:26:52 +1000
commit7fbfde42aabbcd30cffba2fba35158236c0a6c6c (patch)
treee85c90a4f21974b706315d64209021e0b2bde764 /src/ginput/mouse.c
parent42006a67b5ccfd86f30d8a91cc474681c437eaf6 (diff)
downloaduGFX-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/mouse.c')
-rw-r--r--src/ginput/mouse.c20
1 files changed, 9 insertions, 11 deletions
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