Pass width instead of x+width to ab_draw_markers()/cue_draw_markers() and don't recal...
[kugel-rb.git] / utils / wpseditor / libwps / src / dummies.c
blobfaeba63ea7f0e4c7d723ad1f54556f8a2c1923b5
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Rostilav Checkan
10 * $Id$
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 ****************************************************************************/
22 #include <string.h>
23 #include <stdio.h>
24 #include "dummies.h"
25 #include "proxy.h"
27 struct user_settings global_settings;
29 struct wps_state wps_state;
30 struct gui_wps gui_wps[NB_SCREENS];
31 struct wps_data wps_datas[NB_SCREENS];
32 struct cuesheet *curr_cue;
33 struct system_status global_status;
34 struct gui_syncstatusbar statusbars;
35 struct playlist_info current_playlist;
36 struct font sysfont;
37 int battery_percent = 100;
38 struct mp3entry current_song, next_song;
39 int _audio_status;
41 charger_input_state_type charger_input_state;
42 #if CONFIG_CHARGING >= CHARGING_MONITOR
43 charge_state_type charge_state;
44 #endif
46 #if defined(CPU_PP) && defined(BOOTLOADER)
47 /* We don't enable interrupts in the iPod bootloader, so we need to fake
48 the current_tick variable */
49 #define current_tick (signed)(USEC_TIMER/10000)
50 #else
51 volatile long current_tick;
52 #endif
55 void dummies_init(){
56 sysfont.height = 9;
57 sysfont.maxwidth = 6;
58 global_settings.statusbar=true;
61 int playlist_amount_ex(const struct playlist_info* playlist);
62 void sound_set_volume(int value)
64 DEBUGF3("sound_set_volume(int value=%d)",value);
65 global_settings.volume = value;
67 int sound_get_pitch(void)
69 return 0;
71 int sound_min(int setting)
73 DEBUGF3("sound_min(int setting=%d)",setting);
74 return -78; //audiohw_settings[setting].minval;
77 void sleep(int hz)
81 void audio_init(void){}
82 void audio_wait_for_init(void){}
83 void audio_play(long offset){}
84 void audio_stop(void){}
85 void audio_pause(void){}
86 void audio_resume(void){}
87 void audio_next(void){}
88 void audio_prev(void){}
89 int audio_status(void)
91 return _audio_status;
94 #if CONFIG_CODEC == SWCODEC
95 int audio_track_count(void){return 0;} /* SWCODEC only */
96 long audio_filebufused(void){return 0;} /* SWCODEC only */
97 void audio_pre_ff_rewind(void){} /* SWCODEC only */
98 #endif /* CONFIG_CODEC == SWCODEC */
99 void audio_ff_rewind(long newtime){}
100 void audio_flush_and_reload_tracks(void){}
101 #ifdef HAVE_ALBUMART
102 int audio_current_aa_hid(void){return -1;}
103 #endif
104 struct mp3entry* audio_current_track(void){return 0;}
105 struct mp3entry* audio_next_track(void){return 0;}
106 bool audio_has_changed_track(void)
108 return false;
111 int get_sleep_timer(void){return 0;}
114 int battery_level(void){return battery_percent;} /* percent */
115 int battery_time(void){return 0;} /* minutes */
116 unsigned int battery_adc_voltage(void){return 0;} /* voltage from ADC in millivolts */
117 unsigned int battery_voltage(void){return 0;} /* filtered batt. voltage in millivolts */
118 int get_radio_status(void){return 0;}
121 /* returns full path of playlist (minus extension) */
122 char *playlist_name(const struct playlist_info* playlist, char *buf,
123 int buf_size)
125 char *sep;
127 if (!playlist)
128 return "no";
130 snprintf(buf, buf_size, "%s", playlist->filename+playlist->dirlen);
132 if (!buf[0])
133 return NULL;
135 /* Remove extension */
136 sep = strrchr(buf, '.');
137 if(sep)
138 *sep = 0;
140 return buf;
142 int playlist_get_display_index(void)
144 return 1;
147 void gui_syncsplash(int ticks, const unsigned char *fmt, ...)
152 void splash(int ticks, const unsigned char *fmt, ...)
157 void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw){
158 DEBUGF3("gui_statusbar_draw");
161 void yield(void){}
164 /* returns true if cuesheet support is initialised */
165 bool cuesheet_is_enabled(void){return false;}
167 /* allocates the cuesheet buffer */
168 void cuesheet_init(void){}
170 /* looks if there is a cuesheet file that has a name matching "trackpath" */
171 bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path){return false;}
173 /* parse cuesheet "file" and store the information in "cue" */
174 bool parse_cuesheet(char *file, struct cuesheet *cue){return false;}
176 /* reads a cuesheet to find the audio track associated to it */
177 bool get_trackname_from_cuesheet(char *filename, char *buf){return false;}
179 /* display a cuesheet struct */
180 void browse_cuesheet(struct cuesheet *cue){}
182 /* display a cuesheet file after parsing and loading it to the plugin buffer */
183 bool display_cuesheet_content(char* filename){return false;}
185 /* finds the index of the current track played within a cuesheet */
186 int cue_find_current_track(struct cuesheet *cue, unsigned long curpos){return 0;}
188 /* update the id3 info to that of the currently playing track in the cuesheet */
189 void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3){}
191 /* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */
192 bool curr_cuesheet_skip(int direction, unsigned long curr_pos){return false;}
194 #ifdef HAVE_LCD_BITMAP
195 /* draw track markers on the progressbar */
196 void cue_draw_markers(struct screen *screen, unsigned long tracklen,
197 int x, int y, int w, int h){}
198 #endif
200 #ifdef HAVE_ALBUMART
201 void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear)
203 if (!gwps || !gwps->data || !gwps->display || handle_id < 0)
204 return;
206 struct wps_data *data = gwps->data;
208 #ifdef HAVE_REMOTE_LCD
209 /* No album art on RWPS */
210 if (data->remote_wps)
211 return;
212 #endif
214 struct bitmap *bmp;
215 /* if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0)
216 return;*/
218 short x = data->albumart_x;
219 short y = data->albumart_y;
220 short width = bmp->width;
221 short height = bmp->height;
223 if (data->albumart_max_width > 0)
225 /* Crop if the bitmap is too wide */
226 width = MIN(bmp->width, data->albumart_max_width);
228 /* Align */
229 if (data->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT)
230 x += data->albumart_max_width - width;
231 else if (data->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER)
232 x += (data->albumart_max_width - width) / 2;
235 if (data->albumart_max_height > 0)
237 /* Crop if the bitmap is too high */
238 height = MIN(bmp->height, data->albumart_max_height);
240 /* Align */
241 if (data->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM)
242 y += data->albumart_max_height - height;
243 else if (data->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER)
244 y += (data->albumart_max_height - height) / 2;
247 if (!clear)
249 /* Draw the bitmap */
250 gwps->display->set_drawmode(DRMODE_FG);
251 gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, bmp->width,
252 x, y, width, height);
253 gwps->display->set_drawmode(DRMODE_SOLID);
255 else
257 /* Clear the bitmap */
258 gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
259 gwps->display->fillrect(x, y, width, height);
260 gwps->display->set_drawmode(DRMODE_SOLID);
263 #endif
264 /* Update the "data" pointer to make the handle's data available to the caller.
265 Return the length of the available linear data or < 0 for failure (handle
266 not found).
267 The caller is blocked until the requested amount of data is available.
268 size is the amount of linear data requested. it can be 0 to get as
269 much as possible.
270 The guard buffer may be used to provide the requested size. This means it's
271 unsafe to request more than the size of the guard buffer.
273 size_t bufgetdata(int handle_id, size_t size, void **data)
277 return size;
281 void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
282 bool force_redraw)
284 #ifdef HAVE_LCD_BITMAP
285 if(!global_settings.statusbar)
286 return;
287 #endif /* HAVE_LCD_BITMAP */
288 int i;
289 FOR_NB_SCREENS(i) {
290 gui_statusbar_draw( &(bars->statusbars[i]), force_redraw );
293 void unload_wps_backdrop(void)
297 void unload_remote_wps_backdrop(void)
302 #if CONFIG_CODEC == SWCODEC
303 int get_replaygain_mode(bool have_track_gain, bool have_album_gain)
305 int type;
307 bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK)
308 || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
309 && global_settings.playlist_shuffle));
311 type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM
312 : have_track_gain ? REPLAYGAIN_TRACK : -1;
314 return type;
316 #endif
318 /* Common functions for all targets */
319 void rtc_init(void){}
320 int rtc_read_datetime(unsigned char* buf){return 0;}
321 int rtc_write_datetime(unsigned char* buf){return 0;}
323 void backlight_on(void){}
324 void backlight_off(void){}
326 void remote_backlight_on(void){}
327 void remote_backlight_off(void){}
329 void debugf(const char *fmt, ...)
331 void panicf( const char *fmt, ...)
335 off_t filesize(int fd){return 0;}
337 int playlist_amount(void)
339 return playlist_amount_ex(NULL);
341 int playlist_amount_ex(const struct playlist_info* playlist)
343 if (!playlist)
344 playlist = &current_playlist;
346 return playlist->amount;
349 int get_action(int context, int timeout)
351 return 0;
354 void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width,
355 int height){}
357 void pcm_calculate_rec_peaks(int *left, int *right)
360 void pcm_calculate_peaks(int *left, int *right)
363 bool led_read(int delayticks) /* read by status bar update */
365 return false;
368 #ifndef HAS_BUTTON_HOLD
369 bool is_keys_locked(void)
371 return false;
373 #endif
375 long default_event_handler_ex(long event, void (*callback)(void *), void *parameter)
377 return 0;
380 long default_event_handler(long event)
382 return default_event_handler_ex(event, NULL, NULL);
385 void ab_draw_markers(struct screen * screen, int capacity,
386 int x, int y, int w, int h)
389 void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude){}