Fix 'make fullinstall'
[kugel-rb.git] / apps / plugins / logo.c
blobe61de014ccc68d2e78afa5c5a99bd72039f91b1e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Jonas H�gqvist
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 **************************************************************************/
21 #include "plugin.h"
22 #include "lib/playergfx.h"
24 PLUGIN_HEADER
26 #ifdef HAVE_LCD_BITMAP
27 #define DISPLAY_WIDTH LCD_WIDTH
28 #define DISPLAY_HEIGHT LCD_HEIGHT
29 #define RAND_SCALE 5
31 #ifdef HAVE_REMOTE_LCD
32 #define REMOTE_WIDTH LCD_REMOTE_WIDTH
33 #define REMOTE_HEIGHT LCD_REMOTE_HEIGHT
34 #include "pluginbitmaps/remote_rockboxlogo.h"
35 #define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo
36 #define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo
37 #define REMOTE_LOGO remote_rockboxlogo
38 extern const fb_remote_data remote_rockboxlogo[];
39 #endif /* HAVE_REMOTE_LCD */
41 #define LOGO rockboxlogo
42 #include "pluginbitmaps/rockboxlogo.h"
43 #define LOGO_WIDTH BMPWIDTH_rockboxlogo
44 #define LOGO_HEIGHT BMPHEIGHT_rockboxlogo
45 extern const fb_data rockboxlogo[];
47 #else /* !LCD_BITMAP */
48 #define DISPLAY_WIDTH 55
49 #define DISPLAY_HEIGHT 14
50 #define RAND_SCALE 2
51 #define LOGO_WIDTH 16
52 #define LOGO_HEIGHT 7
53 #define LOGO rockbox16x7
54 const unsigned char rockbox16x7[] = {
55 0x47, 0x18, 0xa6, 0xd8, 0x66, 0xde, 0xb7, 0x9b,
56 0x76, 0xdb, 0x26, 0xdb, 0x66, 0xde,
58 #endif /* !LCD_BITMAP */
60 /* variable button definitions */
61 #if CONFIG_KEYPAD == PLAYER_PAD
62 #define LP_QUIT BUTTON_STOP
63 #define LP_DEC_X BUTTON_LEFT
64 #define LP_INC_X BUTTON_RIGHT
65 #define LP_DEC_Y (BUTTON_ON | BUTTON_LEFT)
66 #define LP_INC_Y (BUTTON_ON | BUTTON_RIGHT)
68 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
69 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
70 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
71 #define LP_QUIT BUTTON_MENU
72 #define LP_DEC_X BUTTON_LEFT
73 #define LP_INC_X BUTTON_RIGHT
74 #define LP_DEC_Y BUTTON_SCROLL_BACK
75 #define LP_INC_Y BUTTON_SCROLL_FWD
77 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
78 #define LP_QUIT BUTTON_PLAY
79 #define LP_DEC_X BUTTON_LEFT
80 #define LP_INC_X BUTTON_RIGHT
81 #define LP_DEC_Y BUTTON_DOWN
82 #define LP_INC_Y BUTTON_UP
84 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
85 #define LP_QUIT BUTTON_POWER
86 #define LP_DEC_X BUTTON_LEFT
87 #define LP_INC_X BUTTON_RIGHT
88 #define LP_DEC_Y BUTTON_DOWN
89 #define LP_INC_Y BUTTON_UP
91 #elif CONFIG_KEYPAD == GIGABEAT_PAD
92 #define LP_QUIT BUTTON_POWER
93 #define LP_DEC_X BUTTON_LEFT
94 #define LP_INC_X BUTTON_RIGHT
95 #define LP_DEC_Y BUTTON_DOWN
96 #define LP_INC_Y BUTTON_UP
98 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
99 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
100 (CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
101 (CONFIG_KEYPAD == SANSA_M200_PAD) || \
102 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
103 #define LP_QUIT BUTTON_POWER
104 #define LP_DEC_X BUTTON_LEFT
105 #define LP_INC_X BUTTON_RIGHT
106 #define LP_DEC_Y BUTTON_DOWN
107 #define LP_INC_Y BUTTON_UP
109 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
110 #define LP_QUIT (BUTTON_HOME|BUTTON_REPEAT)
111 #define LP_DEC_X BUTTON_LEFT
112 #define LP_INC_X BUTTON_RIGHT
113 #define LP_DEC_Y BUTTON_DOWN
114 #define LP_INC_Y BUTTON_UP
116 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
117 #define LP_QUIT BUTTON_POWER
118 #define LP_DEC_X BUTTON_LEFT
119 #define LP_INC_X BUTTON_RIGHT
120 #define LP_DEC_Y BUTTON_SCROLL_DOWN
121 #define LP_INC_Y BUTTON_SCROLL_UP
123 #elif CONFIG_KEYPAD == MROBE500_PAD
124 #define LP_QUIT BUTTON_POWER
126 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
127 #define LP_QUIT BUTTON_BACK
128 #define LP_DEC_X BUTTON_LEFT
129 #define LP_INC_X BUTTON_RIGHT
130 #define LP_DEC_Y BUTTON_DOWN
131 #define LP_INC_Y BUTTON_UP
133 #elif CONFIG_KEYPAD == MROBE100_PAD
134 #define LP_QUIT BUTTON_POWER
135 #define LP_DEC_X BUTTON_LEFT
136 #define LP_INC_X BUTTON_RIGHT
137 #define LP_DEC_Y BUTTON_DOWN
138 #define LP_INC_Y BUTTON_UP
140 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
141 #define LP_QUIT BUTTON_RC_REC
142 #define LP_DEC_X BUTTON_RC_REW
143 #define LP_INC_X BUTTON_RC_FF
144 #define LP_DEC_Y BUTTON_RC_VOL_DOWN
145 #define LP_INC_Y BUTTON_RC_VOL_UP
147 #elif CONFIG_KEYPAD == COWOND2_PAD
148 #define LP_QUIT BUTTON_POWER
150 #elif CONFIG_KEYPAD == IAUDIO67_PAD
151 #define LP_QUIT BUTTON_POWER
152 #define LP_DEC_X BUTTON_LEFT
153 #define LP_INC_X BUTTON_RIGHT
154 #define LP_DEC_Y BUTTON_PLAY
155 #define LP_INC_Y BUTTON_STOP
157 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
158 #define LP_QUIT BUTTON_BACK
159 #define LP_DEC_X BUTTON_LEFT
160 #define LP_INC_X BUTTON_RIGHT
161 #define LP_DEC_Y BUTTON_DOWN
162 #define LP_INC_Y BUTTON_UP
164 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
165 #define LP_QUIT BUTTON_POWER
166 #define LP_DEC_X BUTTON_LEFT
167 #define LP_INC_X BUTTON_RIGHT
168 #define LP_DEC_Y BUTTON_DOWN
169 #define LP_INC_Y BUTTON_UP
171 #elif CONFIG_KEYPAD == ONDAVX747_PAD
172 #define LP_QUIT BUTTON_POWER
174 #else
175 #define LP_QUIT BUTTON_OFF
176 #define LP_DEC_X BUTTON_LEFT
177 #define LP_INC_X BUTTON_RIGHT
178 #define LP_DEC_Y BUTTON_DOWN
179 #define LP_INC_Y BUTTON_UP
180 #endif
182 #ifdef CONFIG_REMOTE_KEYPAD
183 #if (CONFIG_REMOTE_KEYPAD == H100_REMOTE) || \
184 (CONFIG_REMOTE_KEYPAD == H300_REMOTE)
185 #define LP_R_QUIT BUTTON_RC_STOP
186 #define LP_R_DEC_X BUTTON_RC_REW
187 #define LP_R_INC_X BUTTON_RC_FF
188 #define LP_R_DEC_Y BUTTON_RC_SOURCE
189 #define LP_R_INC_Y BUTTON_RC_BITRATE
191 #elif (CONFIG_REMOTE_KEYPAD==MROBE_REMOTE)
192 #define LP_R_QUIT BUTTON_RC_HEART
193 #define LP_R_DEC_X BUTTON_RC_REW
194 #define LP_R_INC_X BUTTON_RC_FF
195 #define LP_R_DEC_Y BUTTON_RC_DOWN
196 #define LP_R_INC_Y BUTTON_RC_PLAY
197 #endif
199 #endif /* CONFIG_REMOTE_KEYPAD */
201 #ifdef HAVE_TOUCHSCREEN
202 #ifndef LP_QUIT
203 #define LP_QUIT BUTTON_TOPLEFT
204 #endif
205 #ifndef LP_DEC_X
206 #define LP_DEC_X BUTTON_MIDLEFT
207 #endif
208 #ifndef LP_INC_X
209 #define LP_INC_X BUTTON_MIDRIGHT
210 #endif
211 #ifndef LP_DEC_Y
212 #define LP_DEC_Y BUTTON_TOPMIDDLE
213 #endif
214 #ifndef LP_INC_Y
215 #define LP_INC_Y BUTTON_BOTTOMMIDDLE
216 #endif
217 #endif
219 enum plugin_status plugin_start(const void* parameter) {
220 int button;
221 int timer = 10;
222 int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2);
223 int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2);
224 int dx;
225 int dy;
226 #ifdef HAVE_LCD_CHARCELLS
227 int cpos = -1;
228 int old_cpos = -1;
229 #endif
231 (void)parameter;
233 #ifdef HAVE_LCD_CHARCELLS
234 if (!pgfx_init(4, 2)) {
235 rb->splash(HZ*2, "Old LCD :(");
236 return PLUGIN_OK;
238 #endif
239 rb->srand(*rb->current_tick);
240 dx = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE;
241 dy = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE;
243 while (1) {
244 #ifdef HAVE_LCD_BITMAP
245 rb->lcd_clear_display();
246 rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT);
247 #ifdef REMOTE_LOGO
248 rb->lcd_remote_clear_display();
249 rb->lcd_remote_bitmap(REMOTE_LOGO,
250 (x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH),
251 (y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT),
252 REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT);
253 #endif
254 #else
255 pgfx_clear_display();
256 pgfx_mono_bitmap(LOGO, x % 5, y, LOGO_WIDTH, LOGO_HEIGHT);
257 cpos = x / 5;
258 #endif
260 x += dx;
261 if (x < 0) {
262 dx = -dx;
263 x = 0;
265 if (x > DISPLAY_WIDTH - LOGO_WIDTH) {
266 dx = -dx;
267 x = DISPLAY_WIDTH - LOGO_WIDTH;
270 y += dy;
271 if (y < 0) {
272 dy = -dy;
273 y = 0;
275 if (y > DISPLAY_HEIGHT - LOGO_HEIGHT) {
276 dy = -dy;
277 y = DISPLAY_HEIGHT - LOGO_HEIGHT;
280 #ifdef HAVE_LCD_BITMAP
281 rb->lcd_update();
282 #ifdef REMOTE_LOGO
283 rb->lcd_remote_update();
284 #endif
285 #else
286 if (cpos != old_cpos) {
287 rb->lcd_clear_display();
288 pgfx_display(cpos, 0);
289 old_cpos = cpos;
291 pgfx_update();
292 #endif
293 rb->sleep(HZ/timer);
295 button = rb->button_get(false);
296 switch (button) {
297 case LP_QUIT:
298 #ifdef CONFIG_REMOTE_KEYPAD
299 case LP_R_QUIT:
300 #endif
301 #ifdef HAVE_LCD_CHARCELLS
302 pgfx_release();
303 #endif
304 return PLUGIN_OK;
305 case LP_DEC_X:
306 #ifdef CONFIG_REMOTE_KEYPAD
307 case LP_R_DEC_X:
308 #endif
309 if (dx)
310 dx += (dx < 0) ? 1 : -1;
311 break;
312 case LP_INC_X:
313 #ifdef CONFIG_REMOTE_KEYPAD
314 case LP_R_INC_X:
315 #endif
316 dx += (dx < 0) ? -1 : 1;
317 break;
318 case LP_DEC_Y:
319 #ifdef CONFIG_REMOTE_KEYPAD
320 case LP_R_DEC_Y:
321 #endif
322 if (dy)
323 dy += (dy < 0) ? 1 : -1;
324 break;
325 case LP_INC_Y:
326 #ifdef CONFIG_REMOTE_KEYPAD
327 case LP_R_INC_Y:
328 #endif
329 dy += (dy < 0) ? -1 : 1;
330 break;
332 default:
333 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
334 #ifdef HAVE_LCD_CHARCELLS
335 pgfx_release();
336 #endif
337 return PLUGIN_USB_CONNECTED;
339 break;