aboutsummaryrefslogtreecommitdiffstats
path: root/demos/modules
diff options
context:
space:
mode:
Diffstat (limited to 'demos/modules')
-rw-r--r--demos/modules/ginput/touch_driver_test/main.c12
-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
4 files changed, 29 insertions, 21 deletions
diff --git a/demos/modules/ginput/touch_driver_test/main.c b/demos/modules/ginput/touch_driver_test/main.c
index 95d29d28..c7866ec3 100644
--- a/demos/modules/ginput/touch_driver_test/main.c
+++ b/demos/modules/ginput/touch_driver_test/main.c
@@ -201,28 +201,24 @@ StepCalibrate:
gwinSetButtonText(ghNext, "Next", FALSE);
gsNext = gwinGetButtonSource(ghNext);
geventAttachSource(&gl, gsNext, 0);
- gwinAttachButtonMouseSource(ghNext, gs);
+ gwinAttachButtonMouse(ghNext, 0);
ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, font, GBTN_NORMAL);
gwinSetButtonText(ghPrev, "Back", FALSE);
gsPrev = gwinGetButtonSource(ghPrev);
geventAttachSource(&gl, gsPrev, 0);
- gwinAttachButtonMouseSource(ghPrev, gs);
+ gwinAttachButtonMouse(ghPrev, 0);
#if 0
{
- GSourceHandle gsButton1, gsButton2;
-
// Attach a couple of hardware toggle buttons to our Next and Back buttons as well.
// We can always use the mouse to trigger the buttons if you don't want to use hardware toggles.
// This code depends on your hardware. Turn it on only if you have
// defined a board definition for your toggle driver. Then change
// the next two lines to be correct for your hardware. The values
// below are correct for the Win32 toggle driver.
- gsButton1 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY1);
- gsButton2 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY2);
- gwinAttachButtonToggleSource(ghNext, gsButton2);
- gwinAttachButtonToggleSource(ghPrev, gsButton1);
+ gwinAttachButtonToggle(ghNext, GINPUT_TOGGLE_MOMENTARY1);
+ gwinAttachButtonToggle(ghPrev, GINPUT_TOGGLE_MOMENTARY2);
}
#endif
}
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