rockbox/apps/settings.c

1443 lines
42 KiB
C
Raw Normal View History

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Stuart Martin
* RTC config saving code (C) 2002 by hessu@hes.iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
/* Define LOGF_ENABLE to enable logf output in this file */
/*#define LOGF_ENABLE*/
/*Define DEBUG_AVAIL_SETTINGS to get a list of all available settings and flags */
/*#define DEBUG_AVAIL_SETTINGS*/ /* Needs (LOGF_ENABLE) */
#include "logf.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <limits.h>
#include "inttypes.h"
#include "config.h"
#include "rbpaths.h"
#include "action.h"
#include "crc32.h"
#include "sound.h"
#include "settings.h"
#include "debug.h"
#include "usb.h"
#include "backlight.h"
#include "audio.h"
#include "talk.h"
#include "string-extra.h"
#include "rtc.h"
#include "power.h"
#include "ata_idle_notify.h"
#include "storage.h"
#include "screens.h"
#include "ctype.h"
#include "file.h"
#include "system.h"
#include "general.h"
#include "misc.h"
#include "icons.h"
#include "font.h"
#include "peakmeter.h"
#include "lang.h"
#include "language.h"
#include "powermgmt.h"
#include "keyboard.h"
#include "version.h"
#include "rbunicode.h"
#include "dircache.h"
#include "splash.h"
#include "list.h"
#include "settings_list.h"
#include "filetypes.h"
#include "option_select.h"
#if CONFIG_TUNER
#include "radio.h"
#endif
#include "wps.h"
#include "skin_engine/skin_engine.h"
#include "viewport.h"
Initial custom statusbar commit. The custom statusbar can be used as a WPS for the main UI, using .(r)sbs files. It's using the skin engine and knows all tags the WPS also knows. The default folder for .sbs is the wps folder to reuse images used in the WPS. As it can be shown in the WPS also, it's useful to move shared parts to the custom statusbar in order to save skin buffer space. There are a few restrictions/TODOs: *) Peak meter doesn't redraw nicely(not frequent enough), as very frequent updates would slow the UI down as hell (some targets fight with it in the WPS already: FS#10686) *) No touchregion support as the statusbar doesn't have any action handling (it won't fail to parse though). *) Drawing stuff into the default VP is forbidden (loading images in it is not). You *need* to use viewports for the displaying stuff (parsing fails if no viewport is used). *) Themes that don't use a custom ui viewport can be fixed up using the new %Vi tag to avoid nasty redraw effectts (you must not draw into it as well, it's used to fix up the ui viewport). %Vi describes the viewport that the lists can use without getting in the way of the statusbar. Otherwise, it behaves like the classic statusbar, it can be configured in the theme settings, and can be turned off in the wps using %wd. Note to translaters: When translating LANG_STATUSBAR_CUSTOM, please consider using the same translation as for LANG_CHANNEL_CUSTOM if it's compatible. They could be combined later then. Flyspray: FS#10566 Author: myself git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23258 a1c6a512-1295-4272-9138-f99709370657
2009-10-19 15:28:15 +00:00
#include "statusbar-skinned.h"
#include "bootchart.h"
#include "scroll_engine.h"
struct user_settings global_settings;
struct system_status global_status;
#include "dsp_proc_settings.h"
#include "playback.h"
#ifdef HAVE_RECORDING
#include "enc_config.h"
#endif
#include "pcm_sampr.h"
#define NVRAM_DATA_START 8
#define NVRAM_BLOCK_SIZE (sizeof(struct system_status) + NVRAM_DATA_START)
#define MAX_LINES 10
#ifdef HAVE_REMOTE_LCD
#include "lcd-remote.h"
#endif
#if defined(DX50) || defined(DX90)
#include "governor-ibasso.h"
#include "usb-ibasso.h"
#endif
#ifdef ROCKBOX_NO_TEMP_SETTINGS_FILE /* Overwrites same file each time */
#define CONFIGFILE_TEMP CONFIGFILE
#define NVRAM_FILE_TEMP NVRAM_FILE
#define rename_temp_file(a,b,c)
#else /* creates temp files on save, renames next load, saves old file if desired */
#define CONFIGFILE_TEMP CONFIGFILE".new"
#define NVRAM_FILE_TEMP NVRAM_FILE".new"
#ifdef LOGF_ENABLE
static char *debug_get_flags(uint32_t flags);
#endif
static void debug_available_settings(void);
static void rename_temp_file(const char *tempfile,
const char *file,
const char *oldfile)
{
/* if tempfile does not exist -- Return
* if oldfile is supplied -- Rename file to oldfile
* if tempfile does exist -- Rename tempfile to file
*/
if (file_exists(tempfile))
{
if (oldfile != NULL && file_exists(file))
rename(file, oldfile);
rename(tempfile, file);
}
}
#endif
long lasttime = 0;
/** NVRAM stuff, if the target doesnt have NVRAM it is saved in ROCKBOX_DIR /nvram.bin **/
/* NVRAM is set out as
*
* [0] 'R'
* [1] 'b'
* [2] version
* [3] stored variable count
* [4-7] crc32 checksum in host endian order
* [8+] data
*/
static unsigned int nvram_crc(char *buf, int max_len)
{
return crc_32(&buf[NVRAM_DATA_START], max_len - NVRAM_DATA_START - 1, 0xffffffff);
}
static void read_nvram_data(void)
{
rename_temp_file(NVRAM_FILE_TEMP, NVRAM_FILE, NVRAM_FILE".old");
int fd = open(NVRAM_FILE, O_RDONLY);
if (fd < 0)
return;
char buf[NVRAM_BLOCK_SIZE];
memset(buf, 0, sizeof(buf));
ssize_t bytes = read(fd, buf, sizeof(buf));
close(fd);
if (bytes < 8) /* min is 8 bytes,magic, ver, vars, crc32 */
return;
/* check magic, version */
if (buf[0] != 'R' || buf[1] != 'b' || buf[2] != NVRAM_CONFIG_VERSION)
return;
/* check crc32 */
unsigned int crc32 = nvram_crc(buf, sizeof(buf));
if (crc32 != load_h32(&buf[4]))
return;
/* all good, so read in the settings */
int var_count = buf[3];
size_t buf_pos = NVRAM_DATA_START;
for(int i = 0; i < nb_settings; i++)
{
const struct settings_list *setting = &settings[i];
int nvram_bytes = (setting->flags & F_NVRAM_BYTES_MASK) >> F_NVRAM_MASK_SHIFT;
if (nvram_bytes)
{
if (var_count > 0 && buf_pos < (size_t)bytes)
{
memcpy(setting->setting, &buf[buf_pos], nvram_bytes);
buf_pos += nvram_bytes;
var_count--;
}
else /* should only happen when new items are added to the end */
{
memcpy(setting->setting, &setting->default_val, nvram_bytes);
}
}
}
}
static void write_nvram_data(void)
{
char buf[NVRAM_BLOCK_SIZE];
memset(buf, 0, sizeof(buf));
/* magic, version */
buf[0] = 'R';
buf[1] = 'b';
buf[2] = NVRAM_CONFIG_VERSION;
size_t buf_pos = NVRAM_DATA_START;
int var_count = 0;
for(int i = 0; i < nb_settings && buf_pos < sizeof(buf); i++)
{
const struct settings_list *setting = &settings[i];
int nvram_bytes = (setting->flags & F_NVRAM_BYTES_MASK) >> F_NVRAM_MASK_SHIFT;
if (nvram_bytes)
{
memcpy(&buf[buf_pos], setting->setting, nvram_bytes);
buf_pos += nvram_bytes;
var_count++;
}
}
/* count and crc32 */
buf[3] = var_count;
store_h32(&buf[4], nvram_crc(buf, sizeof(buf)));
int fd = open(NVRAM_FILE_TEMP,O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd < 0)
return;
write(fd, buf, sizeof(buf));
close(fd);
}
/** Reading from a config file **/
/*
* load settings from disk or RTC RAM
*/
void settings_load(int which)
{
logf("\r\n%s()\r\n", __func__);
debug_available_settings();
if (which & SETTINGS_RTC)
read_nvram_data();
if (which & SETTINGS_HD)
{
rename_temp_file(CONFIGFILE_TEMP, CONFIGFILE, CONFIGFILE".old");
settings_load_config(CONFIGFILE, false);
settings_load_config(FIXEDSETTINGSFILE, false);
}
}
bool cfg_string_to_int(const struct settings_list *setting, int* out, const char* str)
{
const char* ptr = setting->cfg_vals;
size_t len = strlen(str);
int index = 0;
while (true)
{
if (!strncmp(ptr, str, len))
{
ptr += len;
/* if the next character is not a comma or end of string,
* it means the comparison was only a partial match. */
if (*ptr == ',' || *ptr == '\0')
{
*out = index;
return true;
}
}
while (*ptr != ',')
{
if (!*ptr)
return false;
ptr++;
}
ptr++;
index++;
}
}
/**
* Copy an input string to an output buffer, stripping the prefix and
* suffix listed in the filename setting. Returns false if the output
* string does not fit in the buffer or is longer than the setting's
* max_len, and the output buffer will not be modified.
*
* Returns true if the setting was copied successfully. The input and
* output buffers are allowed to alias.
*/
bool copy_filename_setting(char *buf, size_t buflen, const char *input,
const struct filename_setting *fs)
{
size_t input_len = strlen(input);
size_t len;
if (fs->prefix)
{
len = strlen(fs->prefix);
if (len <= input_len && !strncasecmp(input, fs->prefix, len))
{
input += len;
input_len -= len;
}
}
if (fs->suffix)
{
len = strlen(fs->suffix);
if (len <= input_len &&
!strcasecmp(input + input_len - len, fs->suffix))
{
input_len -= len;
}
}
/* Make sure it fits the output buffer and repsects the setting's max_len.
* Note that max_len is a buffer size and thus includes a null terminator */
if (input_len >= (size_t)fs->max_len || input_len >= buflen)
return false;
/* Copy what remains into buf - use memmove in case of aliasing */
memmove(buf, input, input_len);
buf[input_len] = '\0';
return true;
}
bool settings_load_config(const char* file, bool apply)
{
logf("%s()\r\n", __func__);
const struct settings_list *setting;
int fd;
char line[128];
char* name;
char* value;
bool theme_changed = false;
fd = open_utf8(file, O_RDONLY);
if (fd < 0)
return false;
while (read_line(fd, line, sizeof line) > 0)
{
if (!settings_parseline(line, &name, &value))
continue;
setting = find_setting_by_cfgname(name);
if (!setting)
continue;
if (setting->flags & F_THEMESETTING)
theme_changed = true;
switch (setting->flags & F_T_MASK)
{
case F_T_CUSTOM:
setting->custom_setting->load_from_cfg(setting->setting, value);
logf("Val: %s\r\n",value);
break;
case F_T_INT:
case F_T_UINT:
#ifdef HAVE_LCD_COLOR
if (setting->flags & F_RGB)
{
hex_to_rgb(value, (int*)setting->setting);
logf("Val: %s\r\n", value);
}
else
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
2016-11-22 05:21:31 +00:00
#endif
if (setting->cfg_vals == NULL)
{
*(int*)setting->setting = atoi(value);
logf("Val: %s\r\n",value);
}
else
{
int temp, *v = (int*)setting->setting;
bool found = cfg_string_to_int(setting, &temp, value);
if (found)
{
if (setting->flags & F_TABLE_SETTING)
*v = setting->table_setting->values[temp];
else
*v = temp;
logf("Val: %d\r\n", *v);
}
else if (setting->flags & F_ALLOW_ARBITRARY_VALS)
{
*v = atoi(value);
logf("Val: %s = %d\r\n", value, *v);
}
else if (setting->flags & F_TABLE_SETTING)
{
const struct table_setting *info = setting->table_setting;
temp = atoi(value);
*v = setting->default_val.int_;
if (info->values)
{
for(int i = 0; i < info->count; i++)
{
if (info->values[i] == temp)
{
*v = temp;
break;
}
}
}
logf("Val: %s", *v == temp ? "Found":"Error Not Found");
logf("Val: %s = %d\r\n", value, *v);
}
else
{
logf("Error: %s: Not Found! [%s]\r\n",
setting->cfg_name, value);
}
}
break;
case F_T_BOOL:
{
int temp;
if (cfg_string_to_int(setting, &temp, value))
{
*(bool*)setting->setting = !!temp;
logf("Val: %s\r\n", value);
}
if (setting->bool_setting->option_callback)
{
setting->bool_setting->option_callback(!!temp);
}
break;
}
/* these can be plain text, filenames, or dirnames */
case F_T_CHARPTR:
case F_T_UCHARPTR:
{
const struct filename_setting *fs = setting->filename_setting;
copy_filename_setting((char*)setting->setting,
fs->max_len, value, fs);
logf("Val: %s\r\n", value);
break;
}
}
} /* while(...) */
close(fd);
if (apply)
{
settings_save();
settings_apply(true);
if (theme_changed)
settings_apply_skins();
}
return true;
}
/** Writing to a config file and saving settings **/
bool cfg_int_to_string(const struct settings_list *setting, int val, char* buf, int buf_len)
{
const char* ptr = setting->cfg_vals;
const int *values = NULL;
int index = 0;
if (setting->flags & F_TABLE_SETTING)
values = setting->table_setting->values;
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
2016-11-22 05:21:31 +00:00
while (true)
{
if ((values && values[index] == val) ||
(!values && index == val))
{
char *buf_end = buf + buf_len - 1;
while (*ptr && *ptr != ',' && buf != buf_end)
*buf++ = *ptr++;
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
2016-11-22 05:21:31 +00:00
*buf++ = '\0';
return true;
}
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
2016-11-22 05:21:31 +00:00
while (*ptr != ',')
{
if (!*ptr)
return false;
ptr++;
}
ptr++;
index++;
}
}
void cfg_to_string(const struct settings_list *setting, char* buf, int buf_len)
{
switch (setting->flags & F_T_MASK)
{
case F_T_CUSTOM:
setting->custom_setting->write_to_cfg(setting->setting, buf, buf_len);
break;
case F_T_INT:
case F_T_UINT:
#ifdef HAVE_LCD_COLOR
if (setting->flags & F_RGB)
{
int colour = *(int*)setting->setting;
snprintf(buf,buf_len,"%02x%02x%02x",
(int)RGB_UNPACK_RED(colour),
(int)RGB_UNPACK_GREEN(colour),
(int)RGB_UNPACK_BLUE(colour));
}
else
#endif
if (setting->cfg_vals == NULL)
{
snprintf(buf, buf_len, "%d", *(int*)setting->setting);
}
else
{
if (!cfg_int_to_string(setting, *(int*)setting->setting,
buf, buf_len))
snprintf(buf, buf_len, "%d", *(int*)setting->setting);
}
break;
case F_T_BOOL:
cfg_int_to_string(setting, *(bool*)setting->setting, buf, buf_len);
break;
case F_T_CHARPTR:
case F_T_UCHARPTR:
{
char *value = setting->setting;
const struct filename_setting *fs = setting->filename_setting;
if (value[0] && fs->prefix)
{
if (value[0] == '-')
{
buf[0] = '-';
buf[1] = '\0';
}
else
{
snprintf(buf, buf_len, "%s%s%s",
fs->prefix, value, fs->suffix);
}
}
else
{
strmemccpy(buf, value, buf_len);
}
break;
}
} /* switch () */
}
static bool is_changed(const struct settings_list *setting)
{
switch (setting->flags&F_T_MASK)
{
case F_T_CUSTOM:
return setting->custom_setting->is_changed(setting->setting,
setting->default_val.custom);
break;
case F_T_INT:
case F_T_UINT:
if (setting->flags&F_DEF_ISFUNC)
{
if (*(int*)setting->setting == setting->default_val.func())
return false;
}
else if (setting->flags&F_T_SOUND)
{
if (*(int*)setting->setting ==
sound_default(setting->sound_setting->setting))
return false;
}
else if (*(int*)setting->setting == setting->default_val.int_)
return false;
break;
case F_T_BOOL:
if (*(bool*)setting->setting == setting->default_val.bool_)
return false;
break;
case F_T_CHARPTR:
case F_T_UCHARPTR:
if (!strcmp((char*)setting->setting, setting->default_val.charptr))
return false;
break;
}
return true;
}
static bool settings_write_config(const char* filename, int options)
{
logf("%s\r\n", __func__);
int i;
int fd;
char value[MAX_PATH];
fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd < 0)
return false;
fdprintf(fd, "# .cfg file created by rockbox %s - "
"http://www.rockbox.org\r\n\r\n", rbversion);
for(i=0; i<nb_settings; i++)
{
const struct settings_list *setting = &settings[i];
if (!setting->cfg_name || (setting->flags & F_DEPRECATED))
continue;
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
2016-11-22 05:21:31 +00:00
switch (options)
{
case SETTINGS_SAVE_CHANGED:
if (!is_changed(setting))
continue;
break;
case SETTINGS_SAVE_SOUND:
if (!(setting->flags & F_SOUNDSETTING))
continue;
break;
case SETTINGS_SAVE_THEME:
if (!(setting->flags & F_THEMESETTING))
continue;
break;
#ifdef HAVE_RECORDING
case SETTINGS_SAVE_RECPRESETS:
if (!(setting->flags & F_RECSETTING))
continue;
break;
#endif
case SETTINGS_SAVE_EQPRESET:
if (!(setting->flags & F_EQSETTING))
continue;
break;
}
cfg_to_string(setting, value, MAX_PATH);
logf("Written: '%s: %s'\r\n",setting->cfg_name, value);
fdprintf(fd,"%s: %s\r\n",setting->cfg_name,value);
} /* for(...) */
close(fd);
return true;
}
static void flush_global_status_callback(void)
{
write_nvram_data();
}
static void flush_config_block_callback(void)
{
write_nvram_data();
settings_write_config(CONFIGFILE_TEMP, SETTINGS_SAVE_CHANGED);
}
void reset_runtime(void)
{
lasttime = current_tick;
global_status.runtime = 0;
}
/*
* persist all runtime user settings to disk or RTC RAM
*/
static void update_runtime(void)
{
int elapsed_secs;
elapsed_secs = (current_tick - lasttime) / HZ;
global_status.runtime += elapsed_secs;
lasttime += (elapsed_secs * HZ);
if ( global_status.runtime > global_status.topruntime )
global_status.topruntime = global_status.runtime;
}
void status_save(void)
{
update_runtime();
register_storage_idle_func(flush_global_status_callback);
}
int settings_save(void)
{
logf("%s", __func__);
update_runtime();
register_storage_idle_func(flush_config_block_callback);
return 0;
}
bool settings_save_config(int options)
{
/* if we have outstanding temp files it would be a good idea to flush
them before the user starts saving things */
rename_temp_file(NVRAM_FILE_TEMP, NVRAM_FILE, NULL); /* dont overwrite .old */
rename_temp_file(CONFIGFILE_TEMP, CONFIGFILE, NULL); /* files from last boot */
char filename[MAX_PATH];
const char *folder, *namebase;
switch (options)
{
case SETTINGS_SAVE_THEME:
folder = THEME_DIR;
namebase = "theme";
break;
#ifdef HAVE_RECORDING
case SETTINGS_SAVE_RECPRESETS:
folder = RECPRESETS_DIR;
namebase = "recording";
break;
#endif
case SETTINGS_SAVE_EQPRESET:
folder = EQS_DIR;
namebase = "eq";
break;
case SETTINGS_SAVE_SOUND:
folder = ROCKBOX_DIR;
namebase = "sound";
break;
default:
folder = ROCKBOX_DIR;
namebase = "config";
break;
}
create_numbered_filename(filename, folder, namebase, ".cfg", 2
IF_CNFN_NUM_(, NULL));
/* allow user to modify filename */
while (true) {
if (!kbd_input(filename, sizeof(filename), NULL)) {
break;
}
else {
return false;
}
}
if (settings_write_config(filename, options))
splash(HZ, ID2P(LANG_SETTINGS_SAVED));
else
splash(HZ, ID2P(LANG_FAILED));
return true;
}
/** Apply and Reset settings **/
/*
* Applies the range infos stored in global_settings to
* the peak meter.
*/
void settings_apply_pm_range(void)
{
int pm_min, pm_max;
/* depending on the scale mode (dBfs or percent) the values
of global_settings.peak_meter_dbfs have different meanings */
if (global_settings.peak_meter_dbfs)
{
/* convert to dBfs * 100 */
pm_min = -(((int)global_settings.peak_meter_min) * 100);
pm_max = -(((int)global_settings.peak_meter_max) * 100);
}
else
{
/* percent is stored directly -> no conversion */
pm_min = global_settings.peak_meter_min;
pm_max = global_settings.peak_meter_max;
}
/* apply the range */
peak_meter_init_range(global_settings.peak_meter_dbfs, pm_min, pm_max);
}
void sound_settings_apply(void)
{
#ifdef AUDIOHW_HAVE_BASS
sound_set(SOUND_BASS, global_settings.bass);
#endif
#ifdef AUDIOHW_HAVE_TREBLE
sound_set(SOUND_TREBLE, global_settings.treble);
#endif
sound_set(SOUND_BALANCE, global_settings.balance);
#ifndef PLATFORM_HAS_VOLUME_CHANGE
sound_set(SOUND_VOLUME, global_settings.volume);
#endif
sound_set(SOUND_CHANNELS, global_settings.channel_config);
sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width);
#ifdef AUDIOHW_HAVE_BASS_CUTOFF
sound_set(SOUND_BASS_CUTOFF, global_settings.bass_cutoff);
#endif
#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
sound_set(SOUND_TREBLE_CUTOFF, global_settings.treble_cutoff);
#endif
#ifdef AUDIOHW_HAVE_DEPTH_3D
sound_set(SOUND_DEPTH_3D, global_settings.depth_3d);
#endif
#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
sound_set(SOUND_FILTER_ROLL_OFF, global_settings.roll_off);
#endif
#ifdef AUDIOHW_HAVE_POWER_MODE
sound_set(SOUND_POWER_MODE, global_settings.power_mode);
#endif
#ifdef AUDIOHW_HAVE_EQ
int b;
for (b = 0; b < AUDIOHW_EQ_BAND_NUM; b++)
{
int setting = sound_enum_hw_eq_band_setting(b, AUDIOHW_EQ_GAIN);
sound_set(setting, global_settings.hw_eq_bands[b].gain);
#ifdef AUDIOHW_HAVE_EQ_FREQUENCY
setting = sound_enum_hw_eq_band_setting(b, AUDIOHW_EQ_FREQUENCY);
if (setting != -1)
sound_set(setting, global_settings.hw_eq_bands[b].frequency);
#endif /* AUDIOHW_HAVE_EQ_FREQUENCY */
#ifdef AUDIOHW_HAVE_EQ_WIDTH
setting = sound_enum_hw_eq_band_setting(b, AUDIOHW_EQ_WIDTH);
if (setting != -1)
sound_set(setting, global_settings.hw_eq_bands[b].width);
#endif /* AUDIOHW_HAVE_EQ_WIDTH */
}
#endif
}
void settings_apply(bool read_disk)
{
logf("%s", __func__);
int rc;
Rewrite filesystem code (WIP) This patch redoes the filesystem code from the FAT driver up to the clipboard code in onplay.c. Not every aspect of this is finished therefore it is still "WIP". I don't wish to do too much at once (haha!). What is left to do is get dircache back in the sim and find an implementation for the dircache indicies in the tagcache and playlist code or do something else that has the same benefit. Leaving these out for now does not make anything unusable. All the basics are done. Phone app code should probably get vetted (and app path handling just plain rewritten as environment expansions); the SDL app and Android run well. Main things addressed: 1) Thread safety: There is none right now in the trunk code. Most of what currently works is luck when multiple threads are involved or multiple descriptors to the same file are open. 2) POSIX compliance: Many of the functions behave nothing like their counterparts on a host system. This leads to inconsistent code or very different behavior from native to hosted. One huge offender was rename(). Going point by point would fill a book. 3) Actual running RAM usage: Many targets will use less RAM and less stack space (some more RAM because I upped the number of cache buffers for large memory). There's very little memory lying fallow in rarely-used areas (see 'Key core changes' below). Also, all targets may open the same number of directory streams whereas before those with less than 8MB RAM were limited to 8, not 12 implying those targets will save slightly less. 4) Performance: The test_disk plugin shows markedly improved performance, particularly in the area of (uncached) directory scanning, due partly to more optimal directory reading and to a better sector cache algorithm. Uncached times tend to be better while there is a bit of a slowdown in dircache due to it being a bit heavier of an implementation. It's not noticeable by a human as far as I can say. Key core changes: 1) Files and directories share core code and data structures. 2) The filesystem code knows which descriptors refer to same file. This ensures that changes from one stream are appropriately reflected in every open descriptor for that file (fileobj_mgr.c). 3) File and directory cache buffers are borrowed from the main sector cache. This means that when they are not in use by a file, they are not wasted, but used for the cache. Most of the time, only a few of them are needed. It also means that adding more file and directory handles is less expensive. All one must do in ensure a large enough cache to borrow from. 4) Relative path components are supported and the namespace is unified. It does not support full relative paths to an implied current directory; what is does support is use of "." and "..". Adding the former would not be very difficult. The namespace is unified in the sense that volumes may be specified several times along with relative parts, e.g.: "/<0>/foo/../../<1>/bar" :<=> "/<1>/bar". 5) Stack usage is down due to sharing of data, static allocation and less duplication of strings on the stack. This requires more serialization than I would like but since the number of threads is limited to a low number, the tradoff in favor of the stack seems reasonable. 6) Separates and heirarchicalizes (sic) the SIM and APP filesystem code. SIM path and volume handling is just like the target. Some aspects of the APP file code get more straightforward (e.g. no path hashing is needed). Dircache: Deserves its own section. Dircache is new but pays homage to the old. The old one was not compatible and so it, since it got redone, does all the stuff it always should have done such as: 1) It may be update and used at any time during the build process. No longer has one to wait for it to finish building to do basic file management (create, remove, rename, etc.). 2) It does not need to be either fully scanned or completely disabled; it can be incomplete (i.e. overfilled, missing paths), still be of benefit and be correct. 3) Handles mounting and dismounting of individual volumes which means a full rebuild is not needed just because you pop a new SD card in the slot. Now, because it reuses its freed entry data, may rebuild only that volume. 4) Much more fundamental to the file code. When it is built, it is the keeper of the master file list whether enabled or not ("disabled" is just a state of the cache). Its must always to ready to be started and bind all streams opened prior to being enabled. 5) Maintains any short filenames in OEM format which means that it does not need to be rebuilt when changing the default codepage. Miscellaneous Compatibility: 1) Update any other code that would otherwise not work such as the hotswap mounting code in various card drivers. 2) File management: Clipboard needed updating because of the behavioral changes. Still needs a little more work on some finer points. 3) Remove now-obsolete functionality such as the mutex's "no preempt" flag (which was only for the prior FAT driver). 4) struct dirinfo uses time_t rather than raw FAT directory entry time fields. I plan to follow up on genericizing everything there (i.e. no FAT attributes). 5) unicode.c needed some redoing so that the file code does not try try to load codepages during a scan, which is actually a problem with the current code. The default codepage, if any is required, is now kept in RAM separarately (bufalloced) from codepages specified to iso_decode() (which must not be bufalloced because the conversion may be done by playback threads). Brings with it some additional reusable core code: 1) Revised file functions: Reusable code that does things such as safe path concatenation and parsing without buffer limitations or data duplication. Variants that copy or alter the input path may be based off these. To do: 1) Put dircache functionality back in the sim. Treating it internally as a different kind of file system seems the best approach at this time. 2) Restore use of dircache indexes in the playlist and database or something effectively the same. Since the cache doesn't have to be complete in order to be used, not getting a hit on the cache doesn't unambiguously say if the path exists or not. Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8 Reviewed-on: http://gerrit.rockbox.org/566 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
CHART(">set_codepage");
set_codepage(global_settings.default_codepage);
CHART("<set_codepage");
sound_settings_apply();
#ifdef HAVE_DISK_STORAGE
audio_set_buffer_margin(global_settings.buffer_margin);
#endif
#ifdef HAVE_LCD_CONTRAST
lcd_set_contrast(global_settings.contrast);
#endif
lcd_scroll_speed(global_settings.scroll_speed);
#ifdef HAVE_REMOTE_LCD
lcd_remote_set_contrast(global_settings.remote_contrast);
lcd_remote_set_invert_display(global_settings.remote_invert);
#ifdef HAVE_LCD_FLIP
lcd_remote_set_flip(global_settings.remote_flip_display);
#endif
lcd_remote_scroll_speed(global_settings.remote_scroll_speed);
lcd_remote_scroll_step(global_settings.remote_scroll_step);
lcd_remote_scroll_delay(global_settings.remote_scroll_delay);
lcd_remote_bidir_scroll(global_settings.remote_bidir_limit);
#ifdef HAVE_REMOTE_LCD_TICKING
lcd_remote_emireduce(global_settings.remote_reduce_ticking);
#endif
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
#if CONFIG_CHARGING
remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged);
#endif
#ifdef HAS_REMOTE_BUTTON_HOLD
remote_backlight_set_on_button_hold(global_settings.remote_backlight_on_button_hold);
#endif
#endif /* HAVE_REMOTE_LCD */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
backlight_set_brightness(global_settings.brightness);
#endif
#ifdef HAVE_BACKLIGHT
backlight_set_timeout(global_settings.backlight_timeout);
#if CONFIG_CHARGING
backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
#endif
#if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
|| defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
backlight_set_fade_in(global_settings.backlight_fade_in);
backlight_set_fade_out(global_settings.backlight_fade_out);
#endif
#endif
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
buttonlight_set_brightness(global_settings.buttonlight_brightness);
#endif
#ifdef HAVE_BUTTON_LIGHT
buttonlight_set_timeout(global_settings.buttonlight_timeout);
#endif
#ifdef HAVE_DISK_STORAGE
storage_spindown(global_settings.disk_spindown);
#endif
set_poweroff_timeout(global_settings.poweroff);
if (global_settings.sleeptimer_on_startup)
set_sleeptimer_duration(global_settings.sleeptimer_duration);
set_keypress_restarts_sleep_timer(
global_settings.keypress_restarts_sleeptimer);
#if BATTERY_CAPACITY_INC > 0
/* only call if it's really exchangable */
set_battery_capacity(global_settings.battery_capacity);
#endif
#if BATTERY_TYPES_COUNT > 1
set_battery_type(global_settings.battery_type);
#endif
#ifdef HAVE_LCD_INVERT
lcd_set_invert_display(global_settings.invert);
#endif
#ifdef HAVE_LCD_FLIP
lcd_set_flip(global_settings.flip_display);
button_set_flip(global_settings.flip_display);
#endif
lcd_update(); /* refresh after flipping the screen */
settings_apply_pm_range();
peak_meter_init_times(
global_settings.peak_meter_release, global_settings.peak_meter_hold,
global_settings.peak_meter_clip_hold);
#ifdef HAVE_SPEAKER
audio_enable_speaker(global_settings.speaker_mode);
#endif
if (read_disk)
{
char buf[MAX_PATH];
/* fonts need to be loaded before the WPS */
if (global_settings.font_file[0]
&& global_settings.font_file[0] != '-') {
int font_ui = screens[SCREEN_MAIN].getuifont();
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
global_settings.font_file);
if (!font_filename_matches_loaded_id(font_ui, buf))
{
CHART2(">font_load ", global_settings.font_file);
if (font_ui >= 0)
font_unload(font_ui);
rc = font_load_ex(buf, 0, global_settings.glyphs_to_cache);
CHART2("<font_load ", global_settings.font_file);
screens[SCREEN_MAIN].setuifont(rc);
screens[SCREEN_MAIN].setfont(rc);
}
}
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
2016-11-22 05:21:31 +00:00
#ifdef HAVE_REMOTE_LCD
if ( global_settings.remote_font_file[0]
&& global_settings.remote_font_file[0] != '-') {
int font_ui = screens[SCREEN_REMOTE].getuifont();
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
global_settings.remote_font_file);
if (!font_filename_matches_loaded_id(font_ui, buf))
{
CHART2(">font_load_remoteui ", global_settings.remote_font_file);
if (font_ui >= 0)
font_unload(font_ui);
rc = font_load(buf);
CHART2("<font_load_remoteui ", global_settings.remote_font_file);
screens[SCREEN_REMOTE].setuifont(rc);
screens[SCREEN_REMOTE].setfont(rc);
}
}
#endif
if ( global_settings.kbd_file[0]
&& global_settings.kbd_file[0] != '-') {
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
global_settings.kbd_file);
CHART(">load_kbd");
load_kbd(buf);
CHART("<load_kbd");
}
else
load_kbd(NULL);
if ( global_settings.lang_file[0]) {
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
global_settings.lang_file);
CHART(">lang_core_load");
lang_core_load(buf);
CHART("<lang_core_load");
}
CHART(">talk_init");
talk_init(); /* use voice of same language */
CHART("<talk_init");
/* load the icon set */
CHART(">icons_init");
icons_init();
CHART("<icons_init");
#ifdef HAVE_LCD_COLOR
CHART(">read_color_theme_file");
read_color_theme_file();
CHART("<read_color_theme_file");
#endif
}
#ifdef HAVE_LCD_COLOR
screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
screens[SCREEN_MAIN].set_background(global_settings.bg_color);
#endif
lcd_scroll_step(global_settings.scroll_step);
lcd_bidir_scroll(global_settings.bidir_limit);
lcd_scroll_delay(global_settings.scroll_delay);
#ifdef HAVE_ALBUMART
set_albumart_mode(global_settings.album_art);
#endif
#ifdef HAVE_PLAY_FREQ
/* before crossfade */
audio_set_playback_frequency(global_settings.play_frequency);
#endif
#ifdef HAVE_CROSSFADE
audio_set_crossfade(global_settings.crossfade);
#endif
replaygain_update();
dsp_set_crossfeed_type(global_settings.crossfeed);
dsp_set_crossfeed_direct_gain(global_settings.crossfeed_direct_gain);
dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain,
global_settings.crossfeed_hf_attenuation,
global_settings.crossfeed_hf_cutoff);
/* Configure software equalizer, hardware eq is handled in audio_init() */
dsp_eq_enable(global_settings.eq_enabled);
dsp_set_eq_precut(global_settings.eq_precut);
for(int i = 0; i < EQ_NUM_BANDS; i++) {
dsp_set_eq_coefs(i, &global_settings.eq_band_settings[i]);
}
dsp_dither_enable(global_settings.dithering_enabled);
dsp_surround_set_balance(global_settings.surround_balance);
dsp_surround_set_cutoff(global_settings.surround_fx1, global_settings.surround_fx2);
dsp_surround_mix(global_settings.surround_mix);
dsp_surround_enable(global_settings.surround_enabled);
dsp_afr_enable(global_settings.afr_enabled);
dsp_pbe_precut(global_settings.pbe_precut);
dsp_pbe_enable(global_settings.pbe);
#ifdef HAVE_PITCHCONTROL
dsp_timestretch_enable(global_settings.timestretch_enabled);
#endif
dsp_set_compressor(&global_settings.compressor_settings);
#ifdef HAVE_SPDIF_POWER
spdif_power_enable(global_settings.spdif_enable);
#endif
#ifdef HAVE_BACKLIGHT
set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
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
2016-11-22 05:21:31 +00:00
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
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
2016-11-22 05:21:31 +00:00
#ifdef HAVE_LCD_SLEEP_SETTING
lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off);
#endif
#endif /* HAVE_BACKLIGHT */
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
2016-11-22 05:21:31 +00:00
#ifndef HAS_BUTTON_HOLD
set_selective_softlock_actions(
global_settings.bt_selective_softlock_actions,
global_settings.bt_selective_softlock_actions_mask);
action_autosoftlock_init();
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
2016-11-22 05:21:31 +00:00
#endif
#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
touchpad_set_sensitivity(global_settings.touchpad_sensitivity);
#endif
#ifdef HAVE_TOUCHPAD_DEADZONE
touchpad_set_deadzone(global_settings.touchpad_deadzone);
#endif
#ifdef HAVE_USB_CHARGING_ENABLE
usb_charging_enable(global_settings.usb_charging);
#endif
#ifdef HAVE_TOUCHSCREEN
touchscreen_set_mode(global_settings.touch_mode);
memcpy(&calibration_parameters, &global_settings.ts_calibration_data, sizeof(struct touchscreen_parameter));
#endif
#if defined(DX50) || defined(DX90)
ibasso_set_usb_mode(global_settings.usb_mode);
#elif defined(HAVE_USB_POWER) && !defined(USB_NONE) && !defined(SIMULATOR)
usb_set_mode(global_settings.usb_mode);
#endif
#if defined(DX50) || defined(DX90)
ibasso_set_governor(global_settings.governor);
#endif
/* This should stay last */
#if defined(HAVE_RECORDING)
enc_global_settings_apply();
#endif
Initial custom statusbar commit. The custom statusbar can be used as a WPS for the main UI, using .(r)sbs files. It's using the skin engine and knows all tags the WPS also knows. The default folder for .sbs is the wps folder to reuse images used in the WPS. As it can be shown in the WPS also, it's useful to move shared parts to the custom statusbar in order to save skin buffer space. There are a few restrictions/TODOs: *) Peak meter doesn't redraw nicely(not frequent enough), as very frequent updates would slow the UI down as hell (some targets fight with it in the WPS already: FS#10686) *) No touchregion support as the statusbar doesn't have any action handling (it won't fail to parse though). *) Drawing stuff into the default VP is forbidden (loading images in it is not). You *need* to use viewports for the displaying stuff (parsing fails if no viewport is used). *) Themes that don't use a custom ui viewport can be fixed up using the new %Vi tag to avoid nasty redraw effectts (you must not draw into it as well, it's used to fix up the ui viewport). %Vi describes the viewport that the lists can use without getting in the way of the statusbar. Otherwise, it behaves like the classic statusbar, it can be configured in the theme settings, and can be turned off in the wps using %wd. Note to translaters: When translating LANG_STATUSBAR_CUSTOM, please consider using the same translation as for LANG_CHANNEL_CUSTOM if it's compatible. They could be combined later then. Flyspray: FS#10566 Author: myself git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23258 a1c6a512-1295-4272-9138-f99709370657
2009-10-19 15:28:15 +00:00
/* already called with THEME_STATUSBAR in settings_apply_skins() */
CHART(">viewportmanager_theme_changed");
viewportmanager_theme_changed(THEME_UI_VIEWPORT|THEME_LANGUAGE|THEME_BUTTONBAR);
CHART("<viewportmanager_theme_changed");
}
/*
* reset all settings to their default value
*/
void reset_setting(const struct settings_list *setting, void *var)
{
switch (setting->flags&F_T_MASK)
{
case F_T_CUSTOM:
setting->custom_setting->set_default(setting->setting,
setting->default_val.custom);
break;
case F_T_INT:
case F_T_UINT:
if (setting->flags&F_DEF_ISFUNC)
*(int*)var = setting->default_val.func();
else if (setting->flags&F_T_SOUND)
*(int*)var = sound_default(setting->sound_setting->setting);
else *(int*)var = setting->default_val.int_;
break;
case F_T_BOOL:
*(bool*)var = setting->default_val.bool_;
break;
case F_T_CHARPTR:
case F_T_UCHARPTR:
strmemccpy((char*)var, setting->default_val.charptr,
setting->filename_setting->max_len);
break;
}
}
void settings_reset(void)
{
for(int i=0; i<nb_settings; i++)
reset_setting(&settings[i], settings[i].setting);
#if defined (HAVE_RECORDING)
enc_global_settings_reset();
#endif
FOR_NB_SCREENS(i)
{
if (screens[i].getuifont() > FONT_SYSFIXED)
{
font_unload(screens[i].getuifont());
screens[i].setuifont(FONT_SYSFIXED);
screens[i].setfont(FONT_SYSFIXED);
}
}
}
/** Changing setting values **/
const struct settings_list* find_setting(const void* variable)
{
for(int i = 0; i < nb_settings; i++)
{
const struct settings_list *setting = &settings[i];
if (setting->setting == variable)
return setting;
}
return NULL;
}
const struct settings_list* find_setting_by_cfgname(const char* name)
{
logf("Searching for Setting: '%s'",name);
for(int i = 0; i < nb_settings; i++)
{
const struct settings_list *setting = &settings[i];
if (setting->cfg_name && !strcasecmp(setting->cfg_name, name))
{
logf("Found, flags: %s", debug_get_flags(settings[i].flags));
return setting;
}
}
logf("Setting: '%s' Not Found!",name);
return NULL;
}
bool set_bool(const char* string, const bool* variable )
{
return set_bool_options(string, variable,
(char *)STR(LANG_SET_BOOL_YES),
(char *)STR(LANG_SET_BOOL_NO),
NULL);
}
bool set_bool_options(const char* string, const bool* variable,
const char* yes_str, int yes_voice,
const char* no_str, int no_voice,
void (*function)(bool))
{
struct opt_items names[] = {
{(unsigned const char *)no_str, no_voice},
{(unsigned const char *)yes_str, yes_voice}
};
bool result;
result = set_option(string, variable, BOOL, names, 2,
(void (*)(int))(void (*)(void))function);
return result;
}
bool set_int(const unsigned char* string,
const char* unit,
int voice_unit,
const int* variable,
void (*function)(int),
int step,
int min,
int max,
const char* (*formatter)(char*, size_t, int, const char*) )
{
return set_int_ex(string, unit, voice_unit, variable, function,
step, min, max, formatter, NULL);
}
bool set_int_ex(const unsigned char* string,
const char* unit,
int voice_unit,
const int* variable,
void (*function)(int),
int step,
int min,
int max,
const char* (*formatter)(char*, size_t, int, const char*),
int32_t (*get_talk_id)(int, int))
{
(void)unit;
struct settings_list item;
const struct int_setting data = {
.option_callback = function,
.unit = voice_unit,
.step = step,
.min = min,
.max = max,
.formatter = formatter,
.get_talk_id = get_talk_id,
};
item.int_setting = &data;
item.flags = F_INT_SETTING|F_T_INT;
item.lang_id = -1;
item.cfg_vals = (char*)string;
item.setting = (void *)variable;
return option_screen(&item, NULL, false, NULL);
}
static const struct opt_items *set_option_options;
static const char* set_option_formatter(char* buf, size_t size, int item, const char* unit)
{
(void)buf, (void)unit, (void)size;
return P2STR(set_option_options[item].string);
}
static int32_t set_option_get_talk_id(int value, int unit)
{
(void)unit;
return set_option_options[value].voice_id;
}
bool set_option(const char* string, const void* variable, enum optiontype type,
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
2016-11-22 05:21:31 +00:00
const struct opt_items* options,
int numoptions, void (*function)(int))
{
int temp;
struct settings_list item;
const struct int_setting data = {
.option_callback = function,
.unit = UNIT_INT,
.step = 1,
.min = 0,
.max = numoptions-1,
.formatter = set_option_formatter,
.get_talk_id = set_option_get_talk_id
};
memset(&item, 0, sizeof(struct settings_list));
set_option_options = options;
item.int_setting = &data;
item.flags = F_INT_SETTING|F_T_INT;
item.lang_id = -1;
item.cfg_vals = (char*)string;
item.setting = &temp;
if (type == BOOL)
temp = *(bool*)variable? 1: 0;
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
2016-11-22 05:21:31 +00:00
else
temp = *(int*)variable;
if (!option_screen(&item, NULL, false, NULL))
{
if (type == BOOL)
*(bool*)variable = (temp == 1);
else
*(int*)variable = temp;
return false;
}
return true;
}
/*
* Takes filename, removes the directory and the extension,
* and then copies the basename into setting, unless the basename exceeds maxlen
**/
void set_file(const char* filename, char* setting, const int maxlen)
{
const char* fptr = strrchr(filename,'/');
const char* extptr;
int len;
int extlen = 0;
if (!fptr)
return;
fptr++;
extptr = strrchr(fptr, '.');
if (!extptr || extptr < fptr)
extlen = 0;
else
extlen = strlen(extptr);
len = strlen(fptr) - extlen + 1;
/* error if filename isn't in ROCKBOX_DIR */
if (len > maxlen)
return;
strmemccpy(setting, fptr, len);
settings_save();
}
#ifdef LOGF_ENABLE
static char *debug_get_flags(uint32_t flags)
{
static char buf[256] = {0};
uint32_t ftype = flags & F_T_MASK; /* the variable type for the setting */
flags &= ~F_T_MASK;
switch (ftype)
{
case F_T_CUSTOM:
strlcpy(buf, "[Type CUSTOM] ", sizeof(buf));
break;
case F_T_INT:
strlcpy(buf, "[Type INT] ", sizeof(buf));
break;
case F_T_UINT:
strlcpy(buf, "[Type UINT] ", sizeof(buf));
break;
case F_T_BOOL:
strlcpy(buf, "[Type BOOL] ", sizeof(buf));
break;
case F_T_CHARPTR:
strlcpy(buf, "[Type CHARPTR] ", sizeof(buf));
break;
case F_T_UCHARPTR:
strlcpy(buf, "[Type UCHARPTR] ", sizeof(buf));
break;
}
#define SETTINGFLAGS(n) \
if(flags & n) { \
flags &= ~n; \
strlcat(buf, "["#n"]", sizeof(buf));}
SETTINGFLAGS(F_T_SOUND);
SETTINGFLAGS(F_BOOL_SETTING);
SETTINGFLAGS(F_RGB);
SETTINGFLAGS(F_FILENAME);
SETTINGFLAGS(F_INT_SETTING);
SETTINGFLAGS(F_CHOICE_SETTING);
SETTINGFLAGS(F_CHOICETALKS);
SETTINGFLAGS(F_TABLE_SETTING);
SETTINGFLAGS(F_ALLOW_ARBITRARY_VALS);
SETTINGFLAGS(F_CB_ON_SELECT_ONLY);
SETTINGFLAGS(F_MIN_ISFUNC);
SETTINGFLAGS(F_MAX_ISFUNC);
SETTINGFLAGS(F_DEF_ISFUNC);
SETTINGFLAGS(F_CUSTOM_SETTING);
SETTINGFLAGS(F_TIME_SETTING);
SETTINGFLAGS(F_THEMESETTING);
SETTINGFLAGS(F_RECSETTING);
SETTINGFLAGS(F_EQSETTING);
SETTINGFLAGS(F_SOUNDSETTING);
SETTINGFLAGS(F_TEMPVAR);
SETTINGFLAGS(F_PADTITLE);
SETTINGFLAGS(F_NO_WRAP);
SETTINGFLAGS(F_BANFROMQS);
SETTINGFLAGS(F_DEPRECATED);
#undef SETTINGFLAGS
if (flags & F_NVRAM_BYTES_MASK)
{
flags &= ~F_NVRAM_BYTES_MASK;
strlcat(buf, "[NVRAM]", sizeof(buf));
}
/* anything left is unknown */
if (flags)
{
strlcat(buf, "[UNKNOWN FLAGS]", sizeof(buf));
size_t len = strlen(buf);
if (len < sizeof(buf))
snprintf(buf + len, sizeof(buf) - len - 1, "[%x]", flags);
}
return buf;
}
#endif
static void debug_available_settings(void)
{
#if defined(DEBUG_AVAIL_SETTINGS) && defined(LOGF_ENABLE)
logf("\r\nAvailable Settings:");
for (int i=0; i<nb_settings; i++)
{
uint32_t flags = settings[i].flags;
const char *name;
if (settings[i].cfg_name)
name = settings[i].cfg_name;
else if (settings[i].RESERVED == NULL)
{
name = "SYS (NVRAM?)";
if (flags & F_NVRAM_BYTES_MASK)
{
flags &= ~F_NVRAM_BYTES_MASK;
flags |= 0x80000; /* unused by other flags */
}
}
else
{
name = "?? UNKNOWN NAME ?? ";
}
logf("'%s' flags: %s",name, debug_get_flags(flags));
}
logf("End Available Settings\r\n");
#endif
}