From 9ee7c284e63fc419f70ffc3c53eb23590767ee08 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Sun, 7 Apr 2013 16:02:10 +1000 Subject: Add GINPUT Dial, simplify GWIN input assignment Added GINPUT Dial support and a driver that uses GADC to read the dial. Added support for Dial inputs to the GWIN slider. Updated the slider demo for Dial Inputs. Simplified the assigning of inputs to GWIN "widgets" button and slider. Updated the demo's to match the new input to button assignment. --- demos/modules/gwin/slider/main.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'demos/modules/gwin/slider/main.c') diff --git a/demos/modules/gwin/slider/main.c b/demos/modules/gwin/slider/main.c index 9a318943..19a56f6a 100644 --- a/demos/modules/gwin/slider/main.c +++ b/demos/modules/gwin/slider/main.c @@ -31,7 +31,7 @@ int main(void) { coord_t swidth, sheight; GHandle ghSliderH, ghSliderV, ghConsole; font_t fui2; - GSourceHandle gsMouse; + GEvent * pe; GEventGWinSlider * pSliderEvent; BaseSequentialStream *consout; @@ -58,10 +58,15 @@ int main(void) { gwinSetColor(ghConsole, White); gwinSetBgColor(ghConsole, Blue); - // Assign the mouse to the sliders. - gsMouse = ginputGetMouse(0); - gwinAttachSliderMouseSource(ghSliderH, gsMouse); - gwinAttachSliderMouseSource(ghSliderV, gsMouse); + // Assign the mouse and dials to the sliders. +#if GINPUT_NEED_MOUSE + gwinAttachSliderMouse(ghSliderH, 0); + gwinAttachSliderMouse(ghSliderV, 0); +#endif +#if GINPUT_NEED_DIAL + gwinAttachSliderDial(ghSliderV, 0); + gwinAttachSliderDial(ghSliderH, 1); +#endif // We want to listen for slider events geventListenerInit(&gl); @@ -75,14 +80,14 @@ int main(void) { while(1) { // Get an Event - // - we can assume it is a slider event as that is all we are listening for - pSliderEvent = (GEventGWinSlider *)geventEventWait(&gl, TIME_INFINITE); - - // Double check that assumption - if (pSliderEvent->type != GEVENT_GWIN_SLIDER) - continue; - - chprintf(consout, "%c=%d\n", pSliderEvent->slider == ghSliderH ? 'H' : 'V', pSliderEvent->position); + pe = geventEventWait(&gl, TIME_INFINITE); + + switch(pe->type) { + case GEVENT_GWIN_SLIDER: + pSliderEvent = (GEventGWinSlider *)pe; + chprintf(consout, "%c=%d\n", pSliderEvent->slider == ghSliderH ? 'H' : 'V', pSliderEvent->position); + break; + } } return 0; -- cgit v1.2.3