aboutsummaryrefslogtreecommitdiffstats
path: root/demos/modules/gwin
diff options
context:
space:
mode:
Diffstat (limited to 'demos/modules/gwin')
-rw-r--r--demos/modules/gwin/slider/gfxconf.h1
-rw-r--r--demos/modules/gwin/slider/main.c31
-rw-r--r--demos/modules/gwin/slider/readme.txt6
3 files changed, 25 insertions, 13 deletions
diff --git a/demos/modules/gwin/slider/gfxconf.h b/demos/modules/gwin/slider/gfxconf.h
index 477d7d29..947fc4c8 100644
--- a/demos/modules/gwin/slider/gfxconf.h
+++ b/demos/modules/gwin/slider/gfxconf.h
@@ -53,5 +53,6 @@
/* Features for the GINPUT sub-system. */
#define GINPUT_NEED_MOUSE TRUE
+#define GINPUT_NEED_DIAL TRUE
#endif /* _GFXCONF_H */
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;
diff --git a/demos/modules/gwin/slider/readme.txt b/demos/modules/gwin/slider/readme.txt
new file mode 100644
index 00000000..2864873a
--- /dev/null
+++ b/demos/modules/gwin/slider/readme.txt
@@ -0,0 +1,6 @@
+This demo supports input from both a mouse/touch and/or a dial input.
+If your platform does not support one or the other, turn it off in
+gfxconf.h
+
+Note that you will need to include the drivers into your project
+makefile for whichever inputs you decide to use. \ No newline at end of file