mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
allow int settings to call a function to get the default value (Fixes the contrast problem on archos)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12102 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
228d62dd18
commit
0c3375648c
3 changed files with 23 additions and 9 deletions
|
@ -851,7 +851,9 @@ void settings_reset(void) {
|
|||
{
|
||||
case F_T_INT:
|
||||
case F_T_UINT:
|
||||
if (settings[i].flags&F_T_SOUND)
|
||||
if (settings[i].flags&F_DEF_ISFUNC)
|
||||
*(int*)settings[i].setting = settings[i].default_val.func();
|
||||
else if (settings[i].flags&F_T_SOUND)
|
||||
*(int*)settings[i].setting =
|
||||
sound_default(settings[i].sound_setting->setting);
|
||||
else *(int*)settings[i].setting = settings[i].default_val.int_;
|
||||
|
|
|
@ -88,6 +88,7 @@ static const char backlight_times_conf [] =
|
|||
#define BOOL(a) {.bool_ = a}
|
||||
#define CHARPTR(a) {.charptr = a}
|
||||
#define UCHARPTR(a) {.ucharptr = a}
|
||||
#define FUNCTYPE(a) {.func = a}
|
||||
#define NODEFAULT INT(0)
|
||||
|
||||
#define SOUND_SETTING(flags,var,setting) \
|
||||
|
@ -134,7 +135,7 @@ const struct settings_list settings[] = {
|
|||
"off,all,one,shuffle,ab" , UNUSED},
|
||||
/* LCD */
|
||||
#ifdef HAVE_LCD_CONTRAST
|
||||
{F_T_INT, GS(contrast), INT(DEFAULT_CONTRAST_SETTING),
|
||||
{F_T_INT|F_DEF_ISFUNC, GS(contrast), FUNCTYPE(lcd_default_contrast),
|
||||
"contrast", NULL , UNUSED},
|
||||
#endif
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
|
|
|
@ -24,12 +24,15 @@
|
|||
#include <limits.h>
|
||||
#include "inttypes.h"
|
||||
|
||||
typedef int (*_isfunc_type)(void);
|
||||
|
||||
union storage_type {
|
||||
int int_;
|
||||
unsigned int uint_;
|
||||
bool bool_;
|
||||
char *charptr;
|
||||
unsigned char *ucharptr;
|
||||
_isfunc_type func;
|
||||
};
|
||||
/* the variable type for the setting */
|
||||
#define F_T_INT 1
|
||||
|
@ -53,12 +56,25 @@ struct bool_setting {
|
|||
#define F_BOOL_SETTING F_T_BOOL|0x10
|
||||
#define F_RGB 0x20
|
||||
|
||||
struct filename_setting {
|
||||
const char* prefix;
|
||||
const char* suffix;
|
||||
int max_len;
|
||||
};
|
||||
#define F_FILENAME 0x40
|
||||
|
||||
struct int_setting {
|
||||
void (*option_callback)(int);
|
||||
int min;
|
||||
int max;
|
||||
int step;
|
||||
};
|
||||
/* these use the _isfunc_type type for the function */
|
||||
/* typedef int (*_isfunc_type)(void); */
|
||||
#define F_MIN_ISFUNC 0x100000 /* min(above) is function pointer to above type */
|
||||
#define F_MAX_ISFUNC 0x200000 /* max(above) is function pointer to above type */
|
||||
#define F_DEF_ISFUNC 0x400000 /* default_val is function pointer to above type */
|
||||
|
||||
#define F_NVRAM_BYTES_MASK 0xE00 /*0-4 bytes can be stored */
|
||||
#define F_NVRAM_MASK_SHIFT 9
|
||||
#define NVRAM_CONFIG_VERSION 2
|
||||
|
@ -68,14 +84,9 @@ struct int_setting {
|
|||
- a NVRAM setting is removed
|
||||
*/
|
||||
|
||||
struct filename_setting {
|
||||
const char* prefix;
|
||||
const char* suffix;
|
||||
int max_len;
|
||||
};
|
||||
#define F_FILENAME 0x40
|
||||
|
||||
struct settings_list {
|
||||
uint32_t flags; /* ____ ____ ____ ____ ____ NNN_ _FRB STTT */
|
||||
uint32_t flags; /* ____ ____ _FFF ____ ____ NNN_ IFRB STTT */
|
||||
void *setting;
|
||||
union storage_type default_val;
|
||||
const char *cfg_name; /* this settings name in the cfg file */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue