summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Conrad <dconrad@fastmail.com>2021-05-27 18:26:59 -0500
committerAidan MacDonald <amachronic@protonmail.com>2021-06-04 00:00:57 +0000
commit14f7a958af8c343d96a500c713df34f76fcb9d80 (patch)
tree7babc9f6ccc172930cf01008eccc1900a4298ddf
parentcec6422ace933fecc02053c0fa6b239f7a6792e5 (diff)
downloadrockbox-14f7a958af8c343d96a500c713df34f76fcb9d80.tar.gz
rockbox-14f7a958af8c343d96a500c713df34f76fcb9d80.zip
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
-rw-r--r--apps/action.c59
-rw-r--r--apps/action.h9
-rw-r--r--apps/menus/settings_menu.c1
-rw-r--r--apps/settings.c1
4 files changed, 66 insertions, 4 deletions
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)
735#else 735#else
736 int action = cur->action; 736 int action = cur->action;
737 737
738 if (!last->screen_has_lock) 738 /* check to make sure we don't get stuck without a way to unlock - if locked,
739 { /* no need to check softlock return immediately */ 739 * we can still use unlock_combo to unlock */
740 if (!last->screen_has_lock && !last->keys_locked)
741 {
742 /* no need to check softlock return immediately */
740 return; 743 return;
741 } 744 }
742 745
@@ -1180,7 +1183,7 @@ void set_selective_backlight_actions(bool selective, unsigned int mask,
1180#ifndef HAS_BUTTON_HOLD 1183#ifndef HAS_BUTTON_HOLD
1181bool is_keys_locked(void) 1184bool is_keys_locked(void)
1182{ 1185{
1183 return (action_last.screen_has_lock && action_last.keys_locked); 1186 return (action_last.keys_locked);
1184} 1187}
1185 1188
1186/* Enable selected actions to bypass a locked state */ 1189/* Enable selected actions to bypass a locked state */
@@ -1196,7 +1199,57 @@ void set_selective_softlock_actions(bool selective, unsigned int mask)
1196 action_last.softlock_mask = SEL_ACTION_NONE; 1199 action_last.softlock_mask = SEL_ACTION_NONE;
1197 } 1200 }
1198} 1201}
1202
1203
1204void action_autosoftlock_init(void)
1205{
1206 action_cur_t cur;
1207 int i = 0;
1208
1209 if (action_last.unlock_combo == BUTTON_NONE)
1210 {
1211 /* search CONTEXT_WPS, should be here */
1212 cur.items = get_context_mapping(CONTEXT_WPS);
1213 while (cur.items[i].button_code != BUTTON_NONE)
1214 {
1215 if (cur.items[i].action_code == ACTION_STD_KEYLOCK)
1216 {
1217 action_last.unlock_combo = cur.items[i].button_code;
1218 break;
1219 }
1220 i = i + 1;
1221 }
1222
1223 /* not there... let's try std
1224 * I doubt any targets will need this, but... */
1225 if (action_last.unlock_combo == BUTTON_NONE)
1226 {
1227 i = 0;
1228 cur.items = get_context_mapping(CONTEXT_STD);
1229 while (cur.items[i].button_code != BUTTON_NONE)
1230 {
1231 if (cur.items[i].action_code == ACTION_STD_KEYLOCK)
1232 {
1233 action_last.unlock_combo = cur.items[i].button_code;
1234 break;
1235 }
1236 i = i + 1;
1237 }
1238 }
1239 }
1240
1241 /* if we have autolock and alwaysautolock, go ahead and arm it */
1242 if (has_flag(action_last.softlock_mask, SEL_ACTION_AUTOLOCK) &&
1243 has_flag(action_last.softlock_mask, SEL_ACTION_ALWAYSAUTOLOCK) &&
1244 (action_last.unlock_combo != BUTTON_NONE))
1245 {
1246 action_last.softlock_mask = action_last.softlock_mask | SEL_ACTION_ALOCK_OK;
1247 }
1248
1249 return;
1250}
1199#endif /* !HAS_BUTTON_HOLD */ 1251#endif /* !HAS_BUTTON_HOLD */
1252
1200/* 1253/*
1201******************************************************************************* 1254*******************************************************************************
1202* END EXPORTED ACTION FUNCTIONS *********************************************** 1255* 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 @@
68#if !defined(HAS_BUTTON_HOLD) 68#if !defined(HAS_BUTTON_HOLD)
69/* returns true if keys_locked and screen_has_lock */ 69/* returns true if keys_locked and screen_has_lock */
70bool is_keys_locked(void); 70bool is_keys_locked(void);
71
71/* Enable selected actions to bypass a locked state 72/* Enable selected actions to bypass a locked state
72* mask is combination of Selective action selection flags */ 73* mask is combination of Selective action selection flags */
73void set_selective_softlock_actions(bool selective, unsigned int mask); 74void set_selective_softlock_actions(bool selective, unsigned int mask);
74#endif 75
76/* search the standard and wps contexts for ACTION_STD_KEYLOCK,
77 * load it into unlock_combo if we find it,
78 * also arm autolock if enabled. */
79void action_autosoftlock_init(void);
80
81#endif /* !defined(HAS_BUTTON_HOLD) */
75 82
76#if defined(HAVE_BACKLIGHT) 83#if defined(HAVE_BACKLIGHT)
77/* Enable selected actions to leave the backlight off 84/* 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,
73 set_selective_softlock_actions( 73 set_selective_softlock_actions(
74 global_settings.bt_selective_softlock_actions, 74 global_settings.bt_selective_softlock_actions,
75 global_settings.bt_selective_softlock_actions_mask); 75 global_settings.bt_selective_softlock_actions_mask);
76 action_autosoftlock_init();
76 break; 77 break;
77 } 78 }
78 79
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)
1010 set_selective_softlock_actions( 1010 set_selective_softlock_actions(
1011 global_settings.bt_selective_softlock_actions, 1011 global_settings.bt_selective_softlock_actions,
1012 global_settings.bt_selective_softlock_actions_mask); 1012 global_settings.bt_selective_softlock_actions_mask);
1013 action_autosoftlock_init();
1013#endif 1014#endif
1014 1015
1015#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING 1016#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING