📄 settings.c
字号:
global_settings.playlist_viewer_indices = (config_block[0xae] >> 5) & 1; global_settings.playlist_viewer_track_display = (config_block[0xae] >> 6) & 1; } if(config_block[0xb0] != 0xff) { global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f; global_settings.peak_meter_performance = (config_block[0xb0] & 0x80) != 0; } if(config_block[0xb1] != 0xff) { global_settings.peak_meter_release = config_block[0xb1] & 0x7f; global_settings.peak_meter_dbfs = (config_block[0xb1] & 0x80) != 0; } if(config_block[0xb2] != 0xff) global_settings.peak_meter_min = config_block[0xb2]; if(config_block[0xb3] != 0xff) global_settings.peak_meter_max = config_block[0xb3]; if(config_block[0xb4] != 0xff) global_settings.battery_capacity = config_block[0xb4]*50 + 1000; if (config_block[0xb5] != 0xff) global_settings.scroll_step = config_block[0xb5]; if (config_block[0xb6] != 0xff) global_settings.scroll_delay = config_block[0xb6]; if (config_block[0xb7] != 0xff) global_settings.bidir_limit = config_block[0xb7]; if (config_block[0xac] != 0xff) global_settings.max_files_in_dir = config_block[0xac] | (config_block[0xad] << 8); if (config_block[0xaa] != 0xff) global_settings.max_files_in_playlist = config_block[0xaa] | (config_block[0xab] << 8); strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME); strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME); strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME); if (config_block[0xf4] != 0xff) { global_settings.rec_prerecord_time = config_block[0xf4] & 0x1f; global_settings.rec_directory = (config_block[0xf4] >> 5) & 3; } #ifdef HAVE_LCD_CHARCELLS if (config_block[0xa8] != 0xff) global_settings.jump_scroll = config_block[0xa8]; if (config_block[0xa9] != 0xff) global_settings.jump_scroll_delay = config_block[0xa9];#endif if(config_block[0xaf] != 0xff) { global_settings.usemrb = (config_block[0xaf] >> 5) & 3; global_settings.autocreatebookmark = (config_block[0xaf] >> 2) & 7; global_settings.autoloadbookmark = (config_block[0xaf]) & 3; } } settings_apply();}/* parse a line from a configuration file. the line format is: setting name: setting value Any whitespace before setting name or value (after ':') is ignored. A # as first non-whitespace character discards the whole line. Function sets pointers to null-terminated setting name and value. Returns false if no valid config entry was found.*/static bool settings_parseline(char* line, char** name, char** value){ char* ptr; while ( isspace(*line) ) line++; if ( *line == '#' ) return false; ptr = strchr(line, ':'); if ( !ptr ) return false; *name = line; *ptr = 0; ptr++; while (isspace(*ptr)) ptr++; *value = ptr; return true;}void set_file(char* filename, char* setting, int maxlen){ char* fptr = strrchr(filename,'/'); int len; int extlen = 0; char* ptr; if (!fptr) return; *fptr = 0; fptr++; len = strlen(fptr); ptr = fptr + len; while (*ptr != '.') { extlen++; ptr--; } if (strncmp(ROCKBOX_DIR, filename ,strlen(ROCKBOX_DIR)) || (len-extlen > maxlen)) return; strncpy(setting, fptr, len-extlen); setting[len-extlen]=0; settings_save();}static void set_sound(char* value, int type, int* setting){ int num = atoi(value); num = mpeg_phys2val(type, num); if ((num > mpeg_sound_max(type)) || (num < mpeg_sound_min(type))) { num = mpeg_sound_default(type); } *setting = num; mpeg_sound_set(type, num);#ifdef HAVE_MAS3507D /* This is required to actually apply balance */ if (SOUND_BALANCE == type) mpeg_sound_set(SOUND_VOLUME, global_settings.volume);#endif}static void set_cfg_bool(bool* variable, char* value){ /* look for the 'n' in 'on' */ if ((value[1] & 0xdf) == 'N') *variable = true; else *variable = false;}static void set_cfg_int(int* variable, char* value, int min, int max ){ *variable = atoi(value); if (*variable < min) *variable = min; else if (*variable > max) *variable = max;}static void set_cfg_option(int* variable, char* value, char* options[], int numoptions ){ int i; for (i=0; i<numoptions; i++) { if (!strcasecmp(options[i], value)) { *variable = i; break; } }}bool settings_load_config(char* file){ int fd; char line[128]; fd = open(file, O_RDONLY); if (fd < 0) return false; while (read_line(fd, line, sizeof line) > 0) { char* name; char* value; if (!settings_parseline(line, &name, &value)) continue; if (!strcasecmp(name, "volume")) set_sound(value, SOUND_VOLUME, &global_settings.volume); else if (!strcasecmp(name, "bass")) set_sound(value, SOUND_BASS, &global_settings.bass); else if (!strcasecmp(name, "treble")) set_sound(value, SOUND_TREBLE, &global_settings.treble); else if (!strcasecmp(name, "balance")) set_sound(value, SOUND_BALANCE, &global_settings.balance); else if (!strcasecmp(name, "channels")) { static char* options[] = { "stereo","stereo narrow","mono","mono left", "mono right","karaoke","stereo wide"}; set_cfg_option(&global_settings.channel_config, value, options, 7); } else if (!strcasecmp(name, "wps")) { if (wps_load(value,false)) set_file(value, global_settings.wps_file, MAX_FILENAME); } else if (!strcasecmp(name, "lang")) { if (!lang_load(value)) set_file(value, global_settings.lang_file, MAX_FILENAME); } else if (!strcasecmp(name, "bidir limit")) set_cfg_int(&global_settings.bidir_limit, value, 0, 200);#ifdef HAVE_LCD_BITMAP else if (!strcasecmp(name, "font")) { if (font_load(value)) set_file(value, global_settings.font_file, MAX_FILENAME); } else if (!strcasecmp(name, "scroll step")) set_cfg_int(&global_settings.scroll_step, value, 1, LCD_WIDTH); else if (!strcasecmp(name, "statusbar")) set_cfg_bool(&global_settings.statusbar, value); else if (!strcasecmp(name, "peak meter release")) set_cfg_int(&global_settings.peak_meter_release, value, 1, 0x7e); else if (!strcasecmp(name, "peak meter hold")) { static char* options[] = { "off","200ms","300ms","500ms", "1","2","3","4","5","6","7","8","9","10", "15","20","30","1min"}; set_cfg_option(&global_settings.peak_meter_hold, value, options, 18); } else if (!strcasecmp(name, "peak meter clip hold")) { static char* options[] = { "on","1","2","3","4","5","6","7","8","9","10", "15","20","25","30","45","60","90", "2min","3min","5min","10min","20min","45min","90min"}; set_cfg_option(&global_settings.peak_meter_clip_hold, value, options, 25); } else if (!strcasecmp(name, "peak meter dbfs")) set_cfg_bool(&global_settings.peak_meter_dbfs, value); else if (!strcasecmp(name, "peak meter min")) set_cfg_int(&global_settings.peak_meter_min, value, 0, 100); else if (!strcasecmp(name, "peak meter max")) set_cfg_int(&global_settings.peak_meter_max, value, 0, 100); else if (!strcasecmp(name, "peak meter busy")) set_cfg_bool(&global_settings.peak_meter_performance, value); else if (!strcasecmp(name, "volume display")) { static char* options[] = {"graphic", "numeric"}; set_cfg_option(&global_settings.volume_type, value, options, 2); } else if (!strcasecmp(name, "battery display")) { static char* options[] = {"graphic", "numeric"}; set_cfg_option(&global_settings.battery_type, value, options, 2); } else if (!strcasecmp(name, "time format")) { static char* options[] = {"24hour", "12hour"}; set_cfg_option(&global_settings.timeformat, value, options, 2); } else if (!strcasecmp(name, "scrollbar")) set_cfg_bool(&global_settings.scrollbar, value); else if (!strcasecmp(name, "invert")) set_cfg_bool(&global_settings.invert, value); else if (!strcasecmp(name, "flip display")) set_cfg_bool(&global_settings.flip_display, value); else if (!strcasecmp(name, "invert cursor")) set_cfg_bool(&global_settings.invert_cursor, value); else if (!strcasecmp(name, "show icons")) set_cfg_bool(&global_settings.show_icons, value);#endif else if (!strcasecmp(name, "caption backlight")) set_cfg_bool(&global_settings.caption_backlight, value); else if (!strcasecmp(name, "shuffle")) set_cfg_bool(&global_settings.playlist_shuffle, value); else if (!strcasecmp(name, "repeat")) { static char* options[] = {"off", "all", "one"}; set_cfg_option(&global_settings.repeat_mode, value, options, 3); } else if (!strcasecmp(name, "resume")) { static char* options[] = {"off", "ask", "ask once", "on"}; set_cfg_option(&global_settings.resume, value, options, 4); } else if (!strcasecmp(name, "sort case")) set_cfg_bool(&global_settings.sort_case, value); else if (!strcasecmp(name, "show files")) { static char* options[] = {"all", "supported","music", "playlists"}; set_cfg_option(&global_settings.dirfilter, value, options, 4); } else if (!strcasecmp(name, "follow playlist")) set_cfg_bool(&global_settings.browse_current, value); else if (!strcasecmp(name, "play selected")) set_cfg_bool(&global_settings.play_selected, value); else if (!strcasecmp(name, "contrast")) set_cfg_int(&global_settings.contrast, value, MIN_CONTRAST_SETTING, MAX_CONTRAST_SETTING); else if (!strcasecmp(name, "scroll speed")) set_cfg_int(&global_settings.scroll_speed, value, 1, 10); else if (!strcasecmp(name, "scan min step")) { static char* options[] = {"1","2","3","4","5","6","8","10", "15","20","25","30","45","60"}; set_cfg_option(&global_settings.ff_rewind_min_step, value, options, 14); } else if (!strcasecmp(name, "scan accel")) set_cfg_int(&global_settings.ff_rewind_accel, value, 0, 15); else if (!strcasecmp(name, "scroll delay")) set_cfg_int(&global_settings.scroll_delay, value, 0, 250); else if (!strcasecmp(name, "backlight timeout")) { static char* options[] = { "off","on","1","2","3","4","5","6","7","8","9", "10","15","20","25","30","45","60","90"}; set_cfg_option(&global_settings.backlight_timeout, value, options, 19); } else if (!strcasecmp(name, "backlight when plugged")) set_cfg_bool(&global_settings.backlight_on_when_charging, value); else if (!strcasecmp(name, "antiskip")) set_cfg_int(&global_settings.buffer_margin, value, 0, 7); else if (!strcasecmp(name, "disk spindown")) set_cfg_int(&global_settings.disk_spindown, value, 3, 254);#ifdef HAVE_ATA_POWER_OFF else if (!strcasecmp(name, "disk poweroff")) set_cfg_bool(&global_settings.disk_poweroff, value);#endif#ifdef HAVE_MAS3587F else if (!strcasecmp(name, "loudness")) set_sound(value, SOUND_LOUDNESS, &global_settings.loudness); else if (!strcasecmp(name, "bass boost")) set_sound(value, SOUND_SUPERBASS, &global_settings.bass_boost); else if (!strcasecmp(name, "auto volume")) { static char* options[] = {"off", "2", "4", "8" }; set_cfg_option(&global_settings.avc, value, options, 4); } else if (!strcasecmp(name, "rec mic gain")) set_sound(value, SOUND_MIC_GAIN, &global_settings.rec_mic_gain); else if (!strcasecmp(name, "rec left gain")) set_sound(value, SOUND_LEFT_GAIN, &global_settings.rec_left_gain); else if (!strcasecmp(name, "rec right gain")) set_sound(value, SOUND_RIGHT_GAIN, &global_settings.rec_right_gain); else if (!strcasecmp(name, "rec quality")) set_cfg_int(&global_settings.rec_quality, value, 0, 7); else if (!strcasecmp(name, "rec timesplit")){ static char* options[] = {"off", "00:05","00:10","00:15", "00:30","01:00","02:00","04:00", "06:00","08:00","10:00","12:00", "18:00","24:00"}; set_cfg_option(&global_settings.rec_timesplit, value, options, 14); } else if (!strcasecmp(name, "rec source")) { static char* options[] = {"mic", "line", "spdif"};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -