diff options
author | William Wilgus <me.theuser@yahoo.com> | 2016-11-22 06:21:31 +0100 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2017-01-17 23:06:17 +0100 |
commit | dc87e9e9f3c383b63c3cb3713886a6c93b6a79d1 (patch) | |
tree | 47a6c0d49e7741f91fa74d7230b1267f60617902 /apps/menus | |
parent | 16a9f84571276a13f4cfd5c66db8cd63ce4e2e7f (diff) |
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/menus')
-rw-r--r-- | apps/menus/display_menu.c | 123 | ||||
-rw-r--r-- | apps/menus/settings_menu.c | 83 |
2 files changed, 173 insertions, 33 deletions
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index 948dcede00..5d53cbfe16 100644 --- a/apps/menus/display_menu.c +++ b/apps/menus/display_menu.c @@ -38,6 +38,10 @@ #ifdef HAVE_REMOTE_LCD #include "lcd-remote.h" #endif +#ifdef HAVE_BACKLIGHT +#include "mask_select.h" +#include "splash.h" +#endif #ifdef HAVE_TOUCHSCREEN #include "screens.h" #endif @@ -46,9 +50,29 @@ #include "rbunicode.h" #ifdef HAVE_BACKLIGHT -static int filterfirstkeypress_callback(int action,const struct menu_item_ex *this_item) +static int selectivebacklight_callback(int action,const struct menu_item_ex *this_item) { (void)this_item; + + switch (action) + { + case ACTION_EXIT_MENUITEM: + case ACTION_STD_MENU: + case ACTION_STD_CANCEL: + set_selective_backlight_actions( + global_settings.bl_selective_actions, + global_settings.bl_selective_actions_mask, + global_settings.bl_filter_first_keypress); + break; + } + + return action; +} + +static int filterfirstkeypress_callback(int action,const struct menu_item_ex *this_item) +{ + /*(void)this_item;REMOVED*/ + switch (action) { case ACTION_EXIT_MENUITEM: @@ -56,13 +80,43 @@ static int filterfirstkeypress_callback(int action,const struct menu_item_ex *th #ifdef HAVE_REMOTE_LCD set_remote_backlight_filter_keypress( global_settings.remote_bl_filter_first_keypress); -#endif - +#endif /* HAVE_REMOTE_LCD */ + selectivebacklight_callback(action,this_item);/*uses Filter First KP*/ break; } + return action; } + +static int selectivebacklight_set_mask(void* param) +{ + (void)param; + int mask = global_settings.bl_selective_actions_mask; + struct s_mask_items maskitems[]={ + {ID2P(LANG_VOLUME) , SEL_ACTION_VOL}, + {ID2P(LANG_ACTION_PLAY), SEL_ACTION_PLAY}, + {ID2P(LANG_ACTION_SEEK), SEL_ACTION_SEEK}, + {ID2P(LANG_ACTION_SKIP), SEL_ACTION_SKIP}, + {ID2P(LANG_ACTION_DISABLE_UNMAPPED), SEL_ACTION_NOUNMAPPED} +#if CONFIG_CHARGING + ,{ID2P(LANG_ACTION_DISABLE_EXT_POWER), SEL_ACTION_NOEXT} #endif + }; + + mask = mask_select(mask, ID2P(LANG_BACKLIGHT_SELECTIVE) + , maskitems, ARRAYLEN(maskitems)); + + if (mask == SEL_ACTION_NONE || mask == SEL_ACTION_NOEXT) + global_settings.bl_selective_actions = false; + else if (global_settings.bl_selective_actions_mask != mask) + global_settings.bl_selective_actions = true; + + global_settings.bl_selective_actions_mask = mask; + + return true; +} + +#endif /* HAVE_BACKLIGHT */ #ifdef HAVE_LCD_FLIP static int flipdisplay_callback(int action,const struct menu_item_ex *this_item) { @@ -88,11 +142,11 @@ static int flipdisplay_callback(int action,const struct menu_item_ex *this_item) #ifdef HAVE_BACKLIGHT MENUITEM_SETTING(backlight_timeout, &global_settings.backlight_timeout, NULL); #if CONFIG_CHARGING -MENUITEM_SETTING(backlight_timeout_plugged, +MENUITEM_SETTING(backlight_timeout_plugged, &global_settings.backlight_timeout_plugged, NULL); #endif #ifdef HAS_BUTTON_HOLD -MENUITEM_SETTING(backlight_on_button_hold, +MENUITEM_SETTING(backlight_on_button_hold, &global_settings.backlight_on_button_hold, NULL); #endif MENUITEM_SETTING(caption_backlight, &global_settings.caption_backlight, NULL); @@ -101,9 +155,21 @@ MENUITEM_SETTING(caption_backlight, &global_settings.caption_backlight, NULL); MENUITEM_SETTING(backlight_fade_in, &global_settings.backlight_fade_in, NULL); MENUITEM_SETTING(backlight_fade_out, &global_settings.backlight_fade_out, NULL); #endif -MENUITEM_SETTING(bl_filter_first_keypress, - &global_settings.bl_filter_first_keypress, +MENUITEM_SETTING(bl_filter_first_keypress, + &global_settings.bl_filter_first_keypress, filterfirstkeypress_callback); + +MENUITEM_SETTING(bl_selective_actions, + &global_settings.bl_selective_actions, + selectivebacklight_callback); + +MENUITEM_FUNCTION(sel_backlight_mask, 0, ID2P(LANG_SETTINGS), + selectivebacklight_set_mask, NULL, + selectivebacklight_callback, Icon_Menu_setting); + +MAKE_MENU(sel_backlight, ID2P(LANG_BACKLIGHT_SELECTIVE), + NULL, Icon_Menu_setting, &bl_selective_actions, &sel_backlight_mask); + #ifdef HAVE_LCD_SLEEP_SETTING MENUITEM_SETTING(lcd_sleep_after_backlight_off, &global_settings.lcd_sleep_after_backlight_off, NULL); @@ -124,6 +190,8 @@ MENUITEM_SETTING(flip_display, &global_settings.flip_display, flipdisplay_callba #endif #endif /* HAVE_LCD_BITMAP */ + + /* now the actual menu */ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU), NULL, Icon_Display_menu @@ -141,6 +209,7 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU), ,&backlight_fade_in, &backlight_fade_out #endif ,&bl_filter_first_keypress + ,&sel_backlight # ifdef HAVE_LCD_SLEEP_SETTING ,&lcd_sleep_after_backlight_off # endif @@ -167,31 +236,31 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU), /********************************/ /* Remote LCD settings menu */ #ifdef HAVE_REMOTE_LCD -MENUITEM_SETTING(remote_backlight_timeout, +MENUITEM_SETTING(remote_backlight_timeout, &global_settings.remote_backlight_timeout, NULL); #if CONFIG_CHARGING -MENUITEM_SETTING(remote_backlight_timeout_plugged, +MENUITEM_SETTING(remote_backlight_timeout_plugged, &global_settings.remote_backlight_timeout_plugged, NULL); #endif #ifdef HAS_REMOTE_BUTTON_HOLD -MENUITEM_SETTING(remote_backlight_on_button_hold, +MENUITEM_SETTING(remote_backlight_on_button_hold, &global_settings.remote_backlight_on_button_hold, NULL); #endif -MENUITEM_SETTING(remote_caption_backlight, +MENUITEM_SETTING(remote_caption_backlight, &global_settings.remote_caption_backlight, NULL); -MENUITEM_SETTING(remote_bl_filter_first_keypress, - &global_settings.remote_bl_filter_first_keypress, +MENUITEM_SETTING(remote_bl_filter_first_keypress, + &global_settings.remote_bl_filter_first_keypress, filterfirstkeypress_callback); -MENUITEM_SETTING(remote_contrast, +MENUITEM_SETTING(remote_contrast, &global_settings.remote_contrast, NULL); -MENUITEM_SETTING(remote_invert, +MENUITEM_SETTING(remote_invert, &global_settings.remote_invert, NULL); - -#ifdef HAVE_LCD_FLIP -MENUITEM_SETTING(remote_flip_display, + +#ifdef HAVE_LCD_FLIP +MENUITEM_SETTING(remote_flip_display, &global_settings.remote_flip_display, flipdisplay_callback); #endif @@ -207,7 +276,7 @@ static int ticking_callback(int action,const struct menu_item_ex *this_item) } return action; } -MENUITEM_SETTING(remote_reduce_ticking, +MENUITEM_SETTING(remote_reduce_ticking, &global_settings.remote_reduce_ticking, ticking_callback); #endif @@ -222,7 +291,7 @@ MAKE_MENU(lcd_remote_settings, ID2P(LANG_LCD_REMOTE_MENU), #endif &remote_caption_backlight, &remote_bl_filter_first_keypress, &remote_contrast, &remote_invert - + #ifdef HAVE_LCD_FLIP ,&remote_flip_display #endif @@ -319,15 +388,15 @@ static int peakmeter_callback(int action,const struct menu_item_ex *this_item) } return action; } -MENUITEM_SETTING(peak_meter_hold, +MENUITEM_SETTING(peak_meter_hold, &global_settings.peak_meter_hold, peakmeter_callback); -MENUITEM_SETTING(peak_meter_clip_hold, +MENUITEM_SETTING(peak_meter_clip_hold, &global_settings.peak_meter_clip_hold, peakmeter_callback); #ifdef HAVE_RECORDING MENUITEM_SETTING(peak_meter_clipcounter, &global_settings.peak_meter_clipcounter, NULL); #endif -MENUITEM_SETTING(peak_meter_release, +MENUITEM_SETTING(peak_meter_release, &global_settings.peak_meter_release, peakmeter_callback); /** * Menu to select wether the scale of the meter @@ -356,7 +425,7 @@ static int peak_meter_scale(void) { /* we only store -dBfs */ global_settings.peak_meter_min = -peak_meter_get_min() / 100; global_settings.peak_meter_max = -peak_meter_get_max() / 100; - + /* limit the returned value to the allowed range */ if(global_settings.peak_meter_min > 89) global_settings.peak_meter_min = 89; @@ -472,12 +541,12 @@ MENUITEM_FUNCTION(histogram, 0, MENUITEM_FUNCTION(peak_meter_scale_item, 0, ID2P(LANG_PM_SCALE), peak_meter_scale, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(peak_meter_min_item, 0, ID2P(LANG_PM_MIN), +MENUITEM_FUNCTION(peak_meter_min_item, 0, ID2P(LANG_PM_MIN), peak_meter_min, NULL, NULL, Icon_NOICON); -MENUITEM_FUNCTION(peak_meter_max_item, 0, ID2P(LANG_PM_MAX), +MENUITEM_FUNCTION(peak_meter_max_item, 0, ID2P(LANG_PM_MAX), peak_meter_max, NULL, NULL, Icon_NOICON); MAKE_MENU(peak_meter_menu, ID2P(LANG_PM_MENU), NULL, Icon_NOICON, - &peak_meter_release, &peak_meter_hold, + &peak_meter_release, &peak_meter_hold, &peak_meter_clip_hold, #ifdef HAVE_RECORDING &peak_meter_clipcounter, diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index f42550cc6a..5c99cb4cd4 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -49,12 +49,67 @@ #include "dircache.h" #endif #include "folder_select.h" - +#ifndef HAS_BUTTON_HOLD +#include "mask_select.h" +#endif #if defined(DX50) || defined(DX90) #include "governor-ibasso.h" #include "usb-ibasso.h" #endif +#ifndef HAS_BUTTON_HOLD +static int selectivesoftlock_callback(int action, + const struct menu_item_ex *this_item) +{ + (void)this_item; + + switch (action) + { + case ACTION_STD_MENU: + case ACTION_STD_CANCEL: + case ACTION_EXIT_MENUITEM: + set_selective_softlock_actions( + global_settings.bt_selective_softlock_actions, + global_settings.bt_selective_softlock_actions_mask); + break; + } + + return action; +} + +static int selectivesoftlock_set_mask(void* param) +{ + (void)param; +int mask = global_settings.bt_selective_softlock_actions_mask; + struct s_mask_items maskitems[]={ + {ID2P(LANG_VOLUME) , SEL_ACTION_VOL}, + {ID2P(LANG_ACTION_PLAY), SEL_ACTION_PLAY}, + {ID2P(LANG_ACTION_SEEK), SEL_ACTION_SEEK}, + {ID2P(LANG_ACTION_SKIP), SEL_ACTION_SKIP}, + #ifdef HAVE_BACKLIGHT + {ID2P(LANG_ACTION_AUTOLOCK_ON), SEL_ACTION_AUTOLOCK}, + #endif + #if defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN) + {ID2P(LANG_ACTION_DISABLE_TOUCH) , SEL_ACTION_NOTOUCH}, + #endif + {ID2P(LANG_ACTION_DISABLE_NOTIFY), SEL_ACTION_NONOTIFY} + }; + + mask = mask_select(mask, ID2P(LANG_SOFTLOCK_SELECTIVE) + , maskitems,ARRAYLEN(maskitems)); + + if (mask == SEL_ACTION_NONE) + global_settings.bt_selective_softlock_actions = false; + else if (global_settings.bt_selective_softlock_actions_mask != mask) + global_settings.bt_selective_softlock_actions = true; + + global_settings.bt_selective_softlock_actions_mask = mask; + + return true; +} + +#endif /* !HAS_BUTTON_HOLD */ + /***********************************/ /* TAGCACHE MENU */ #ifdef HAVE_TAGCACHE @@ -137,7 +192,7 @@ static int clear_start_directory(void) splash(HZ, ID2P(LANG_RESET_DONE_CLEAR)); return false; } -MENUITEM_FUNCTION(clear_start_directory_item, 0, ID2P(LANG_RESET_START_DIR), +MENUITEM_FUNCTION(clear_start_directory_item, 0, ID2P(LANG_RESET_START_DIR), clear_start_directory, NULL, NULL, Icon_file_view_menu); static int fileview_callback(int action,const struct menu_item_ex *this_item) { @@ -330,6 +385,19 @@ MENUITEM_SETTING(touchpad_deadzone, &global_settings.touchpad_deadzone, NULL); MENUITEM_SETTING(shortcuts_replaces_quickscreen, &global_settings.shortcuts_replaces_qs, NULL); #endif +#ifndef HAS_BUTTON_HOLD + +MENUITEM_SETTING(bt_selective_actions, + &global_settings.bt_selective_softlock_actions, + selectivesoftlock_callback); +MENUITEM_FUNCTION(sel_softlock_mask, 0, ID2P(LANG_SETTINGS), + selectivesoftlock_set_mask, NULL, + selectivesoftlock_callback, Icon_Menu_setting); + +MAKE_MENU(sel_softlock, ID2P(LANG_SOFTLOCK_SELECTIVE), + NULL, Icon_Menu_setting, &bt_selective_actions, &sel_softlock_mask); +#endif /* !HAS_BUTTON_HOLD */ + #if defined(DX50) || defined(DX90) MENUITEM_SETTING(governor, &global_settings.governor, NULL); MENUITEM_SETTING(usb_mode, &global_settings.usb_mode, NULL); @@ -380,6 +448,9 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), #ifdef HAVE_TOUCHPAD_DEADZONE &touchpad_deadzone, #endif +#ifndef HAS_BUTTON_HOLD + &sel_softlock, +#endif #ifdef USB_ENABLE_HID &usb_hid, &usb_keypad_mode, @@ -544,7 +615,7 @@ MAKE_MENU(bookmark_settings_menu, ID2P(LANG_BOOKMARK_SETTINGS), 0, /***********************************/ /* AUTORESUME MENU */ #ifdef HAVE_TAGCACHE -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC static int autoresume_callback(int action, const struct menu_item_ex *this_item) { @@ -557,7 +628,7 @@ static int autoresume_callback(int action, const struct menu_item_ex *this_item) static const char *lines[] = {ID2P(LANG_TAGCACHE_BUSY), ID2P(LANG_TAGCACHE_FORCE_UPDATE)}; static const struct text_message message = {lines, 2}; - + if (gui_syncyesno_run(&message, NULL, NULL) == YESNO_YES) tagcache_rebuild_with_splash(); } @@ -672,9 +743,9 @@ MAKE_MENU(settings_menu_item, ID2P(LANG_GENERAL_SETTINGS), 0, &startup_shutdown_menu, &bookmark_settings_menu, #ifdef HAVE_TAGCACHE -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC &autoresume_menu, -#endif +#endif #endif &browse_langs, &voice_settings_menu, #ifdef HAVE_HOTKEY |