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
This commit is contained in:
Dana Conrad 2021-05-27 18:26:59 -05:00 committed by Aidan MacDonald
parent cec6422ace
commit 14f7a958af
4 changed files with 66 additions and 4 deletions

View File

@ -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 ***********************************************

View File

@ -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

View File

@ -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;
}

View File

@ -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