summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_parser.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-03-01 12:31:03 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-03-01 12:31:03 +0000
commit485ff795843597483264b1c9ce1a29a154aa6679 (patch)
tree63d99c6a73c55f9fb2159633264355209e186b38 /apps/gui/skin_engine/skin_parser.c
parent735ea2fd1f746bed999e488eee129ff5b3af059a (diff)
downloadrockbox-485ff795843597483264b1c9ce1a29a154aa6679.tar.gz
rockbox-485ff795843597483264b1c9ce1a29a154aa6679.zip
Add an ability to set a setting to a specific value with a touchscreen action.
example: %T(0,0,20,12, setting_set, repeat, off) That will set the repeat mode to "off" when it is pressed. "setting_set" is the action name "repeat" is the name of the setting in the config files "off" is the value to set it to (same values as the legal values in the config files) Not all settings are supported, outright unsupported settings will fail to parse. Some settings might not work too well if they don't apply instantly (Any that work well int he quickscreen should work well here) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29483 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r--apps/gui/skin_engine/skin_parser.c75
1 files changed, 52 insertions, 23 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 25734954e5..0eb966198d 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -937,7 +937,8 @@ static const struct touchaction touchactions[] = {
937 {"mute", ACTION_TOUCH_MUTE }, 937 {"mute", ACTION_TOUCH_MUTE },
938 938
939 /* generic settings changers */ 939 /* generic settings changers */
940 {"setting_inc", ACTION_SETTINGS_INC}, {"setting_dec", ACTION_SETTINGS_DEC}, 940 {"setting_inc", ACTION_SETTINGS_INC}, {"setting_dec", ACTION_SETTINGS_DEC},
941 {"setting_set", ACTION_SETTINGS_SET},
941 942
942 /* WPS specific actions */ 943 /* WPS specific actions */
943 {"browse", ACTION_WPS_BROWSE }, 944 {"browse", ACTION_WPS_BROWSE },
@@ -952,6 +953,7 @@ static const struct touchaction touchactions[] = {
952 {"presets", ACTION_FM_PRESET}, 953 {"presets", ACTION_FM_PRESET},
953#endif 954#endif
954}; 955};
956bool cfg_string_to_int(int setting_id, int* out, const char* str);
955 957
956static int parse_touchregion(struct skin_element *element, 958static int parse_touchregion(struct skin_element *element,
957 struct wps_token *token, 959 struct wps_token *token,
@@ -966,26 +968,9 @@ static int parse_touchregion(struct skin_element *element,
966 const char vol_string[] = "volume"; 968 const char vol_string[] = "volume";
967 char temp[20]; 969 char temp[20];
968 970
969 /* format: %T(x,y,width,height,action) 971 /* format: %T([label,], x,y,width,height,action[, ...])
970 * if action starts with & the area must be held to happen 972 * if action starts with & the area must be held to happen
971 * action is one of: 973 */
972 * play - play/pause playback
973 * stop - stop playback, exit the wps
974 * prev - prev track
975 * next - next track
976 * ffwd - seek forward
977 * rwd - seek backwards
978 * menu - go back to the main menu
979 * browse - go back to the file/db browser
980 * shuffle - toggle shuffle mode
981 * repmode - cycle the repeat mode
982 * quickscreen - go into the quickscreen
983 * contextmenu - open the context menu
984 * playlist - go into the playlist
985 * pitch - go into the pitchscreen
986 * volup - increase volume by one step
987 * voldown - decrease volume by one step
988 */
989 974
990 975
991 region = (struct touchregion*)skin_buffer_alloc(sizeof(struct touchregion)); 976 region = (struct touchregion*)skin_buffer_alloc(sizeof(struct touchregion));
@@ -1018,7 +1003,7 @@ static int parse_touchregion(struct skin_element *element,
1018 region->wvp = curr_vp; 1003 region->wvp = curr_vp;
1019 region->armed = false; 1004 region->armed = false;
1020 region->reverse_bar = false; 1005 region->reverse_bar = false;
1021 region->data = NULL; 1006 region->value = 0;
1022 region->last_press = 0xffff; 1007 region->last_press = 0xffff;
1023 action = element->params[p++].data.text; 1008 action = element->params[p++].data.text;
1024 1009
@@ -1055,7 +1040,8 @@ static int parse_touchregion(struct skin_element *element,
1055 { 1040 {
1056 region->action = touchactions[i].action; 1041 region->action = touchactions[i].action;
1057 if (region->action == ACTION_SETTINGS_INC || 1042 if (region->action == ACTION_SETTINGS_INC ||
1058 region->action == ACTION_SETTINGS_DEC) 1043 region->action == ACTION_SETTINGS_DEC ||
1044 region->action == ACTION_SETTINGS_SET)
1059 { 1045 {
1060 if (element->params_count < p+1) 1046 if (element->params_count < p+1)
1061 { 1047 {
@@ -1072,7 +1058,50 @@ static int parse_touchregion(struct skin_element *element,
1072 break; 1058 break;
1073 if (j==nb_settings) 1059 if (j==nb_settings)
1074 return WPS_ERROR_INVALID_PARAM; 1060 return WPS_ERROR_INVALID_PARAM;
1075 region->data = (void*)&settings[j]; 1061 region->setting_data.setting = (void*)&settings[j];
1062 if (region->action == ACTION_SETTINGS_SET)
1063 {
1064 char* text;
1065 int temp;
1066 struct touchsetting *setting =
1067 &region->setting_data;
1068 if (element->params_count < p+2)
1069 return WPS_ERROR_INVALID_PARAM;
1070 text = element->params[p+1].data.text;
1071 switch (settings[j].flags&F_T_MASK)
1072 {
1073 case F_T_CUSTOM:
1074 setting->value.text = text;
1075 break;
1076 case F_T_INT:
1077 case F_T_UINT:
1078 if (settings[j].cfg_vals == NULL)
1079 {
1080 setting->value.number = atoi(text);
1081 }
1082 else if (cfg_string_to_int(j, &temp, text))
1083 {
1084 if (settings[j].flags&F_TABLE_SETTING)
1085 setting->value.number =
1086 settings[j].table_setting->values[temp];
1087 else
1088 setting->value.number = temp;
1089 }
1090 else
1091 return WPS_ERROR_INVALID_PARAM;
1092 break;
1093 case F_T_BOOL:
1094 if (cfg_string_to_int(j, &temp, text))
1095 {
1096 setting->value.number = temp;
1097 }
1098 else
1099 return WPS_ERROR_INVALID_PARAM;
1100 break;
1101 default:
1102 return WPS_ERROR_INVALID_PARAM;
1103 }
1104 }
1076 } 1105 }
1077 } 1106 }
1078 break; 1107 break;