volumio-plugins icon indicating copy to clipboard operation
volumio-plugins copied to clipboard

Touch screen, wake-up only on first touch

Open bertmelis opened this issue 5 years ago • 6 comments

After the RPI screen goes dark, the first touch not only wakes the screen but also executes the action attached to the region where pushed. As the screen is dark, you cannot see what will happen.

This is annoying behaviour.

Is it possible to have the first touch only wake up the screen without any command?

bertmelis avatar Dec 09 '19 11:12 bertmelis

This is my problem as well. My 6-year-old daughter uses the touchscreen and doesn't always remind herself to touch a certain spot on the screen where nothing would happen. It would be really nice if there was an option that could prevent the action when the screen is deactivated.

Is this even technically possible? If yes, I could try a pull request...

EDIT: It looks like this file here contains the code with the "problem":

https://github.com/volumio/volumio-plugins/blob/master/plugins/miscellanea/touch_display/index.js

Or more specifically, this code here: https://github.com/volumio/volumio-plugins/blob/2c2d5c6d1b73142ecdd78fddf6bf81ed0a138dc6/plugins/miscellanea/touch_display/index.js#L148-L164

I don't know when "pushState" is emitted, but I guess it's when a button is pushed in the UI (play/pause/change to lists/settings/etc.)

The code reads like this: When some action (pushState) arrives, reset the screensaver (with some configured conditions). What I don't know is whether one can stop propagating the pushState event from here. If the "resetScreensaver" listener is always queued before the "process pushState to action" listener, one could stopEventPropagation() here. But I don't know for sure...

danowar2k avatar Apr 26 '20 09:04 danowar2k

I've searched for an event like beforePushState or something to have to something to latch onto to prevent further state changes when the display. No luck so far...

Links to people trying to bypass the same problem: https://unix.stackexchange.com/questions/265557/ignoring-first-click-event-on-dpms-or-screen-wakeup https://askubuntu.com/questions/1060331/prevent-wakeup-touch-from-being-registered-as-click-after-turn-screen-off-comm https://unix.stackexchange.com/questions/88119/xorg-ignore-first-click-event-when-resuming-from-screen-blanking?noredirect=1&lq=1 https://www.raspberrypi.org/forums/viewtopic.php?t=153259

Added still more links to people asking about this stuff...

Here's stuff about intercepting touch events from the touchscreen... https://raspberrypi.stackexchange.com/questions/45579/disable-or-catch-touch-screen-events

danowar2k avatar Apr 26 '20 09:04 danowar2k

So, maybe it would be a solution to not just turn the screensaver on after 120 seconds, but instead switch to a different console after 120 seconds and there turn the screensaver on. Then when a touch is registered, switch back to the volumio GUI and reset the timeout.

What do the maintainers think? Would that be reasonable?

EDIT: Who are the maintainers for these plugins? It seems @volumio is the maintainer of the whole project, do the plugins have separate maintainers? Maybe @balbuze or @gvolt ?

I'd like to contribute, but I'm still not firm enough in the code so that I could do so at the moment. I hope that I will find enlightenment about the contribution process, testing and the scope of feature requests. As this issue was never commented upon by anyone else, I kinda don't know if contributions would be wanted for this...

danowar2k avatar Apr 26 '20 09:04 danowar2k

I'll just collect more info here for now:

https://github.com/volumio/Volumio2-UI/blob/master/src/app/services/player.service.js This file from the UI repo or rather the function registerListner seems relevant, at least if there would be a way to block event propagation somehow.

danowar2k avatar Apr 26 '20 19:04 danowar2k

The plugins originates from Volumio. In last months I reworked most of the node js part (index.js).

EDIT: It looks like this file here contains the code with the "problem":

https://github.com/volumio/volumio-plugins/blob/master/plugins/miscellanea/touch_display/index.js

Or more specifically, this code here:

...

I don't know when "pushState" is emitted, but I guess it's when a button is pushed in the UI (play/pause/change to lists/settings/etc.)

The code reads like this: When some action (pushState) arrives, reset the screensaver (with some configured conditions). What I don't know is whether one can stop propagating the pushState event from here.

"pushState" is emitted not only on touching the local (touch)screen but also on commands send by IR remotes or on actions that happen in a browser running on another device (mobile, tablet, PC...).

AFAIK from the events in the Volumio system it is not possible to differentiate from where (from which input device) a change of the playing state originates. So IMHO changing the code above would need another "source" from which the origin of an input event can be determined. I guess this would involve detecting what input device the touchscreen is assigned to and then reading input events from this device.

I have been experimenting with this approach some time ago, but did not finish because lack of time. As soon as time allows, I will have a look at it again.

gvolt avatar Apr 26 '20 19:04 gvolt

I have been experimenting with this approach some time ago, but did not finish because lack of time. As soon as time allows, I will have a look at it again.

Thank you for commenting!

Hm, if pushState is emitted by many devices, is there maybe a way to go between touching the touchscreen and emitting pushState? Maybe that would involve the X display screensaver and that would be too low level? Hmm....

danowar2k avatar Apr 26 '20 21:04 danowar2k