summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h8
-rw-r--r--apps/plugins/lib/helper.c15
-rw-r--r--apps/plugins/lib/helper.h10
-rw-r--r--firmware/drivers/button.c16
-rw-r--r--firmware/export/button.h5
6 files changed, 55 insertions, 3 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 1506554790..7d40a8db4f 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -387,6 +387,10 @@ static const struct plugin_api rockbox_api = {
387#ifdef HAS_BUTTON_HOLD 387#ifdef HAS_BUTTON_HOLD
388 button_hold, 388 button_hold,
389#endif 389#endif
390#ifdef HAVE_SW_POWEROFF
391 button_set_sw_poweroff_state,
392 button_get_sw_poweroff_state,
393#endif
390#ifdef HAVE_TOUCHSCREEN 394#ifdef HAVE_TOUCHSCREEN
391 touchscreen_set_mode, 395 touchscreen_set_mode,
392 touchscreen_get_mode, 396 touchscreen_get_mode,
diff --git a/apps/plugin.h b/apps/plugin.h
index c737d7adeb..430c15a2a6 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -161,12 +161,12 @@ void* plugin_get_buffer(size_t *buffer_size);
161#define PLUGIN_MAGIC 0x526F634B /* RocK */ 161#define PLUGIN_MAGIC 0x526F634B /* RocK */
162 162
163/* increase this every time the api struct changes */ 163/* increase this every time the api struct changes */
164#define PLUGIN_API_VERSION 237 164#define PLUGIN_API_VERSION 238
165 165
166/* update this to latest version if a change to the api struct breaks 166/* update this to latest version if a change to the api struct breaks
167 backwards compatibility (and please take the opportunity to sort in any 167 backwards compatibility (and please take the opportunity to sort in any
168 new function which are "waiting" at the end of the function table) */ 168 new function which are "waiting" at the end of the function table) */
169#define PLUGIN_MIN_API_VERSION 237 169#define PLUGIN_MIN_API_VERSION 238
170 170
171/* plugin return codes */ 171/* plugin return codes */
172/* internal returns start at 0x100 to make exit(1..255) work */ 172/* internal returns start at 0x100 to make exit(1..255) work */
@@ -435,6 +435,10 @@ struct plugin_api {
435#ifdef HAS_BUTTON_HOLD 435#ifdef HAS_BUTTON_HOLD
436 bool (*button_hold)(void); 436 bool (*button_hold)(void);
437#endif 437#endif
438#ifdef HAVE_SW_POWEROFF
439 void (*button_set_sw_poweroff_state)(bool enable);
440 bool (*button_get_sw_poweroff_state)(void);
441#endif
438#ifdef HAVE_TOUCHSCREEN 442#ifdef HAVE_TOUCHSCREEN
439 void (*touchscreen_set_mode)(enum touchscreen_mode); 443 void (*touchscreen_set_mode)(enum touchscreen_mode);
440 enum touchscreen_mode (*touchscreen_get_mode)(void); 444 enum touchscreen_mode (*touchscreen_get_mode)(void);
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)
66#endif /* CONFIG_CHARGING */ 66#endif /* CONFIG_CHARGING */
67} 67}
68 68
69#ifdef HAVE_SW_POWEROFF
70static bool original_sw_poweroff_state = true;
71
72void sw_poweroff_disable(void)
73{
74 original_sw_poweroff_state = rb->button_get_sw_poweroff_state();
75 rb->button_set_sw_poweroff_state(false);
76}
77
78void sw_poweroff_restore(void)
79{
80 rb->button_set_sw_poweroff_state(original_sw_poweroff_state);
81}
82#endif
83
69#ifdef HAVE_REMOTE_LCD 84#ifdef HAVE_REMOTE_LCD
70/* Force the backlight on */ 85/* Force the backlight on */
71void remote_backlight_force_on(void) 86void 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 @@
29void backlight_force_on(void); 29void backlight_force_on(void);
30void backlight_ignore_timeout(void); 30void backlight_ignore_timeout(void);
31void backlight_use_settings(void); 31void backlight_use_settings(void);
32
33#ifdef HAVE_SW_POWEROFF
34/**
35 * Disable and restore software poweroff (i.e. holding PLAY on iPods).
36 * Only call _restore() if _disable() was called earlier!
37 */
38void sw_poweroff_disable(void);
39void sw_poweroff_restore(void);
40#endif
41
32#ifdef HAVE_REMOTE_LCD 42#ifdef HAVE_REMOTE_LCD
33void remote_backlight_force_on(void); 43void remote_backlight_force_on(void);
34void remote_backlight_ignore_timeout(void); 44void remote_backlight_ignore_timeout(void);
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_ */