diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2011-03-27 07:23:38 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2011-03-27 07:23:38 +0000 |
commit | 443b1349830912add7211e07557029b9c185d948 (patch) | |
tree | bffa8efdf04b0eb8d3502e0af4691c9a257f1c8f /apps | |
parent | 86c4ec7277ac1c2a130a9ac1a3500c8360af5c7e (diff) | |
download | rockbox-443b1349830912add7211e07557029b9c185d948.tar.gz rockbox-443b1349830912add7211e07557029b9c185d948.zip |
Fix touchregions muting volume, and change &<action> to mean 'needs long press but only fire once'. Use *<action> for 'long press and allow repeats'
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29653 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/action.h | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 16 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_touchsupport.c | 38 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 11 | ||||
-rw-r--r-- | apps/gui/wps.c | 4 |
5 files changed, 41 insertions, 30 deletions
diff --git a/apps/action.h b/apps/action.h index a9e4de1665..e380b1289a 100644 --- a/apps/action.h +++ b/apps/action.h | |||
@@ -248,6 +248,8 @@ enum { | |||
248 | ACTION_TOUCH_SHUFFLE, | 248 | ACTION_TOUCH_SHUFFLE, |
249 | ACTION_TOUCH_REPMODE, | 249 | ACTION_TOUCH_REPMODE, |
250 | ACTION_TOUCH_MUTE, | 250 | ACTION_TOUCH_MUTE, |
251 | ACTION_TOUCH_SCROLLBAR, | ||
252 | ACTION_TOUCH_VOLUME, | ||
251 | #endif | 253 | #endif |
252 | 254 | ||
253 | /* USB HID codes */ | 255 | /* USB HID codes */ |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 236c6feea1..468f6808c4 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -1030,6 +1030,7 @@ static int parse_touchregion(struct skin_element *element, | |||
1030 | region->reverse_bar = false; | 1030 | region->reverse_bar = false; |
1031 | region->value = 0; | 1031 | region->value = 0; |
1032 | region->last_press = 0xffff; | 1032 | region->last_press = 0xffff; |
1033 | region->press_length = PRESS; | ||
1033 | action = element->params[p++].data.text; | 1034 | action = element->params[p++].data.text; |
1034 | 1035 | ||
1035 | strcpy(temp, action); | 1036 | strcpy(temp, action); |
@@ -1042,20 +1043,23 @@ static int parse_touchregion(struct skin_element *element, | |||
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | if(!strcmp(pb_string, action)) | 1045 | if(!strcmp(pb_string, action)) |
1045 | region->type = WPS_TOUCHREGION_SCROLLBAR; | 1046 | region->action = ACTION_TOUCH_SCROLLBAR; |
1046 | else if(!strcmp(vol_string, action)) | 1047 | else if(!strcmp(vol_string, action)) |
1047 | region->type = WPS_TOUCHREGION_VOLUME; | 1048 | region->action = ACTION_TOUCH_VOLUME; |
1048 | else | 1049 | else |
1049 | { | 1050 | { |
1050 | region->type = WPS_TOUCHREGION_ACTION; | ||
1051 | |||
1052 | if (*action == '&') | 1051 | if (*action == '&') |
1053 | { | 1052 | { |
1054 | action++; | 1053 | action++; |
1055 | region->repeat = true; | 1054 | region->press_length = LONG_PRESS; |
1055 | } | ||
1056 | else if(*action == '*') | ||
1057 | { | ||
1058 | action++; | ||
1059 | region->press_length = REPEAT; | ||
1056 | } | 1060 | } |
1057 | else | 1061 | else |
1058 | region->repeat = false; | 1062 | region->press_length = PRESS; |
1059 | 1063 | ||
1060 | imax = ARRAYLEN(touchactions); | 1064 | imax = ARRAYLEN(touchactions); |
1061 | for (i = 0; i < imax; i++) | 1065 | for (i = 0; i < imax; i++) |
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index e1a7d0688e..beb6780c3c 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c | |||
@@ -62,6 +62,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
62 | bool released = (type == BUTTON_REL); | 62 | bool released = (type == BUTTON_REL); |
63 | bool pressed = (type == BUTTON_TOUCHSCREEN); | 63 | bool pressed = (type == BUTTON_TOUCHSCREEN); |
64 | struct skin_token_list *regions = data->touchregions; | 64 | struct skin_token_list *regions = data->touchregions; |
65 | bool needs_repeat; | ||
65 | 66 | ||
66 | while (regions) | 67 | while (regions) |
67 | { | 68 | { |
@@ -72,6 +73,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
72 | regions = regions->next; | 73 | regions = regions->next; |
73 | continue; | 74 | continue; |
74 | } | 75 | } |
76 | needs_repeat = r->press_length != PRESS; | ||
75 | /* check if it's inside this viewport */ | 77 | /* check if it's inside this viewport */ |
76 | if (viewport_point_within_vp(&(r->wvp->vp), x, y)) | 78 | if (viewport_point_within_vp(&(r->wvp->vp), x, y)) |
77 | { /* reposition the touch inside the viewport since touchregions | 79 | { /* reposition the touch inside the viewport since touchregions |
@@ -87,22 +89,10 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
87 | vy -= r->y; | 89 | vy -= r->y; |
88 | 90 | ||
89 | 91 | ||
90 | switch(r->type) | 92 | switch(r->action) |
91 | { | 93 | { |
92 | case WPS_TOUCHREGION_ACTION: | 94 | case ACTION_TOUCH_SCROLLBAR: |
93 | if (r->armed && ((repeated && r->repeat) || (released && !r->repeat))) | 95 | case ACTION_TOUCH_VOLUME: |
94 | { | ||
95 | last_action = r->action; | ||
96 | returncode = r->action; | ||
97 | temp = r; | ||
98 | } | ||
99 | if (pressed) | ||
100 | { | ||
101 | r->armed = true; | ||
102 | r->last_press = current_tick; | ||
103 | } | ||
104 | break; | ||
105 | default: | ||
106 | if (edge_offset) | 96 | if (edge_offset) |
107 | { | 97 | { |
108 | if(r->width > r->height) | 98 | if(r->width > r->height) |
@@ -112,8 +102,22 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
112 | if (r->reverse_bar) | 102 | if (r->reverse_bar) |
113 | *edge_offset = 100 - *edge_offset; | 103 | *edge_offset = 100 - *edge_offset; |
114 | } | 104 | } |
115 | returncode = r->type; | ||
116 | temp = r; | 105 | temp = r; |
106 | returncode = r->action; | ||
107 | break; | ||
108 | default: | ||
109 | if (r->armed && ((repeated && needs_repeat) || | ||
110 | (released && !needs_repeat))) | ||
111 | { | ||
112 | last_action = r->action; | ||
113 | returncode = r->action; | ||
114 | temp = r; | ||
115 | } | ||
116 | if (pressed) | ||
117 | { | ||
118 | r->armed = true; | ||
119 | r->last_press = current_tick; | ||
120 | } | ||
117 | break; | 121 | break; |
118 | } | 122 | } |
119 | } | 123 | } |
@@ -126,6 +130,8 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
126 | skin_disarm_touchregions(data); | 130 | skin_disarm_touchregions(data); |
127 | if (retregion && temp) | 131 | if (retregion && temp) |
128 | *retregion = temp; | 132 | *retregion = temp; |
133 | if (temp && temp->press_length == LONG_PRESS) | ||
134 | temp->armed = false; | ||
129 | 135 | ||
130 | if (returncode != ACTION_NONE) | 136 | if (returncode != ACTION_NONE) |
131 | { | 137 | { |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 47453ed34b..0f5cb6df0c 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -188,13 +188,12 @@ struct touchregion { | |||
188 | short int y; /* y-pos */ | 188 | short int y; /* y-pos */ |
189 | short int width; /* width */ | 189 | short int width; /* width */ |
190 | short int height; /* height */ | 190 | short int height; /* height */ |
191 | enum { | ||
192 | WPS_TOUCHREGION_ACTION, | ||
193 | WPS_TOUCHREGION_SCROLLBAR, | ||
194 | WPS_TOUCHREGION_VOLUME | ||
195 | } type; /* type of touch region */ | ||
196 | bool reverse_bar; /* if true 0% is the left or top */ | 191 | bool reverse_bar; /* if true 0% is the left or top */ |
197 | bool repeat; /* requires the area be held for the action */ | 192 | enum { |
193 | PRESS, /* quick press only */ | ||
194 | LONG_PRESS, /* Long press without repeat */ | ||
195 | REPEAT, /* long press allowing repeats */ | ||
196 | } press_length; | ||
198 | int action; /* action this button will return */ | 197 | int action; /* action this button will return */ |
199 | bool armed; /* A region is armed on press. Only armed regions are triggered | 198 | bool armed; /* A region is armed on press. Only armed regions are triggered |
200 | on repeat or release. */ | 199 | on repeat or release. */ |
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index fc91b9abb2..c33268e6bd 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -217,7 +217,7 @@ static int skintouch_to_wps(struct wps_data *data) | |||
217 | case ACTION_STD_HOTKEY: | 217 | case ACTION_STD_HOTKEY: |
218 | return ACTION_WPS_HOTKEY; | 218 | return ACTION_WPS_HOTKEY; |
219 | #endif | 219 | #endif |
220 | case WPS_TOUCHREGION_SCROLLBAR: | 220 | case ACTION_TOUCH_SCROLLBAR: |
221 | skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100; | 221 | skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100; |
222 | if (!skin_get_global_state()->paused) | 222 | if (!skin_get_global_state()->paused) |
223 | #if (CONFIG_CODEC == SWCODEC) | 223 | #if (CONFIG_CODEC == SWCODEC) |
@@ -231,7 +231,7 @@ static int skintouch_to_wps(struct wps_data *data) | |||
231 | audio_resume(); | 231 | audio_resume(); |
232 | #endif | 232 | #endif |
233 | return ACTION_TOUCHSCREEN; | 233 | return ACTION_TOUCHSCREEN; |
234 | case WPS_TOUCHREGION_VOLUME: | 234 | case ACTION_TOUCH_VOLUME: |
235 | { | 235 | { |
236 | const int min_vol = sound_min(SOUND_VOLUME); | 236 | const int min_vol = sound_min(SOUND_VOLUME); |
237 | const int max_vol = sound_max(SOUND_VOLUME); | 237 | const int max_vol = sound_max(SOUND_VOLUME); |