summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2016-11-22 06:21:31 +0100
committerWilliam Wilgus <me.theuser@yahoo.com>2017-01-17 23:06:17 +0100
commitdc87e9e9f3c383b63c3cb3713886a6c93b6a79d1 (patch)
tree47a6c0d49e7741f91fa74d7230b1267f60617902 /apps/settings.c
parent16a9f84571276a13f4cfd5c66db8cd63ce4e2e7f (diff)
downloadrockbox-dc87e9e9f3c383b63c3cb3713886a6c93b6a79d1.tar.gz
rockbox-dc87e9e9f3c383b63c3cb3713886a6c93b6a79d1.zip
Selective Backlight/Advanced Softlock - Selective actions based on context
Selective backlight allows the user to choose actions that will not enable the backlight when pressed. Advanced softlock allows user to choose actions that will not be blocked by screenlock on devices without a hold button. Both only occur in FM and WPS Contexts. Update: Back from the dead -Cleaned up code, removed unnecessary calls, re-arranged last filter action timeout conditional to work in case last_filtered_action_tick was never set -Added entries to the manual -Fixed back button on some menus not activating backlight -Made menus more intuitive, no actions selected now changes menu item to off. -Added talk fuctionality. -Added option to disable selective backlight while on external power. -Rewrote backlight and softlock handling code to fix issue with scrollwheels -Menu changed to have toggle(yes/no) and settings -Optimized selective actions lookup -Added option to disable notification of 'buttons locked' while softlocked -Removed uneeded code, consolidated action lookup to single function -Fixed incorrect name on selective softlock menu -Added option to disable touch on touchscreen devices -Fixed backlight on original screenlock without selective screenlock active -Added text selection in mask_select for when show_icons is off -Fixed voice in mask_select to speak if voice is defined instead of spelling -Added more lang defines (play skip seek) -Added option to disable unknown keys turning on backlight -Fixed Conditional argument In wrong place causing players without backlight to fail to build -Fixed Disable Unknown blocking detection of context change -Fixed canceling menu didn't update new settings -Added Autolock on backlight off -Removed backlight_on_force from backlight.c, Now sets ignore next to false and uses backlight_on -Cleaned up autolock code added strings to lang file -Fixed issue where rapid presses would bypass softlock -Removed old softlock code, Cleaned selective actions code -Changed menu to match existing RB menus -Fixed Backlight_on_Hold blocked by backlight_ignore_next -Fixed ignore_next for ipod -Fixed bug allowing context with softlock to bypass selective backlight -Changed mask_select to no longer prompt for changes to be saved -Changed menu names -Added ignore timeout to allow ipod scroll wheel to work properly and other players to still work properly, removed some previous code including ignore_event -Increased ignore timeout to prevent sd card accesses from interrupting action code and turning on backlight -Changed Unknown action to unmapped action in menu, changed handling code -Removed unneeded logic and variables for handling unfiltered actions -Reverted unmapped action code to previous functionality -Added manual entries (thanks JohnB) -Removed elusive unhandled unicode character from manual, changed formatting slightly Actions: Volume,Play,Seek,Skip Extras: Disable unmapped actions Disable selective backlight on external power Disable touch during softlock on touchscreen devices Disable softlock notifications (power button still notifies) Autolock on backlight off Method: Adds a function to ignore backlight on next call If selected action occurs backlight is forced on, Filter_first_keypress stays intact. Selective softlock allows selected actions through, bypasses the normal softlock routine. ToDo: DONE previous commit (#1) has attribution for folder_select.c which mask_select is based from. Change-Id: I08132ddcfd64c81751ef23b720f3ec6d68695fe4
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/apps/settings.c b/apps/settings.c
index eed2b3a692..992cc1f391 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -146,7 +146,7 @@ static bool read_nvram_data(char* buf, int max_len)
146 buf[i] = rtc_read(0x14+i); 146 buf[i] = rtc_read(0x14+i);
147#endif 147#endif
148 /* check magic, version */ 148 /* check magic, version */
149 if ((buf[0] != 'R') || (buf[1] != 'b') 149 if ((buf[0] != 'R') || (buf[1] != 'b')
150 || (buf[2] != NVRAM_CONFIG_VERSION)) 150 || (buf[2] != NVRAM_CONFIG_VERSION))
151 return false; 151 return false;
152 /* check crc32 */ 152 /* check crc32 */
@@ -221,7 +221,7 @@ static bool write_nvram_data(char* buf, int max_len)
221 supports that, but this will have to do for now 8-) */ 221 supports that, but this will have to do for now 8-) */
222 for (i=0; i < NVRAM_BLOCK_SIZE; i++ ) { 222 for (i=0; i < NVRAM_BLOCK_SIZE; i++ ) {
223 int r = rtc_write(0x14+i, buf[i]); 223 int r = rtc_write(0x14+i, buf[i]);
224 if (r) 224 if (r)
225 return false; 225 return false;
226 } 226 }
227#endif 227#endif
@@ -307,8 +307,8 @@ bool settings_load_config(const char* file, bool apply)
307#ifdef HAVE_LCD_COLOR 307#ifdef HAVE_LCD_COLOR
308 if (settings[i].flags&F_RGB) 308 if (settings[i].flags&F_RGB)
309 hex_to_rgb(value, (int*)settings[i].setting); 309 hex_to_rgb(value, (int*)settings[i].setting);
310 else 310 else
311#endif 311#endif
312 if (settings[i].cfg_vals == NULL) 312 if (settings[i].cfg_vals == NULL)
313 { 313 {
314 *(int*)settings[i].setting = atoi(value); 314 *(int*)settings[i].setting = atoi(value);
@@ -392,7 +392,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
392 const char* start = settings[setting_id].cfg_vals; 392 const char* start = settings[setting_id].cfg_vals;
393 char* end = NULL; 393 char* end = NULL;
394 int count = 0; 394 int count = 0;
395 395
396 if ((flags&F_T_MASK)==F_T_INT && 396 if ((flags&F_T_MASK)==F_T_INT &&
397 flags&F_TABLE_SETTING) 397 flags&F_TABLE_SETTING)
398 { 398 {
@@ -404,7 +404,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
404 { 404 {
405 if (end == NULL) 405 if (end == NULL)
406 strlcpy(buf, start, buf_len); 406 strlcpy(buf, start, buf_len);
407 else 407 else
408 { 408 {
409 int len = (buf_len > (end-start))? end-start: buf_len; 409 int len = (buf_len > (end-start))? end-start: buf_len;
410 strlcpy(buf, start, len+1); 410 strlcpy(buf, start, len+1);
@@ -412,7 +412,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
412 return true; 412 return true;
413 } 413 }
414 count++; 414 count++;
415 415
416 if (end) 416 if (end)
417 start = end+1; 417 start = end+1;
418 else 418 else
@@ -420,7 +420,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
420 } 420 }
421 return false; 421 return false;
422 } 422 }
423 423
424 while (count < val) 424 while (count < val)
425 { 425 {
426 start = strchr(start,','); 426 start = strchr(start,',');
@@ -432,7 +432,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
432 end = strchr(start,','); 432 end = strchr(start,',');
433 if (end == NULL) 433 if (end == NULL)
434 strlcpy(buf, start, buf_len); 434 strlcpy(buf, start, buf_len);
435 else 435 else
436 { 436 {
437 int len = (buf_len > (end-start))? end-start: buf_len; 437 int len = (buf_len > (end-start))? end-start: buf_len;
438 strlcpy(buf, start, len+1); 438 strlcpy(buf, start, len+1);
@@ -561,7 +561,7 @@ static bool settings_write_config(const char* filename, int options)
561 value[0] = '\0'; 561 value[0] = '\0';
562 if (settings[i].flags & F_DEPRECATED) 562 if (settings[i].flags & F_DEPRECATED)
563 continue; 563 continue;
564 564
565 switch (options) 565 switch (options)
566 { 566 {
567 case SETTINGS_SAVE_CHANGED: 567 case SETTINGS_SAVE_CHANGED:
@@ -939,7 +939,7 @@ void settings_apply(bool read_disk)
939 && global_settings.font_file[0] != '-') { 939 && global_settings.font_file[0] != '-') {
940 int font_ui = screens[SCREEN_MAIN].getuifont(); 940 int font_ui = screens[SCREEN_MAIN].getuifont();
941 const char* loaded_font = font_filename(font_ui); 941 const char* loaded_font = font_filename(font_ui);
942 942
943 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", 943 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
944 global_settings.font_file); 944 global_settings.font_file);
945 if (!loaded_font || strcmp(loaded_font, buf)) 945 if (!loaded_font || strcmp(loaded_font, buf))
@@ -953,7 +953,7 @@ void settings_apply(bool read_disk)
953 screens[SCREEN_MAIN].setfont(rc); 953 screens[SCREEN_MAIN].setfont(rc);
954 } 954 }
955 } 955 }
956#ifdef HAVE_REMOTE_LCD 956#ifdef HAVE_REMOTE_LCD
957 if ( global_settings.remote_font_file[0] 957 if ( global_settings.remote_font_file[0]
958 && global_settings.remote_font_file[0] != '-') { 958 && global_settings.remote_font_file[0] != '-') {
959 int font_ui = screens[SCREEN_REMOTE].getuifont(); 959 int font_ui = screens[SCREEN_REMOTE].getuifont();
@@ -1064,17 +1064,27 @@ void settings_apply(bool read_disk)
1064 1064
1065#ifdef HAVE_BACKLIGHT 1065#ifdef HAVE_BACKLIGHT
1066 set_backlight_filter_keypress(global_settings.bl_filter_first_keypress); 1066 set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
1067 set_selective_backlight_actions(global_settings.bl_selective_actions,
1068 global_settings.bl_selective_actions_mask,
1069 global_settings.bl_filter_first_keypress);
1067#ifdef HAVE_REMOTE_LCD 1070#ifdef HAVE_REMOTE_LCD
1068 set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress); 1071 set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
1069#endif 1072#endif
1070#ifdef HAS_BUTTON_HOLD 1073#ifdef HAS_BUTTON_HOLD
1071 backlight_set_on_button_hold(global_settings.backlight_on_button_hold); 1074 backlight_set_on_button_hold(global_settings.backlight_on_button_hold);
1072#endif 1075#endif
1076
1073#ifdef HAVE_LCD_SLEEP_SETTING 1077#ifdef HAVE_LCD_SLEEP_SETTING
1074 lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); 1078 lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off);
1075#endif 1079#endif
1076#endif /* HAVE_BACKLIGHT */ 1080#endif /* HAVE_BACKLIGHT */
1077 1081
1082#ifndef HAS_BUTTON_HOLD
1083 set_selective_softlock_actions(
1084 global_settings.bt_selective_softlock_actions,
1085 global_settings.bt_selective_softlock_actions_mask);
1086#endif
1087
1078#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING 1088#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
1079 touchpad_set_sensitivity(global_settings.touchpad_sensitivity); 1089 touchpad_set_sensitivity(global_settings.touchpad_sensitivity);
1080#endif 1090#endif
@@ -1243,7 +1253,7 @@ bool set_int_ex(const unsigned char* string,
1243 (void)unit; 1253 (void)unit;
1244 struct settings_list item; 1254 struct settings_list item;
1245 struct int_setting data = { 1255 struct int_setting data = {
1246 function, voice_unit, min, max, step, 1256 function, voice_unit, min, max, step,
1247 formatter, get_talk_id 1257 formatter, get_talk_id
1248 }; 1258 };
1249 item.int_setting = &data; 1259 item.int_setting = &data;
@@ -1269,7 +1279,7 @@ static int32_t set_option_get_talk_id(int value, int unit)
1269} 1279}
1270 1280
1271bool set_option(const char* string, const void* variable, enum optiontype type, 1281bool set_option(const char* string, const void* variable, enum optiontype type,
1272 const struct opt_items* options, 1282 const struct opt_items* options,
1273 int numoptions, void (*function)(int)) 1283 int numoptions, void (*function)(int))
1274{ 1284{
1275 int temp; 1285 int temp;
@@ -1287,7 +1297,7 @@ bool set_option(const char* string, const void* variable, enum optiontype type,
1287 item.setting = &temp; 1297 item.setting = &temp;
1288 if (type == BOOL) 1298 if (type == BOOL)
1289 temp = *(bool*)variable? 1: 0; 1299 temp = *(bool*)variable? 1: 0;
1290 else 1300 else
1291 temp = *(int*)variable; 1301 temp = *(int*)variable;
1292 if (!option_screen(&item, NULL, false, NULL)) 1302 if (!option_screen(&item, NULL, false, NULL))
1293 { 1303 {