summaryrefslogtreecommitdiffstats
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 = {
#ifdef HAS_BUTTON_HOLD
button_hold,
#endif
+#ifdef HAVE_SW_POWEROFF
+ button_set_sw_poweroff_state,
+ button_get_sw_poweroff_state,
+#endif
#ifdef HAVE_TOUCHSCREEN
touchscreen_set_mode,
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);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 237
+#define PLUGIN_API_VERSION 238
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 237
+#define PLUGIN_MIN_API_VERSION 238
/* plugin return codes */
/* internal returns start at 0x100 to make exit(1..255) work */
@@ -435,6 +435,10 @@ struct plugin_api {
#ifdef HAS_BUTTON_HOLD
bool (*button_hold)(void);
#endif
+#ifdef HAVE_SW_POWEROFF
+ void (*button_set_sw_poweroff_state)(bool enable);
+ bool (*button_get_sw_poweroff_state)(void);
+#endif
#ifdef HAVE_TOUCHSCREEN
void (*touchscreen_set_mode)(enum touchscreen_mode);
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)
#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);
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_ */