button: allow disabling software poweroff

On some devices, the button driver allows a "software poweroff" by long-
pressing a certain key. This behavior is inconvnient when that button needs
to be held down for other purposes, such as moving the cursor in rockpaint
or sgt-untangle.

This patch allows selectively disabling the software poweroff (enabled by
default) from both core and plugin code.

Change-Id: I7580752888ae5c7c7c5eb1be5966e3d67f17d4b4
This commit is contained in:
Franklin Wei 2020-06-26 20:53:15 -04:00
parent f49442d7b7
commit a65a341a00
6 changed files with 55 additions and 3 deletions

View file

@ -66,6 +66,21 @@ void backlight_use_settings(void)
#endif /* CONFIG_CHARGING */
}
#ifdef HAVE_SW_POWEROFF
static bool original_sw_poweroff_state = true;
void sw_poweroff_disable(void)
{
original_sw_poweroff_state = rb->button_get_sw_poweroff_state();
rb->button_set_sw_poweroff_state(false);
}
void sw_poweroff_restore(void)
{
rb->button_set_sw_poweroff_state(original_sw_poweroff_state);
}
#endif
#ifdef HAVE_REMOTE_LCD
/* Force the backlight on */
void remote_backlight_force_on(void)