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 | |
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
-rw-r--r-- | apps/gui/music_screen.c | 47 | ||||
-rw-r--r-- | apps/gui/wps_engine/wps_internals.h | 5 | ||||
-rw-r--r-- | apps/gui/wps_engine/wps_parser.c | 55 | ||||
-rw-r--r-- | wps/cabbiev2.240x400x16.wps | 2 |
4 files changed, 84 insertions, 25 deletions
diff --git a/apps/gui/music_screen.c b/apps/gui/music_screen.c index 39d5e0e85b..d5eccd5868 100644 --- a/apps/gui/music_screen.c +++ b/apps/gui/music_screen.c | |||
@@ -553,12 +553,49 @@ int wps_get_touchaction(struct wps_data *data) | |||
553 | if (vx >= r->x && vx < r->x+r->width && | 553 | if (vx >= r->x && vx < r->x+r->width && |
554 | vy >= r->y && vy < r->y+r->height) | 554 | vy >= r->y && vy < r->y+r->height) |
555 | { | 555 | { |
556 | if ((repeated && r->repeat) || | 556 | /* reposition the touch within the area */ |
557 | (released && !r->repeat)) | 557 | vx -= r->x; |
558 | vy -= r->y; | ||
559 | |||
560 | switch(r->type) | ||
558 | { | 561 | { |
559 | last_action = r->action; | 562 | case WPS_TOUCHREGION_ACTION: |
560 | return r->action; | 563 | if ((repeated && r->repeat) || (released && !r->repeat)) |
561 | } | 564 | { |
565 | last_action = r->action; | ||
566 | return r->action; | ||
567 | } | ||
568 | break; | ||
569 | case WPS_TOUCHREGION_SCROLLBAR: | ||
570 | if(r->width > r->height) | ||
571 | /* landscape */ | ||
572 | wps_state.id3->elapsed = (vx * | ||
573 | wps_state.id3->length) / r->width; | ||
574 | else | ||
575 | /* portrait */ | ||
576 | wps_state.id3->elapsed = (vy * | ||
577 | wps_state.id3->length) / r->height; | ||
578 | |||
579 | audio_ff_rewind(wps_state.id3->elapsed); | ||
580 | break; | ||
581 | case WPS_TOUCHREGION_VOLUME: | ||
582 | { | ||
583 | const int min_vol = sound_min(SOUND_VOLUME); | ||
584 | const int max_vol = sound_max(SOUND_VOLUME); | ||
585 | if(r->width > r->height) | ||
586 | /* landscape */ | ||
587 | global_settings.volume = (vx * | ||
588 | (max_vol - min_vol)) / r->width; | ||
589 | else | ||
590 | /* portrait */ | ||
591 | global_settings.volume = (vy * | ||
592 | (max_vol-min_vol)) / r->height; | ||
593 | |||
594 | global_settings.volume += min_vol; | ||
595 | setvol(); | ||
596 | break; | ||
597 | } | ||
598 | } | ||
562 | } | 599 | } |
563 | } | 600 | } |
564 | } | 601 | } |
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 | } |
diff --git a/wps/cabbiev2.240x400x16.wps b/wps/cabbiev2.240x400x16.wps index 9d45643074..2ef33d5bcf 100644 --- a/wps/cabbiev2.240x400x16.wps +++ b/wps/cabbiev2.240x400x16.wps | |||
@@ -9,6 +9,8 @@ | |||
9 | %T|182|372|18|92|repmode| | 9 | %T|182|372|18|92|repmode| |
10 | %T|139|372|37|23|shuffle| | 10 | %T|139|372|37|23|shuffle| |
11 | %T|90|238|60|20|playlist| | 11 | %T|90|238|60|20|playlist| |
12 | %T|22|284|199|13|progressbar| | ||
13 | %T|98|372|33|23|volume| | ||
12 | 14 | ||
13 | %X|wpsbackdrop-240x400x16.bmp| | 15 | %X|wpsbackdrop-240x400x16.bmp| |
14 | %xl|A|lock-240x320x16.bmp|11|372|2| | 16 | %xl|A|lock-240x320x16.bmp|11|372|2| |