summaryrefslogtreecommitdiff
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.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;
65#ifdef HAVE_LINEOUT_DETECTION 65#ifdef HAVE_LINEOUT_DETECTION
66static bool lineout_present = false; 66static bool lineout_present = false;
67#endif 67#endif
68#ifdef HAVE_SW_POWEROFF
69static bool enable_sw_poweroff = true;
70#endif
68 71
69/* how long until repeat kicks in, in centiseconds */ 72/* how long until repeat kicks in, in centiseconds */
70#define REPEAT_START (30*HZ/100) 73#define REPEAT_START (30*HZ/100)
@@ -280,7 +283,8 @@ static void button_tick(void)
280 which doesn't shut down easily with the OFF 283 which doesn't shut down easily with the OFF
281 key */ 284 key */
282#ifdef HAVE_SW_POWEROFF 285#ifdef HAVE_SW_POWEROFF
283 if ((btn & POWEROFF_BUTTON 286 if (enable_sw_poweroff &&
287 (btn & POWEROFF_BUTTON
284#ifdef RC_POWEROFF_BUTTON 288#ifdef RC_POWEROFF_BUTTON
285 || btn == RC_POWEROFF_BUTTON 289 || btn == RC_POWEROFF_BUTTON
286#endif 290#endif
@@ -773,3 +777,13 @@ void button_enable_touch(bool en)
773#endif 777#endif
774} 778}
775#endif 779#endif
780
781#ifdef HAVE_SW_POWEROFF
782void button_set_sw_poweroff_state(bool en) {
783 enable_sw_poweroff = en;
784}
785
786bool button_get_sw_poweroff_state() {
787 return enable_sw_poweroff;
788}
789#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);
130void button_enable_touch(bool en); 130void button_enable_touch(bool en);
131#endif 131#endif
132 132
133#ifdef HAVE_SW_POWEROFF
134void button_set_sw_poweroff_state(bool en);
135bool button_get_sw_poweroff_state(void);
136#endif
137
133#endif /* _BUTTON_H_ */ 138#endif /* _BUTTON_H_ */