summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/action.h1
-rw-r--r--apps/gui/skin_engine/skin_parser.c75
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c42
-rw-r--r--apps/gui/skin_engine/wps_internals.h10
-rw-r--r--apps/settings.c2
-rw-r--r--lib/skin_parser/tag_table.c4
6 files changed, 105 insertions, 29 deletions
diff --git a/apps/action.h b/apps/action.h
index e664c03fdf..a9e4de1665 100644
--- a/apps/action.h
+++ b/apps/action.h
@@ -196,6 +196,7 @@ enum {
196 ACTION_SETTINGS_DECREPEAT, 196 ACTION_SETTINGS_DECREPEAT,
197 ACTION_SETTINGS_DECBIGSTEP, 197 ACTION_SETTINGS_DECBIGSTEP,
198 ACTION_SETTINGS_RESET, 198 ACTION_SETTINGS_RESET,
199 ACTION_SETTINGS_SET, /* Used by touchscreen targets */
199 200
200 /* bookmark screen */ 201 /* bookmark screen */
201 ACTION_BMS_DELETE, 202 ACTION_BMS_DELETE,
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;
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c
index 3206579adf..110e97f997 100644
--- a/apps/gui/skin_engine/skin_touchsupport.c
+++ b/apps/gui/skin_engine/skin_touchsupport.c
@@ -27,6 +27,7 @@
27#include "misc.h" 27#include "misc.h"
28#include "option_select.h" 28#include "option_select.h"
29#include "sound.h" 29#include "sound.h"
30#include "settings_list.h"
30 31
31 32
32/** Disarms all touchregions. */ 33/** Disarms all touchregions. */
@@ -129,8 +130,45 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
129 case ACTION_SETTINGS_INC: 130 case ACTION_SETTINGS_INC:
130 case ACTION_SETTINGS_DEC: 131 case ACTION_SETTINGS_DEC:
131 { 132 {
132 const struct settings_list *setting = temp->data; 133 const struct settings_list *setting =
133 option_select_next_val(setting, returncode == ACTION_SETTINGS_DEC, true); 134 temp->setting_data.setting;
135 option_select_next_val(setting,
136 returncode == ACTION_SETTINGS_DEC,
137 true);
138 returncode = ACTION_REDRAW;
139 }
140 break;
141 case ACTION_SETTINGS_SET:
142 {
143 struct touchsetting *data = &temp->setting_data;
144 const struct settings_list *s = data->setting;
145 void (*f)(int) = NULL;
146 switch (s->flags&F_T_MASK)
147 {
148 case F_T_CUSTOM:
149 s->custom_setting
150 ->load_from_cfg(s->setting, data->value.text);
151 break;
152 case F_T_INT:
153 case F_T_UINT:
154 *(int*)s->setting = data->value.number;
155 if (s->flags&F_CHOICE_SETTING)
156 f = s->choice_setting->option_callback;
157 else if (s->flags&F_TABLE_SETTING)
158 f = s->table_setting->option_callback;
159 else
160 f = s->int_setting->option_callback;
161
162 if (f)
163 f(data->value.number);
164 break;
165 case F_T_BOOL:
166 *(bool*)s->setting = data->value.number ? true : false;
167 if (s->bool_setting->option_callback)
168 s->bool_setting
169 ->option_callback(data->value.number ? true : false);
170 break;
171 }
134 returncode = ACTION_REDRAW; 172 returncode = ACTION_REDRAW;
135 } 173 }
136 break; 174 break;
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 28697c8b69..86d191f687 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -199,12 +199,20 @@ struct touchregion {
199 bool armed; /* A region is armed on press. Only armed regions are triggered 199 bool armed; /* A region is armed on press. Only armed regions are triggered
200 on repeat or release. */ 200 on repeat or release. */
201 union { /* Extra data, action dependant */ 201 union { /* Extra data, action dependant */
202 void* data; 202 struct touchsetting {
203 const struct settings_list *setting; /* setting being controlled */
204 union { /* Value to set the setting to for ACTION_SETTING_SET */
205 int number;
206 char* text;
207 } value;
208 } setting_data;
203 int value; 209 int value;
204 }; 210 };
205 long last_press; /* last tick this was pressed */ 211 long last_press; /* last tick this was pressed */
206}; 212};
207 213
214
215
208struct touchregion_lastpress { 216struct touchregion_lastpress {
209 struct touchregion *region; 217 struct touchregion *region;
210 long timeout; 218 long timeout;
diff --git a/apps/settings.c b/apps/settings.c
index e491c5b6f2..e9458dc601 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -231,7 +231,7 @@ void settings_load(int which)
231 } 231 }
232} 232}
233 233
234static bool cfg_string_to_int(int setting_id, int* out, const char* str) 234bool cfg_string_to_int(int setting_id, int* out, const char* str)
235{ 235{
236 const char* start = settings[setting_id].cfg_vals; 236 const char* start = settings[setting_id].cfg_vals;
237 char* end = NULL; 237 char* end = NULL;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index 68e4b03a4e..56f5df1911 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -206,10 +206,10 @@ static const struct tag_info legal_tags[] =
206 /* HACK Alert (jdgordon): The next two tags have hacks so we could 206 /* HACK Alert (jdgordon): The next two tags have hacks so we could
207 * add a S param at the front without breaking old skins. 207 * add a S param at the front without breaking old skins.
208 * [SD]D <- handled by the callback, allows SD or S or D params 208 * [SD]D <- handled by the callback, allows SD or S or D params
209 * [SI]III[SI]|SS -< SIIIIS|S or IIIIS|S 209 * [SI]III[SI]|SN -< SIIIIS|S or IIIIS|S
210 * keep in sync with parse_touchregion() and parse_lasttouch() */ 210 * keep in sync with parse_touchregion() and parse_lasttouch() */
211 { SKIN_TOKEN_LASTTOUCH, "Tl" , "|[SD]D", SKIN_REFRESH_DYNAMIC }, 211 { SKIN_TOKEN_LASTTOUCH, "Tl" , "|[SD]D", SKIN_REFRESH_DYNAMIC },
212 { SKIN_TOKEN_TOUCHREGION, "T" , "[SI]III[SI]|SS", 0|NOBREAK }, 212 { SKIN_TOKEN_TOUCHREGION, "T" , "[SI]III[SI]|SN", 0|NOBREAK },
213 213
214 { SKIN_TOKEN_HAVE_TOUCH, "Tp", "", FEATURE_TAG }, 214 { SKIN_TOKEN_HAVE_TOUCH, "Tp", "", FEATURE_TAG },
215 215