diff options
author | Tectu <joel@unormal.org> | 2013-04-07 02:59:42 -0700 |
---|---|---|
committer | Tectu <joel@unormal.org> | 2013-04-07 02:59:42 -0700 |
commit | 1d24b6977dd86d7fa68e5ddd451722430b371b78 (patch) | |
tree | 393c6669e4d683c84f53749e6ab189044d00f265 /demos/modules/gwin/slider/main.c | |
parent | 05aebebb8bcaa6213076ebf5e191974bb5741d46 (diff) | |
parent | 5412fa559673f46cdec652068eaaddcbb6271779 (diff) | |
download | uGFX-1d24b6977dd86d7fa68e5ddd451722430b371b78.tar.gz uGFX-1d24b6977dd86d7fa68e5ddd451722430b371b78.tar.bz2 uGFX-1d24b6977dd86d7fa68e5ddd451722430b371b78.zip |
Merge pull request #63 from inmarket/master
GINPUT Dial. Simplify input -> GWIN widget 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; |