baskerville / plato

Document reader
Other
1.23k stars 102 forks source link

Add screen lock functionality, unlocked by pressing both forward and back buttons simultaneously #341

Open narodnik opened 7 months ago

narodnik commented 7 months ago

Motivation

I have a waterproof Kobo Libra H2O. In the rain or shower, water generates touch events on the screen. I want a way to disable these temporarily and only use the buttons.

The functionality is accessible inside the reader, select the top bar and select "Lock Screen Input". Then the screen is disabled, but you can still navigate using the buttons. Pressing them together unlocks the screen.

Core Organization

Most of the code is implemented in the top level plato and emulator apps. The code is duplicated, so I'd appreciate advise on where to put them. I added a LockScreenInput event, which sets a boolean, and then sends Event::Toggle(ViewId::TopBottomBars).

When the boolean is_screen_locked is set, then all Gesture events are caught and skipped. Lmk if this is the correct way to do this.

Apart from that, there's a bit of logic to handle pressing both buttons together.