Split Attaching Sources to a GWIN button
Split Attaching Sources to a GWIN button to allow for new input types that require a parameter in future eg. Keyboard will require a parameter.
This commit is contained in:
parent
a2c192ffd0
commit
74e94d39b9
3 changed files with 27 additions and 27 deletions
|
@ -201,13 +201,13 @@ StepCalibrate:
|
||||||
gwinSetButtonText(ghNext, "Next", FALSE);
|
gwinSetButtonText(ghNext, "Next", FALSE);
|
||||||
gsNext = gwinGetButtonSource(ghNext);
|
gsNext = gwinGetButtonSource(ghNext);
|
||||||
geventAttachSource(&gl, gsNext, 0);
|
geventAttachSource(&gl, gsNext, 0);
|
||||||
gwinAttachButtonSource(ghNext, gs, GEVENT_MOUSE);
|
gwinAttachButtonMouseSource(ghNext, gs);
|
||||||
|
|
||||||
ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, &fontUI2, GBTN_NORMAL);
|
ghPrev = gwinCreateButton(&gPrev, swidth-100, 0, 50, 20, &fontUI2, GBTN_NORMAL);
|
||||||
gwinSetButtonText(ghPrev, "Back", FALSE);
|
gwinSetButtonText(ghPrev, "Back", FALSE);
|
||||||
gsPrev = gwinGetButtonSource(ghPrev);
|
gsPrev = gwinGetButtonSource(ghPrev);
|
||||||
geventAttachSource(&gl, gsPrev, 0);
|
geventAttachSource(&gl, gsPrev, 0);
|
||||||
gwinAttachButtonSource(ghPrev, gs, GEVENT_MOUSE);
|
gwinAttachButtonMouseSource(ghPrev, gs);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
|
@ -221,8 +221,8 @@ StepCalibrate:
|
||||||
// below are correct for the Win32 toggle driver.
|
// below are correct for the Win32 toggle driver.
|
||||||
gsButton1 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY1);
|
gsButton1 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY1);
|
||||||
gsButton2 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY2);
|
gsButton2 = ginputGetToggle(GINPUT_TOGGLE_MOMENTARY2);
|
||||||
gwinAttachButtonSource(ghNext, gsButton2, GEVENT_TOGGLE);
|
gwinAttachButtonToggleSource(ghNext, gsButton2);
|
||||||
gwinAttachButtonSource(ghPrev, gsButton1, GEVENT_TOGGLE);
|
gwinAttachButtonToggleSource(ghPrev, gsButton1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,8 +129,15 @@ extern "C" {
|
||||||
// Get the source handle so the application can listen for events
|
// Get the source handle so the application can listen for events
|
||||||
#define gwinGetButtonSource(gh) ((GSourceHandle)(gh))
|
#define gwinGetButtonSource(gh) ((GSourceHandle)(gh))
|
||||||
|
|
||||||
// Attach a source to this button. Sources recognised: Mouse, Touch and Toggle - others are ignored (returns false).
|
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
|
||||||
bool_t gwinAttachButtonSource(GHandle gh, GSourceHandle gsh, GEventType type);
|
// Attach a mouse source to this button.
|
||||||
|
bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE
|
||||||
|
// Attach a toggle source to this button.
|
||||||
|
bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,30 +297,23 @@ void gwinButtonDraw(GHandle gh) {
|
||||||
#undef gbw
|
#undef gbw
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach a source to this button. Sources recognised: Mouse, Touch and Toggle - others are ignored (returns false).
|
|
||||||
bool_t gwinAttachButtonSource(GHandle gh, GSourceHandle gsh, GEventType type) {
|
|
||||||
#define gbw ((GButtonObject *)gh)
|
|
||||||
unsigned flags;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
|
#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
|
||||||
case GEVENT_MOUSE:
|
bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh) {
|
||||||
case GEVENT_TOUCH:
|
if (gh->type != GW_BUTTON)
|
||||||
flags = GLISTEN_MOUSEMETA;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE
|
|
||||||
case GEVENT_TOGGLE:
|
|
||||||
flags = GLISTEN_TOGGLE_OFF|GLISTEN_TOGGLE_ON;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
return geventAttachSource(&gbw->listener, gsh, flags);
|
|
||||||
|
|
||||||
#undef gbw
|
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)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return geventAttachSource(&((GButtonObject *)gh)->listener, gsh, GLISTEN_TOGGLE_OFF|GLISTEN_TOGGLE_ON);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */
|
#endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
Loading…
Add table
Reference in a new issue