Use DBOP to check for left button on C200v2 like we are supposed to instead of right...
[kugel-rb.git] / tools / checkwps / checkwps.c
blob94136e02f0561106c8d6bf370064ca3323d5510d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Dave Chapman
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 <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "config.h"
26 #include "checkwps.h"
27 #include "resize.h"
28 #include "wps.h"
29 #include "skin_engine.h"
30 #include "wps_internals.h"
31 #include "settings.h"
32 #include "viewport.h"
33 #include "file.h"
34 #include "font.h"
36 bool debug_wps = true;
37 int wps_verbose_level = 0;
39 int errno;
41 const struct settings_list *settings;
42 const int nb_settings = 0;
44 /* static endianness conversion */
45 #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \
46 ((unsigned short)(x) << 8)))
48 #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \
49 (((unsigned long)(x) & 0xff0000ul) >> 8) | \
50 (((unsigned long)(x) & 0xff00ul) << 8) | \
51 ((unsigned long)(x) << 24)))
53 #ifndef letoh16
54 unsigned short letoh16(unsigned short x)
56 unsigned short n = 0x1234;
57 unsigned char* ch = (unsigned char*)&n;
59 if (*ch == 0x34)
61 /* Little-endian */
62 return x;
63 } else {
64 return SWAP_16(x);
67 #endif
69 #ifndef letoh32
70 unsigned short letoh32(unsigned short x)
72 unsigned short n = 0x1234;
73 unsigned char* ch = (unsigned char*)&n;
75 if (*ch == 0x34)
77 /* Little-endian */
78 return x;
79 } else {
80 return SWAP_32(x);
83 #endif
85 #ifndef htole32
86 unsigned int htole32(unsigned int x)
88 unsigned short n = 0x1234;
89 unsigned char* ch = (unsigned char*)&n;
91 if (*ch == 0x34)
93 /* Little-endian */
94 return x;
95 } else {
96 return SWAP_32(x);
99 #endif
101 int recalc_dimension(struct dim *dst, struct dim *src)
103 return 0;
106 #ifdef HAVE_ALBUMART
107 int playback_claim_aa_slot(struct dim *dim)
109 return 0;
112 void playback_release_aa_slot(int slot)
114 return;
116 #endif
118 int resize_on_load(struct bitmap *bm, bool dither,
119 struct dim *src, struct rowset *tmp_row,
120 unsigned char *buf, unsigned int len,
121 const struct custom_format *cformat,
122 IF_PIX_FMT(int format_index,)
123 struct img_part* (*store_part)(void *args),
124 void *args)
126 return 0;
129 static char pluginbuf[PLUGIN_BUFFER_SIZE];
131 static unsigned dummy_func2(void)
133 return 0;
136 void* plugin_get_buffer(size_t *buffer_size)
138 *buffer_size = PLUGIN_BUFFER_SIZE;
139 return pluginbuf;
142 struct user_settings global_settings = {
143 .statusbar = STATUSBAR_TOP,
144 #ifdef HAVE_LCD_COLOR
145 .bg_color = LCD_DEFAULT_BG,
146 .fg_color = LCD_DEFAULT_FG,
147 #endif
150 int getwidth(void) { return LCD_WIDTH; }
151 int getheight(void) { return LCD_HEIGHT; }
152 #ifdef HAVE_REMOTE_LCD
153 int remote_getwidth(void) { return LCD_REMOTE_WIDTH; }
154 int remote_getheight(void) { return LCD_REMOTE_HEIGHT; }
155 #endif
157 static inline bool backdrop_load(const char *filename, char* backdrop_buffer)
159 (void)filename; (void)backdrop_buffer; return true;
162 struct screen screens[NB_SCREENS] =
165 .screen_type=SCREEN_MAIN,
166 .lcdwidth=LCD_WIDTH,
167 .lcdheight=LCD_HEIGHT,
168 .depth=LCD_DEPTH,
169 #ifdef HAVE_LCD_COLOR
170 .is_color=true,
171 #else
172 .is_color=false,
173 #endif
174 .getwidth = getwidth,
175 .getheight = getheight,
176 #if LCD_DEPTH > 1
177 .get_foreground=dummy_func2,
178 .get_background=dummy_func2,
179 .backdrop_load=backdrop_load,
180 #endif
182 #ifdef HAVE_REMOTE_LCD
184 .screen_type=SCREEN_REMOTE,
185 .lcdwidth=LCD_REMOTE_WIDTH,
186 .lcdheight=LCD_REMOTE_HEIGHT,
187 .depth=LCD_REMOTE_DEPTH,
188 .is_color=false,/* No color remotes yet */
189 .getwidth=remote_getwidth,
190 .getheight=remote_getheight,
191 #if LCD_REMOTE_DEPTH > 1
192 .get_foreground=dummy_func2,
193 .get_background=dummy_func2,
194 .backdrop_load=backdrop_load,
195 #endif
197 #endif
200 #ifdef HAVE_LCD_BITMAP
201 void screen_clear_area(struct screen * display, int xstart, int ystart,
202 int width, int height)
204 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
205 display->fillrect(xstart, ystart, width, height);
206 display->set_drawmode(DRMODE_SOLID);
208 #endif
210 #if CONFIG_TUNER
211 bool radio_hardware_present(void)
213 return true;
215 #endif
217 #ifdef HAVE_LCD_BITMAP
218 static int loaded_fonts = 0;
219 int font_load(struct font* pf, const char *path)
221 int id = SYSTEMFONTCOUNT + loaded_fonts;
222 loaded_fonts++;
223 return id;
226 void font_unload(int font_id)
228 (void)font_id;
230 #endif
232 int main(int argc, char **argv)
234 int res;
235 int filearg = 1;
237 struct wps_data wps;
238 enum screen_type screen = SCREEN_MAIN;
239 struct screen* wps_screen;
241 /* No arguments -> print the help text
242 * Also print the help text upon -h or --help */
243 if( (argc < 2) ||
244 strcmp(argv[1],"-h") == 0 ||
245 strcmp(argv[1],"--help") == 0 )
247 printf("Usage: checkwps [OPTIONS] filename.wps [filename2.wps]...\n");
248 printf("\nOPTIONS:\n");
249 printf("\t-v\t\tverbose\n");
250 printf("\t-vv\t\tmore verbose\n");
251 printf("\t-vvv\t\tvery verbose\n");
252 printf("\t-h,\t--help\tshow this message\n");
253 return 1;
256 if (argv[1][0] == '-') {
257 filearg++;
258 int i = 1;
259 while (argv[1][i] && argv[1][i] == 'v') {
260 i++;
261 wps_verbose_level++;
265 skin_buffer_init();
266 #ifdef HAVE_LCD_BITMAP
267 skin_font_init();
268 #endif
270 /* Go through every wps that was thrown at us, error out at the first
271 * flawed wps */
272 while (argv[filearg]) {
273 printf("Checking %s...\n", argv[filearg]);
274 #ifdef HAVE_REMOTE_LCD
275 if((strcmp(&argv[filearg][strlen(argv[filearg])-4], "rwps") == 0) ||
276 (strcmp(&argv[filearg][strlen(argv[filearg])-4], "rsbs") == 0) ||
277 (strcmp(&argv[filearg][strlen(argv[filearg])-4], "rfms") == 0))
278 screen = SCREEN_REMOTE;
279 else
280 screen = SCREEN_MAIN;
281 #endif
282 wps_screen = &screens[screen];
284 res = skin_data_load(screen, &wps, argv[filearg], true);
286 if (!res) {
287 printf("WPS parsing failure\n");
288 return 3;
291 printf("WPS parsed OK\n\n");
292 filearg++;
294 return 0;