diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2013-04-07 16:02:10 +1000 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2013-04-07 16:02:10 +1000 |
commit | 9ee7c284e63fc419f70ffc3c53eb23590767ee08 (patch) | |
tree | 57a45c0ca6e5222292bebb8445dffaff5757275b /demos/modules/gwin/slider/main.c | |
parent | 90f5e851467e5ea14b710ada937409e506820d58 (diff) | |
download | uGFX-9ee7c284e63fc419f70ffc3c53eb23590767ee08.tar.gz uGFX-9ee7c284e63fc419f70ffc3c53eb23590767ee08.tar.bz2 uGFX-9ee7c284e63fc419f70ffc3c53eb23590767ee08.zip |
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.
Diffstat (limited to 'demos/modules/gwin/slider/main.c')
-rw-r--r-- | demos/modules/gwin/slider/main.c | 31 |
1 files changed, 18 insertions, 13 deletions
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; |