-
Notifications
You must be signed in to change notification settings - Fork 224
Description
The vast majority of touch drivers will grab any interrupt pins a touch controller provides, rendering it inaccessible to user code.
Touch events often need a generalized processing additionally to gui-related processing, e.g. for haptic feedback or backlight control. Conversely, wether or not touch events should be processed by the GUI often depends on overall device state, e.g. one might not want a touch to register as a button press if the backlight was turned off at the time.
GUIslice currently doesn't provide a convenient, non-hacky possibility for user code to be notified of touch events. Any solutions I have been able to find either required modified drivers or extensive modifications in the library code. Various workarounds like setting a semaphore in a GUIslice callback proved to sluggish to give a good user experience.
GUIslice should provide a way to register a general touch listener that has the possibility to advise how the touch event is to be treated. Here's a quick and dirty example how I would envision it(beware of hacked together pseudocode):
//----- this part is provided by GUIslice ---
typedef enum gslc_tsTouchH { GSLC_TOUCH_CONSUME, GSLC_TOUCH_HANDLE };
typedef gslc_tsTouchH (*GSLC_CB_GLOBAL_TOUCH)(void);
void gslc_GuiRegisterGlobalTouchHandler(gslc_tsGui* pGui, GSLC_CB_GLOBAL_TOUCH globalTouchHandler);
//----- this part is how it is used in user code ---
gslc_tsTouchH touchBacklightHandler(){
if(backlightOn){
return GSLC_TOUCH_HANDLE;
} else {
setBacklightOn();
return GSLC_TOUCH_CONSUME;
}
}
gslc_GuiRegisterGlobalTouchHandler(&m_gui,touchBacklightHandler);