summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2020-06-26 20:53:15 -0400
committerFranklin Wei <franklin@rockbox.org>2020-06-27 13:27:40 -0400
commita65a341a0036737f161bfdd30adeab25faed3134 (patch)
treeba255c7d2ce392ca451c83f78a69caa50ba8e8a7 /firmware
parentf49442d7b739e13985e0d0054aa27865c0acff0c (diff)
downloadrockbox-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 'firmware')
-rw-r--r--firmware/drivers/button.c16
-rw-r--r--firmware/export/button.h5
2 files changed, 20 insertions, 1 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 9677580838..626afc415f 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -65,6 +65,9 @@ static bool phones_present = false;
#ifdef HAVE_LINEOUT_DETECTION
static bool lineout_present = false;
#endif
+#ifdef HAVE_SW_POWEROFF
+static bool enable_sw_poweroff = true;
+#endif
/* how long until repeat kicks in, in centiseconds */
#define REPEAT_START (30*HZ/100)
@@ -280,7 +283,8 @@ static void button_tick(void)
which doesn't shut down easily with the OFF
key */
#ifdef HAVE_SW_POWEROFF
- if ((btn & POWEROFF_BUTTON
+ if (enable_sw_poweroff &&
+ (btn & POWEROFF_BUTTON
#ifdef RC_POWEROFF_BUTTON
|| btn == RC_POWEROFF_BUTTON
#endif
@@ -773,3 +777,13 @@ void button_enable_touch(bool en)
#endif
}
#endif
+
+#ifdef HAVE_SW_POWEROFF
+void button_set_sw_poweroff_state(bool en) {
+ enable_sw_poweroff = en;
+}
+
+bool button_get_sw_poweroff_state() {
+ return enable_sw_poweroff;
+}
+#endif
diff --git a/firmware/export/button.h b/firmware/export/button.h
index d9732ebe8b..36b615f216 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -130,4 +130,9 @@ int touchscreen_last_touch(void);
void button_enable_touch(bool en);
#endif
+#ifdef HAVE_SW_POWEROFF
+void button_set_sw_poweroff_state(bool en);
+bool button_get_sw_poweroff_state(void);
+#endif
+
#endif /* _BUTTON_H_ */