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
This commit is contained in:
parent
f49442d7b7
commit
a65a341a00
6 changed files with 55 additions and 3 deletions
|
@ -387,6 +387,10 @@ static const struct plugin_api rockbox_api = {
|
||||||
#ifdef HAS_BUTTON_HOLD
|
#ifdef HAS_BUTTON_HOLD
|
||||||
button_hold,
|
button_hold,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SW_POWEROFF
|
||||||
|
button_set_sw_poweroff_state,
|
||||||
|
button_get_sw_poweroff_state,
|
||||||
|
#endif
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
touchscreen_set_mode,
|
touchscreen_set_mode,
|
||||||
touchscreen_get_mode,
|
touchscreen_get_mode,
|
||||||
|
|
|
@ -161,12 +161,12 @@ void* plugin_get_buffer(size_t *buffer_size);
|
||||||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||||
|
|
||||||
/* increase this every time the api struct changes */
|
/* 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
|
/* update this to latest version if a change to the api struct breaks
|
||||||
backwards compatibility (and please take the opportunity to sort in any
|
backwards compatibility (and please take the opportunity to sort in any
|
||||||
new function which are "waiting" at the end of the function table) */
|
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 */
|
/* plugin return codes */
|
||||||
/* internal returns start at 0x100 to make exit(1..255) work */
|
/* internal returns start at 0x100 to make exit(1..255) work */
|
||||||
|
@ -435,6 +435,10 @@ struct plugin_api {
|
||||||
#ifdef HAS_BUTTON_HOLD
|
#ifdef HAS_BUTTON_HOLD
|
||||||
bool (*button_hold)(void);
|
bool (*button_hold)(void);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SW_POWEROFF
|
||||||
|
void (*button_set_sw_poweroff_state)(bool enable);
|
||||||
|
bool (*button_get_sw_poweroff_state)(void);
|
||||||
|
#endif
|
||||||
#ifdef HAVE_TOUCHSCREEN
|
#ifdef HAVE_TOUCHSCREEN
|
||||||
void (*touchscreen_set_mode)(enum touchscreen_mode);
|
void (*touchscreen_set_mode)(enum touchscreen_mode);
|
||||||
enum touchscreen_mode (*touchscreen_get_mode)(void);
|
enum touchscreen_mode (*touchscreen_get_mode)(void);
|
||||||
|
|
|
@ -66,6 +66,21 @@ void backlight_use_settings(void)
|
||||||
#endif /* CONFIG_CHARGING */
|
#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
|
#ifdef HAVE_REMOTE_LCD
|
||||||
/* Force the backlight on */
|
/* Force the backlight on */
|
||||||
void remote_backlight_force_on(void)
|
void remote_backlight_force_on(void)
|
||||||
|
|
|
@ -29,6 +29,16 @@
|
||||||
void backlight_force_on(void);
|
void backlight_force_on(void);
|
||||||
void backlight_ignore_timeout(void);
|
void backlight_ignore_timeout(void);
|
||||||
void backlight_use_settings(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
|
#ifdef HAVE_REMOTE_LCD
|
||||||
void remote_backlight_force_on(void);
|
void remote_backlight_force_on(void);
|
||||||
void remote_backlight_ignore_timeout(void);
|
void remote_backlight_ignore_timeout(void);
|
||||||
|
|
|
@ -65,6 +65,9 @@ static bool phones_present = false;
|
||||||
#ifdef HAVE_LINEOUT_DETECTION
|
#ifdef HAVE_LINEOUT_DETECTION
|
||||||
static bool lineout_present = false;
|
static bool lineout_present = false;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SW_POWEROFF
|
||||||
|
static bool enable_sw_poweroff = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* how long until repeat kicks in, in centiseconds */
|
/* how long until repeat kicks in, in centiseconds */
|
||||||
#define REPEAT_START (30*HZ/100)
|
#define REPEAT_START (30*HZ/100)
|
||||||
|
@ -280,7 +283,8 @@ static void button_tick(void)
|
||||||
which doesn't shut down easily with the OFF
|
which doesn't shut down easily with the OFF
|
||||||
key */
|
key */
|
||||||
#ifdef HAVE_SW_POWEROFF
|
#ifdef HAVE_SW_POWEROFF
|
||||||
if ((btn & POWEROFF_BUTTON
|
if (enable_sw_poweroff &&
|
||||||
|
(btn & POWEROFF_BUTTON
|
||||||
#ifdef RC_POWEROFF_BUTTON
|
#ifdef RC_POWEROFF_BUTTON
|
||||||
|| btn == RC_POWEROFF_BUTTON
|
|| btn == RC_POWEROFF_BUTTON
|
||||||
#endif
|
#endif
|
||||||
|
@ -773,3 +777,13 @@ void button_enable_touch(bool en)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#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
|
||||||
|
|
|
@ -130,4 +130,9 @@ int touchscreen_last_touch(void);
|
||||||
void button_enable_touch(bool en);
|
void button_enable_touch(bool en);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SW_POWEROFF
|
||||||
|
void button_set_sw_poweroff_state(bool en);
|
||||||
|
bool button_get_sw_poweroff_state(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _BUTTON_H_ */
|
#endif /* _BUTTON_H_ */
|
||||||
|
|
Loading…
Reference in a new issue