summaryrefslogtreecommitdiff
path: root/utils/wpseditor/libwps
diff options
context:
space:
mode:
Diffstat (limited to 'utils/wpseditor/libwps')
-rw-r--r--utils/wpseditor/libwps/Makefile100
-rw-r--r--utils/wpseditor/libwps/buildall.sh7
-rw-r--r--utils/wpseditor/libwps/cleanall.sh7
-rw-r--r--utils/wpseditor/libwps/src/api.c268
-rw-r--r--utils/wpseditor/libwps/src/api.h85
-rw-r--r--utils/wpseditor/libwps/src/defs.h41
-rw-r--r--utils/wpseditor/libwps/src/dummies.c363
-rw-r--r--utils/wpseditor/libwps/src/dummies.h44
-rw-r--r--utils/wpseditor/libwps/src/include/lang.h10
-rw-r--r--utils/wpseditor/libwps/src/include/rockboxlogo.h1
-rw-r--r--utils/wpseditor/libwps/src/include/sysfont.h1
-rw-r--r--utils/wpseditor/libwps/src/include/system-target.h1
-rw-r--r--utils/wpseditor/libwps/src/lcd.c150
-rw-r--r--utils/wpseditor/libwps/src/proxy.c132
-rw-r--r--utils/wpseditor/libwps/src/proxy.h25
-rw-r--r--utils/wpseditor/libwps/src/wpsstate.h34
-rw-r--r--utils/wpseditor/libwps/targets.txt33
17 files changed, 1302 insertions, 0 deletions
diff --git a/utils/wpseditor/libwps/Makefile b/utils/wpseditor/libwps/Makefile
new file mode 100644
index 0000000000..3779a9ed30
--- /dev/null
+++ b/utils/wpseditor/libwps/Makefile
@@ -0,0 +1,100 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9ROOT=../../..
10
11OS = w32
12CC = gcc
13MKDIR = mkdir -p
14
15ifeq ($(findstring MINGW,$(shell uname)),MINGW)
16OS = w32
17CC = mingw32-gcc
18COPY = copy
19RM = rm
20endif
21
22ifeq ($(findstring Linux,$(shell uname)),Linux)
23OS = linux
24CC = gcc
25COPY = cp
26RM = rm -f
27endif
28
29
30
31COMMON= \
32 src/dummies.c \
33 src/api.c \
34 src/lcd.c \
35 $(ROOT)/apps/gui/wps_parser.c \
36 $(ROOT)/apps/gui/wps_debug.c \
37 $(ROOT)/firmware/font.c \
38 $(ROOT)/apps/misc.c \
39 $(ROOT)/apps/gui/gwps-common.c \
40 $(ROOT)/apps/status.c \
41 $(ROOT)/apps/recorder/peakmeter.c \
42 $(ROOT)/apps/recorder/icons.c \
43 $(ROOT)/apps/gui/scrollbar.c \
44 $(ROOT)/firmware/common/timefuncs.c \
45 $(ROOT)/firmware/common/unicode.c \
46 $(ROOT)/firmware/common/ctype.c \
47 $(ROOT)/firmware/id3.c \
48 $(ROOT)/firmware/font_cache.c \
49 $(ROOT)/firmware/lru.c \
50 $(ROOT)/firmware/mp3data.c \
51 $(ROOT)/firmware/replaygain.c
52
53# $(ROOT)/apps/recorder/bmp.c
54# $(ROOT)/apps/abrepeat.c \
55# $(ROOT)/apps/action.c \
56# $(ROOT)/apps/cuesheet.c \
57# $(ROOT)/apps/gui/statusbar.c \
58# $(ROOT)/apps/gui/gwps.c \
59
60INCLUDE=-I src/include \
61 -I $(ROOT)/apps/gui \
62 -I $(ROOT)/firmware/export \
63 -I $(ROOT)/firmware/include \
64 -I $(ROOT)/apps/recorder \
65 -I $(ROOT)/apps \
66 -I src
67
68CFLAGS = -g -Wall -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE
69
70all:
71 @echo To build, run the buildall.sh script
72
73build: build-$(OS)
74
75build-w32: src/proxy.c $(COMMON)
76 @echo CC [$(TARGET)]
77 @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -DBUILD_DLL $(COMMON) -shared src/proxy.c -o libwps_$(MODEL).dll
78
79build-linux: src/proxy.c $(COMMON)
80 @echo CC [$(TARGET)]
81 @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -shared -Wl,-soname,libwps_$(MODEL).so,-olibwps_$(MODEL).so -fPIC $(COMMON) src/proxy.c
82
83clean: clean-$(OS)
84
85clean-w32:
86 $(RM) "libwps_$(MODEL).dll"
87
88clean-linux:
89 $(RM) "libwps_$(MODEL).so.1"
90
91shared: shared-$(OS)
92
93shared-w32: src/proxy.c $(COMMON)
94 @echo CC [IRIVER_H10_5GB]
95 @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -DBUILD_DLL $(COMMON) -shared src/proxy.c -o ../gui/bin/libwps.dll
96
97shared-linux: src/proxy.c $(COMMON)
98 @echo CC [IRIVER_H10_5GB]
99 @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -shared -Wl,-soname,libwps.so,-olibwps.so -fPIC $(COMMON) src/proxy.c
100 @$(COPY) libwps.so ../gui/bin/libwps.so
diff --git a/utils/wpseditor/libwps/buildall.sh b/utils/wpseditor/libwps/buildall.sh
new file mode 100644
index 0000000000..60677d22b6
--- /dev/null
+++ b/utils/wpseditor/libwps/buildall.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2cat targets.txt | (
3 while read target model
4 do
5 make MODEL=$model TARGET=$target build
6 done
7)
diff --git a/utils/wpseditor/libwps/cleanall.sh b/utils/wpseditor/libwps/cleanall.sh
new file mode 100644
index 0000000000..15b733a6a7
--- /dev/null
+++ b/utils/wpseditor/libwps/cleanall.sh
@@ -0,0 +1,7 @@
1#!/bin/sh
2cat targets.txt | (
3 while read target model
4 do
5 make MODEL=$model TARGET=$target clean
6 done
7)
diff --git a/utils/wpseditor/libwps/src/api.c b/utils/wpseditor/libwps/src/api.c
new file mode 100644
index 0000000000..485efa8e00
--- /dev/null
+++ b/utils/wpseditor/libwps/src/api.c
@@ -0,0 +1,268 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include "sound.h"
4#include "api.h"
5#include "proxy.h"
6#include "dummies.h"
7#include "scroll_engine.h"
8#include "wpsstate.h"
9#include <string.h>
10
11struct proxy_api *xapi;
12
13void get_current_vp(struct viewport_api *avp);
14/*************************************************************
15
16*************************************************************/
17#ifdef HAVE_LCD_BITMAP
18void screen_clear_area(struct screen * display, int xstart, int ystart,
19 int width, int height) {
20 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
21 display->fillrect(xstart, ystart, width, height);
22 display->set_drawmode(DRMODE_SOLID);
23}
24#endif
25
26bool load_wps_backdrop(char* filename) {
27 return xapi->load_wps_backdrop(filename);
28}
29
30bool load_remote_wps_backdrop(char* filename) {
31 return xapi->load_remote_wps_backdrop(filename);
32}
33
34int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) {
35 if (!xapi->read_bmp_file)
36 {
37 DEBUGF1("can't read bmp file! NULL api!\n");
38 return -1;
39 }
40 bm->format = 3;//FORMAT_ANY?
41 bm->data = (unsigned char*)malloc(255);
42 memset(bm->data,0,255);
43 strcpy((char*)bm->data,filename);
44 //bm->data[strlen(filename)] = '\0';
45 xapi->read_bmp_file(filename,&bm->width, &bm->height);
46 return 1;
47}
48
49bool load_wps_backdrop2(char* filename) {
50 DEBUGF1("load_wps_backdrop(char* filename='%s')",filename);
51 return true;
52}
53
54bool load_remote_wps_backdrop2(char* filename) {
55 DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename);
56 return true;
57}
58
59void stop_scroll() {
60 DEBUGF3("stop_scroll\n");
61 return;
62}
63
64void puts_scroll(int x, int y, const unsigned char *string) {
65 DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x,y,string);
66}
67
68void putsxy(int x, int y, const unsigned char *str) {
69 DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x,y,str);
70}
71
72void lcd_update() {
73 DEBUGF3("update\n");
74}
75
76void clear_viewport(int x, int y, int w, int h, int color) {
77 DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x, y, w, h, color);
78};
79
80int getstringsize(const unsigned char *str, int *w, int *h) {
81 //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h);
82 *w=strlen((char*)str)*sysfont.maxwidth;
83 *h=sysfont.height;
84 return 1;
85}
86
87void set_wpsstate(struct wpsstate state){
88 sysfont.height = state.fontheight;
89 sysfont.maxwidth = state.fontwidth;
90 global_settings.volume = state.volume;
91 battery_percent = state.battery_level;
92 _audio_status = state.audio_status;
93}
94
95void set_trackstate(struct trackstate state){
96 gui_wps[0].state->id3->title = state.title;
97 gui_wps[0].state->id3->artist = state.artist;
98 gui_wps[0].state->id3->album = state.album;
99 gui_wps[0].state->id3->elapsed = state.elapsed;
100 gui_wps[0].state->id3->length = state.length;
101}
102
103void set_next_trackstate(struct trackstate state)
104{
105 gui_wps[0].state->nid3->title = state.title;
106 gui_wps[0].state->nid3->artist = state.artist;
107 gui_wps[0].state->nid3->album = state.album;
108 gui_wps[0].state->nid3->elapsed = state.elapsed;
109 gui_wps[0].state->nid3->length = state.length;
110}
111
112enum api_playmode playmodes[PLAYMODES_NUM] = {
113 API_STATUS_PLAY,
114 API_STATUS_STOP,
115 API_STATUS_PAUSE,
116 API_STATUS_FASTFORWARD,
117 API_STATUS_FASTBACKWARD
118};
119
120const char *playmodeNames[] = {
121 "Play", "Stop", "Pause", "FastForward", "FastBackward"
122};
123
124
125void set_audio_status(int status){
126 DEBUGF1("%s",playmodeNames[status]);
127 switch(status){
128 case API_STATUS_PLAY:
129 _audio_status = AUDIO_STATUS_PLAY;
130 status_set_ffmode(STATUS_PLAY);
131 break;
132 case API_STATUS_STOP:
133 _audio_status = 0;
134 status_set_ffmode(STATUS_STOP);
135 break;
136 case API_STATUS_PAUSE:
137 _audio_status = AUDIO_STATUS_PAUSE;
138 status_set_ffmode(STATUS_PLAY);
139 break;
140 case API_STATUS_FASTFORWARD:
141 status_set_ffmode(STATUS_FASTFORWARD);
142 break;
143 case API_STATUS_FASTBACKWARD:
144 status_set_ffmode(STATUS_FASTBACKWARD);
145 break;
146 default:
147 DEBUGF1("ERR: Unknown status");
148 }
149}
150
151void test_api(struct proxy_api *api) {
152 if (!api->stop_scroll)
153 api->stop_scroll=stop_scroll;
154 if (!api->set_viewport)
155 api->set_viewport=lcd_set_viewport;
156 if (!api->clear_viewport)
157 api->clear_viewport=clear_viewport;
158 if (!api->getstringsize)
159 api->getstringsize=getstringsize;
160 if (!api->getwidth)
161 api->getwidth=lcd_getwidth;
162 if (!api->getheight)
163 api->getheight=lcd_getheight;
164 if (!api->set_drawmode)
165 api->set_drawmode=lcd_set_drawmode;
166 if (!api->puts_scroll)
167 api->puts_scroll=puts_scroll;
168 if (!api->update)
169 api->update=lcd_update;
170 if (!api->clear_display)
171 api->clear_display=lcd_clear_display;
172 if (!api->getfont)
173 api->getfont=lcd_getfont;
174 if (!api->putsxy)
175 api->putsxy=putsxy;
176
177#if LCD_DEPTH > 1
178 if (!api->get_foreground)
179 api->get_foreground=lcd_get_foreground;
180 if (!api->get_background)
181 api->get_background=lcd_get_background;
182#endif
183 if (!api->load_remote_wps_backdrop)
184 api->load_remote_wps_backdrop = load_remote_wps_backdrop2;
185 if (!api->load_wps_backdrop)
186 api->load_wps_backdrop = load_wps_backdrop2;
187 //dbgf = printf;
188}
189
190/**************************************************************
191
192**************************************************************/
193
194int set_api(struct proxy_api* api) {
195 if (api->debugf)
196 dbgf = api->debugf;
197 screens[0].screen_type=SCREEN_MAIN;
198 screens[0].lcdwidth=LCD_WIDTH;
199 screens[0].lcdheight=LCD_HEIGHT;
200 screens[0].depth=LCD_DEPTH;
201#ifdef HAVE_LCD_COLOR
202 screens[0].is_color=true;
203#else
204 screens[0].is_color=false;
205#endif
206 if (api->getwidth)
207 screens[0].getwidth = api->getwidth;
208 if (api->stop_scroll)
209 screens[0].stop_scroll=api->stop_scroll;
210 screens[0].scroll_stop = lcd_scroll_stop;
211 if (api->set_viewport)
212 screens[0].set_viewport=api->set_viewport;
213 if (api->clear_viewport)
214 screens[0].clear_viewport=lcd_clear_viewport;
215 if (api->getstringsize)
216 screens[0].getstringsize=api->getstringsize;
217 if (api->getwidth)
218 screens[0].getwidth=api->getwidth;
219 if (api->getheight)
220 screens[0].getheight=api->getheight;
221 if (api->set_drawmode)
222 screens[0].set_drawmode=api->set_drawmode;
223 if (api->fillrect)
224 screens[0].fillrect=api->fillrect;
225 if (api->puts_scroll)
226 screens[0].puts_scroll=api->puts_scroll;
227 if (api->transparent_bitmap_part)
228 screens[0].transparent_bitmap_part=api->transparent_bitmap_part;
229 if (api->update)
230 screens[0].update=api->update;
231 if (api->clear_display)
232 screens[0].clear_display=api->clear_display;
233 if (api->getfont)
234 screens[0].getfont=api->getfont;
235 if (api->hline)
236 screens[0].hline=api->hline;
237 if (api->vline)
238 screens[0].vline=api->vline;
239 if (api->drawpixel)
240 screens[0].drawpixel=api->drawpixel;
241 if (api->putsxy)
242 screens[0].putsxy=api->putsxy;
243#if LCD_DEPTH > 1
244 if (api->get_foreground)
245 screens[0].get_foreground=api->get_foreground;
246 if (api->get_background)
247 screens[0].get_background=api->get_background;
248#endif
249
250 screens[0].bitmap_part = api->bitmap_part;
251 /**************************
252 * OUT *
253 **************************/
254 api->get_model_name = get_model_name;
255 api->get_current_vp = get_current_vp;
256 api->set_wpsstate = set_wpsstate;
257 api->set_trackstate = set_trackstate;
258 api->set_next_trackstate= set_next_trackstate;
259 api->set_audio_status= set_audio_status;
260 xapi = api;
261 return 0;
262}
263
264
265
266
267
268
diff --git a/utils/wpseditor/libwps/src/api.h b/utils/wpseditor/libwps/src/api.h
new file mode 100644
index 0000000000..86bb1a6597
--- /dev/null
+++ b/utils/wpseditor/libwps/src/api.h
@@ -0,0 +1,85 @@
1#ifndef API_H_INCLUDED
2#define API_H_INCLUDED
3#include <stdbool.h>
4#include <stddef.h>
5#include "defs.h"
6#include "wpsstate.h"
7#ifdef __PCTOOL__
8#include "dummies.h"
9#endif
10
11struct viewport_api {
12 int x;
13 int y;
14 int width;
15 int height;
16 int font;
17 int drawmode;
18 unsigned fg_pattern;
19 unsigned bg_pattern;
20 unsigned lss_pattern;
21 unsigned lse_pattern;
22 unsigned lst_pattern;
23
24 //TODO: ??
25 int fontheight;
26 int fontwidth;
27};
28
29struct proxy_api
30{
31 bool (*load_remote_wps_backdrop)(char* file_name);
32 bool (*load_wps_backdrop)(char* file_name);
33
34 unsigned (*get_foreground)(void);
35 unsigned (*get_background)(void);
36 int (*getwidth)(void);
37 int (*getheight)(void);
38
39 void (*puts_scroll)(int x, int y, const unsigned char *string);
40 void (*putsxy)(int x, int y, const unsigned char *str);
41 int (*getfont)();
42 int (*getstringsize)(const unsigned char *str, int *w, int *h);
43 void (*stop_scroll)();
44
45 void (*transparent_bitmap_part)(const void *src, int src_x, int src_y,
46 int stride, int x, int y, int width, int height);
47 void (*bitmap_part)(const void *src, int src_x, int src_y,
48 int stride, int x, int y, int width, int height);
49 void (*hline)(int x1, int x2, int y);
50 void (*vline)(int x, int y1, int y2);
51 void (*drawpixel)(int x, int y);
52 void (*set_drawmode)(int mode);
53 void (*fillrect)(int x, int y, int width, int height);
54
55
56 void (*update)();
57 void (*set_viewport)(struct viewport* vp);
58 void (*clear_display)(void);
59 void (*clear_viewport)(int x,int y,int w,int h, int color);
60
61 void* (*plugin_get_buffer)(size_t *buffer_size);
62 int (*read_bmp_file)(const char* filename,int *width, int *height);
63 void (*set_wpsstate)(struct wpsstate state);
64 void (*set_trackstate)(struct trackstate state);
65 void (*set_next_trackstate)(struct trackstate state);
66 void (*set_audio_status)(int status);
67
68 pfdebugf debugf;
69 int verbose;
70
71
72/**************************
73* OUT *
74**************************/
75 const char* (*get_model_name)();
76 void (*get_current_vp)(struct viewport_api *avp);
77
78
79};
80
81extern struct proxy_api *xapi;
82
83EXPORT int set_api(struct proxy_api* api);
84
85#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 0000000000..810c8da238
--- /dev/null
+++ b/utils/wpseditor/libwps/src/defs.h
@@ -0,0 +1,41 @@
1#ifndef DEFS_H_INCLUDED
2#define DEFS_H_INCLUDED
3
4typedef int (*pfdebugf)(const char* fmt,...);
5extern pfdebugf dbgf;
6
7#ifdef BUILD_DLL
8# define EXPORT __declspec(dllexport)
9#else
10# define EXPORT
11#endif
12
13#ifndef MIN
14# define MIN(a, b) (((a)<(b))?(a):(b))
15#endif
16
17#ifndef MAX
18# define MAX(a, b) (((a)>(b))?(a):(b))
19#endif
20
21#define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
22 ((unsigned short)(x) << 8)))
23
24#define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
25 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
26 (((unsigned long)(x) & 0xff00ul) << 8) | \
27 ((unsigned long)(x) << 24)))
28
29#define PLAYMODES_NUM 5
30enum api_playmode {
31 API_STATUS_PLAY,
32 API_STATUS_STOP,
33 API_STATUS_PAUSE,
34 API_STATUS_FASTFORWARD,
35 API_STATUS_FASTBACKWARD
36};
37
38extern enum api_playmode playmodes[PLAYMODES_NUM];
39extern const char *playmodeNames[];
40
41#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 0000000000..8592610701
--- /dev/null
+++ b/utils/wpseditor/libwps/src/dummies.c
@@ -0,0 +1,363 @@
1#include <string.h>
2#include <stdio.h>
3#include "dummies.h"
4#include "proxy.h"
5
6struct user_settings global_settings;
7
8struct wps_state wps_state;
9struct gui_wps gui_wps[NB_SCREENS];
10struct wps_data wps_datas[NB_SCREENS];
11struct cuesheet *curr_cue;
12struct cuesheet *temp_cue;
13struct system_status global_status;
14struct gui_syncstatusbar statusbars;
15struct playlist_info current_playlist;
16struct font sysfont;
17int battery_percent = 100;
18struct mp3entry current_song, next_song;
19int _audio_status;
20
21charger_input_state_type charger_input_state;
22#if CONFIG_CHARGING >= CHARGING_MONITOR
23charge_state_type charge_state;
24#endif
25
26#if defined(CPU_PP) && defined(BOOTLOADER)
27/* We don't enable interrupts in the iPod bootloader, so we need to fake
28the current_tick variable */
29#define current_tick (signed)(USEC_TIMER/10000)
30#else
31volatile long current_tick;
32#endif
33
34
35void dummies_init(){
36 sysfont.height = 9;
37 sysfont.maxwidth = 6;
38 global_settings.statusbar=true;
39}
40
41int playlist_amount_ex(const struct playlist_info* playlist);
42void sound_set_volume(int value)
43{
44 DEBUGF3("sound_set_volume(int value=%d)",value);
45 global_settings.volume = value;
46}
47int sound_get_pitch(void)
48{
49 return 0;
50}
51int sound_min(int setting)
52{
53 DEBUGF3("sound_min(int setting=%d)",setting);
54 return -78; //audiohw_settings[setting].minval;
55}
56
57void sleep(int hz)
58{
59}
60
61void audio_init(void){}
62void audio_wait_for_init(void){}
63void audio_play(long offset){}
64void audio_stop(void){}
65void audio_pause(void){}
66void audio_resume(void){}
67void audio_next(void){}
68void audio_prev(void){}
69int audio_status(void)
70{
71 return _audio_status;
72}
73
74#if CONFIG_CODEC == SWCODEC
75int audio_track_count(void){return 0;} /* SWCODEC only */
76long audio_filebufused(void){return 0;} /* SWCODEC only */
77void audio_pre_ff_rewind(void){} /* SWCODEC only */
78#endif /* CONFIG_CODEC == SWCODEC */
79void audio_ff_rewind(long newtime){}
80void audio_flush_and_reload_tracks(void){}
81#ifdef HAVE_ALBUMART
82int audio_current_aa_hid(void){return -1;}
83#endif
84struct mp3entry* audio_current_track(void){return 0;}
85struct mp3entry* audio_next_track(void){return 0;}
86bool audio_has_changed_track(void)
87{
88 return false;
89}
90
91int get_sleep_timer(void){return 0;}
92
93
94int battery_level(void){return battery_percent;} /* percent */
95int battery_time(void){return 0;} /* minutes */
96unsigned int battery_adc_voltage(void){return 0;} /* voltage from ADC in millivolts */
97unsigned int battery_voltage(void){return 0;} /* filtered batt. voltage in millivolts */
98int get_radio_status(void){return 0;}
99
100
101/* returns full path of playlist (minus extension) */
102char *playlist_name(const struct playlist_info* playlist, char *buf,
103int buf_size)
104{
105 char *sep;
106
107 if (!playlist)
108 return "no";
109
110 snprintf(buf, buf_size, "%s", playlist->filename+playlist->dirlen);
111
112 if (!buf[0])
113 return NULL;
114
115 /* Remove extension */
116 sep = strrchr(buf, '.');
117 if(sep)
118 *sep = 0;
119
120 return buf;
121}
122int playlist_get_display_index(void)
123{
124 return 1;
125}
126
127void gui_syncsplash(int ticks, const unsigned char *fmt, ...)
128{
129
130}
131
132void splash(int ticks, const unsigned char *fmt, ...)
133{
134
135}
136
137void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw){
138 DEBUGF3("gui_statusbar_draw");
139}
140
141void yield(void){}
142
143
144/* returns true if cuesheet support is initialised */
145bool cuesheet_is_enabled(void){return false;}
146
147/* allocates the cuesheet buffer */
148void cuesheet_init(void){}
149
150/* looks if there is a cuesheet file that has a name matching "trackpath" */
151bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path){return false;}
152
153/* parse cuesheet "file" and store the information in "cue" */
154bool parse_cuesheet(char *file, struct cuesheet *cue){return false;}
155
156/* reads a cuesheet to find the audio track associated to it */
157bool get_trackname_from_cuesheet(char *filename, char *buf){return false;}
158
159/* display a cuesheet struct */
160void browse_cuesheet(struct cuesheet *cue){}
161
162/* display a cuesheet file after parsing and loading it to the plugin buffer */
163bool display_cuesheet_content(char* filename){return false;}
164
165/* finds the index of the current track played within a cuesheet */
166int cue_find_current_track(struct cuesheet *cue, unsigned long curpos){return 0;}
167
168/* update the id3 info to that of the currently playing track in the cuesheet */
169void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3){}
170
171/* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */
172bool curr_cuesheet_skip(int direction, unsigned long curr_pos){return false;}
173
174#ifdef HAVE_LCD_BITMAP
175/* draw track markers on the progressbar */
176void cue_draw_markers(struct screen *screen, unsigned long tracklen,
177int x1, int x2, int y, int h){}
178#endif
179
180
181void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear)
182{
183 if (!gwps || !gwps->data || !gwps->display || handle_id < 0)
184 return;
185
186 struct wps_data *data = gwps->data;
187
188#ifdef HAVE_REMOTE_LCD
189 /* No album art on RWPS */
190 if (data->remote_wps)
191 return;
192#endif
193
194 struct bitmap *bmp;
195 /* if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0)
196 return;*/
197
198 short x = data->albumart_x;
199 short y = data->albumart_y;
200 short width = bmp->width;
201 short height = bmp->height;
202
203 if (data->albumart_max_width > 0)
204 {
205 /* Crop if the bitmap is too wide */
206 width = MIN(bmp->width, data->albumart_max_width);
207
208 /* Align */
209 if (data->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT)
210 x += data->albumart_max_width - width;
211 else if (data->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER)
212 x += (data->albumart_max_width - width) / 2;
213 }
214
215 if (data->albumart_max_height > 0)
216 {
217 /* Crop if the bitmap is too high */
218 height = MIN(bmp->height, data->albumart_max_height);
219
220 /* Align */
221 if (data->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM)
222 y += data->albumart_max_height - height;
223 else if (data->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER)
224 y += (data->albumart_max_height - height) / 2;
225 }
226
227 if (!clear)
228 {
229 /* Draw the bitmap */
230 gwps->display->set_drawmode(DRMODE_FG);
231 gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, bmp->width,
232 x, y, width, height);
233 gwps->display->set_drawmode(DRMODE_SOLID);
234 }
235 else
236 {
237 /* Clear the bitmap */
238 gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
239 gwps->display->fillrect(x, y, width, height);
240 gwps->display->set_drawmode(DRMODE_SOLID);
241 }
242}
243
244/* Update the "data" pointer to make the handle's data available to the caller.
245Return the length of the available linear data or < 0 for failure (handle
246not found).
247The caller is blocked until the requested amount of data is available.
248size is the amount of linear data requested. it can be 0 to get as
249much as possible.
250The guard buffer may be used to provide the requested size. This means it's
251unsafe to request more than the size of the guard buffer.
252*/
253size_t bufgetdata(int handle_id, size_t size, void **data)
254{
255
256
257 return size;
258}
259
260
261void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
262bool force_redraw)
263{
264#ifdef HAVE_LCD_BITMAP
265 if(!global_settings.statusbar)
266 return;
267#endif /* HAVE_LCD_BITMAP */
268 int i;
269 FOR_NB_SCREENS(i) {
270 gui_statusbar_draw( &(bars->statusbars[i]), force_redraw );
271 }
272}
273void unload_wps_backdrop(void)
274{
275
276}
277
278#if CONFIG_CODEC == SWCODEC
279int get_replaygain_mode(bool have_track_gain, bool have_album_gain)
280{
281 int type;
282
283 bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK)
284 || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE)
285 && global_settings.playlist_shuffle));
286
287 type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM
288 : have_track_gain ? REPLAYGAIN_TRACK : -1;
289
290 return type;
291}
292#endif
293
294/* Common functions for all targets */
295void rtc_init(void){}
296int rtc_read_datetime(unsigned char* buf){return 0;}
297int rtc_write_datetime(unsigned char* buf){return 0;}
298
299void backlight_on(void){}
300void backlight_off(void){}
301
302
303void debugf(const char *fmt, ...)
304{}
305void panicf( const char *fmt, ...)
306{
307}
308
309off_t filesize(int fd){return 0;}
310
311int playlist_amount(void)
312{
313 return playlist_amount_ex(NULL);
314}
315int playlist_amount_ex(const struct playlist_info* playlist)
316{
317 if (!playlist)
318 playlist = &current_playlist;
319
320 return playlist->amount;
321}
322
323int get_action(int context, int timeout)
324{
325 return 0;
326}
327
328void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width,
329 int height){}
330
331void pcm_calculate_rec_peaks(int *left, int *right)
332{
333}
334void pcm_calculate_peaks(int *left, int *right)
335{
336}
337bool led_read(int delayticks) /* read by status bar update */
338{
339 return false;
340}
341
342#ifndef HAS_BUTTON_HOLD
343bool is_keys_locked(void)
344{
345 return false;
346}
347#endif
348
349long default_event_handler_ex(long event, void (*callback)(void *), void *parameter)
350{
351 return 0;
352}
353
354long default_event_handler(long event)
355{
356 return default_event_handler_ex(event, NULL, NULL);
357}
358
359void ab_draw_markers(struct screen * screen, int capacity,
360 int x0, int x1, int y, int h)
361 {
362 }
363void 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 0000000000..2bfce1d53b
--- /dev/null
+++ b/utils/wpseditor/libwps/src/dummies.h
@@ -0,0 +1,44 @@
1#ifndef DUMMIES_H_INCLUDED
2#define DUMMIES_H_INCLUDED
3
4#include <stdio.h>
5
6#include "settings.h"
7#include "gwps.h"
8#include "lang.h"
9#include "powermgmt.h"
10#include "font.h"
11#include "playlist.h"
12
13#include "defs.h"
14
15extern struct font sysfont;
16extern struct user_settings global_settings;
17extern struct wps_state wps_state;
18extern struct gui_wps gui_wps[NB_SCREENS];
19extern struct wps_data wps_datas[NB_SCREENS];
20extern struct cuesheet *curr_cue;
21extern struct cuesheet *temp_cue;
22extern struct system_status global_status;
23extern struct gui_syncstatusbar statusbars;
24extern struct playlist_info current_playlist;
25extern int battery_percent;
26extern struct mp3entry current_song, next_song;
27extern int _audio_status;
28
29charger_input_state_type charger_input_state;
30#if CONFIG_CHARGING >= CHARGING_MONITOR
31extern charge_state_type charge_state;
32#endif
33
34#if defined(CPU_PP) && defined(BOOTLOADER)
35/* We don't enable interrupts in the iPod bootloader, so we need to fake
36the current_tick variable */
37#define current_tick (signed)(USEC_TIMER/10000)
38#else
39extern volatile long current_tick;
40#endif
41
42void dummies_init();
43
44#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 0000000000..3274bdec6c
--- /dev/null
+++ b/utils/wpseditor/libwps/src/include/lang.h
@@ -0,0 +1,10 @@
1#define LANG_END_PLAYLIST (signed char)1
2#define LANG_KEYLOCK_ON (signed char)2
3#define LANG_KEYLOCK_OFF (signed char)3
4#define LANG_WEEKDAY_SUNDAY (signed char)4
5#define LANG_MONTH_JANUARY (signed char)5
6#define VOICE_PAUSE (signed char)6
7#define LANG_BATTERY_TIME (signed char)7
8#define UNIT_PERCENT (signed char)8
9
10#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 0000000000..8d1c8b69c3
--- /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 0000000000..4ba770347c
--- /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 0000000000..8d1c8b69c3
--- /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 0000000000..1f12332750
--- /dev/null
+++ b/utils/wpseditor/libwps/src/lcd.c
@@ -0,0 +1,150 @@
1#include "font.h"
2#include "screen_access.h"
3//#include <windef.h>
4#include "api.h"
5#include "defs.h"
6#include "proxy.h"
7#include "dummies.h"
8
9static struct viewport default_vp =
10{
11 .x = 0,
12 .y = 0,
13 .width = LCD_WIDTH,
14 .height = LCD_HEIGHT,
15 .font = FONT_SYSFIXED,
16 .drawmode = DRMODE_SOLID,
17 .fg_pattern = LCD_DEFAULT_FG,
18 .bg_pattern = LCD_DEFAULT_BG,
19 .lss_pattern = LCD_DEFAULT_BG,
20 .lse_pattern = LCD_DEFAULT_BG,
21 .lst_pattern = LCD_DEFAULT_BG,
22};
23
24struct viewport* current_vp = &default_vp;
25
26void get_current_vp(struct viewport_api *avp){
27 avp->x = current_vp->x;
28 avp->y = current_vp->y;
29 avp->width = current_vp->width;
30 avp->height = current_vp->height;
31
32 //TODO: font_get(current_vp->font)->height;
33 avp->fontheight = sysfont.height;
34}
35
36void lcd_set_viewport(struct viewport* vp)
37{
38 if (vp == NULL){
39 current_vp = &default_vp;
40 DEBUGF3("lcd_set_viewport(struct viewport* vp= DEFAULT)\n");
41 }
42 else{
43 current_vp = vp;
44 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);
45 }
46}
47
48void lcd_update_viewport(void)
49{
50 //lcd_update_rect(current_vp->x, current_vp->y,current_vp->width, current_vp->height);
51}
52
53void lcd_update_viewport_rect(int x, int y, int width, int height)
54{
55 //lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height);
56}
57/*** parameter handling ***/
58
59void lcd_set_drawmode(int mode)
60{
61 current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
62}
63
64int lcd_get_drawmode(void)
65{
66 return current_vp->drawmode;
67}
68
69void lcd_set_foreground(unsigned color)
70{
71 current_vp->fg_pattern = color;
72}
73
74unsigned lcd_get_foreground(void)
75{
76 return current_vp->fg_pattern;
77}
78
79void lcd_set_background(unsigned color)
80{
81 current_vp->bg_pattern = color;
82}
83
84unsigned lcd_get_background(void)
85{
86 return current_vp->bg_pattern;
87}
88
89void lcd_set_selector_start(unsigned color)
90{
91 current_vp->lss_pattern = color;
92}
93
94void lcd_set_selector_end(unsigned color)
95{
96 current_vp->lse_pattern = color;
97}
98
99void lcd_set_selector_text(unsigned color)
100{
101 current_vp->lst_pattern = color;
102}
103
104void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color)
105{
106 //lcd_set_drawmode(mode);
107 current_vp->fg_pattern = fg_color;
108 current_vp->bg_pattern = bg_color;
109}
110
111int lcd_getwidth(void)
112{
113 return current_vp->width;
114}
115
116int lcd_getheight(void)
117{
118 return current_vp->height;
119}
120
121void lcd_setfont(int newfont)
122{
123 current_vp->font = newfont;
124}
125
126int lcd_getfont(void)
127{
128 return current_vp->font;
129}
130
131/* Clear the whole display */
132void lcd_clear_display(void)
133{
134 struct viewport* old_vp = current_vp;
135
136 current_vp = &default_vp;
137
138 lcd_clear_viewport();
139
140 current_vp = old_vp;
141}
142
143void lcd_clear_viewport(){
144 DEBUGF2("lcd_clear_viewport()\n");
145 xapi->clear_viewport(current_vp->x,current_vp->y,current_vp->width,current_vp->height,current_vp->bg_pattern);
146
147}
148void lcd_scroll_stop(struct viewport* vp){
149 DEBUGF3("lcd_scroll_stop(struct viewport* vp=%x)\n",vp);
150}
diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c
new file mode 100644
index 0000000000..3a3b8ce4d9
--- /dev/null
+++ b/utils/wpseditor/libwps/src/proxy.c
@@ -0,0 +1,132 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include "dummies.h"
4#include "proxy.h"
5#include "api.h"
6#include "gwps.h"
7#include "gwps-common.h"
8#include <string.h>
9
10struct screen screens[NB_SCREENS];
11struct wps_data wpsdata;
12struct gui_wps gwps;
13struct mp3entry id3;
14struct mp3entry nid3;
15
16extern void test_api(struct proxy_api *api);
17
18bool debug_wps = true;
19int wps_verbose_level = 0;
20int errno_;
21pfdebugf dbgf = 0;
22
23static char pluginbuf[PLUGIN_BUFFER_SIZE];
24
25const char* get_model_name(){
26#ifdef TARGET_MODEL
27 return TARGET_MODEL;
28#else
29 return "unknown";
30#endif
31}
32
33int read_line(int fd, char* buffer, int buffer_size)
34{
35 int count = 0;
36 int num_read = 0;
37
38 errno_ = 0;
39
40 while (count < buffer_size)
41 {
42 unsigned char c;
43
44 if (1 != read(fd, &c, 1))
45 break;
46
47 num_read++;
48
49 if ( c == '\n' )
50 break;
51
52 if ( c == '\r' )
53 continue;
54
55 buffer[count++] = c;
56 }
57
58 buffer[MIN(count, buffer_size - 1)] = 0;
59
60 return errno_ ? -1 : num_read;
61}
62
63void* plugin_get_buffer(size_t *buffer_size)
64{
65 *buffer_size = PLUGIN_BUFFER_SIZE;
66 return pluginbuf;
67}
68
69int checkwps(const char *filename, int verbose){
70 int res;
71 int fd;
72
73 struct wps_data wps;
74 wps_verbose_level = verbose;
75
76 fd = open(filename, O_RDONLY);
77 if (fd < 0) {
78 DEBUGF1("Failed to open %s\n",filename);
79 return 2;
80 }
81 close(fd);
82
83 res = wps_data_load(&wps, &screens[0], filename, true);
84
85 if (!res) {
86 DEBUGF1("WPS parsing failure\n");
87 return 3;
88 }
89
90 DEBUGF1("WPS parsed OK\n");
91 return 0;
92}
93
94int wps_init(const char* filename,struct proxy_api *api, bool isfile){
95 int res;
96 if (!api)
97 return 4;
98 dummies_init();
99 test_api(api);
100 set_api(api);
101 wps_data_init(&wpsdata);
102 wps_verbose_level = api->verbose;
103 res = wps_data_load(&wpsdata, &screens[0], filename, isfile);
104 if (!res)
105 {
106 DEBUGF1("ERR: WPS parsing failure\n");
107 return 3;
108 }
109 DEBUGF1("WPS parsed OK\n");
110 DEBUGF1("\n-------------------------------------------------\n");
111 wps_state.paused = true;
112 gwps.data = &wpsdata;
113 gwps.display = &screens[0];
114 gwps.state = &wps_state;
115 gwps.state->id3 = &id3;
116 gwps.state->nid3 = &nid3;
117 gui_wps[0] = gwps;
118 return res;
119}
120
121int wps_display(){
122 DEBUGF3("wps_display(): begin\n");
123 int res = gui_wps_display();
124 DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not "));
125 return res;
126}
127int wps_refresh(){
128 DEBUGF3("-----------------<wps_refresh(): begin>-----------------\n");
129 int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL);
130 DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not "));
131 return res;
132}
diff --git a/utils/wpseditor/libwps/src/proxy.h b/utils/wpseditor/libwps/src/proxy.h
new file mode 100644
index 0000000000..3836ecc6d0
--- /dev/null
+++ b/utils/wpseditor/libwps/src/proxy.h
@@ -0,0 +1,25 @@
1#ifndef PROXY_H
2#define PROXY_h
3
4#include "screen_access.h"
5#include "api.h"
6#include "defs.h"
7
8#define DEBUGF dbgf
9#define DEBUGF1 dbgf
10#define DEBUGF2(...)
11#define DEBUGF3(...)
12
13EXPORT int checkwps(const char *filename, int verbose);
14EXPORT int wps_init(const char* filename,struct proxy_api *api,bool isfile);
15EXPORT int wps_display();
16EXPORT int wps_refresh();
17
18const char* get_model_name();
19
20extern struct screen screens[NB_SCREENS];
21extern bool debug_wps;
22extern int wps_verbose_level;
23
24
25#endif
diff --git a/utils/wpseditor/libwps/src/wpsstate.h b/utils/wpseditor/libwps/src/wpsstate.h
new file mode 100644
index 0000000000..148936a481
--- /dev/null
+++ b/utils/wpseditor/libwps/src/wpsstate.h
@@ -0,0 +1,34 @@
1#ifndef STATES_H
2#define STATES_H
3//
4struct trackstate
5{
6 char* title;
7 char* artist;
8 char* album;
9 char* genre_string;
10 char* disc_string;
11 char* track_string;
12 char* year_string;
13 char* composer;
14 char* comment;
15 char* albumartist;
16 char* grouping;
17 int discnum;
18 int tracknum;
19 int version;
20 int layer;
21 int year;
22
23 int length;
24 int elapsed;
25};
26
27struct wpsstate{
28 int volume;
29 int fontheight;
30 int fontwidth;
31 int battery_level;
32 int audio_status;
33};
34#endif
diff --git a/utils/wpseditor/libwps/targets.txt b/utils/wpseditor/libwps/targets.txt
new file mode 100644
index 0000000000..d2c54378d9
--- /dev/null
+++ b/utils/wpseditor/libwps/targets.txt
@@ -0,0 +1,33 @@
1ARCHOS_RECORDER recorder
2ARCHOS_FMRECORDER fmrecorder
3ARCHOS_RECORDERV2 recorderv2
4ARCHOS_ONDIOSP ondiosp
5ARCHOS_ONDIOFM ondiofm
6IRIVER_H120 h120
7IRIVER_H300 h300
8IRIVER_H100 h100
9IRIVER_IFP7XX ifp7xx
10IRIVER_H10 h10
11IRIVER_H10_5GB h10_5gb
12IPOD_COLOR ipodcolor
13IPOD_NANO ipodnano
14IPOD_VIDEO ipodvideo
15IPOD_3G ipod3g
16IPOD_4G ipod4g
17IPOD_MINI ipodmini
18IPOD_MINI2G ipodmini2g
19IPOD_1G2G ipod1g2g
20IAUDIO_X5 x5
21IAUDIO_M5 m5
22COWON_D2 cowond2
23IAUDIO_M3 m3
24GIGABEAT_F gigabeatf
25GIGABEAT_S gigabeats
26MROBE_500 mrobe500
27MROBE_100 mrobe100
28LOGIK_DAX logikdax
29CREATIVE_ZVM creativezvm
30SANSA_E200 e200
31SANSA_E200 e200r
32SANSA_C200 c200
33ELIO_TPJ1022 tpj1022