diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-02-12 12:54:03 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-02-12 12:54:03 +0000 |
commit | 20ce2448dea283660ab81fcab0637d17c63a31e9 (patch) | |
tree | ffd385898c7511e5dd0b1796eaae04e081c9a3db | |
parent | 6878cf34ef36fdff95528718ca9d35764cc9374c (diff) | |
download | rockbox-20ce2448dea283660ab81fcab0637d17c63a31e9.tar.gz rockbox-20ce2448dea283660ab81fcab0637d17c63a31e9.zip |
"remote_control: don't use goto.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24617 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/remote_control.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/apps/plugins/remote_control.c b/apps/plugins/remote_control.c index 8e05c67283..e00d5de54c 100644 --- a/apps/plugins/remote_control.c +++ b/apps/plugins/remote_control.c | |||
@@ -25,7 +25,9 @@ | |||
25 | 25 | ||
26 | PLUGIN_HEADER | 26 | PLUGIN_HEADER |
27 | 27 | ||
28 | static void remote_control_setcolors(void); | 28 | #define PLUGIN_CONTINUE 10 |
29 | |||
30 | static inline void remote_control_setcolors(void); | ||
29 | 31 | ||
30 | /***************************************************************************** | 32 | /***************************************************************************** |
31 | * remote_control_setcolors() set the foreground and background colors. | 33 | * remote_control_setcolors() set the foreground and background colors. |
@@ -48,9 +50,7 @@ static int menu_desktop(void) | |||
48 | { | 50 | { |
49 | int id = HID_GENERIC_DESKTOP_UNDEFINED; | 51 | int id = HID_GENERIC_DESKTOP_UNDEFINED; |
50 | 52 | ||
51 | selection = rb->do_menu(&menu, &selection, NULL, false); | 53 | switch (rb->do_menu(&menu, &selection, NULL, false)) |
52 | |||
53 | switch (selection) | ||
54 | { | 54 | { |
55 | case 0: /* Escape */ | 55 | case 0: /* Escape */ |
56 | id = HID_KEYBOARD_ESCAPE; | 56 | id = HID_KEYBOARD_ESCAPE; |
@@ -71,7 +71,7 @@ static int menu_desktop(void) | |||
71 | case MENU_ATTACHED_USB: | 71 | case MENU_ATTACHED_USB: |
72 | return PLUGIN_USB_CONNECTED; | 72 | return PLUGIN_USB_CONNECTED; |
73 | case GO_TO_PREVIOUS: | 73 | case GO_TO_PREVIOUS: |
74 | return 0; | 74 | return PLUGIN_CONTINUE; |
75 | default: | 75 | default: |
76 | break; | 76 | break; |
77 | } | 77 | } |
@@ -92,9 +92,7 @@ static int menu_presentation(void) | |||
92 | { | 92 | { |
93 | int id = HID_GENERIC_DESKTOP_UNDEFINED; | 93 | int id = HID_GENERIC_DESKTOP_UNDEFINED; |
94 | 94 | ||
95 | selection = rb->do_menu(&menu, &selection, NULL, false); | 95 | switch (rb->do_menu(&menu, &selection, NULL, false)) |
96 | |||
97 | switch (selection) | ||
98 | { | 96 | { |
99 | case 0: /* Next Slide */ | 97 | case 0: /* Next Slide */ |
100 | id = HID_KEYBOARD_N; | 98 | id = HID_KEYBOARD_N; |
@@ -117,7 +115,7 @@ static int menu_presentation(void) | |||
117 | case MENU_ATTACHED_USB: | 115 | case MENU_ATTACHED_USB: |
118 | return PLUGIN_USB_CONNECTED; | 116 | return PLUGIN_USB_CONNECTED; |
119 | case GO_TO_PREVIOUS: | 117 | case GO_TO_PREVIOUS: |
120 | return 0; | 118 | return PLUGIN_CONTINUE; |
121 | default: | 119 | default: |
122 | break; | 120 | break; |
123 | } | 121 | } |
@@ -137,9 +135,7 @@ static int menu_media_player(void) | |||
137 | { | 135 | { |
138 | int id = HID_CONSUMER_USAGE_UNASSIGNED; | 136 | int id = HID_CONSUMER_USAGE_UNASSIGNED; |
139 | 137 | ||
140 | selection = rb->do_menu(&menu, &selection, NULL, false); | 138 | switch (rb->do_menu(&menu, &selection, NULL, false)) |
141 | |||
142 | switch (selection) | ||
143 | { | 139 | { |
144 | case 0: /* Play */ | 140 | case 0: /* Play */ |
145 | id = HID_CONSUMER_USAGE_PLAY_PAUSE; | 141 | id = HID_CONSUMER_USAGE_PLAY_PAUSE; |
@@ -165,7 +161,7 @@ static int menu_media_player(void) | |||
165 | case MENU_ATTACHED_USB: | 161 | case MENU_ATTACHED_USB: |
166 | return PLUGIN_USB_CONNECTED; | 162 | return PLUGIN_USB_CONNECTED; |
167 | case GO_TO_PREVIOUS: | 163 | case GO_TO_PREVIOUS: |
168 | return 0; | 164 | return PLUGIN_CONTINUE; |
169 | default: | 165 | default: |
170 | break; | 166 | break; |
171 | } | 167 | } |
@@ -180,7 +176,7 @@ static int menu_media_player(void) | |||
180 | ******************************************************************************/ | 176 | ******************************************************************************/ |
181 | enum plugin_status plugin_start(const void* parameter) | 177 | enum plugin_status plugin_start(const void* parameter) |
182 | { | 178 | { |
183 | enum plugin_status rc = PLUGIN_USB_CONNECTED; | 179 | enum plugin_status rc = PLUGIN_CONTINUE; |
184 | int selection = 0; | 180 | int selection = 0; |
185 | 181 | ||
186 | (void)parameter; | 182 | (void)parameter; |
@@ -196,34 +192,30 @@ enum plugin_status plugin_start(const void* parameter) | |||
196 | 192 | ||
197 | MENUITEM_STRINGLIST(menu, "Remote Control", NULL, "Desktop", "Presentation", | 193 | MENUITEM_STRINGLIST(menu, "Remote Control", NULL, "Desktop", "Presentation", |
198 | "Media Player", "Quit"); | 194 | "Media Player", "Quit"); |
199 | while(1) | 195 | while(rc == PLUGIN_CONTINUE) |
200 | { | 196 | { |
201 | selection = rb->do_menu(&menu, &selection, NULL, false); | 197 | switch (rb->do_menu(&menu, &selection, NULL, false)) |
202 | switch (selection) | ||
203 | { | 198 | { |
204 | case 0: /* Desktop */ | 199 | case 0: /* Desktop */ |
205 | if (menu_desktop() == PLUGIN_USB_CONNECTED) | 200 | rc = menu_desktop(); |
206 | goto Exit; | ||
207 | break; | 201 | break; |
208 | case 1: /* Presentation */ | 202 | case 1: /* Presentation */ |
209 | if (menu_presentation() == PLUGIN_USB_CONNECTED) | 203 | rc = menu_presentation(); |
210 | goto Exit; | ||
211 | break; | 204 | break; |
212 | case 2: /* Media Player */ | 205 | case 2: /* Media Player */ |
213 | if (menu_media_player() == PLUGIN_USB_CONNECTED) | 206 | rc = menu_media_player(); |
214 | goto Exit; | ||
215 | break; | 207 | break; |
216 | case 3: /* Quit */ | 208 | case 3: /* Quit */ |
217 | case GO_TO_PREVIOUS: | 209 | case GO_TO_PREVIOUS: |
218 | rc = PLUGIN_OK; | 210 | rc = PLUGIN_OK; |
219 | goto Exit; | 211 | break; |
220 | case MENU_ATTACHED_USB: | 212 | case MENU_ATTACHED_USB: |
221 | goto Exit; | 213 | rc = PLUGIN_USB_CONNECTED; |
214 | break; | ||
222 | default: | 215 | default: |
223 | break; | 216 | break; |
224 | } | 217 | } |
225 | } | 218 | } |
226 | Exit: | ||
227 | rb->lcd_setfont(FONT_UI); | 219 | rb->lcd_setfont(FONT_UI); |
228 | 220 | ||
229 | return rc; | 221 | return rc; |