aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-12-20 18:32:33 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-12-20 18:32:33 +1000
commit9da1afa34ac189c7cc50aedd4df688bd0c9b66d7 (patch)
treeca2409e182f4ab61b8841c0c351c3d1f22d62a9f /src
parentb669bf98f1bc57672b222c6cdac759d0a30858ed (diff)
downloaduGFX-9da1afa34ac189c7cc50aedd4df688bd0c9b66d7.tar.gz
uGFX-9da1afa34ac189c7cc50aedd4df688bd0c9b66d7.tar.bz2
uGFX-9da1afa34ac189c7cc50aedd4df688bd0c9b66d7.zip
Using ginput with polling allow thread preemption
GINPUT when being exclusively polled by the application, did not allow pre-emption of the main thread and therefore some platforms (Win32) the mouse/toggle stopped working.
Diffstat (limited to 'src')
-rw-r--r--src/ginput/mouse.c4
-rw-r--r--src/ginput/toggle.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/ginput/mouse.c b/src/ginput/mouse.c
index 35a55bc5..94734888 100644
--- a/src/ginput/mouse.c
+++ b/src/ginput/mouse.c
@@ -378,6 +378,10 @@ 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);
+
if (instance || (MouseConfig.flags & (FLG_INIT_DONE|FLG_IN_CAL)) != FLG_INIT_DONE)
return FALSE;
diff --git a/src/ginput/toggle.c b/src/ginput/toggle.c
index 66021cd0..4401e295 100644
--- a/src/ginput/toggle.c
+++ b/src/ginput/toggle.c
@@ -145,6 +145,10 @@ void ginputInvertToggle(uint16_t instance, bool_t invert) {
* 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.
+ chThdSleepMilliseconds(1);
+
if (instance >= GINPUT_TOGGLE_NUM_PORTS)
return FALSE;
ptoggle->type = GEVENT_TOGGLE;