Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 Itai Shaked |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | **************************************************************************/ |
| 21 | #include "plugin.h" |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 22 | #include "playergfx.h" |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 23 | |
Jens Arnold | a36b1d4 | 2006-01-15 18:20:18 +0000 | [diff] [blame] | 24 | PLUGIN_HEADER |
| 25 | |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 26 | #ifdef HAVE_LCD_BITMAP |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 27 | #define MYLCD(fn) rb->lcd_ ## fn |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 28 | #define GFX_X (LCD_WIDTH/2-1) |
| 29 | #define GFX_Y (LCD_HEIGHT/2-1) |
| 30 | #if LCD_WIDTH != LCD_HEIGHT |
| 31 | #define GFX_WIDTH GFX_X |
| 32 | #define GFX_HEIGHT GFX_Y |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 33 | #else |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 34 | #define GFX_WIDTH GFX_X |
| 35 | #define GFX_HEIGHT (4*GFX_Y/5) |
| 36 | #endif |
| 37 | #else |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 38 | #define MYLCD(fn) pgfx_ ## fn |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 39 | #define GFX_X 9 |
| 40 | #define GFX_Y 6 |
| 41 | #define GFX_WIDTH 9 |
| 42 | #define GFX_HEIGHT 6 |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 43 | #endif |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 44 | |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 45 | /* variable button definitions */ |
| 46 | #if CONFIG_KEYPAD == RECORDER_PAD |
| 47 | #define MOSAIQUE_QUIT BUTTON_OFF |
| 48 | #define MOSAIQUE_SPEED BUTTON_F1 |
| 49 | #define MOSAIQUE_RESTART BUTTON_PLAY |
| 50 | |
Dave Chapman | d64e626 | 2007-01-14 13:48:09 +0000 | [diff] [blame] | 51 | #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD |
| 52 | #define MOSAIQUE_QUIT BUTTON_OFF |
| 53 | #define MOSAIQUE_SPEED BUTTON_F1 |
| 54 | #define MOSAIQUE_RESTART BUTTON_SELECT |
| 55 | |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 56 | #elif CONFIG_KEYPAD == PLAYER_PAD |
| 57 | #define MOSAIQUE_QUIT BUTTON_STOP |
| 58 | #define MOSAIQUE_SPEED BUTTON_MENU |
| 59 | #define MOSAIQUE_RESTART BUTTON_PLAY |
| 60 | |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 61 | #elif CONFIG_KEYPAD == ONDIO_PAD |
| 62 | #define MOSAIQUE_QUIT BUTTON_OFF |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 63 | #define MOSAIQUE_SPEED BUTTON_MENU |
| 64 | #define MOSAIQUE_RESTART BUTTON_RIGHT |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 65 | |
Daniel Stenberg | 01377e2 | 2005-06-29 12:47:24 +0000 | [diff] [blame] | 66 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ |
| 67 | (CONFIG_KEYPAD == IRIVER_H300_PAD) |
Daniel Stenberg | 6700ad8 | 2005-02-04 12:41:09 +0000 | [diff] [blame] | 68 | #define MOSAIQUE_QUIT BUTTON_OFF |
| 69 | #define MOSAIQUE_SPEED BUTTON_MODE |
| 70 | #define MOSAIQUE_RESTART BUTTON_ON |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 71 | |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 72 | #define MOSAIQUE_RC_QUIT BUTTON_RC_STOP |
| 73 | |
Dave Chapman | fb4e384 | 2006-02-24 20:54:09 +0000 | [diff] [blame] | 74 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 75 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
| 76 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
Dave Chapman | 54d44c8 | 2005-12-14 01:31:37 +0000 | [diff] [blame] | 77 | #define MOSAIQUE_QUIT BUTTON_MENU |
| 78 | #define MOSAIQUE_SPEED BUTTON_SELECT |
| 79 | #define MOSAIQUE_RESTART BUTTON_PLAY |
Dave Chapman | d83e929 | 2006-01-12 00:35:50 +0000 | [diff] [blame] | 80 | |
| 81 | #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD |
| 82 | #define MOSAIQUE_QUIT BUTTON_PLAY |
| 83 | #define MOSAIQUE_SPEED BUTTON_MODE |
| 84 | #define MOSAIQUE_RESTART BUTTON_SELECT |
| 85 | |
Jens Arnold | 85a226d | 2007-03-16 23:02:39 +0000 | [diff] [blame] | 86 | #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD |
Daniel Stenberg | cedba88 | 2006-01-18 11:09:06 +0000 | [diff] [blame] | 87 | #define MOSAIQUE_QUIT BUTTON_POWER |
Linus Nielsen Feltzing | 568ac3e | 2006-02-24 15:06:25 +0000 | [diff] [blame] | 88 | #define MOSAIQUE_SPEED BUTTON_SELECT |
Daniel Stenberg | cedba88 | 2006-01-18 11:09:06 +0000 | [diff] [blame] | 89 | #define MOSAIQUE_RESTART BUTTON_PLAY |
| 90 | |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 91 | #elif CONFIG_KEYPAD == GIGABEAT_PAD |
Marcoen Hirschberg | a7168fe | 2007-05-19 23:38:09 +0000 | [diff] [blame] | 92 | #define MOSAIQUE_QUIT BUTTON_POWER |
| 93 | #define MOSAIQUE_SPEED BUTTON_A |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 94 | #define MOSAIQUE_RESTART BUTTON_SELECT |
| 95 | |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 96 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ |
| 97 | (CONFIG_KEYPAD == SANSA_C200_PAD) |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 98 | #define MOSAIQUE_QUIT BUTTON_POWER |
| 99 | #define MOSAIQUE_SPEED BUTTON_DOWN |
| 100 | #define MOSAIQUE_RESTART BUTTON_SELECT |
| 101 | |
Daniel Stenberg | 1e88be5 | 2006-08-03 20:17:25 +0000 | [diff] [blame] | 102 | #elif CONFIG_KEYPAD == IRIVER_H10_PAD |
| 103 | #define MOSAIQUE_QUIT BUTTON_POWER |
| 104 | #define MOSAIQUE_SPEED BUTTON_FF |
| 105 | #define MOSAIQUE_RESTART BUTTON_PLAY |
| 106 | |
Jonathan Gordon | 56ddddc | 2007-10-23 15:40:51 +0000 | [diff] [blame] | 107 | #elif CONFIG_KEYPAD == MROBE500_PAD |
| 108 | #define MOSAIQUE_QUIT BUTTON_POWER |
| 109 | #define MOSAIQUE_SPEED BUTTON_RC_FF |
| 110 | #define MOSAIQUE_RESTART BUTTON_RC_PLAY |
| 111 | |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 112 | #elif CONFIG_KEYPAD == GIGABEAT_S_PAD |
| 113 | #define MOSAIQUE_QUIT BUTTON_BACK |
| 114 | #define MOSAIQUE_SPEED BUTTON_SELECT |
| 115 | #define MOSAIQUE_RESTART BUTTON_MENU |
| 116 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 117 | #elif CONFIG_KEYPAD == MROBE100_PAD |
| 118 | #define MOSAIQUE_QUIT BUTTON_POWER |
| 119 | #define MOSAIQUE_SPEED BUTTON_DISPLAY |
| 120 | #define MOSAIQUE_RESTART BUTTON_SELECT |
| 121 | |
Jens Arnold | 29361ab | 2008-03-22 10:24:28 +0000 | [diff] [blame] | 122 | #elif CONFIG_KEYPAD == IAUDIO_M3_PAD |
| 123 | #define MOSAIQUE_QUIT BUTTON_RC_REC |
| 124 | #define MOSAIQUE_SPEED BUTTON_RC_MENU |
| 125 | #define MOSAIQUE_RESTART BUTTON_RC_PLAY |
| 126 | |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 127 | #elif CONFIG_KEYPAD == COWOND2_PAD |
| 128 | #define MOSAIQUE_QUIT BUTTON_POWER |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 129 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 130 | #else |
| 131 | #error No keymap defined! |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 132 | #endif |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 133 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 134 | #ifdef HAVE_TOUCHPAD |
| 135 | #ifndef MOSAIQUE_QUIT |
| 136 | #define MOSAIQUE_QUIT BUTTON_TOPLEFT |
| 137 | #endif |
| 138 | #ifndef MOSAIQUE_SPEED |
| 139 | #define MOSAIQUE_SPEED BUTTON_MIDRIGHT |
| 140 | #endif |
| 141 | #ifndef MOSAIQUE_RESTART |
| 142 | #define MOSAIQUE_RESTART BUTTON_CENTER |
| 143 | #endif |
| 144 | #endif |
| 145 | |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 146 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 147 | { |
| 148 | int button; |
| 149 | int timer = 10; |
| 150 | int x=0; |
| 151 | int y=0; |
| 152 | int sx = 3; |
| 153 | int sy = 3; |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 154 | const struct plugin_api* rb = api; |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 155 | (void)parameter; |
| 156 | |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 157 | #ifdef HAVE_LCD_CHARCELLS |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 158 | if (!pgfx_init(rb, 4, 2)) |
| 159 | { |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 160 | rb->splash(HZ*2, "Old LCD :("); |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 161 | return PLUGIN_OK; |
| 162 | } |
| 163 | pgfx_display(3, 0); |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 164 | #endif |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 165 | MYLCD(clear_display)(); |
| 166 | MYLCD(set_drawmode)(DRMODE_COMPLEMENT); |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 167 | while (1) { |
| 168 | |
| 169 | x+=sx; |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 170 | if (x>GFX_WIDTH) |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 171 | { |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 172 | x = 2*GFX_WIDTH-x; |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 173 | sx=-sx; |
| 174 | } |
| 175 | |
| 176 | if (x<0) |
| 177 | { |
| 178 | x = -x; |
| 179 | sx = -sx; |
| 180 | } |
| 181 | |
| 182 | y+=sy; |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 183 | if (y>GFX_HEIGHT) |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 184 | { |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 185 | y = 2*GFX_HEIGHT-y; |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 186 | sy=-sy; |
| 187 | } |
| 188 | |
| 189 | if (y<0) |
| 190 | { |
| 191 | y = -y; |
| 192 | sy = -sy; |
| 193 | } |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 194 | |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 195 | MYLCD(fillrect)(GFX_X-x, GFX_Y-y, 2*x+1, 1); |
| 196 | MYLCD(fillrect)(GFX_X-x, GFX_Y+y, 2*x+1, 1); |
| 197 | MYLCD(fillrect)(GFX_X-x, GFX_Y-y+1, 1, 2*y-1); |
| 198 | MYLCD(fillrect)(GFX_X+x, GFX_Y-y+1, 1, 2*y-1); |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 199 | MYLCD(update)(); |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 200 | |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 201 | rb->sleep(HZ/timer); |
| 202 | |
| 203 | button = rb->button_get(false); |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 204 | switch (button) |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 205 | { |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 206 | #ifdef MOSAIQUE_RC_QUIT |
| 207 | case MOSAIQUE_RC_QUIT: |
| 208 | #endif |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 209 | case MOSAIQUE_QUIT: |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 210 | MYLCD(set_drawmode)(DRMODE_SOLID); |
| 211 | #ifdef HAVE_LCD_CHARCELLS |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 212 | pgfx_release(); |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 213 | #endif |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 214 | return PLUGIN_OK; |
| 215 | |
| 216 | case MOSAIQUE_SPEED: |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 217 | timer = timer+5; |
| 218 | if (timer>20) |
| 219 | timer=5; |
| 220 | break; |
| 221 | |
| 222 | case MOSAIQUE_RESTART: |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 223 | |
Jens Arnold | 4a037df | 2006-09-21 20:28:06 +0000 | [diff] [blame] | 224 | sx = rb->rand() % (GFX_HEIGHT/2) + 1; |
| 225 | sy = rb->rand() % (GFX_HEIGHT/2) + 1; |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 226 | x=0; |
| 227 | y=0; |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 228 | MYLCD(clear_display)(); |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 229 | break; |
| 230 | |
| 231 | |
| 232 | default: |
| 233 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 234 | { |
Jens Arnold | 9386730 | 2005-06-30 21:07:00 +0000 | [diff] [blame] | 235 | MYLCD(set_drawmode)(DRMODE_SOLID); |
| 236 | #ifdef HAVE_LCD_CHARCELLS |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 237 | pgfx_release(); |
| 238 | #endif |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 239 | return PLUGIN_USB_CONNECTED; |
Jens Arnold | b021f78 | 2005-02-11 19:48:52 +0000 | [diff] [blame] | 240 | } |
Jens Arnold | e35a658 | 2004-10-18 21:45:00 +0000 | [diff] [blame] | 241 | break; |
| 242 | } |
Daniel Stenberg | e428647 | 2004-01-08 13:09:45 +0000 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 246 | |