| 808 |
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"
|
| 833 |
theseven |
31 |
#include "settings.h"
|
| 808 |
theseven |
32 |
#include "settingchooser.h"
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_mainchooser =
|
|
|
36 |
{
|
|
|
37 |
.size = LIBUI_POINT(260, 10),
|
|
|
38 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
39 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
40 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
41 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
42 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
43 |
.icon_opacity = 0,
|
| 823 |
theseven |
44 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
45 |
.icon_selected_opacity = 0,
|
|
|
46 |
.text = "Return to main menu",
|
|
|
47 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
48 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
49 |
.text_color_selected = 0xff7fffff,
|
|
|
50 |
.render = NULL
|
| 808 |
theseven |
51 |
};
|
|
|
52 |
|
|
|
53 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_umsboot =
|
|
|
54 |
{
|
|
|
55 |
.size = LIBUI_POINT(260, 10),
|
|
|
56 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
57 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
58 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
59 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
60 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
61 |
.icon_opacity = 0,
|
| 823 |
theseven |
62 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
63 |
.icon_selected_opacity = 0,
|
|
|
64 |
.text = "Run UMSboot",
|
|
|
65 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
66 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
67 |
.text_color_selected = 0xff7fffff,
|
|
|
68 |
.render = NULL
|
| 808 |
theseven |
69 |
};
|
|
|
70 |
|
|
|
71 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_rockbox_fallback =
|
|
|
72 |
{
|
|
|
73 |
.size = LIBUI_POINT(260, 10),
|
|
|
74 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
75 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
76 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
77 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
78 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
79 |
.icon_opacity = 0,
|
| 823 |
theseven |
80 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
81 |
.icon_selected_opacity = 0,
|
|
|
82 |
.text = "Run Rockbox fallback image",
|
|
|
83 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
84 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
85 |
.text_color_selected = 0xff7fffff,
|
|
|
86 |
.render = NULL
|
| 808 |
theseven |
87 |
};
|
|
|
88 |
|
|
|
89 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_clearcfg =
|
|
|
90 |
{
|
|
|
91 |
.size = LIBUI_POINT(260, 10),
|
|
|
92 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
93 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
94 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
95 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
96 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
97 |
.icon_opacity = 0,
|
| 823 |
theseven |
98 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
99 |
.icon_selected_opacity = 0,
|
|
|
100 |
.text = "Clear Rockbox configuration",
|
|
|
101 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
102 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
103 |
.text_color_selected = 0xff7fffff,
|
|
|
104 |
.render = NULL
|
| 808 |
theseven |
105 |
};
|
|
|
106 |
|
|
|
107 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_cleardb =
|
|
|
108 |
{
|
|
|
109 |
.size = LIBUI_POINT(260, 10),
|
|
|
110 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
111 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
112 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
113 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
114 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
115 |
.icon_opacity = 0,
|
| 823 |
theseven |
116 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
117 |
.icon_selected_opacity = 0,
|
|
|
118 |
.text = "Clear Rockbox database",
|
|
|
119 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
120 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
121 |
.text_color_selected = 0xff7fffff,
|
|
|
122 |
.render = NULL
|
| 808 |
theseven |
123 |
};
|
|
|
124 |
|
|
|
125 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_reformat =
|
|
|
126 |
{
|
|
|
127 |
.size = LIBUI_POINT(260, 10),
|
|
|
128 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
129 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
130 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
131 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
132 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
133 |
.icon_opacity = 0,
|
| 823 |
theseven |
134 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
135 |
.icon_selected_opacity = 0,
|
|
|
136 |
.text = "Reformat data partition",
|
|
|
137 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
138 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
139 |
.text_color_selected = 0xff7fffff,
|
|
|
140 |
.render = NULL
|
| 808 |
theseven |
141 |
};
|
|
|
142 |
|
|
|
143 |
static struct chooser_renderer_list_itemdata toolchooser_rparams_settingchooser =
|
|
|
144 |
{
|
|
|
145 |
.size = LIBUI_POINT(260, 10),
|
|
|
146 |
.fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(260, 10)),
|
|
|
147 |
.fill_color = 0xa0000000,
|
| 833 |
theseven |
148 |
.fill_color_selected = 0x60000000,
|
| 823 |
theseven |
149 |
.icon_pos = LIBUI_POINT_NULL,
|
|
|
150 |
.icon = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
151 |
.icon_opacity = 0,
|
| 823 |
theseven |
152 |
.icon_selected = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
153 |
.icon_selected_opacity = 0,
|
|
|
154 |
.text = "Settings",
|
|
|
155 |
.text_pos = LIBUI_POINT(1, 1),
|
|
|
156 |
.text_color = 0xffffffff,
|
| 823 |
theseven |
157 |
.text_color_selected = 0xff7fffff,
|
|
|
158 |
.render = NULL
|
| 808 |
theseven |
159 |
};
|
|
|
160 |
|
|
|
161 |
static struct chooser_renderer_list_params toolchooser_rparams =
|
|
|
162 |
{
|
|
|
163 |
.version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
|
|
164 |
.copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
|
|
165 |
.copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
|
|
166 |
LIBUI_POINT(320, 240)),
|
| 823 |
theseven |
167 |
.bg_dest = LIBUI_LOCATION_NULL,
|
|
|
168 |
.bg_src = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
169 |
.bg_opacity = 0,
|
| 823 |
theseven |
170 |
.fill_dest = LIBUI_SURFACE_NULL,
|
| 808 |
theseven |
171 |
.fill_color = 0,
|
|
|
172 |
.viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(30, 50)),
|
|
|
173 |
LIBUI_POINT(260, 160)),
|
|
|
174 |
.blit_dest = LIBUI_POINT(0, 0),
|
|
|
175 |
.blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 320), LIBUI_POINT(0, 0)),
|
|
|
176 |
LIBUI_POINT(320, 240)),
|
|
|
177 |
.preblit = update_display,
|
|
|
178 |
.postblit = NULL
|
|
|
179 |
};
|
|
|
180 |
|
|
|
181 |
static struct chooser_action_handler_wheel_params toolchooser_aparams =
|
|
|
182 |
{
|
|
|
183 |
.version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
|
|
|
184 |
.stepsperitem = 128,
|
|
|
185 |
.eventfilter = NULL,
|
|
|
186 |
.timeout_initial = TIMEOUT_BLOCK,
|
|
|
187 |
.timeout_idle = TIMEOUT_BLOCK,
|
|
|
188 |
.timeout_item = 0,
|
| 823 |
theseven |
189 |
.tick_force_redraw = true,
|
| 808 |
theseven |
190 |
.buttoncount = 5,
|
|
|
191 |
.buttonmap =
|
|
|
192 |
{
|
|
|
193 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| 826 |
theseven |
194 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| 808 |
theseven |
195 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_CANCEL,
|
|
|
196 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
|
|
|
197 |
CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
|
|
|
198 |
}
|
|
|
199 |
};
|
|
|
200 |
|
|
|
201 |
static struct chooser_info toolchooser =
|
|
|
202 |
{
|
|
|
203 |
.version = CHOOSER_INFO_VERSION,
|
|
|
204 |
.actionhandler = NULL,
|
|
|
205 |
.actionhandlerparams = &toolchooser_aparams,
|
|
|
206 |
.renderer = NULL,
|
|
|
207 |
.rendererparams = &toolchooser_rparams,
|
|
|
208 |
.userparams = NULL,
|
|
|
209 |
.tickinterval = 10000000,
|
|
|
210 |
.itemcount = 7,
|
|
|
211 |
.defaultitem = 0,
|
|
|
212 |
.items =
|
|
|
213 |
{
|
|
|
214 |
{
|
|
|
215 |
.user = NULL,
|
|
|
216 |
.actionparams = NULL,
|
|
|
217 |
.renderparams = &toolchooser_rparams_mainchooser
|
|
|
218 |
},
|
|
|
219 |
{
|
|
|
220 |
.user = run_umsboot,
|
|
|
221 |
.actionparams = NULL,
|
|
|
222 |
.renderparams = &toolchooser_rparams_umsboot
|
|
|
223 |
},
|
|
|
224 |
{
|
|
|
225 |
.user = run_rockbox_fallback,
|
|
|
226 |
.actionparams = NULL,
|
|
|
227 |
.renderparams = &toolchooser_rparams_rockbox_fallback
|
|
|
228 |
},
|
|
|
229 |
{
|
|
|
230 |
.user = run_clearcfg,
|
|
|
231 |
.actionparams = NULL,
|
|
|
232 |
.renderparams = &toolchooser_rparams_clearcfg
|
|
|
233 |
},
|
|
|
234 |
{
|
|
|
235 |
.user = run_cleardb,
|
|
|
236 |
.actionparams = NULL,
|
|
|
237 |
.renderparams = &toolchooser_rparams_cleardb
|
|
|
238 |
},
|
|
|
239 |
{
|
|
|
240 |
.user = run_reformat,
|
|
|
241 |
.actionparams = NULL,
|
|
|
242 |
.renderparams = &toolchooser_rparams_reformat
|
|
|
243 |
},
|
|
|
244 |
{
|
|
|
245 |
.user = run_settingchooser,
|
|
|
246 |
.actionparams = NULL,
|
|
|
247 |
.renderparams = &toolchooser_rparams_settingchooser
|
|
|
248 |
}
|
|
|
249 |
}
|
|
|
250 |
};
|
|
|
251 |
|
|
|
252 |
void run_toolchooser(void** firmware, void** app, int* size)
|
|
|
253 |
{
|
| 830 |
theseven |
254 |
while (!*firmware && !*app)
|
| 808 |
theseven |
255 |
{
|
|
|
256 |
const struct chooser_item* result = ui->chooser_run(&toolchooser);
|
|
|
257 |
if (!result || !result->user) return;
|
|
|
258 |
void (*selected_function)(void** firmware, void** app, int* size);
|
|
|
259 |
selected_function = (void(*)(void** firmware, void** app, int* size))(result->user);
|
|
|
260 |
selected_function(firmware, app, size);
|
|
|
261 |
}
|
|
|
262 |
}
|
|
|
263 |
|
|
|
264 |
void toolchooser_init()
|
|
|
265 |
{
|
|
|
266 |
toolchooser.actionhandler = ui->chooser_action_handler_wheel;
|
|
|
267 |
toolchooser.renderer = ui->chooser_renderer_list;
|
|
|
268 |
toolchooser_rparams.copy_dest.buf.addr = framebuf;
|
|
|
269 |
toolchooser_rparams.copy_src.loc.buf.addr = bg;
|
|
|
270 |
toolchooser_rparams.viewport.loc.buf.addr = framebuf;
|
|
|
271 |
toolchooser_rparams.blit_src.loc.buf.addr = framebuf;
|
| 823 |
theseven |
272 |
toolchooser_rparams_mainchooser.render = ui->chooser_renderer_list_show_arrow_left;
|
|
|
273 |
toolchooser_rparams_settingchooser.render = ui->chooser_renderer_list_show_arrow_right;
|
| 808 |
theseven |
274 |
}
|
| 833 |
theseven |
275 |
|
|
|
276 |
void toolchooser_apply_settings()
|
|
|
277 |
{
|
|
|
278 |
if (settings.snow) toolchooser.tickinterval = 50000;
|
|
|
279 |
else toolchooser.tickinterval = 10000000;
|
|
|
280 |
}
|