blob: 6dc33a22d9b9f954ca0d45bd52447ed39bfb3f66 [file] [log] [blame]
Dave Chapman603f87f2006-02-26 02:48:05 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Zakk Robertsb81f5962006-03-21 02:02:04 +00008 * $Id$
Dave Chapman603f87f2006-02-26 02:48:05 +00009 *
10 * Copyright (C) Jonathan Gordon (2006)
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
Dave Chapman3ea74cc2006-07-19 14:31:24 +000019#include "config.h"
Dave Chapman603f87f2006-02-26 02:48:05 +000020#include "stdarg.h"
21#include "string.h"
22#include "stdio.h"
23#include "kernel.h"
24#include "system.h"
25#include "screen_access.h"
Michael Sevakiscc66aea2006-10-11 20:34:25 +000026#include "font.h"
Dave Chapman603f87f2006-02-26 02:48:05 +000027#include "debug.h"
28#include "misc.h"
29#include "settings.h"
30#include "scrollbar.h"
31#include "lang.h"
Zakk Roberts87142ab2006-03-04 10:55:54 +000032#include "splash.h"
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +000033#include "action.h"
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +000034#include "icon.h"
Dave Chapman603f87f2006-02-26 02:48:05 +000035
Michael Sevakiscc66aea2006-10-11 20:34:25 +000036/* structure for color info */
37struct rgb_pick
38{
39 unsigned color; /* native color value */
40 union
41 {
42 unsigned char rgb_val[6]; /* access to components as array */
43 struct
44 {
45 unsigned char r; /* native red value */
46 unsigned char g; /* native green value */
47 unsigned char b; /* native blue value */
48 unsigned char red; /* 8 bit red value */
49 unsigned char green; /* 8 bit green value */
50 unsigned char blue; /* 8 bit blue value */
51 } __attribute__ ((__packed__)); /* assume byte packing */
52 };
53};
Dave Chapman603f87f2006-02-26 02:48:05 +000054
Michael Sevakiscc66aea2006-10-11 20:34:25 +000055
56/* list of primary colors */
Michael Sevakis661c3402006-10-13 04:16:49 +000057#define SB_PRIM 0
58#define SB_FILL 1
Michael Sevakise0710b22006-10-15 17:51:00 +000059static const fb_data prim_rgb[][3] =
Michael Sevakiscc66aea2006-10-11 20:34:25 +000060{
Michael Sevakis661c3402006-10-13 04:16:49 +000061 /* Foreground colors for sliders */
62 {
63 LCD_RGBPACK(255, 0, 0),
64 LCD_RGBPACK( 0, 255, 0),
65 LCD_RGBPACK( 0, 0, 255),
66 },
67 /* Fill colors for sliders */
68 {
69 LCD_RGBPACK( 85, 0, 0),
70 LCD_RGBPACK( 0, 85, 0),
71 LCD_RGBPACK( 0, 0, 85),
72 },
Michael Sevakise0710b22006-10-15 17:51:00 +000073};
74
75/* maximum values for components */
76static const unsigned char rgb_max[3] =
77{
78 LCD_MAX_RED,
79 LCD_MAX_GREEN,
80 LCD_MAX_BLUE
Michael Sevakiscc66aea2006-10-11 20:34:25 +000081};
82
83/* Unpacks the color value into native rgb values and 24 bit rgb values */
84static void unpack_rgb(struct rgb_pick *rgb)
85{
Michael Sevakise0710b22006-10-15 17:51:00 +000086 unsigned color = _LCD_UNSWAP_COLOR(rgb->color);
Michael Sevakiscc66aea2006-10-11 20:34:25 +000087 rgb->red = _RGB_UNPACK_RED(color);
88 rgb->green = _RGB_UNPACK_GREEN(color);
89 rgb->blue = _RGB_UNPACK_BLUE(color);
Michael Sevakise0710b22006-10-15 17:51:00 +000090 rgb->r = _RGB_UNPACK_RED_LCD(color);
91 rgb->g = _RGB_UNPACK_GREEN_LCD(color);
92 rgb->b = _RGB_UNPACK_BLUE_LCD(color);
Michael Sevakiscc66aea2006-10-11 20:34:25 +000093}
94
95/* Packs the native rgb colors into a color value */
Michael Sevakise0710b22006-10-15 17:51:00 +000096static inline void pack_rgb(struct rgb_pick *rgb)
Michael Sevakiscc66aea2006-10-11 20:34:25 +000097{
Michael Sevakise0710b22006-10-15 17:51:00 +000098 rgb->color = LCD_RGBPACK_LCD(rgb->r, rgb->g, rgb->b);
Michael Sevakiscc66aea2006-10-11 20:34:25 +000099}
100
101/* Returns LCD_BLACK if the color is above a threshold brightness
102 else return LCD_WHITE */
103static inline unsigned get_black_or_white(const struct rgb_pick *rgb)
104{
Michael Sevakis661c3402006-10-13 04:16:49 +0000105 return (2*rgb->red + 5*rgb->green + rgb->blue) >= 1024 ?
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000106 LCD_BLACK : LCD_WHITE;
107}
108
Michael Sevakis661c3402006-10-13 04:16:49 +0000109#define MARGIN_LEFT 0 /* Left margin of screen */
110#define MARGIN_TOP 2 /* Top margin of screen */
111#define MARGIN_RIGHT 0 /* Right margin of screen */
112#define MARGIN_BOTTOM 6 /* Bottom margin of screen */
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000113#define SLIDER_MARGIN_LEFT 2 /* Gap to left of sliders */
114#define SLIDER_MARGIN_RIGHT 2 /* Gap to right of sliders */
115#define TITLE_MARGIN_BOTTOM 4 /* Space below title bar */
Michael Sevakis661c3402006-10-13 04:16:49 +0000116#define SELECTOR_LR_MARGIN 0 /* Margin between ">" and text */
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000117#define SELECTOR_TB_MARGIN 1 /* Margin on top and bottom of selector */
118#define SWATCH_TOP_MARGIN 4 /* Space between last slider and swatch */
Jonathan Gordoncfe0f482007-06-11 13:32:29 +0000119#define SELECTOR_WIDTH get_icon_width(display->screen_type)
Michael Sevakis661c3402006-10-13 04:16:49 +0000120#define SELECTOR_HEIGHT 8 /* Height of > and < bitmaps */
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000121
122/* dunno why lcd_set_drawinfo should be left out of struct screen */
123static void set_drawinfo(struct screen *display, int mode,
124 unsigned foreground, unsigned background)
125{
126 display->set_drawmode(mode);
127 if (display->depth > 1)
128 {
129 display->set_foreground(foreground);
130 display->set_background(background);
131 }
132}
Dave Chapman603f87f2006-02-26 02:48:05 +0000133
Zakk Robertsb81f5962006-03-21 02:02:04 +0000134static void draw_screen(struct screen *display, char *title,
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000135 struct rgb_pick *rgb, int row)
Dave Chapman603f87f2006-02-26 02:48:05 +0000136{
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000137 unsigned text_color = LCD_BLACK;
138 unsigned background_color = LCD_WHITE;
139 char buf[32];
140 int i, x, y;
141 int text_top;
142 int slider_left, slider_width;
143 bool display_three_rows;
144 int max_label_width;
Dave Chapman603f87f2006-02-26 02:48:05 +0000145
146 display->clear_display();
147
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000148 if (display->depth > 1)
149 {
150 text_color = display->get_foreground();
151 background_color = display->get_background();
Dave Chapman603f87f2006-02-26 02:48:05 +0000152 }
153
Michael Sevakisa7c8c712006-10-12 00:50:13 +0000154 /* Find out if there's enough room for three sliders or just
155 enough to display the selected slider - calculate total height
156 of display with three sliders present */
157 display_three_rows =
158 display->height >= MARGIN_TOP +
159 display->char_height*4 + /* Title + 3 sliders */
160 TITLE_MARGIN_BOTTOM +
161 SELECTOR_TB_MARGIN*6 + /* 2 margins/slider */
162 MARGIN_BOTTOM;
Zakk Robertsb81f5962006-03-21 02:02:04 +0000163
Michael Sevakisa7c8c712006-10-12 00:50:13 +0000164 /* Figure out widest label character in case they vary -
165 this function assumes labels are one character */
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000166 for (i = 0, max_label_width = 0; i < 3; i++)
Dave Chapman603f87f2006-02-26 02:48:05 +0000167 {
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000168 buf[0] = str(LANG_COLOR_RGB_LABELS)[i];
169 buf[1] = '\0';
170 x = display->getstringsize(buf, NULL, NULL);
171 if (x > max_label_width)
172 max_label_width = x;
173 }
174
175 /* Draw title string */
176 set_drawinfo(display, DRMODE_SOLID, text_color, background_color);
177 display->getstringsize(title, &x, &y);
178 display->putsxy((display->width - x) / 2, MARGIN_TOP, title);
179
180 /* Get slider positions and top starting position */
181 text_top = MARGIN_TOP + y + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN;
Michael Sevakis661c3402006-10-13 04:16:49 +0000182 slider_left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN +
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000183 max_label_width + SLIDER_MARGIN_LEFT;
184 slider_width = display->width - slider_left - SLIDER_MARGIN_RIGHT -
Michael Sevakis661c3402006-10-13 04:16:49 +0000185 display->char_width*2 - SELECTOR_LR_MARGIN - SELECTOR_WIDTH -
186 MARGIN_RIGHT;
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000187
188 for (i = 0; i < 3; i++)
189 {
Michael Sevakis661c3402006-10-13 04:16:49 +0000190 unsigned sb_flags = HORIZONTAL;
191 int mode = DRMODE_SOLID;
192 unsigned fg = text_color;
193 unsigned bg = background_color;
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000194
Dave Chapman3ea74cc2006-07-19 14:31:24 +0000195 if (!display_three_rows)
Michael Sevakis661c3402006-10-13 04:16:49 +0000196 i = row;
Zakk Robertsb81f5962006-03-21 02:02:04 +0000197
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000198 if (i == row)
Dave Chapman603f87f2006-02-26 02:48:05 +0000199 {
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000200 set_drawinfo(display, DRMODE_SOLID, text_color,
201 background_color);
202
Nicolas Pennequinf3b015f2007-09-27 15:42:55 +0000203 if (global_settings.cursor_style != 0)
Dave Chapman603f87f2006-02-26 02:48:05 +0000204 {
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000205 /* Draw solid bar selection bar */
206 display->fillrect(0,
207 text_top - SELECTOR_TB_MARGIN,
208 display->width,
209 display->char_height +
210 SELECTOR_TB_MARGIN*2);
211
Michael Sevakis661c3402006-10-13 04:16:49 +0000212 if (display->depth < 16)
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000213 {
Michael Sevakis661c3402006-10-13 04:16:49 +0000214 sb_flags |= FOREGROUND | INNER_FILL;
215 mode |= DRMODE_INVERSEVID;
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000216 }
Dave Chapman603f87f2006-02-26 02:48:05 +0000217 }
Dave Chapman3ea74cc2006-07-19 14:31:24 +0000218 else if (display_three_rows)
Dave Chapman603f87f2006-02-26 02:48:05 +0000219 {
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000220 /* Draw "> <" around sliders */
Michael Sevakis661c3402006-10-13 04:16:49 +0000221 int top = text_top + (display->char_height -
222 SELECTOR_HEIGHT) / 2;
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +0000223 screen_put_iconxy(display, MARGIN_LEFT, top, Icon_Cursor);
224 screen_put_iconxy(display,
225 display->width - MARGIN_RIGHT -
226 get_icon_width(display->screen_type),
227 top, Icon_Cursor);
Michael Sevakis661c3402006-10-13 04:16:49 +0000228 }
229
230 if (display->depth >= 16)
231 {
232 sb_flags |= FOREGROUND | INNER_BGFILL;
233 mode = DRMODE_FG;
234 fg = prim_rgb[SB_PRIM][i];
235 bg = prim_rgb[SB_FILL][i];
Dave Chapman603f87f2006-02-26 02:48:05 +0000236 }
237 }
Michael Sevakis661c3402006-10-13 04:16:49 +0000238
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000239 set_drawinfo(display, mode, fg, bg);
Dave Chapman603f87f2006-02-26 02:48:05 +0000240
Michael Sevakisa7c8c712006-10-12 00:50:13 +0000241 /* Draw label */
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000242 buf[0] = str(LANG_COLOR_RGB_LABELS)[i];
243 buf[1] = '\0';
244 display->putsxy(slider_left - display->char_width -
245 SLIDER_MARGIN_LEFT, text_top, buf);
Dave Chapman603f87f2006-02-26 02:48:05 +0000246
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000247 /* Draw color value */
248 snprintf(buf, 3, "%02d", rgb->rgb_val[i]);
249 display->putsxy(slider_left + slider_width + SLIDER_MARGIN_RIGHT,
250 text_top, buf);
Zakk Robertsb81f5962006-03-21 02:02:04 +0000251
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000252 /* Draw scrollbar */
253 gui_scrollbar_draw(display,
254 slider_left,
255 text_top + display->char_height / 4,
256 slider_width,
257 display->char_height / 2,
Michael Sevakise0710b22006-10-15 17:51:00 +0000258 rgb_max[i],
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000259 0,
260 rgb->rgb_val[i],
Michael Sevakis661c3402006-10-13 04:16:49 +0000261 sb_flags);
Zakk Robertsb81f5962006-03-21 02:02:04 +0000262
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000263 /* Advance to next line */
264 text_top += display->char_height + 2*SELECTOR_TB_MARGIN;
265
Dave Chapman3ea74cc2006-07-19 14:31:24 +0000266 if (!display_three_rows)
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000267 break;
Michael Sevakis661c3402006-10-13 04:16:49 +0000268 } /* end for */
269
270 /* Draw color value in system font */
271 display->setfont(FONT_SYSFIXED);
Dave Chapman603f87f2006-02-26 02:48:05 +0000272
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000273 /* Format RGB: #rrggbb */
274 snprintf(buf, sizeof(buf), str(LANG_COLOR_RGB_VALUE),
275 rgb->red, rgb->green, rgb->blue);
276
277 if (display->depth >= 16)
278 {
279 /* Display color swatch on color screens only */
Michael Sevakis661c3402006-10-13 04:16:49 +0000280 int left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN;
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000281 int top = text_top + SWATCH_TOP_MARGIN;
Michael Sevakis661c3402006-10-13 04:16:49 +0000282 int width = display->width - left - SELECTOR_LR_MARGIN -
283 SELECTOR_WIDTH - MARGIN_RIGHT;
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000284 int height = display->height - top - MARGIN_BOTTOM;
285
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000286 /* Only draw if room */
287 if (height >= display->char_height + 2)
288 {
289 display->set_foreground(rgb->color);
290 display->fillrect(left, top, width, height);
291
292 /* Draw RGB: #rrggbb in middle of swatch */
293 display->set_drawmode(DRMODE_FG);
294 display->getstringsize(buf, &x, &y);
295 display->set_foreground(get_black_or_white(rgb));
296
297 x = left + (width - x) / 2;
298 y = top + (height - y) / 2;
299
300 display->putsxy(x, y, buf);
301 display->set_drawmode(DRMODE_SOLID);
302
303 /* Draw border */
304 display->set_foreground(text_color);
Michael Sevakis661c3402006-10-13 04:16:49 +0000305 display->drawrect(left, top, width, height);
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000306 }
Dave Chapman603f87f2006-02-26 02:48:05 +0000307 }
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000308 else
309 {
310 /* Display RGB value only centered on remaining display if room */
311 display->getstringsize(buf, &x, &y);
312 i = text_top + SWATCH_TOP_MARGIN;
Dave Chapman603f87f2006-02-26 02:48:05 +0000313
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000314 if (i + y <= display->height - MARGIN_BOTTOM)
315 {
316 set_drawinfo(display, DRMODE_SOLID, text_color, background_color);
317 x = (display->width - x) / 2;
318 y = (i + display->height - MARGIN_BOTTOM - y) / 2;
319 display->putsxy(x, y, buf);
320 }
Dave Chapman603f87f2006-02-26 02:48:05 +0000321 }
322
Michael Sevakis661c3402006-10-13 04:16:49 +0000323 display->setfont(FONT_UI);
324
Dave Chapman603f87f2006-02-26 02:48:05 +0000325 display->update();
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000326 /* Be sure screen mode is reset */
327 set_drawinfo(display, DRMODE_SOLID, text_color, background_color);
Dave Chapman603f87f2006-02-26 02:48:05 +0000328}
329
Jonathan Gordonfd9bad62007-11-04 10:42:22 +0000330#ifdef HAVE_TOUCHPAD
331int touchpad_slider(struct rgb_pick *rgb, int *selected_slider)
332{
333 short x,y;
334 int text_top,i,x1;
335 int slider_left, slider_width;
336 unsigned button = action_get_touchpad_press(&x, &y);
337 bool display_three_rows;
338 int max_label_width;
339 struct screen *display = &screens[SCREEN_MAIN];
340 int pressed_slider;
341 char buf[2];
342
343 if (button == BUTTON_NONE)
344 return ACTION_NONE;
345 /* same logic as draw_screen */
346 /* Figure out widest label character in case they vary -
347 this function assumes labels are one character */
348 for (i = 0, max_label_width = 0; i < 3; i++)
349 {
350 buf[0] = str(LANG_COLOR_RGB_LABELS)[i];
351 buf[1] = '\0';
352 x1 = display->getstringsize(buf, NULL, NULL);
353 if (x1 > max_label_width)
354 max_label_width = x1;
355 }
356 /* Get slider positions and top starting position */
357 text_top = MARGIN_TOP + display->char_height + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN;
358 slider_left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN +
359 max_label_width + SLIDER_MARGIN_LEFT;
360 slider_width = display->width - slider_left - SLIDER_MARGIN_RIGHT -
361 display->char_width*2 - SELECTOR_LR_MARGIN - SELECTOR_WIDTH -
362 MARGIN_RIGHT;
363 display_three_rows =
364 display->height >= MARGIN_TOP +
365 display->char_height*4 + /* Title + 3 sliders */
366 TITLE_MARGIN_BOTTOM +
367 SELECTOR_TB_MARGIN*6 + /* 2 margins/slider */
368 MARGIN_BOTTOM;
369 if (y < MARGIN_TOP+display->char_height)
370 {
371 if (button == BUTTON_REL)
372 return ACTION_STD_CANCEL;
373 }
374 y -= text_top;
375 pressed_slider = y/display->char_height;
376 if (pressed_slider > (display_three_rows?2:0))
377 {
378 if (button == BUTTON_REL)
379 return ACTION_STD_OK;
380 }
Jonathan Gordoneb201492007-11-04 10:51:11 +0000381 if (pressed_slider != *selected_slider)
Jonathan Gordonfd9bad62007-11-04 10:42:22 +0000382 *selected_slider = pressed_slider;
Jonathan Gordoneb201492007-11-04 10:51:11 +0000383 //if (pressed_slider == *selected_slider)
Jonathan Gordonfd9bad62007-11-04 10:42:22 +0000384 {
385 x -= slider_left;
386 rgb->rgb_val[pressed_slider] =
387 (x*rgb_max[pressed_slider]/(slider_width-slider_left));
388 pack_rgb(rgb);
389 }
390 return ACTION_NONE;
391}
392#endif
Dave Chapman603f87f2006-02-26 02:48:05 +0000393/***********
Zakk Robertsb81f5962006-03-21 02:02:04 +0000394 set_color
Dave Chapman603f87f2006-02-26 02:48:05 +0000395 returns true if USB was inserted, false otherwise
396 color is a pointer to the colour (in native format) to modify
Zakk Roberts87142ab2006-03-04 10:55:54 +0000397 set banned_color to -1 to allow all
Dave Chapman603f87f2006-02-26 02:48:05 +0000398 ***********/
Michael Sevakise0710b22006-10-15 17:51:00 +0000399bool set_color(struct screen *display, char *title, unsigned *color,
400 unsigned banned_color)
Dave Chapman603f87f2006-02-26 02:48:05 +0000401{
Michael Sevakise0710b22006-10-15 17:51:00 +0000402 int exit = 0, slider = 0;
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000403 struct rgb_pick rgb;
Dave Chapman603f87f2006-02-26 02:48:05 +0000404
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000405 rgb.color = *color;
Dave Chapman603f87f2006-02-26 02:48:05 +0000406
407 while (!exit)
408 {
Michael Sevakise0710b22006-10-15 17:51:00 +0000409 int button;
410
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000411 unpack_rgb(&rgb);
Dave Chapman603f87f2006-02-26 02:48:05 +0000412
Michael Sevakise0710b22006-10-15 17:51:00 +0000413 if (display != NULL)
Dave Chapman3ea74cc2006-07-19 14:31:24 +0000414 {
Michael Sevakise0710b22006-10-15 17:51:00 +0000415 draw_screen(display, title, &rgb, slider);
416 }
417 else
418 {
419 int i;
420 FOR_NB_SCREENS(i)
421 draw_screen(&screens[i], title, &rgb, slider);
Dave Chapman3ea74cc2006-07-19 14:31:24 +0000422 }
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000423
424 button = get_action(CONTEXT_SETTINGS_COLOURCHOOSER, TIMEOUT_BLOCK);
Jonathan Gordonfd9bad62007-11-04 10:42:22 +0000425#ifdef HAVE_TOUCHPAD
426 if (button == ACTION_TOUCHPAD)
427 button = touchpad_slider(&rgb, &slider);
428#endif
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000429
Zakk Robertsb81f5962006-03-21 02:02:04 +0000430 switch (button)
Dave Chapman603f87f2006-02-26 02:48:05 +0000431 {
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000432 case ACTION_STD_PREV:
Jonathan Gordond12f81d2006-08-21 07:03:15 +0000433 case ACTION_STD_PREVREPEAT:
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000434 slider = (slider + 2) % 3;
Dave Chapman603f87f2006-02-26 02:48:05 +0000435 break;
436
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000437 case ACTION_STD_NEXT:
Jonathan Gordond12f81d2006-08-21 07:03:15 +0000438 case ACTION_STD_NEXTREPEAT:
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000439 slider = (slider + 1) % 3;
Dave Chapman603f87f2006-02-26 02:48:05 +0000440 break;
441
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000442 case ACTION_SETTINGS_INC:
443 case ACTION_SETTINGS_INCREPEAT:
Michael Sevakise0710b22006-10-15 17:51:00 +0000444 if (rgb.rgb_val[slider] < rgb_max[slider])
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000445 rgb.rgb_val[slider]++;
446 pack_rgb(&rgb);
Dave Chapman603f87f2006-02-26 02:48:05 +0000447 break;
448
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000449 case ACTION_SETTINGS_DEC:
450 case ACTION_SETTINGS_DECREPEAT:
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000451 if (rgb.rgb_val[slider] > 0)
452 rgb.rgb_val[slider]--;
453 pack_rgb(&rgb);
Dave Chapman603f87f2006-02-26 02:48:05 +0000454 break;
Zakk Robertsb81f5962006-03-21 02:02:04 +0000455
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000456 case ACTION_STD_OK:
Michael Sevakise0710b22006-10-15 17:51:00 +0000457 if (banned_color != (unsigned)-1 &&
458 banned_color == rgb.color)
Zakk Roberts87142ab2006-03-04 10:55:54 +0000459 {
Jonathan Gordonfd9bad62007-11-04 10:42:22 +0000460 gui_syncsplash(HZ*2, ID2P(LANG_COLOR_UNACCEPTABLE));
Zakk Roberts87142ab2006-03-04 10:55:54 +0000461 break;
Zakk Robertsb81f5962006-03-21 02:02:04 +0000462 }
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000463 *color = rgb.color;
Dave Chapman603f87f2006-02-26 02:48:05 +0000464 exit = 1;
465 break;
466
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000467 case ACTION_STD_CANCEL:
Dave Chapman603f87f2006-02-26 02:48:05 +0000468 exit = 1;
469 break;
470
471 default:
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000472 if (default_event_handler(button) == SYS_USB_CONNECTED)
Dave Chapman603f87f2006-02-26 02:48:05 +0000473 return true;
Dave Chapman603f87f2006-02-26 02:48:05 +0000474 break;
475 }
476 }
Michael Sevakiscc66aea2006-10-11 20:34:25 +0000477
Dave Chapman603f87f2006-02-26 02:48:05 +0000478 return false;
479}