Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide global interceptor for touch events #510

Open
tfischer4765 opened this issue May 16, 2023 · 3 comments
Open

Provide global interceptor for touch events #510

tfischer4765 opened this issue May 16, 2023 · 3 comments

Comments

@tfischer4765
Copy link

tfischer4765 commented May 16, 2023

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);

@tfischer4765 tfischer4765 changed the title Provide state awareness Provide global interceptor for touch events May 27, 2023
@tfischer4765
Copy link
Author

I renamed the ticket because in hindsight, the original title was a bit non-descriptive of what I was looking to achieve

@Bwanna
Copy link

Bwanna commented Aug 5, 2023

Following.

I like the way you described this Need as it would address a number of possibilities. My particular need is to simply not use Polling for Touchevents. Based on your description, it appears the GUISlice may not have the ability (yet) to handle an IRQ action from any of the touch drivers. Since the XPT2046 seems to be more prevalent, would it difficult to coordinate development with the PS driver to achieve at least one good working scenario?

Unfortunately my skills are limited... still learning, but would offer to help in any way to achieve this.

@ilka-schulz
Copy link

I, too, want to intercept touch events from my XPT2046. I read through the code and it does not seem to support this feature. I guess I will clone the repo and create a PR as soon as I got a working implementation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants