From dc87e9e9f3c383b63c3cb3713886a6c93b6a79d1 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 22 Nov 2016 06:21:31 +0100 Subject: 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 --- apps/settings.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'apps/settings.c') 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) buf[i] = rtc_read(0x14+i); #endif /* check magic, version */ - if ((buf[0] != 'R') || (buf[1] != 'b') + if ((buf[0] != 'R') || (buf[1] != 'b') || (buf[2] != NVRAM_CONFIG_VERSION)) return false; /* check crc32 */ @@ -221,7 +221,7 @@ static bool write_nvram_data(char* buf, int max_len) supports that, but this will have to do for now 8-) */ for (i=0; i < NVRAM_BLOCK_SIZE; i++ ) { int r = rtc_write(0x14+i, buf[i]); - if (r) + if (r) return false; } #endif @@ -307,8 +307,8 @@ bool settings_load_config(const char* file, bool apply) #ifdef HAVE_LCD_COLOR if (settings[i].flags&F_RGB) hex_to_rgb(value, (int*)settings[i].setting); - else -#endif + else +#endif if (settings[i].cfg_vals == NULL) { *(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) const char* start = settings[setting_id].cfg_vals; char* end = NULL; int count = 0; - + if ((flags&F_T_MASK)==F_T_INT && flags&F_TABLE_SETTING) { @@ -404,7 +404,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) { if (end == NULL) strlcpy(buf, start, buf_len); - else + else { int len = (buf_len > (end-start))? end-start: buf_len; strlcpy(buf, start, len+1); @@ -412,7 +412,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) return true; } count++; - + if (end) start = end+1; else @@ -420,7 +420,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) } return false; } - + while (count < val) { start = strchr(start,','); @@ -432,7 +432,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) end = strchr(start,','); if (end == NULL) strlcpy(buf, start, buf_len); - else + else { int len = (buf_len > (end-start))? end-start: buf_len; strlcpy(buf, start, len+1); @@ -561,7 +561,7 @@ static bool settings_write_config(const char* filename, int options) value[0] = '\0'; if (settings[i].flags & F_DEPRECATED) continue; - + switch (options) { case SETTINGS_SAVE_CHANGED: @@ -939,7 +939,7 @@ void settings_apply(bool read_disk) && global_settings.font_file[0] != '-') { int font_ui = screens[SCREEN_MAIN].getuifont(); const char* loaded_font = font_filename(font_ui); - + snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.font_file); if (!loaded_font || strcmp(loaded_font, buf)) @@ -953,7 +953,7 @@ void settings_apply(bool read_disk) screens[SCREEN_MAIN].setfont(rc); } } -#ifdef HAVE_REMOTE_LCD +#ifdef HAVE_REMOTE_LCD if ( global_settings.remote_font_file[0] && global_settings.remote_font_file[0] != '-') { int font_ui = screens[SCREEN_REMOTE].getuifont(); @@ -1064,17 +1064,27 @@ void settings_apply(bool read_disk) #ifdef HAVE_BACKLIGHT set_backlight_filter_keypress(global_settings.bl_filter_first_keypress); + set_selective_backlight_actions(global_settings.bl_selective_actions, + global_settings.bl_selective_actions_mask, + global_settings.bl_filter_first_keypress); #ifdef HAVE_REMOTE_LCD set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress); #endif #ifdef HAS_BUTTON_HOLD backlight_set_on_button_hold(global_settings.backlight_on_button_hold); #endif + #ifdef HAVE_LCD_SLEEP_SETTING lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); #endif #endif /* HAVE_BACKLIGHT */ +#ifndef HAS_BUTTON_HOLD + set_selective_softlock_actions( + global_settings.bt_selective_softlock_actions, + global_settings.bt_selective_softlock_actions_mask); +#endif + #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING touchpad_set_sensitivity(global_settings.touchpad_sensitivity); #endif @@ -1243,7 +1253,7 @@ bool set_int_ex(const unsigned char* string, (void)unit; struct settings_list item; struct int_setting data = { - function, voice_unit, min, max, step, + function, voice_unit, min, max, step, formatter, get_talk_id }; item.int_setting = &data; @@ -1269,7 +1279,7 @@ static int32_t set_option_get_talk_id(int value, int unit) } bool set_option(const char* string, const void* variable, enum optiontype type, - const struct opt_items* options, + const struct opt_items* options, int numoptions, void (*function)(int)) { int temp; @@ -1287,7 +1297,7 @@ bool set_option(const char* string, const void* variable, enum optiontype type, item.setting = &temp; if (type == BOOL) temp = *(bool*)variable? 1: 0; - else + else temp = *(int*)variable; if (!option_screen(&item, NULL, false, NULL)) { -- cgit v1.2.3