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. --- src/gwin/button.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/gwin/button.c') diff --git a/src/gwin/button.c b/src/gwin/button.c index bec738b4..74fe3080 100644 --- a/src/gwin/button.c +++ b/src/gwin/button.c @@ -68,7 +68,7 @@ static void gwinButtonCallback(void *param, GEvent *pe) { #define pbe ((GEventGWinButton *)pe) switch (pe->type) { - #if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE + #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE case GEVENT_MOUSE: case GEVENT_TOUCH: // Ignore anything other than the primary mouse button going up or down @@ -108,7 +108,7 @@ static void gwinButtonCallback(void *param, GEvent *pe) { #endif #endif - #if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE + #if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE case GEVENT_TOGGLE: // State has changed - update the button gbw->state = pxe->on ? GBTN_DOWN : GBTN_UP; @@ -375,18 +375,22 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu } #endif -#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE - bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh) { - if (gh->type != GW_BUTTON) +#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE + bool_t gwinAttachButtonMouse(GHandle gh, uint16_t instance) { + GSourceHandle gsh; + + if (gh->type != GW_BUTTON || !(gsh = ginputGetMouse(instance))) return FALSE; return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_MOUSEMETA); } #endif -#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE - bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh) { - if (gh->type != GW_BUTTON) +#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE + bool_t gwinAttachButtonToggle(GHandle gh, uint16_t instance) { + GSourceHandle gsh; + + if (gh->type != GW_BUTTON || !(gsh = ginputGetToggle(instance))) return FALSE; return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_TOGGLE_OFF|GLISTEN_TOGGLE_ON); -- cgit v1.2.3