From 14f7a958af8c343d96a500c713df34f76fcb9d80 Mon Sep 17 00:00:00 2001 From: Dana Conrad Date: Thu, 27 May 2021 18:26:59 -0500 Subject: Softlock Improvements Add a check to see if the keys are currently locked and allow them to be unlocked to ensure we don't get stuck when the current playlist ends while the WPS is locked. (Original by Aidan MacDonald) Adding initialization for unlock_combo and to arm the autolock (if enabled) without the user needing to press the lock button at least once every boot (which is the prior behavior). Removing screen_has_lock check from is_keys_locked() Change-Id: I0fbf9b9746b011a7086ec8505a7ecc4b84f2d332 --- apps/action.c | 59 +++++++++++++++++++++++++++++++++++++++++++--- apps/action.h | 9 ++++++- apps/menus/settings_menu.c | 1 + apps/settings.c | 1 + 4 files changed, 66 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/action.c b/apps/action.c index 07032f7ae7..15422f987b 100644 --- a/apps/action.c +++ b/apps/action.c @@ -735,8 +735,11 @@ static inline void do_softlock(action_last_t *last, action_cur_t *cur) #else int action = cur->action; - if (!last->screen_has_lock) - { /* no need to check softlock return immediately */ + /* check to make sure we don't get stuck without a way to unlock - if locked, + * we can still use unlock_combo to unlock */ + if (!last->screen_has_lock && !last->keys_locked) + { + /* no need to check softlock return immediately */ return; } @@ -1180,7 +1183,7 @@ void set_selective_backlight_actions(bool selective, unsigned int mask, #ifndef HAS_BUTTON_HOLD bool is_keys_locked(void) { - return (action_last.screen_has_lock && action_last.keys_locked); + return (action_last.keys_locked); } /* Enable selected actions to bypass a locked state */ @@ -1196,7 +1199,57 @@ void set_selective_softlock_actions(bool selective, unsigned int mask) action_last.softlock_mask = SEL_ACTION_NONE; } } + + +void action_autosoftlock_init(void) +{ + action_cur_t cur; + int i = 0; + + if (action_last.unlock_combo == BUTTON_NONE) + { + /* search CONTEXT_WPS, should be here */ + cur.items = get_context_mapping(CONTEXT_WPS); + while (cur.items[i].button_code != BUTTON_NONE) + { + if (cur.items[i].action_code == ACTION_STD_KEYLOCK) + { + action_last.unlock_combo = cur.items[i].button_code; + break; + } + i = i + 1; + } + + /* not there... let's try std + * I doubt any targets will need this, but... */ + if (action_last.unlock_combo == BUTTON_NONE) + { + i = 0; + cur.items = get_context_mapping(CONTEXT_STD); + while (cur.items[i].button_code != BUTTON_NONE) + { + if (cur.items[i].action_code == ACTION_STD_KEYLOCK) + { + action_last.unlock_combo = cur.items[i].button_code; + break; + } + i = i + 1; + } + } + } + + /* if we have autolock and alwaysautolock, go ahead and arm it */ + if (has_flag(action_last.softlock_mask, SEL_ACTION_AUTOLOCK) && + has_flag(action_last.softlock_mask, SEL_ACTION_ALWAYSAUTOLOCK) && + (action_last.unlock_combo != BUTTON_NONE)) + { + action_last.softlock_mask = action_last.softlock_mask | SEL_ACTION_ALOCK_OK; + } + + return; +} #endif /* !HAS_BUTTON_HOLD */ + /* ******************************************************************************* * END EXPORTED ACTION FUNCTIONS *********************************************** diff --git a/apps/action.h b/apps/action.h index 711ec58f71..ad91f31535 100644 --- a/apps/action.h +++ b/apps/action.h @@ -68,10 +68,17 @@ #if !defined(HAS_BUTTON_HOLD) /* returns true if keys_locked and screen_has_lock */ bool is_keys_locked(void); + /* Enable selected actions to bypass a locked state * mask is combination of Selective action selection flags */ void set_selective_softlock_actions(bool selective, unsigned int mask); -#endif + +/* search the standard and wps contexts for ACTION_STD_KEYLOCK, + * load it into unlock_combo if we find it, + * also arm autolock if enabled. */ +void action_autosoftlock_init(void); + +#endif /* !defined(HAS_BUTTON_HOLD) */ #if defined(HAVE_BACKLIGHT) /* Enable selected actions to leave the backlight off diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index 58c328c677..a5e747651a 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -73,6 +73,7 @@ static int selectivesoftlock_callback(int action, set_selective_softlock_actions( global_settings.bt_selective_softlock_actions, global_settings.bt_selective_softlock_actions_mask); + action_autosoftlock_init(); break; } diff --git a/apps/settings.c b/apps/settings.c index 99cede382b..f89fc581ca 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -1010,6 +1010,7 @@ void settings_apply(bool read_disk) set_selective_softlock_actions( global_settings.bt_selective_softlock_actions, global_settings.bt_selective_softlock_actions_mask); + action_autosoftlock_init(); #endif #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING -- cgit v1.2.3