summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-01-24 03:14:07 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-01-24 03:14:07 +0000
commit0c3375648cdd22c341cfb632b66ae673a82aa52c (patch)
tree5fbf21d08bc616a63759f265b4f5365c85ea6b42
parent228d62dd18906eaef814ec63cf888b30a94cd1c8 (diff)
downloadrockbox-0c3375648cdd22c341cfb632b66ae673a82aa52c.zip
rockbox-0c3375648cdd22c341cfb632b66ae673a82aa52c.tar.gz
rockbox-0c3375648cdd22c341cfb632b66ae673a82aa52c.tar.bz2
rockbox-0c3375648cdd22c341cfb632b66ae673a82aa52c.tar.xz
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
-rw-r--r--apps/settings.c4
-rw-r--r--apps/settings_list.c3
-rw-r--r--apps/settings_list.h25
3 files changed, 23 insertions, 9 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 4280ff9..45e2a4e 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -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_;
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 861c3df..939eb31 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -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
diff --git a/apps/settings_list.h b/apps/settings_list.h
index d76d10a..d9ad200 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -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 */