diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-27 13:27:38 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-27 13:27:38 +0000 |
commit | 95c25d6d274e932d01fe6b610f95744ea0882ede (patch) | |
tree | ec173c220033319dee69791650e01ff8fe4bb87c /apps/gui/wps_engine | |
parent | c08a2c7c53fcfc652bf2463986a447120f946b53 (diff) | |
download | rockbox-95c25d6d274e932d01fe6b610f95744ea0882ede.tar.gz rockbox-95c25d6d274e932d01fe6b610f95744ea0882ede.zip |
Touchscreen targets: add basic progress bar & volume handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22068 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/wps_engine')
-rw-r--r-- | apps/gui/wps_engine/wps_internals.h | 5 | ||||
-rw-r--r-- | apps/gui/wps_engine/wps_parser.c | 55 |
2 files changed, 40 insertions, 20 deletions
diff --git a/apps/gui/wps_engine/wps_internals.h b/apps/gui/wps_engine/wps_internals.h index 581763fb9a..ce9b4d3d46 100644 --- a/apps/gui/wps_engine/wps_internals.h +++ b/apps/gui/wps_engine/wps_internals.h | |||
@@ -390,6 +390,11 @@ struct touchregion { | |||
390 | short int y; /* y-pos */ | 390 | short int y; /* y-pos */ |
391 | short int width; /* width */ | 391 | short int width; /* width */ |
392 | short int height; /* height */ | 392 | short int height; /* height */ |
393 | enum { | ||
394 | WPS_TOUCHREGION_ACTION, | ||
395 | WPS_TOUCHREGION_SCROLLBAR, | ||
396 | WPS_TOUCHREGION_VOLUME | ||
397 | } type; /* type of touch region */ | ||
393 | bool repeat; /* requires the area be held for the action */ | 398 | bool repeat; /* requires the area be held for the action */ |
394 | int action; /* action this button will return */ | 399 | int action; /* action this button will return */ |
395 | }; | 400 | }; |
diff --git a/apps/gui/wps_engine/wps_parser.c b/apps/gui/wps_engine/wps_parser.c index 15acc1401d..91c63059b0 100644 --- a/apps/gui/wps_engine/wps_parser.c +++ b/apps/gui/wps_engine/wps_parser.c | |||
@@ -1173,6 +1173,8 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1173 | struct touchregion *region; | 1173 | struct touchregion *region; |
1174 | const char *ptr = wps_bufptr; | 1174 | const char *ptr = wps_bufptr; |
1175 | const char *action; | 1175 | const char *action; |
1176 | const char pb_string[] = "progressbar"; | ||
1177 | const char vol_string[] = "volume"; | ||
1176 | int x,y,w,h; | 1178 | int x,y,w,h; |
1177 | 1179 | ||
1178 | /* format: %T|x|y|width|height|action| | 1180 | /* format: %T|x|y|width|height|action| |
@@ -1203,7 +1205,7 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1203 | /* Check there is a terminating | */ | 1205 | /* Check there is a terminating | */ |
1204 | if (*ptr != '|') | 1206 | if (*ptr != '|') |
1205 | return WPS_ERROR_INVALID_PARAM; | 1207 | return WPS_ERROR_INVALID_PARAM; |
1206 | 1208 | ||
1207 | /* should probably do some bounds checking here with the viewport... but later */ | 1209 | /* should probably do some bounds checking here with the viewport... but later */ |
1208 | region = &wps_data->touchregion[wps_data->touchregion_count]; | 1210 | region = &wps_data->touchregion[wps_data->touchregion_count]; |
1209 | region->action = ACTION_NONE; | 1211 | region->action = ACTION_NONE; |
@@ -1212,28 +1214,41 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1212 | region->width = w; | 1214 | region->width = w; |
1213 | region->height = h; | 1215 | region->height = h; |
1214 | region->wvp = &wps_data->viewports[wps_data->num_viewports]; | 1216 | region->wvp = &wps_data->viewports[wps_data->num_viewports]; |
1215 | i = 0; | ||
1216 | if (*action == '&') | ||
1217 | { | ||
1218 | action++; | ||
1219 | region->repeat = true; | ||
1220 | } | ||
1221 | else | ||
1222 | region->repeat = false; | ||
1223 | 1217 | ||
1224 | imax = ARRAYLEN(touchactions); | 1218 | if(!strncmp(pb_string, action, sizeof(pb_string)-1) |
1225 | while ((region->action == ACTION_NONE) && | 1219 | && *(action + sizeof(pb_string)-1) == '|') |
1226 | (i < imax)) | 1220 | region->type = WPS_TOUCHREGION_SCROLLBAR; |
1221 | else if(!strncmp(vol_string, action, sizeof(vol_string)-1) | ||
1222 | && *(action + sizeof(vol_string)-1) == '|') | ||
1223 | region->type = WPS_TOUCHREGION_VOLUME; | ||
1224 | else | ||
1227 | { | 1225 | { |
1228 | /* try to match with one of our touchregion screens */ | 1226 | region->type = WPS_TOUCHREGION_ACTION; |
1229 | int len = strlen(touchactions[i].s); | 1227 | |
1230 | if (!strncmp(touchactions[i].s, action, len) | 1228 | if (*action == '&') |
1231 | && *(action+len) == '|') | 1229 | { |
1232 | region->action = touchactions[i].action; | 1230 | action++; |
1233 | i++; | 1231 | region->repeat = true; |
1232 | } | ||
1233 | else | ||
1234 | region->repeat = false; | ||
1235 | |||
1236 | i = 0; | ||
1237 | imax = ARRAYLEN(touchactions); | ||
1238 | while ((region->action == ACTION_NONE) && | ||
1239 | (i < imax)) | ||
1240 | { | ||
1241 | /* try to match with one of our touchregion screens */ | ||
1242 | int len = strlen(touchactions[i].s); | ||
1243 | if (!strncmp(touchactions[i].s, action, len) | ||
1244 | && *(action+len) == '|') | ||
1245 | region->action = touchactions[i].action; | ||
1246 | i++; | ||
1247 | } | ||
1248 | if (region->action == ACTION_NONE) | ||
1249 | return WPS_ERROR_INVALID_PARAM; | ||
1234 | } | 1250 | } |
1235 | if (region->action == ACTION_NONE) | 1251 | |
1236 | return WPS_ERROR_INVALID_PARAM; | ||
1237 | wps_data->touchregion_count++; | 1252 | wps_data->touchregion_count++; |
1238 | return skip_end_of_line(wps_bufptr); | 1253 | return skip_end_of_line(wps_bufptr); |
1239 | } | 1254 | } |