| 828 |
theseven |
1 |
//
|
|
|
2 |
//
|
|
|
3 |
// Copyright 2011 TheSeven
|
|
|
4 |
//
|
|
|
5 |
//
|
|
|
6 |
// This file is part of emCORE.
|
|
|
7 |
//
|
|
|
8 |
// emCORE is free software: you can redistribute it and/or
|
|
|
9 |
// modify it under the terms of the GNU General Public License as
|
|
|
10 |
// published by the Free Software Foundation, either version 2 of the
|
|
|
11 |
// License, or (at your option) any later version.
|
|
|
12 |
//
|
|
|
13 |
// emCORE is distributed in the hope that it will be useful,
|
|
|
14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
16 |
// See the GNU General Public License for more details.
|
|
|
17 |
//
|
|
|
18 |
// You should have received a copy of the GNU General Public License along
|
|
|
19 |
// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20 |
//
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
#include "emcoreapp.h"
|
|
|
25 |
#include "libui.h"
|
|
|
26 |
#include "toolchooser.h"
|
|
|
27 |
#include "boot.h"
|
|
|
28 |
#include "tools.h"
|
|
|
29 |
#include "main.h"
|
|
|
30 |
#include "util.h"
|
|
|
31 |
#include "settingchooser.h"
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_mainchooser =
|
|
|
35 |
{
|
|
|
36 |
.size = LIBUI_POINT(164, 10),
|
|
|
37 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
38 |
.fill_color = 0xa0000000,
|
|
|
39 |
.fill_color_selected = 0x60ffffff,
|
|
|
40 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
41 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
42 |
.icon_opacity = 0,
|
|
|
43 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
44 |
.icon_selected_opacity = 0,
|
|
|
45 |
.text = "Return to main menu",
|
|
|
46 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
47 |
.text_color = 0xffffffff,
|
|
|
48 |
.text_color_selected = 0xff7fffff,
|
|
|
49 |
.render = NULL
|
|
|
50 |
};
|
|
|
51 |
|
|
|
52 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_umsboot =
|
|
|
53 |
{
|
|
|
54 |
.size = LIBUI_POINT(164, 10),
|
|
|
55 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
56 |
.fill_color = 0xa0000000,
|
|
|
57 |
.fill_color_selected = 0x60ffffff,
|
|
|
58 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
59 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
60 |
.icon_opacity = 0,
|
|
|
61 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
62 |
.icon_selected_opacity = 0,
|
|
|
63 |
.text = "Run UMSboot",
|
|
|
64 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
65 |
.text_color = 0xffffffff,
|
|
|
66 |
.text_color_selected = 0xff7fffff,
|
|
|
67 |
.render = NULL
|
|
|
68 |
};
|
|
|
69 |
|
|
|
70 |
struct chooser_renderer_list_itemdata toolchooser_rparams_diagmode =
|
|
|
71 |
{
|
|
|
72 |
.size = LIBUI_POINT(164, 10),
|
|
|
73 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
74 |
.fill_color = 0xa0000000,
|
|
|
75 |
.fill_color_selected = 0x60ffffff,
|
|
|
76 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
77 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
78 |
.icon_opacity = 0,
|
|
|
79 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
80 |
.icon_selected_opacity = 0,
|
|
|
81 |
.text = "Run diagnostics mode",
|
|
|
82 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
83 |
.text_color = 0xffffffff,
|
|
|
84 |
.text_color_selected = 0xff7fffff,
|
|
|
85 |
.render = NULL
|
|
|
86 |
};
|
|
|
87 |
|
|
|
88 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_rockbox_fallback =
|
|
|
89 |
{
|
|
|
90 |
.size = LIBUI_POINT(164, 10),
|
|
|
91 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
92 |
.fill_color = 0xa0000000,
|
|
|
93 |
.fill_color_selected = 0x60ffffff,
|
|
|
94 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
95 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
96 |
.icon_opacity = 0,
|
|
|
97 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
98 |
.icon_selected_opacity = 0,
|
|
|
99 |
.text = "Run Rockbox fallback image",
|
|
|
100 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
101 |
.text_color = 0xffffffff,
|
|
|
102 |
.text_color_selected = 0xff7fffff,
|
|
|
103 |
.render = NULL
|
|
|
104 |
};
|
|
|
105 |
|
|
|
106 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_clearcfg =
|
|
|
107 |
{
|
|
|
108 |
.size = LIBUI_POINT(164, 10),
|
|
|
109 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
110 |
.fill_color = 0xa0000000,
|
|
|
111 |
.fill_color_selected = 0x60ffffff,
|
|
|
112 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
113 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
114 |
.icon_opacity = 0,
|
|
|
115 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
116 |
.icon_selected_opacity = 0,
|
|
|
117 |
.text = "Clear Rockbox configuration",
|
|
|
118 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
119 |
.text_color = 0xffffffff,
|
|
|
120 |
.text_color_selected = 0xff7fffff,
|
|
|
121 |
.render = NULL
|
|
|
122 |
};
|
|
|
123 |
|
|
|
124 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_cleardb =
|
|
|
125 |
{
|
|
|
126 |
.size = LIBUI_POINT(164, 10),
|
|
|
127 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
128 |
.fill_color = 0xa0000000,
|
|
|
129 |
.fill_color_selected = 0x60ffffff,
|
|
|
130 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
131 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
132 |
.icon_opacity = 0,
|
|
|
133 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
134 |
.icon_selected_opacity = 0,
|
|
|
135 |
.text = "Clear Rockbox database",
|
|
|
136 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
137 |
.text_color = 0xffffffff,
|
|
|
138 |
.text_color_selected = 0xff7fffff,
|
|
|
139 |
.render = NULL
|
|
|
140 |
};
|
|
|
141 |
|
|
|
142 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_reformat =
|
|
|
143 |
{
|
|
|
144 |
.size = LIBUI_POINT(164, 10),
|
|
|
145 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
146 |
.fill_color = 0xa0000000,
|
|
|
147 |
.fill_color_selected = 0x60ffffff,
|
|
|
148 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
149 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
150 |
.icon_opacity = 0,
|
|
|
151 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
152 |
.icon_selected_opacity = 0,
|
|
|
153 |
.text = "Reformat data partition",
|
|
|
154 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
155 |
.text_color = 0xffffffff,
|
|
|
156 |
.text_color_selected = 0xff7fffff,
|
|
|
157 |
.render = NULL
|
|
|
158 |
};
|
|
|
159 |
|
|
|
160 |
struct chooser_renderer_list_itemdata toolchooser_rparams_uninstaller =
|
|
|
161 |
{
|
|
|
162 |
.size = LIBUI_POINT(164, 10),
|
|
|
163 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
164 |
.fill_color = 0xa0000000,
|
|
|
165 |
.fill_color_selected = 0x60ffffff,
|
|
|
166 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
167 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
168 |
.icon_opacity = 0,
|
|
|
169 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
170 |
.icon_selected_opacity = 0,
|
|
|
171 |
.text = "Uninstall emCORE",
|
|
|
172 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
173 |
.text_color = 0xffffffff,
|
|
|
174 |
.text_color_selected = 0xff7fffff,
|
|
|
175 |
.render = NULL
|
|
|
176 |
};
|
|
|
177 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_settingchooser =
|
|
|
178 |
{
|
|
|
179 |
.size = LIBUI_POINT(164, 10),
|
|
|
180 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
|
|
181 |
.fill_color = 0xa0000000,
|
|
|
182 |
.fill_color_selected = 0x60ffffff,
|
|
|
183 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
184 |
.icon = LIBUI_SURFACE_NULL,
|
|
|
185 |
.icon_opacity = 0,
|
|
|
186 |
.icon_selected = LIBUI_SURFACE_NULL,
|
|
|
187 |
.icon_selected_opacity = 0,
|
|
|
188 |
.text = "Settings",
|
|
|
189 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
190 |
.text_color = 0xffffffff,
|
|
|
191 |
.text_color_selected = 0xff7fffff,
|
|
|
192 |
.render = NULL
|
|
|
193 |
};
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
static struct chooser_renderer_list_params toolchooser_rparams =
|
|
|
197 |
{
|
|
|
198 |
.version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
|
|
199 |
.copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
|
|
200 |
.copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
|
|
201 |
LIBUI_POINT(176, 132)),
|
|
|
202 |
.bg_dest = LIBUI_LOCATION_NULL,
|
|
|
203 |
.bg_src = LIBUI_SURFACE_NULL,
|
|
|
204 |
.bg_opacity = 0,
|
|
|
205 |
.fill_dest = LIBUI_SURFACE_NULL,
|
|
|
206 |
.fill_color = 0,
|
|
|
207 |
.viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(6, 30)),
|
|
|
208 |
LIBUI_POINT(164, 90)),
|
|
|
209 |
.blit_dest = LIBUI_POINT(0, 0),
|
|
|
210 |
.blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
|
|
211 |
LIBUI_POINT(176, 132)),
|
|
|
212 |
.preblit = update_display,
|
|
|
213 |
.postblit = NULL
|
|
|
214 |
};
|
|
|
215 |
|
|
|
216 |
static struct chooser_action_handler_wheel_params toolchooser_aparams =
|
|
|
217 |
{
|
|
|
218 |
.version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
|
|
|
219 |
.stepsperitem = 128,
|
|
|
220 |
.eventfilter = NULL,
|
|
|
221 |
.timeout_initial = TIMEOUT_BLOCK,
|
|
|
222 |
.timeout_idle = TIMEOUT_BLOCK,
|
|
|
223 |
.timeout_item = 0,
|
|
|
224 |
.tick_force_redraw = true,
|
|
|
225 |
.buttoncount = 5,
|
|
|
226 |
.buttonmap =
|
|
|
227 |
{
|
|
|
228 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
|
|
229 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
|
|
230 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_CANCEL,
|
|
|
231 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
|
|
|
232 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
|
|
|
233 |
}
|
|
|
234 |
};
|
|
|
235 |
|
|
|
236 |
static struct chooser_info toolchooser =
|
|
|
237 |
{
|
|
|
238 |
.version = CHOOSER_INFO_VERSION,
|
|
|
239 |
.actionhandler = NULL,
|
|
|
240 |
.actionhandlerparams = &toolchooser_aparams,
|
|
|
241 |
.renderer = NULL,
|
|
|
242 |
.rendererparams = &toolchooser_rparams,
|
|
|
243 |
.userparams = NULL,
|
|
|
244 |
.tickinterval = 10000000,
|
|
|
245 |
.itemcount = 9,
|
|
|
246 |
.defaultitem = 0,
|
|
|
247 |
.items =
|
|
|
248 |
{
|
|
|
249 |
{
|
|
|
250 |
.user = NULL,
|
|
|
251 |
.actionparams = NULL,
|
|
|
252 |
.renderparams = &toolchooser_rparams_mainchooser
|
|
|
253 |
},
|
|
|
254 |
{
|
|
|
255 |
.user = run_umsboot,
|
|
|
256 |
.actionparams = NULL,
|
|
|
257 |
.renderparams = &toolchooser_rparams_umsboot
|
|
|
258 |
},
|
|
|
259 |
{
|
|
|
260 |
.user = run_diagmode,
|
|
|
261 |
.actionparams = NULL,
|
|
|
262 |
.renderparams = &toolchooser_rparams_diagmode
|
|
|
263 |
},
|
|
|
264 |
{
|
|
|
265 |
.user = run_rockbox_fallback,
|
|
|
266 |
.actionparams = NULL,
|
|
|
267 |
.renderparams = &toolchooser_rparams_rockbox_fallback
|
|
|
268 |
},
|
|
|
269 |
{
|
|
|
270 |
.user = run_clearcfg,
|
|
|
271 |
.actionparams = NULL,
|
|
|
272 |
.renderparams = &toolchooser_rparams_clearcfg
|
|
|
273 |
},
|
|
|
274 |
{
|
|
|
275 |
.user = run_cleardb,
|
|
|
276 |
.actionparams = NULL,
|
|
|
277 |
.renderparams = &toolchooser_rparams_cleardb
|
|
|
278 |
},
|
|
|
279 |
{
|
|
|
280 |
.user = run_reformat,
|
|
|
281 |
.actionparams = NULL,
|
|
|
282 |
.renderparams = &toolchooser_rparams_reformat
|
|
|
283 |
},
|
|
|
284 |
{
|
|
|
285 |
.user = run_uninstaller,
|
|
|
286 |
.actionparams = NULL,
|
|
|
287 |
.renderparams = &toolchooser_rparams_uninstaller
|
|
|
288 |
},
|
|
|
289 |
{
|
|
|
290 |
.user = run_settingchooser,
|
|
|
291 |
.actionparams = NULL,
|
|
|
292 |
.renderparams = &toolchooser_rparams_settingchooser
|
|
|
293 |
}
|
|
|
294 |
}
|
|
|
295 |
};
|
|
|
296 |
|
|
|
297 |
void run_toolchooser(void** firmware, void** app, int* size)
|
|
|
298 |
{
|
|
|
299 |
while (true)
|
|
|
300 |
{
|
|
|
301 |
const struct chooser_item* result = ui->chooser_run(&toolchooser);
|
|
|
302 |
if (!result || !result->user) return;
|
|
|
303 |
void (*selected_function)(void** firmware, void** app, int* size);
|
|
|
304 |
selected_function = (void(*)(void** firmware, void** app, int* size))(result->user);
|
|
|
305 |
selected_function(firmware, app, size);
|
|
|
306 |
if (firmware || app) return;
|
|
|
307 |
}
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
void toolchooser_init()
|
|
|
311 |
{
|
|
|
312 |
toolchooser.actionhandler = ui->chooser_action_handler_wheel;
|
|
|
313 |
toolchooser.renderer = ui->chooser_renderer_list;
|
|
|
314 |
toolchooser_rparams.copy_dest.buf.addr = framebuf;
|
|
|
315 |
toolchooser_rparams.copy_src.loc.buf.addr = bg;
|
|
|
316 |
toolchooser_rparams.viewport.loc.buf.addr = framebuf;
|
|
|
317 |
toolchooser_rparams.blit_src.loc.buf.addr = framebuf;
|
|
|
318 |
toolchooser_rparams_mainchooser.render = ui->chooser_renderer_list_show_arrow_left;
|
|
|
319 |
toolchooser_rparams_settingchooser.render = ui->chooser_renderer_list_show_arrow_right;
|
|
|
320 |
}
|