diff options
author | Franklin Wei <franklin@rockbox.org> | 2020-06-26 20:53:15 -0400 |
---|---|---|
committer | Franklin Wei <franklin@rockbox.org> | 2020-06-27 13:27:40 -0400 |
commit | a65a341a0036737f161bfdd30adeab25faed3134 (patch) | |
tree | ba255c7d2ce392ca451c83f78a69caa50ba8e8a7 /apps/plugins | |
parent | f49442d7b739e13985e0d0054aa27865c0acff0c (diff) | |
download | rockbox-a65a341a0036737f161bfdd30adeab25faed3134.tar.gz rockbox-a65a341a0036737f161bfdd30adeab25faed3134.tar.bz2 rockbox-a65a341a0036737f161bfdd30adeab25faed3134.zip |
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
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/lib/helper.c | 15 | ||||
-rw-r--r-- | apps/plugins/lib/helper.h | 10 |
2 files changed, 25 insertions, 0 deletions
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 5aa143a728..506903e808 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c @@ -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) diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index 8086cb52d4..f2e9187a96 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h @@ -29,6 +29,16 @@ void backlight_force_on(void); void backlight_ignore_timeout(void); void backlight_use_settings(void); + +#ifdef HAVE_SW_POWEROFF +/** + * Disable and restore software poweroff (i.e. holding PLAY on iPods). + * Only call _restore() if _disable() was called earlier! + */ +void sw_poweroff_disable(void); +void sw_poweroff_restore(void); +#endif + #ifdef HAVE_REMOTE_LCD void remote_backlight_force_on(void); void remote_backlight_ignore_timeout(void); |