diff options
| author | Frank Gevaerts <frank@gevaerts.be> | 2008-08-29 21:08:38 +0000 |
|---|---|---|
| committer | Frank Gevaerts <frank@gevaerts.be> | 2008-08-29 21:08:38 +0000 |
| commit | 5d22e3cbdd251819a4d2d07b9a12994d5aef778d (patch) | |
| tree | 4c6a81187ccf065a5f296a903b9f7da88503e403 /utils/wpseditor/libwps/src | |
| parent | cc31b1fbdae455f975b69dd6bffc23d8bd021566 (diff) | |
| download | rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.zip rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.gz rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.bz2 rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.xz | |
Add wpseditor, the Google Summer of Code 2008 project of Rostislav Chekan. Closes FS#9327
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18362 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/wpseditor/libwps/src')
| -rw-r--r-- | utils/wpseditor/libwps/src/api.c | 268 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/api.h | 85 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/defs.h | 41 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/dummies.c | 363 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/dummies.h | 44 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/include/lang.h | 10 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/include/rockboxlogo.h | 1 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/include/sysfont.h | 1 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/include/system-target.h | 1 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/lcd.c | 150 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/proxy.c | 132 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/proxy.h | 25 | ||||
| -rw-r--r-- | utils/wpseditor/libwps/src/wpsstate.h | 34 |
13 files changed, 1155 insertions, 0 deletions
diff --git a/utils/wpseditor/libwps/src/api.c b/utils/wpseditor/libwps/src/api.c new file mode 100644 index 0000000..485efa8 --- /dev/null +++ b/utils/wpseditor/libwps/src/api.c @@ -0,0 +1,268 @@ +#include <stdio.h> +#include <stdlib.h> +#include "sound.h" +#include "api.h" +#include "proxy.h" +#include "dummies.h" +#include "scroll_engine.h" +#include "wpsstate.h" +#include <string.h> + +struct proxy_api *xapi; + +void get_current_vp(struct viewport_api *avp); +/************************************************************* + +*************************************************************/ +#ifdef HAVE_LCD_BITMAP +void screen_clear_area(struct screen * display, int xstart, int ystart, + int width, int height) { + display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); + display->fillrect(xstart, ystart, width, height); + display->set_drawmode(DRMODE_SOLID); +} +#endif + +bool load_wps_backdrop(char* filename) { + return xapi->load_wps_backdrop(filename); +} + +bool load_remote_wps_backdrop(char* filename) { + return xapi->load_remote_wps_backdrop(filename); +} + +int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) { + if (!xapi->read_bmp_file) + { + DEBUGF1("can't read bmp file! NULL api!\n"); + return -1; + } + bm->format = 3;//FORMAT_ANY? + bm->data = (unsigned char*)malloc(255); + memset(bm->data,0,255); + strcpy((char*)bm->data,filename); + //bm->data[strlen(filename)] = '\0'; + xapi->read_bmp_file(filename,&bm->width, &bm->height); + return 1; +} + +bool load_wps_backdrop2(char* filename) { + DEBUGF1("load_wps_backdrop(char* filename='%s')",filename); + return true; +} + +bool load_remote_wps_backdrop2(char* filename) { + DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename); + return true; +} + +void stop_scroll() { + DEBUGF3("stop_scroll\n"); + return; +} + +void puts_scroll(int x, int y, const unsigned char *string) { + DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x,y,string); +} + +void putsxy(int x, int y, const unsigned char *str) { + DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x,y,str); +} + +void lcd_update() { + DEBUGF3("update\n"); +} + +void clear_viewport(int x, int y, int w, int h, int color) { + DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x, y, w, h, color); +}; + +int getstringsize(const unsigned char *str, int *w, int *h) { + //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h); + *w=strlen((char*)str)*sysfont.maxwidth; + *h=sysfont.height; + return 1; +} + +void set_wpsstate(struct wpsstate state){ + sysfont.height = state.fontheight; + sysfont.maxwidth = state.fontwidth; + global_settings.volume = state.volume; + battery_percent = state.battery_level; + _audio_status = state.audio_status; +} + +void set_trackstate(struct trackstate state){ + gui_wps[0].state->id3->title = state.title; + gui_wps[0].state->id3->artist = state.artist; + gui_wps[0].state->id3->album = state.album; + gui_wps[0].state->id3->elapsed = state.elapsed; + gui_wps[0].state->id3->length = state.length; +} + +void set_next_trackstate(struct trackstate state) +{ + gui_wps[0].state->nid3->title = state.title; + gui_wps[0].state->nid3->artist = state.artist; + gui_wps[0].state->nid3->album = state.album; + gui_wps[0].state->nid3->elapsed = state.elapsed; + gui_wps[0].state->nid3->length = state.length; +} + +enum api_playmode playmodes[PLAYMODES_NUM] = { + API_STATUS_PLAY, + API_STATUS_STOP, + API_STATUS_PAUSE, + API_STATUS_FASTFORWARD, + API_STATUS_FASTBACKWARD +}; + +const char *playmodeNames[] = { + "Play", "Stop", "Pause", "FastForward", "FastBackward" +}; + + +void set_audio_status(int status){ + DEBUGF1("%s",playmodeNames[status]); + switch(status){ + case API_STATUS_PLAY: + _audio_status = AUDIO_STATUS_PLAY; + status_set_ffmode(STATUS_PLAY); + break; + case API_STATUS_STOP: + _audio_status = 0; + status_set_ffmode(STATUS_STOP); + break; + case API_STATUS_PAUSE: + _audio_status = AUDIO_STATUS_PAUSE; + status_set_ffmode(STATUS_PLAY); + break; + case API_STATUS_FASTFORWARD: + status_set_ffmode(STATUS_FASTFORWARD); + break; + case API_STATUS_FASTBACKWARD: + status_set_ffmode(STATUS_FASTBACKWARD); + break; + default: + DEBUGF1("ERR: Unknown status"); + } +} + +void test_api(struct proxy_api *api) { + if (!api->stop_scroll) + api->stop_scroll=stop_scroll; + if (!api->set_viewport) + api->set_viewport=lcd_set_viewport; + if (!api->clear_viewport) + api->clear_viewport=clear_viewport; + if (!api->getstringsize) + api->getstringsize=getstringsize; + if (!api->getwidth) + api->getwidth=lcd_getwidth; + if (!api->getheight) + api->getheight=lcd_getheight; + if (!api->set_drawmode) + api->set_drawmode=lcd_set_drawmode; + if (!api->puts_scroll) + api->puts_scroll=puts_scroll; + if (!api->update) + api->update=lcd_update; + if (!api->clear_display) + api->clear_display=lcd_clear_display; + if (!api->getfont) + api->getfont=lcd_getfont; + if (!api->putsxy) + api->putsxy=putsxy; + +#if LCD_DEPTH > 1 + if (!api->get_foreground) + api->get_foreground=lcd_get_foreground; + if (!api->get_background) + api->get_background=lcd_get_background; +#endif + if (!api->load_remote_wps_backdrop) + api->load_remote_wps_backdrop = load_remote_wps_backdrop2; + if (!api->load_wps_backdrop) + api->load_wps_backdrop = load_wps_backdrop2; + //dbgf = printf; +} + +/************************************************************** + +**************************************************************/ + +int set_api(struct proxy_api* api) { + if (api->debugf) + dbgf = api->debugf; + screens[0].screen_type=SCREEN_MAIN; + screens[0].lcdwidth=LCD_WIDTH; + screens[0].lcdheight=LCD_HEIGHT; + screens[0].depth=LCD_DEPTH; +#ifdef HAVE_LCD_COLOR + screens[0].is_color=true; +#else + screens[0].is_color=false; +#endif + if (api->getwidth) + screens[0].getwidth = api->getwidth; + if (api->stop_scroll) + screens[0].stop_scroll=api->stop_scroll; + screens[0].scroll_stop = lcd_scroll_stop; + if (api->set_viewport) + screens[0].set_viewport=api->set_viewport; + if (api->clear_viewport) + screens[0].clear_viewport=lcd_clear_viewport; + if (api->getstringsize) + screens[0].getstringsize=api->getstringsize; + if (api->getwidth) + screens[0].getwidth=api->getwidth; + if (api->getheight) + screens[0].getheight=api->getheight; + if (api->set_drawmode) + screens[0].set_drawmode=api->set_drawmode; + if (api->fillrect) + screens[0].fillrect=api->fillrect; + if (api->puts_scroll) + screens[0].puts_scroll=api->puts_scroll; + if (api->transparent_bitmap_part) + screens[0].transparent_bitmap_part=api->transparent_bitmap_part; + if (api->update) + screens[0].update=api->update; + if (api->clear_display) + screens[0].clear_display=api->clear_display; + if (api->getfont) + screens[0].getfont=api->getfont; + if (api->hline) + screens[0].hline=api->hline; + if (api->vline) + screens[0].vline=api->vline; + if (api->drawpixel) + screens[0].drawpixel=api->drawpixel; + if (api->putsxy) + screens[0].putsxy=api->putsxy; +#if LCD_DEPTH > 1 + if (api->get_foreground) + screens[0].get_foreground=api->get_foreground; + if (api->get_background) + screens[0].get_background=api->get_background; +#endif + + screens[0].bitmap_part = api->bitmap_part; + /************************** + * OUT * + **************************/ + api->get_model_name = get_model_name; + api->get_current_vp = get_current_vp; + api->set_wpsstate = set_wpsstate; + api->set_trackstate = set_trackstate; + api->set_next_trackstate= set_next_trackstate; + api->set_audio_status= set_audio_status; + xapi = api; + return 0; +} + + + + + + diff --git a/utils/wpseditor/libwps/src/api.h b/utils/wpseditor/libwps/src/api.h new file mode 100644 index 0000000..86bb1a6 --- /dev/null +++ b/utils/wpseditor/libwps/src/api.h @@ -0,0 +1,85 @@ +#ifndef API_H_INCLUDED +#define API_H_INCLUDED +#include <stdbool.h> +#include <stddef.h> +#include "defs.h" +#include "wpsstate.h" +#ifdef __PCTOOL__ +#include "dummies.h" +#endif + +struct viewport_api { + int x; + int y; + int width; + int height; + int font; + int drawmode; + unsigned fg_pattern; + unsigned bg_pattern; + unsigned lss_pattern; + unsigned lse_pattern; + unsigned lst_pattern; + + //TODO: ?? + int fontheight; + int fontwidth; +}; + +struct proxy_api +{ + bool (*load_remote_wps_backdrop)(char* file_name); + bool (*load_wps_backdrop)(char* file_name); + + unsigned (*get_foreground)(void); + unsigned (*get_background)(void); + int (*getwidth)(void); + int (*getheight)(void); + + void (*puts_scroll)(int x, int y, const unsigned char *string); + void (*putsxy)(int x, int y, const unsigned char *str); + int (*getfont)(); + int (*getstringsize)(const unsigned char *str, int *w, int *h); + void (*stop_scroll)(); + + void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, + int stride, int x, int y, int width, int height); + void (*bitmap_part)(const void *src, int src_x, int src_y, + int stride, int x, int y, int width, int height); + void (*hline)(int x1, int x2, int y); + void (*vline)(int x, int y1, int y2); + void (*drawpixel)(int x, int y); + void (*set_drawmode)(int mode); + void (*fillrect)(int x, int y, int width, int height); + + + void (*update)(); + void (*set_viewport)(struct viewport* vp); + void (*clear_display)(void); + void (*clear_viewport)(int x,int y,int w,int h, int color); + + void* (*plugin_get_buffer)(size_t *buffer_size); + int (*read_bmp_file)(const char* filename,int *width, int *height); + void (*set_wpsstate)(struct wpsstate state); + void (*set_trackstate)(struct trackstate state); + void (*set_next_trackstate)(struct trackstate state); + void (*set_audio_status)(int status); + + pfdebugf debugf; + int verbose; + + +/************************** +* OUT * +**************************/ + const char* (*get_model_name)(); + void (*get_current_vp)(struct viewport_api *avp); + + +}; + +extern struct proxy_api *xapi; + +EXPORT int set_api(struct proxy_api* api); + +#endif // API_H_INCLUDED diff --git a/utils/wpseditor/libwps/src/defs.h b/utils/wpseditor/libwps/src/defs.h new file mode 100644 index 0000000..810c8da --- /dev/null +++ b/utils/wpseditor/libwps/src/defs.h @@ -0,0 +1,41 @@ +#ifndef DEFS_H_INCLUDED +#define DEFS_H_INCLUDED + +typedef int (*pfdebugf)(const char* fmt,...); +extern pfdebugf dbgf; + +#ifdef BUILD_DLL +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + +#ifndef MIN +# define MIN(a, b) (((a)<(b))?(a):(b)) +#endif + +#ifndef MAX +# define MAX(a, b) (((a)>(b))?(a):(b)) +#endif + +#define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \ + ((unsigned short)(x) << 8))) + +#define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \ + (((unsigned long)(x) & 0xff0000ul) >> 8) | \ + (((unsigned long)(x) & 0xff00ul) << 8) | \ + ((unsigned long)(x) << 24))) + +#define PLAYMODES_NUM 5 +enum api_playmode { + API_STATUS_PLAY, + API_STATUS_STOP, + API_STATUS_PAUSE, + API_STATUS_FASTFORWARD, + API_STATUS_FASTBACKWARD +}; + +extern enum api_playmode playmodes[PLAYMODES_NUM]; +extern const char *playmodeNames[]; + +#endif // DEFS_H_INCLUDED diff --git a/utils/wpseditor/libwps/src/dummies.c b/utils/wpseditor/libwps/src/dummies.c new file mode 100644 index 0000000..8592610 --- /dev/null +++ b/utils/wpseditor/libwps/src/dummies.c @@ -0,0 +1,363 @@ +#include <string.h> +#include <stdio.h> +#include "dummies.h" +#include "proxy.h" + +struct user_settings global_settings; + +struct wps_state wps_state; +struct gui_wps gui_wps[NB_SCREENS]; +struct wps_data wps_datas[NB_SCREENS]; +struct cuesheet *curr_cue; +struct cuesheet *temp_cue; +struct system_status global_status; +struct gui_syncstatusbar statusbars; +struct playlist_info current_playlist; +struct font sysfont; +int battery_percent = 100; +struct mp3entry current_song, next_song; +int _audio_status; + +charger_input_state_type charger_input_state; +#if CONFIG_CHARGING >= CHARGING_MONITOR +charge_state_type charge_state; +#endif + +#if defined(CPU_PP) && defined(BOOTLOADER) +/* We don't enable interrupts in the iPod bootloader, so we need to fake +the current_tick variable */ +#define current_tick (signed)(USEC_TIMER/10000) +#else +volatile long current_tick; +#endif + + +void dummies_init(){ + sysfont.height = 9; + sysfont.maxwidth = 6; + global_settings.statusbar=true; +} + +int playlist_amount_ex(const struct playlist_info* playlist); +void sound_set_volume(int value) +{ + DEBUGF3("sound_set_volume(int value=%d)",value); + global_settings.volume = value; +} +int sound_get_pitch(void) +{ + return 0; +} +int sound_min(int setting) +{ + DEBUGF3("sound_min(int setting=%d)",setting); + return -78; //audiohw_settings[setting].minval; +} + +void sleep(int hz) +{ +} + +void audio_init(void){} +void audio_wait_for_init(void){} +void audio_play(long offset){} +void audio_stop(void){} +void audio_pause(void){} +void audio_resume(void){} +void audio_next(void){} +void audio_prev(void){} +int audio_status(void) +{ + return _audio_status; +} + +#if CONFIG_CODEC == SWCODEC +int audio_track_count(void){return 0;} /* SWCODEC only */ +long audio_filebufused(void){return 0;} /* SWCODEC only */ +void audio_pre_ff_rewind(void){} /* SWCODEC only */ +#endif /* CONFIG_CODEC == SWCODEC */ +void audio_ff_rewind(long newtime){} +void audio_flush_and_reload_tracks(void){} +#ifdef HAVE_ALBUMART +int audio_current_aa_hid(void){return -1;} +#endif +struct mp3entry* audio_current_track(void){return 0;} +struct mp3entry* audio_next_track(void){return 0;} +bool audio_has_changed_track(void) +{ + return false; +} + +int get_sleep_timer(void){return 0;} + + +int battery_level(void){return battery_percent;} /* percent */ +int battery_time(void){return 0;} /* minutes */ +unsigned int battery_adc_voltage(void){return 0;} /* voltage from ADC in millivolts */ +unsigned int battery_voltage(void){return 0;} /* filtered batt. voltage in millivolts */ +int get_radio_status(void){return 0;} + + +/* returns full path of playlist (minus extension) */ +char *playlist_name(const struct playlist_info* playlist, char *buf, +int buf_size) +{ + char *sep; + + if (!playlist) + return "no"; + + snprintf(buf, buf_size, "%s", playlist->filename+playlist->dirlen); + + if (!buf[0]) + return NULL; + + /* Remove extension */ + sep = strrchr(buf, '.'); + if(sep) + *sep = 0; + + return buf; +} +int playlist_get_display_index(void) +{ + return 1; +} + +void gui_syncsplash(int ticks, const unsigned char *fmt, ...) +{ + +} + +void splash(int ticks, const unsigned char *fmt, ...) +{ + +} + +void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw){ + DEBUGF3("gui_statusbar_draw"); +} + +void yield(void){} + + +/* returns true if cuesheet support is initialised */ +bool cuesheet_is_enabled(void){return false;} + +/* allocates the cuesheet buffer */ +void cuesheet_init(void){} + +/* looks if there is a cuesheet file that has a name matching "trackpath" */ +bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path){return false;} + +/* parse cuesheet "file" and store the information in "cue" */ +bool parse_cuesheet(char *file, struct cuesheet *cue){return false;} + +/* reads a cuesheet to find the audio track associated to it */ +bool get_trackname_from_cuesheet(char *filename, char *buf){return false;} + +/* display a cuesheet struct */ +void browse_cuesheet(struct cuesheet *cue){} + +/* display a cuesheet file after parsing and loading it to the plugin buffer */ +bool display_cuesheet_content(char* filename){return false;} + +/* finds the index of the current track played within a cuesheet */ +int cue_find_current_track(struct cuesheet *cue, unsigned long curpos){return 0;} + +/* update the id3 info to that of the currently playing track in the cuesheet */ +void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3){} + +/* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */ +bool curr_cuesheet_skip(int direction, unsigned long curr_pos){return false;} + +#ifdef HAVE_LCD_BITMAP +/* draw track markers on the progressbar */ +void cue_draw_markers(struct screen *screen, unsigned long tracklen, +int x1, int x2, int y, int h){} +#endif + + +void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear) +{ + if (!gwps || !gwps->data || !gwps->display || handle_id < 0) + return; + + struct wps_data *data = gwps->data; + +#ifdef HAVE_REMOTE_LCD + /* No album art on RWPS */ + if (data->remote_wps) + return; +#endif + + struct bitmap *bmp; + /* if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0) + return;*/ + + short x = data->albumart_x; + short y = data->albumart_y; + short width = bmp->width; + short height = bmp->height; + + if (data->albumart_max_width > 0) + { + /* Crop if the bitmap is too wide */ + width = MIN(bmp->width, data->albumart_max_width); + + /* Align */ + if (data->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT) + x += data->albumart_max_width - width; + else if (data->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER) + x += (data->albumart_max_width - width) / 2; + } + + if (data->albumart_max_height > 0) + { + /* Crop if the bitmap is too high */ + height = MIN(bmp->height, data->albumart_max_height); + + /* Align */ + if (data->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM) + y += data->albumart_max_height - height; + else if (data->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER) + y += (data->albumart_max_height - height) / 2; + } + + if (!clear) + { + /* Draw the bitmap */ + gwps->display->set_drawmode(DRMODE_FG); + gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, bmp->width, + x, y, width, height); + gwps->display->set_drawmode(DRMODE_SOLID); + } + else + { + /* Clear the bitmap */ + gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); + gwps->display->fillrect(x, y, width, height); + gwps->display->set_drawmode(DRMODE_SOLID); + } +} + +/* Update the "data" pointer to make the handle's data available to the caller. +Return the length of the available linear data or < 0 for failure (handle +not found). +The caller is blocked until the requested amount of data is available. +size is the amount of linear data requested. it can be 0 to get as +much as possible. +The guard buffer may be used to provide the requested size. This means it's +unsafe to request more than the size of the guard buffer. +*/ +size_t bufgetdata(int handle_id, size_t size, void **data) +{ + + + return size; +} + + +void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, +bool force_redraw) +{ +#ifdef HAVE_LCD_BITMAP + if(!global_settings.statusbar) + return; +#endif /* HAVE_LCD_BITMAP */ + int i; + FOR_NB_SCREENS(i) { + gui_statusbar_draw( &(bars->statusbars[i]), force_redraw ); + } +} +void unload_wps_backdrop(void) +{ + +} + +#if CONFIG_CODEC == SWCODEC +int get_replaygain_mode(bool have_track_gain, bool have_album_gain) +{ + int type; + + bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK) + || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE) + && global_settings.playlist_shuffle)); + + type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM + : have_track_gain ? REPLAYGAIN_TRACK : -1; + + return type; +} +#endif + +/* Common functions for all targets */ +void rtc_init(void){} +int rtc_read_datetime(unsigned char* buf){return 0;} +int rtc_write_datetime(unsigned char* buf){return 0;} + +void backlight_on(void){} +void backlight_off(void){} + + +void debugf(const char *fmt, ...) +{} +void panicf( const char *fmt, ...) +{ +} + +off_t filesize(int fd){return 0;} + +int playlist_amount(void) +{ + return playlist_amount_ex(NULL); +} +int playlist_amount_ex(const struct playlist_info* playlist) +{ + if (!playlist) + playlist = ¤t_playlist; + + return playlist->amount; +} + +int get_action(int context, int timeout) +{ + return 0; +} + +void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, + int height){} + +void pcm_calculate_rec_peaks(int *left, int *right) +{ +} +void pcm_calculate_peaks(int *left, int *right) +{ +} +bool led_read(int delayticks) /* read by status bar update */ +{ + return false; +} + +#ifndef HAS_BUTTON_HOLD +bool is_keys_locked(void) +{ + return false; +} +#endif + +long default_event_handler_ex(long event, void (*callback)(void *), void *parameter) +{ + return 0; +} + +long default_event_handler(long event) +{ + return default_event_handler_ex(event, NULL, NULL); +} + +void ab_draw_markers(struct screen * screen, int capacity, + int x0, int x1, int y, int h) + { + } +void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude){} diff --git a/utils/wpseditor/libwps/src/dummies.h b/utils/wpseditor/libwps/src/dummies.h new file mode 100644 index 0000000..2bfce1d --- /dev/null +++ b/utils/wpseditor/libwps/src/dummies.h @@ -0,0 +1,44 @@ +#ifndef DUMMIES_H_INCLUDED +#define DUMMIES_H_INCLUDED + +#include <stdio.h> + +#include "settings.h" +#include "gwps.h" +#include "lang.h" +#include "powermgmt.h" +#include "font.h" +#include "playlist.h" + +#include "defs.h" + +extern struct font sysfont; +extern struct user_settings global_settings; +extern struct wps_state wps_state; +extern struct gui_wps gui_wps[NB_SCREENS]; +extern struct wps_data wps_datas[NB_SCREENS]; +extern struct cuesheet *curr_cue; +extern struct cuesheet *temp_cue; +extern struct system_status global_status; +extern struct gui_syncstatusbar statusbars; +extern struct playlist_info current_playlist; +extern int battery_percent; +extern struct mp3entry current_song, next_song; +extern int _audio_status; + +charger_input_state_type charger_input_state; +#if CONFIG_CHARGING >= CHARGING_MONITOR +extern charge_state_type charge_state; +#endif + +#if defined(CPU_PP) && defined(BOOTLOADER) +/* We don't enable interrupts in the iPod bootloader, so we need to fake +the current_tick variable */ +#define current_tick (signed)(USEC_TIMER/10000) +#else +extern volatile long current_tick; +#endif + +void dummies_init(); + +#endif /*DUMMIES_H_INCLUDED*/ diff --git a/utils/wpseditor/libwps/src/include/lang.h b/utils/wpseditor/libwps/src/include/lang.h new file mode 100644 index 0000000..3274bde --- /dev/null +++ b/utils/wpseditor/libwps/src/include/lang.h @@ -0,0 +1,10 @@ +#define LANG_END_PLAYLIST (signed char)1 +#define LANG_KEYLOCK_ON (signed char)2 +#define LANG_KEYLOCK_OFF (signed char)3 +#define LANG_WEEKDAY_SUNDAY (signed char)4 +#define LANG_MONTH_JANUARY (signed char)5 +#define VOICE_PAUSE (signed char)6 +#define LANG_BATTERY_TIME (signed char)7 +#define UNIT_PERCENT (signed char)8 + +#define str(...) "empty" diff --git a/utils/wpseditor/libwps/src/include/rockboxlogo.h b/utils/wpseditor/libwps/src/include/rockboxlogo.h new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/utils/wpseditor/libwps/src/include/rockboxlogo.h @@ -0,0 +1 @@ + diff --git a/utils/wpseditor/libwps/src/include/sysfont.h b/utils/wpseditor/libwps/src/include/sysfont.h new file mode 100644 index 0000000..4ba7703 --- /dev/null +++ b/utils/wpseditor/libwps/src/include/sysfont.h @@ -0,0 +1 @@ +#define SYSFONT_HEIGHT 9 diff --git a/utils/wpseditor/libwps/src/include/system-target.h b/utils/wpseditor/libwps/src/include/system-target.h new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/utils/wpseditor/libwps/src/include/system-target.h @@ -0,0 +1 @@ + diff --git a/utils/wpseditor/libwps/src/lcd.c b/utils/wpseditor/libwps/src/lcd.c new file mode 100644 index 0000000..1f12332 --- /dev/null +++ b/utils/wpseditor/libwps/src/lcd.c @@ -0,0 +1,150 @@ +#include "font.h" +#include "screen_access.h" +//#include <windef.h> +#include "api.h" +#include "defs.h" +#include "proxy.h" +#include "dummies.h" + +static struct viewport default_vp = +{ + .x = 0, + .y = 0, + .width = LCD_WIDTH, + .height = LCD_HEIGHT, + .font = FONT_SYSFIXED, + .drawmode = DRMODE_SOLID, + .fg_pattern = LCD_DEFAULT_FG, + .bg_pattern = LCD_DEFAULT_BG, + .lss_pattern = LCD_DEFAULT_BG, + .lse_pattern = LCD_DEFAULT_BG, + .lst_pattern = LCD_DEFAULT_BG, +}; + +struct viewport* current_vp = &default_vp; + +void get_current_vp(struct viewport_api *avp){ + avp->x = current_vp->x; + avp->y = current_vp->y; + avp->width = current_vp->width; + avp->height = current_vp->height; + + //TODO: font_get(current_vp->font)->height; + avp->fontheight = sysfont.height; +} + +void lcd_set_viewport(struct viewport* vp) +{ + if (vp == NULL){ + current_vp = &default_vp; + DEBUGF3("lcd_set_viewport(struct viewport* vp= DEFAULT)\n"); + } + else{ + current_vp = vp; + DEBUGF3("lcd_set_viewport(struct viewport* vp=%x,vpx=%d,vpy=%d,vpw=%d,vph=%d)\n",vp,vp->x,vp->y,vp->width,vp->height); + } +} + +void lcd_update_viewport(void) +{ + //lcd_update_rect(current_vp->x, current_vp->y,current_vp->width, current_vp->height); +} + +void lcd_update_viewport_rect(int x, int y, int width, int height) +{ + //lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); +} +/*** parameter handling ***/ + +void lcd_set_drawmode(int mode) +{ + current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); +} + +int lcd_get_drawmode(void) +{ + return current_vp->drawmode; +} + +void lcd_set_foreground(unsigned color) +{ + current_vp->fg_pattern = color; +} + +unsigned lcd_get_foreground(void) +{ + return current_vp->fg_pattern; +} + +void lcd_set_background(unsigned color) +{ + current_vp->bg_pattern = color; +} + +unsigned lcd_get_background(void) +{ + return current_vp->bg_pattern; +} + +void lcd_set_selector_start(unsigned color) +{ + current_vp->lss_pattern = color; +} + +void lcd_set_selector_end(unsigned color) +{ + current_vp->lse_pattern = color; +} + +void lcd_set_selector_text(unsigned color) +{ + current_vp->lst_pattern = color; +} + +void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) +{ + //lcd_set_drawmode(mode); + current_vp->fg_pattern = fg_color; + current_vp->bg_pattern = bg_color; +} + +int lcd_getwidth(void) +{ + return current_vp->width; +} + +int lcd_getheight(void) +{ + return current_vp->height; +} + +void lcd_setfont(int newfont) +{ + current_vp->font = newfont; +} + +int lcd_getfont(void) +{ + return current_vp->font; +} + +/* Clear the whole display */ +void lcd_clear_display(void) +{ + struct viewport* old_vp = current_vp; + + current_vp = &default_vp; + + lcd_clear_viewport(); + + current_vp = old_vp; +} + +void lcd_clear_viewport(){ + DEBUGF2("lcd_clear_viewport()\n"); + xapi->clear_viewport(current_vp->x,current_vp->y,current_vp->width,current_vp->height,current_vp->bg_pattern); + +} +void lcd_scroll_stop(struct viewport* vp){ + DEBUGF3("lcd_scroll_stop(struct viewport* vp=%x)\n",vp); +} diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c new file mode 100644 index 0000000..3a3b8ce --- /dev/null +++ b/utils/wpseditor/libwps/src/proxy.c @@ -0,0 +1,132 @@ +#include <stdio.h> +#include <stdlib.h> +#include "dummies.h" +#include "proxy.h" +#include "api.h" +#include "gwps.h" +#include "gwps-common.h" +#include <string.h> + +struct screen screens[NB_SCREENS]; +struct wps_data wpsdata; +struct gui_wps gwps; +struct mp3entry id3; +struct mp3entry nid3; + +extern void test_api(struct proxy_api *api); + +bool debug_wps = true; +int wps_verbose_level = 0; +int errno_; +pfdebugf dbgf = 0; + +static char pluginbuf[PLUGIN_BUFFER_SIZE]; + +const char* get_model_name(){ +#ifdef TARGET_MODEL + return TARGET_MODEL; +#else + return "unknown"; +#endif +} + +int read_line(int fd, char* buffer, int buffer_size) +{ + int count = 0; + int num_read = 0; + + errno_ = 0; + + while (count < buffer_size) + { + unsigned char c; + + if (1 != read(fd, &c, 1)) + break; + + num_read++; + + if ( c == '\n' ) + break; + + if ( c == '\r' ) + continue; + + buffer[count++] = c; + } + + buffer[MIN(count, buffer_size - 1)] = 0; + + return errno_ ? -1 : num_read; +} + +void* plugin_get_buffer(size_t *buffer_size) +{ + *buffer_size = PLUGIN_BUFFER_SIZE; + return pluginbuf; +} + +int checkwps(const char *filename, int verbose){ + int res; + int fd; + + struct wps_data wps; + wps_verbose_level = verbose; + + fd = open(filename, O_RDONLY); + if (fd < 0) { + DEBUGF1("Failed to open %s\n",filename); + return 2; + } + close(fd); + + res = wps_data_load(&wps, &screens[0], filename, true); + + if (!res) { + DEBUGF1("WPS parsing failure\n"); + return 3; + } + + DEBUGF1("WPS parsed OK\n"); + return 0; +} + +int wps_init(const char* filename,struct proxy_api *api, bool isfile){ + int res; + if (!api) + return 4; + dummies_init(); + test_api(api); + set_api(api); + wps_data_init(&wpsdata); + wps_verbose_level = api->verbose; + res = wps_data_load(&wpsdata, &screens[0], filename, isfile); + if (!res) + { + DEBUGF1("ERR: WPS parsing failure\n"); + return 3; + } + DEBUGF1("WPS parsed OK\n"); + DEBUGF1("\n-------------------------------------------------\n"); + wps_state.paused = true; + gwps.data = &wpsdata; + gwps.display = &screens[0]; + gwps.state = &wps_state; + gwps.state->id3 = &id3; + gwps.state->nid3 = &nid3; + gui_wps[0] = gwps; + return res; +} + +int wps_display(){ + DEBUGF3("wps_display(): begin\n"); + int res = gui_wps_display(); + DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not ")); + return res; +} +int wps_refresh(){ + DEBUGF3("-----------------<wps_refresh(): begin>-----------------\n"); + int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL); + DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not ")); + return res; +} diff --git a/utils/wpseditor/libwps/src/proxy.h b/utils/wpseditor/libwps/src/proxy.h new file mode 100644 index 0000000..3836ecc --- /dev/null +++ b/utils/wpseditor/libwps/src/proxy.h @@ -0,0 +1,25 @@ +#ifndef PROXY_H +#define PROXY_h + +#include "screen_access.h" +#include "api.h" +#include "defs.h" + +#define DEBUGF dbgf +#define DEBUGF1 dbgf +#define DEBUGF2(...) +#define DEBUGF3(...) + +EXPORT int checkwps(const char *filename, int verbose); +EXPORT int wps_init(const char* filename,struct proxy_api *api,bool isfile); +EXPORT int wps_display(); +EXPORT int wps_refresh(); + +const char* get_model_name(); + +extern struct screen screens[NB_SCREENS]; +extern bool debug_wps; +extern int wps_verbose_level; + + +#endif diff --git a/utils/wpseditor/libwps/src/wpsstate.h b/utils/wpseditor/libwps/src/wpsstate.h new file mode 100644 index 0000000..148936a --- /dev/null +++ b/utils/wpseditor/libwps/src/wpsstate.h @@ -0,0 +1,34 @@ +#ifndef STATES_H +#define STATES_H +// +struct trackstate +{ + char* title; + char* artist; + char* album; + char* genre_string; + char* disc_string; + char* track_string; + char* year_string; + char* composer; + char* comment; + char* albumartist; + char* grouping; + int discnum; + int tracknum; + int version; + int layer; + int year; + + int length; + int elapsed; +}; + +struct wpsstate{ + int volume; + int fontheight; + int fontwidth; + int battery_level; + int audio_status; +}; +#endif |