mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
Apply FS#9368 : add generic settings tag to WPS.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19357 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3ad535031a
commit
8289b966b8
4 changed files with 99 additions and 1 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "settings_list.h"
|
||||||
#include "rbunicode.h"
|
#include "rbunicode.h"
|
||||||
#include "rtc.h"
|
#include "rtc.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
@ -1402,6 +1403,53 @@ static const char *get_token_value(struct gui_wps *gwps,
|
||||||
token->value.i * TIMEOUT_UNIT))
|
token->value.i * TIMEOUT_UNIT))
|
||||||
return "v";
|
return "v";
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
case WPS_TOKEN_SETTING:
|
||||||
|
{
|
||||||
|
if (intval)
|
||||||
|
{
|
||||||
|
/* Handle contionals */
|
||||||
|
const struct settings_list *s = settings+token->value.i;
|
||||||
|
switch (s->flags&F_T_MASK)
|
||||||
|
{
|
||||||
|
case F_T_INT:
|
||||||
|
case F_T_UINT:
|
||||||
|
if (s->flags&F_RGB)
|
||||||
|
/* %?St|name|<#000000|#000001|...|#FFFFFF> */
|
||||||
|
/* shouldn't overflow since colors are stored
|
||||||
|
* on 16 bits ...
|
||||||
|
* but this is pretty useless anyway */
|
||||||
|
*intval = *(int*)s->setting + 1;
|
||||||
|
else if (s->cfg_vals == NULL)
|
||||||
|
/* %?St|name|<1st choice|2nd choice|...> */
|
||||||
|
*intval = (*(int*)s->setting-s->int_setting->min)
|
||||||
|
/s->int_setting->step + 1;
|
||||||
|
else
|
||||||
|
/* %?St|name|<1st choice|2nd choice|...> */
|
||||||
|
/* Not sure about this one. cfg_name/vals are
|
||||||
|
* indexed from 0 right? */
|
||||||
|
*intval = *(int*)s->setting + 1;
|
||||||
|
break;
|
||||||
|
case F_T_BOOL:
|
||||||
|
/* %?St|name|<if true|if false> */
|
||||||
|
*intval = *(bool*)s->setting?1:2;
|
||||||
|
break;
|
||||||
|
case F_T_CHARPTR:
|
||||||
|
/* %?St|name|<if non empty string|if empty>
|
||||||
|
* The string's emptyness discards the setting's
|
||||||
|
* prefix and suffix */
|
||||||
|
*intval = ((char*)s->setting)[0]?1:2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* This shouldn't happen ... but you never know */
|
||||||
|
*intval = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg_to_string(token->value.i,buf,buf_size);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,10 @@ enum wps_token_type {
|
||||||
WPS_VIEWPORT_ENABLE,
|
WPS_VIEWPORT_ENABLE,
|
||||||
|
|
||||||
/* buttons */
|
/* buttons */
|
||||||
WPS_TOKEN_BUTTON_VOLUME
|
WPS_TOKEN_BUTTON_VOLUME,
|
||||||
|
|
||||||
|
/* Setting option */
|
||||||
|
WPS_TOKEN_SETTING,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wps_token {
|
struct wps_token {
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@
|
||||||
|
|
||||||
#include "gwps.h"
|
#include "gwps.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "settings_list.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#include "bmp.h"
|
#include "bmp.h"
|
||||||
|
|
@ -137,6 +138,8 @@ static int parse_progressbar(const char *wps_bufptr,
|
||||||
struct wps_token *token, struct wps_data *wps_data);
|
struct wps_token *token, struct wps_data *wps_data);
|
||||||
static int parse_dir_level(const char *wps_bufptr,
|
static int parse_dir_level(const char *wps_bufptr,
|
||||||
struct wps_token *token, struct wps_data *wps_data);
|
struct wps_token *token, struct wps_data *wps_data);
|
||||||
|
static int parse_setting(const char *wps_bufptr,
|
||||||
|
struct wps_token *token, struct wps_data *wps_data);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
static int parse_viewport_display(const char *wps_bufptr,
|
static int parse_viewport_display(const char *wps_bufptr,
|
||||||
|
|
@ -342,6 +345,8 @@ static const struct wps_tag all_tags[] = {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{ WPS_TOKEN_SETTING, "St", WPS_REFRESH_DYNAMIC, parse_setting },
|
||||||
|
|
||||||
{ WPS_TOKEN_UNKNOWN, "", 0, NULL }
|
{ WPS_TOKEN_UNKNOWN, "", 0, NULL }
|
||||||
/* the array MUST end with an empty string (first char is \0) */
|
/* the array MUST end with an empty string (first char is \0) */
|
||||||
};
|
};
|
||||||
|
|
@ -726,6 +731,39 @@ static int parse_viewport(const char *wps_bufptr,
|
||||||
return skip_end_of_line(wps_bufptr);
|
return skip_end_of_line(wps_bufptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_setting(const char *wps_bufptr,
|
||||||
|
struct wps_token *token,
|
||||||
|
struct wps_data *wps_data)
|
||||||
|
{
|
||||||
|
(void)wps_data;
|
||||||
|
const char *ptr = wps_bufptr;
|
||||||
|
const char *end;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Find the setting's cfg_name */
|
||||||
|
if (*ptr != '|')
|
||||||
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
ptr++;
|
||||||
|
end = strchr(ptr,'|');
|
||||||
|
if (!end)
|
||||||
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
|
/* Find the setting */
|
||||||
|
for (i=0; i<nb_settings; i++)
|
||||||
|
if (settings[i].cfg_name &&
|
||||||
|
!strncmp(settings[i].cfg_name,ptr,end-ptr) &&
|
||||||
|
/* prevent matches on cfg_name prefixes */
|
||||||
|
strlen(settings[i].cfg_name)==end-ptr) break;
|
||||||
|
if (i == nb_settings)
|
||||||
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
|
/* Store the setting number */
|
||||||
|
token->value.i = i;
|
||||||
|
|
||||||
|
/* Skip the rest of the line */
|
||||||
|
return end-ptr+2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
|
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
|
||||||
static int parse_image_special(const char *wps_bufptr,
|
static int parse_image_special(const char *wps_bufptr,
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,15 @@ The example above will display the text ``Volume changing'' if the volume is
|
||||||
being changed and 2.5 secs after the volume button has been released. After
|
being changed and 2.5 secs after the volume button has been released. After
|
||||||
that, it will display the volume value.
|
that, it will display the volume value.
|
||||||
|
|
||||||
|
\section{Settings}
|
||||||
|
\begin{table}
|
||||||
|
\begin{tagmap}{}{}
|
||||||
|
\config{\%St{\textbar}<setting name>{\textbar}} & Display the value of any Rockbox setting\\
|
||||||
|
\end{tagmap}
|
||||||
|
\end{table}
|
||||||
|
Example: Can be used as a simple tag \config{\%St{\textbar}skip length{\textbar}} or with conditionals
|
||||||
|
\config{\%?St{\textbar}eq enabled{\textbar}{\textless}Equalizer is enabled{\textbar}Equalizer is disabled{\textgreater}}.
|
||||||
|
|
||||||
\section{Images}
|
\section{Images}
|
||||||
\begin{table}
|
\begin{table}
|
||||||
\begin{tagmap}{}{}
|
\begin{tagmap}{}{}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue