Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

- Move uisimulator/sdl/*.[ch] into the target tree, under firmware/target/hosted/sdl, uisdl.c is split up across button-sdl.c and system-sdl.c. - Refactor the program startup. main() is now in main.c like on target, and the implicit application thread will now act as our main thread (previously a separate one was created for this in thread initialization).

This is part of Rockbox as an application and is the first step to make an application port from the uisimulator. In a further step the sim bits from the sdl build will be separated out.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26065 a1c6a512-1295-4272-9138-f99709370657

+698 -816
+10 -3
apps/main.c
··· 124 124 125 125 static void init(void); 126 126 127 - #ifdef SIMULATOR 128 - void app_main(void) 127 + #ifdef HAVE_SDL 128 + #if defined(WIN32) && defined(main) 129 + /* Don't use SDL_main on windows -> no more stdio redirection */ 130 + #undef main 131 + #endif 132 + int main(int argc, char *argv[]) 133 + { 134 + sys_handle_argv(argc, argv); 129 135 #else 130 136 /* main(), and various functions called by main() and init() may be 131 137 * be INIT_ATTR. These functions must not be called after the final call ··· 133 139 * see definition of INIT_ATTR in config.h */ 134 140 int main(void) INIT_ATTR __attribute__((noreturn)); 135 141 int main(void) 136 - #endif 137 142 { 143 + #endif 138 144 int i; 139 145 CHART(">init"); 140 146 init(); ··· 313 319 314 320 static void init(void) 315 321 { 322 + system_init(); 316 323 kernel_init(); 317 324 buffer_init(); 318 325 enable_irq();
+21
firmware/SOURCES
··· 18 18 thread.c 19 19 timer.c 20 20 #endif /* SIMULATOR */ 21 + #ifdef HAVE_SDL 22 + target/hosted/sdl/button-sdl.c 23 + target/hosted/sdl/kernel-sdl.c 24 + #ifdef HAVE_LCD_BITMAP 25 + target/hosted/sdl/lcd-bitmap.c 26 + #elif defined(HAVE_LCD_CHARCELLS) 27 + target/hosted/sdl/lcd-charcells.c 28 + #endif 29 + #ifdef HAVE_REMOTE_LCD 30 + target/hosted/sdl/lcd-remote-bitmap.c 31 + #endif 32 + target/hosted/sdl/lcd-sdl.c 33 + target/hosted/sdl/system-sdl.c 34 + target/hosted/sdl/thread-sdl.c 35 + target/hosted/sdl/timer-sdl.c 36 + #endif 21 37 panic.c 22 38 debug.c 23 39 ··· 292 308 #elif defined(HAVE_UDA1341) 293 309 drivers/audio/uda1341.c 294 310 #endif /* defined(HAVE_*) */ 311 + #elif defined(HAVE_SDL_AUDIO) 312 + drivers/audio/sdl.c 313 + #if CONFIG_CODEC == SWCODEC 314 + target/hosted/sdl/pcm-sdl.c 315 + #endif 295 316 #endif /* !defined(SIMULATOR) && !defined(BOOTLOADER) */ 296 317 297 318 /* USB Stack */
+186
firmware/drivers/audio/sdl.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright © 2010 Thomas Martitz 11 + * 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. 16 + * 17 + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 + * KIND, either express or implied. 19 + * 20 + ****************************************************************************/ 21 + 22 + #include <SDL_audio.h> 23 + #include "config.h" 24 + #include "audiohw.h" 25 + 26 + /** 27 + * Audio Hardware api. Make them do nothing as we cannot properly simulate with 28 + * SDL. if we used DSP we would run code that doesn't actually run on the target 29 + **/ 30 + 31 + extern void pcm_set_mixer_volume(int); 32 + 33 + void audiohw_set_volume(int volume) 34 + { 35 + #if CONFIG_CODEC == SWCODEC 36 + pcm_set_mixer_volume( 37 + SDL_MIX_MAXVOLUME * ((volume - VOLUME_MIN) / 10) / (VOLUME_RANGE / 10)); 38 + #else 39 + (void)volume; 40 + #endif 41 + } 42 + 43 + const struct sound_settings_info audiohw_settings[] = { 44 + [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25}, 45 + /* Bass and treble tone controls */ 46 + #ifdef AUDIOHW_HAVE_BASS 47 + [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, 48 + #endif 49 + #ifdef AUDIOHW_HAVE_TREBLE 50 + [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, 51 + #endif 52 + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, 53 + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, 54 + [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, 55 + #if defined(HAVE_RECORDING) 56 + [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, 57 + [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, 58 + [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, 59 + #endif 60 + #if defined(AUDIOHW_HAVE_BASS_CUTOFF) 61 + [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1}, 62 + #endif 63 + #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF) 64 + [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1}, 65 + #endif 66 + #if defined(AUDIOHW_HAVE_DEPTH_3D) 67 + [SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0}, 68 + #endif 69 + /* Hardware EQ tone controls */ 70 + #if defined(AUDIOHW_HAVE_EQ_BAND1) 71 + [SOUND_EQ_BAND1_GAIN] = {"dB", 0, 1, -12, 12, 0}, 72 + #endif 73 + #if defined(AUDIOHW_HAVE_EQ_BAND2) 74 + [SOUND_EQ_BAND2_GAIN] = {"dB", 0, 1, -12, 12, 0}, 75 + #endif 76 + #if defined(AUDIOHW_HAVE_EQ_BAND3) 77 + [SOUND_EQ_BAND3_GAIN] = {"dB", 0, 1, -12, 12, 0}, 78 + #endif 79 + #if defined(AUDIOHW_HAVE_EQ_BAND4) 80 + [SOUND_EQ_BAND4_GAIN] = {"dB", 0, 1, -12, 12, 0}, 81 + #endif 82 + #if defined(AUDIOHW_HAVE_EQ_BAND5) 83 + [SOUND_EQ_BAND5_GAIN] = {"dB", 0, 1, -12, 12, 0}, 84 + #endif 85 + #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY) 86 + [SOUND_EQ_BAND1_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 87 + #endif 88 + #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY) 89 + [SOUND_EQ_BAND2_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 90 + #endif 91 + #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY) 92 + [SOUND_EQ_BAND3_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 93 + #endif 94 + #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY) 95 + [SOUND_EQ_BAND4_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 96 + #endif 97 + #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY) 98 + [SOUND_EQ_BAND5_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 99 + #endif 100 + #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH) 101 + [SOUND_EQ_BAND2_WIDTH] = {"", 0, 1, 0, 1, 0}, 102 + #endif 103 + #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH) 104 + [SOUND_EQ_BAND3_WIDTH] = {"", 0, 1, 0, 1, 0}, 105 + #endif 106 + #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH) 107 + [SOUND_EQ_BAND4_WIDTH] = {"", 0, 1, 0, 1, 0}, 108 + #endif 109 + 110 + #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 111 + [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0}, 112 + [SOUND_AVC] = {"", 0, 1, -1, 4, 0}, 113 + [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48}, 114 + [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50}, 115 + [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60}, 116 + [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, 117 + [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, 118 + [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, 119 + #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ 120 + }; 121 + 122 + /** 123 + * stubs here, for the simulator 124 + **/ 125 + 126 + #if defined(AUDIOHW_HAVE_PRESCALER) 127 + void audiohw_set_prescaler(int value) { (void)value; } 128 + #endif 129 + #if defined(AUDIOHW_HAVE_BALANCE) 130 + void audiohw_set_balance(int value) { (void)value; } 131 + #endif 132 + #if defined(AUDIOHW_HAVE_BASS) 133 + void audiohw_set_bass(int value) { (void)value; } 134 + #endif 135 + #if defined(AUDIOHW_HAVE_TREBLE) 136 + void audiohw_set_treble(int value) { (void)value; } 137 + #endif 138 + #if CONFIG_CODEC != SWCODEC 139 + void audiohw_set_channel(int value) { (void)value; } 140 + void audiohw_set_stereo_width(int value){ (void)value; } 141 + #endif 142 + #if defined(AUDIOHW_HAVE_BASS_CUTOFF) 143 + void audiohw_set_bass_cutoff(int value) { (void)value; } 144 + #endif 145 + #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF) 146 + void audiohw_set_treble_cutoff(int value){ (void)value; } 147 + #endif 148 + /* EQ-based tone controls */ 149 + #if defined(AUDIOHW_HAVE_EQ) 150 + void audiohw_set_eq_band_gain(unsigned int band, int value) 151 + { (void)band; (void)value; } 152 + #endif 153 + #if defined(AUDIOHW_HAVE_EQ_FREQUENCY) 154 + void audiohw_set_eq_band_frequency(unsigned int band, int value) 155 + { (void)band; (void)value; } 156 + #endif 157 + #if defined(AUDIOHW_HAVE_EQ_WIDTH) 158 + void audiohw_set_eq_band_width(unsigned int band, int value) 159 + { (void)band; (void)value; } 160 + #endif 161 + #if defined(AUDIOHW_HAVE_DEPTH_3D) 162 + void audiohw_set_depth_3d(int value) 163 + { (void)value; } 164 + #endif 165 + #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 166 + int mas_codec_readreg(int reg) 167 + { 168 + (void)reg; 169 + return 0; 170 + } 171 + 172 + int mas_codec_writereg(int reg, unsigned int val) 173 + { 174 + (void)reg; 175 + (void)val; 176 + return 0; 177 + } 178 + int mas_writemem(int bank, int addr, const unsigned long* src, int len) 179 + { 180 + (void)bank; 181 + (void)addr; 182 + (void)src; 183 + (void)len; 184 + return 0; 185 + } 186 + #endif
+4 -5
firmware/drivers/button.c
··· 429 429 tick_add_task(button_tick); 430 430 } 431 431 432 - #ifndef SIMULATOR 433 432 #ifdef BUTTON_DRIVER_CLOSE 434 433 void button_close(void) 435 434 { ··· 443 442 */ 444 443 static int button_flip(int button) 445 444 { 446 - int newbutton; 445 + int newbutton = button; 447 446 448 - newbutton = button & 447 + #ifndef SIMULATOR 448 + newbutton &= 449 449 ~(BUTTON_LEFT | BUTTON_RIGHT 450 450 #if defined(BUTTON_UP) && defined(BUTTON_DOWN) 451 451 | BUTTON_UP | BUTTON_DOWN ··· 503 503 if (button & BUTTON_PREV) 504 504 newbutton |= BUTTON_NEXT; 505 505 #endif 506 - 506 + #endif /* !SIMULATOR */ 507 507 return newbutton; 508 508 } 509 509 ··· 523 523 } 524 524 } 525 525 #endif /* HAVE_LCD_FLIP */ 526 - #endif /* SIMULATOR */ 527 526 528 527 #ifdef HAVE_BACKLIGHT 529 528 void set_backlight_filter_keypress(bool value)
+5 -1
firmware/export/audiohw.h
··· 66 66 #elif defined(HAVE_AK4537) 67 67 #include "ak4537.h" 68 68 #endif 69 + #if defined(HAVE_SDL_AUDIO) 70 + /* #include <SDL_audio.h> gives errors in other code areas, 71 + * we don't really need it here, so don't. but it should maybe be fixed */ 72 + #endif 69 73 70 74 71 75 ··· 369 373 */ 370 374 void audiohw_close(void); 371 375 372 - #ifdef AUDIOHW_HAVE_CLIPPING 376 + #if defined(AUDIOHW_HAVE_CLIPPING) || defined(HAVE_SDL_AUDIO) 373 377 /** 374 378 * Set new volume value 375 379 * @param val to set.
+4
firmware/export/config/sim.h
··· 80 80 81 81 #undef HAVE_SPEAKER 82 82 83 + #undef BUTTON_DRIVER_CLOSE 84 + 83 85 #if CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG 84 86 #undef CONFIG_BACKLIGHT_FADING 85 87 /* simulate SW_SETTING, as we handle sdl very similary */ ··· 97 99 #define DEFAULT_BRIGHTNESS_SETTING MAX_BRIGHTNESS_SETTING 98 100 #endif 99 101 102 + #define HAVE_SDL 103 + #define HAVE_SDL_AUDIO 100 104 #define _ISOC99_SOURCE 1
+1
firmware/export/system.h
··· 235 235 #if !defined(SIMULATOR) && !defined(__PCTOOL__) 236 236 #include "system-target.h" 237 237 #else /* SIMULATOR */ 238 + #include "system-sdl.h" 238 239 static inline uint16_t swap16(uint16_t value) 239 240 /* 240 241 result[15..8] = value[ 7..0];
+1 -4
firmware/kernel.c
··· 22 22 #include <string.h> 23 23 #include "config.h" 24 24 #include "kernel.h" 25 - #ifdef SIMULATOR 26 - #include "system-sdl.h" 27 - #include "debug.h" 28 - #endif 29 25 #include "thread.h" 30 26 #include "cpu.h" 31 27 #include "system.h" 32 28 #include "panic.h" 29 + #include "debug.h" 33 30 34 31 /* Make this nonzero to enable more elaborate checks on objects */ 35 32 #if defined(DEBUG) || defined(SIMULATOR)
+2 -1
firmware/libc/include/stdlib.h
··· 29 29 void *calloc (size_t nmemb, size_t size); 30 30 void free(void *); 31 31 void *realloc(void *, size_t); 32 + int atexit(void (*)(void)); 32 33 33 34 #define RAND_MAX INT_MAX 34 35 ··· 51 52 #endif 52 53 53 54 int atoi (const char *str); 54 - 55 + 55 56 #ifdef __cplusplus 56 57 } 57 58 #endif
+1 -84
firmware/sound.c
··· 43 43 44 44 extern bool audio_is_initialized; 45 45 46 - #ifdef SIMULATOR 47 - extern void audiohw_set_volume(int value); 48 - /* dummy for sim */ 49 - const struct sound_settings_info audiohw_settings[] = { 50 - [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25}, 51 - /* Bass and treble tone controls */ 52 - #ifdef AUDIOHW_HAVE_BASS 53 - [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, 54 - #endif 55 - #ifdef AUDIOHW_HAVE_TREBLE 56 - [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, 57 - #endif 58 - [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, 59 - [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, 60 - [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, 61 - #if defined(HAVE_RECORDING) 62 - [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, 63 - [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, 64 - [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, 65 - #endif 66 - #if defined(AUDIOHW_HAVE_BASS_CUTOFF) 67 - [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1}, 68 - #endif 69 - #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF) 70 - [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1}, 71 - #endif 72 - #if defined(AUDIOHW_HAVE_DEPTH_3D) 73 - [SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0}, 74 - #endif 75 - /* Hardware EQ tone controls */ 76 - #if defined(AUDIOHW_HAVE_EQ_BAND1) 77 - [SOUND_EQ_BAND1_GAIN] = {"dB", 0, 1, -12, 12, 0}, 78 - #endif 79 - #if defined(AUDIOHW_HAVE_EQ_BAND2) 80 - [SOUND_EQ_BAND2_GAIN] = {"dB", 0, 1, -12, 12, 0}, 81 - #endif 82 - #if defined(AUDIOHW_HAVE_EQ_BAND3) 83 - [SOUND_EQ_BAND3_GAIN] = {"dB", 0, 1, -12, 12, 0}, 84 - #endif 85 - #if defined(AUDIOHW_HAVE_EQ_BAND4) 86 - [SOUND_EQ_BAND4_GAIN] = {"dB", 0, 1, -12, 12, 0}, 87 - #endif 88 - #if defined(AUDIOHW_HAVE_EQ_BAND5) 89 - [SOUND_EQ_BAND5_GAIN] = {"dB", 0, 1, -12, 12, 0}, 90 - #endif 91 - #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY) 92 - [SOUND_EQ_BAND1_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 93 - #endif 94 - #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY) 95 - [SOUND_EQ_BAND2_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 96 - #endif 97 - #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY) 98 - [SOUND_EQ_BAND3_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 99 - #endif 100 - #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY) 101 - [SOUND_EQ_BAND4_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 102 - #endif 103 - #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY) 104 - [SOUND_EQ_BAND5_FREQUENCY] = {"", 0, 1, 1, 4, 1}, 105 - #endif 106 - #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH) 107 - [SOUND_EQ_BAND2_WIDTH] = {"", 0, 1, 0, 1, 0}, 108 - #endif 109 - #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH) 110 - [SOUND_EQ_BAND3_WIDTH] = {"", 0, 1, 0, 1, 0}, 111 - #endif 112 - #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH) 113 - [SOUND_EQ_BAND4_WIDTH] = {"", 0, 1, 0, 1, 0}, 114 - #endif 115 - 116 - #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 117 - [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0}, 118 - [SOUND_AVC] = {"", 0, 1, -1, 4, 0}, 119 - [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48}, 120 - [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50}, 121 - [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60}, 122 - [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, 123 - [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, 124 - [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, 125 - #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ 126 - }; 127 - #endif 128 - 129 46 const char *sound_unit(int setting) 130 47 { 131 48 return audiohw_settings[setting].unit; ··· 356 273 357 274 #elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985) 358 275 audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r)); 359 - #elif defined(HAVE_JZ4740_CODEC) 276 + #elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) 360 277 audiohw_set_volume(current_volume); 361 278 #endif 362 279 #else /* SIMULATOR */
+236
firmware/target/hosted/sdl/system-sdl.c
··· 1 + /*************************************************************************** 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 + * $Id$ 9 + * 10 + * Copyright (C) 2006 by Daniel Everton <dan@iocaine.org> 11 + * 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. 16 + * 17 + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 + * KIND, either express or implied. 19 + * 20 + ****************************************************************************/ 21 + 22 + #include <SDL.h> 23 + #include <stdlib.h> 24 + #include <string.h> 25 + #include <setjmp.h> 26 + #include "system-sdl.h" 27 + #include "thread-sdl.h" 28 + #include "sim-ui-defines.h" 29 + #include "lcd-sdl.h" 30 + #ifdef HAVE_LCD_BITMAP 31 + #include "lcd-bitmap.h" 32 + #elif defined(HAVE_LCD_CHARCELLS) 33 + #include "lcd-charcells.h" 34 + #endif 35 + #ifdef HAVE_REMOTE_LCD 36 + #include "lcd-remote-bitmap.h" 37 + #endif 38 + #include "panic.h" 39 + #include "debug.h" 40 + 41 + SDL_Surface *gui_surface; 42 + 43 + bool background = true; /* use backgrounds by default */ 44 + #ifdef HAVE_REMOTE_LCD 45 + bool showremote = true; /* include remote by default */ 46 + #endif 47 + bool mapping = false; 48 + bool debug_buttons = false; 49 + 50 + bool lcd_display_redraw = true; /* Used for player simulator */ 51 + char having_new_lcd = true; /* Used for player simulator */ 52 + bool sim_alarm_wakeup = false; 53 + const char *sim_root_dir = NULL; 54 + extern int display_zoom; 55 + 56 + #ifdef DEBUG 57 + bool debug_audio = false; 58 + #endif 59 + 60 + bool debug_wps = false; 61 + int wps_verbose_level = 3; 62 + 63 + 64 + void sys_poweroff(void) 65 + { 66 + /* Order here is relevent to prevent deadlocks and use of destroyed 67 + sync primitives by kernel threads */ 68 + sim_thread_shutdown(); 69 + sim_kernel_shutdown(); 70 + SDL_Quit(); 71 + } 72 + 73 + void system_init(void) 74 + { 75 + SDL_Surface *picture_surface; 76 + int width, height; 77 + 78 + if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)) 79 + panicf("%s", SDL_GetError()); 80 + 81 + /* Try and load the background image. If it fails go without */ 82 + if (background) { 83 + picture_surface = SDL_LoadBMP("UI256.bmp"); 84 + if (picture_surface == NULL) { 85 + background = false; 86 + DEBUGF("warn: %s\n", SDL_GetError()); 87 + } 88 + } 89 + 90 + /* Set things up */ 91 + if (background) 92 + { 93 + width = UI_WIDTH; 94 + height = UI_HEIGHT; 95 + } 96 + else 97 + { 98 + #ifdef HAVE_REMOTE_LCD 99 + if (showremote) 100 + { 101 + width = SIM_LCD_WIDTH > SIM_REMOTE_WIDTH ? SIM_LCD_WIDTH : SIM_REMOTE_WIDTH; 102 + height = SIM_LCD_HEIGHT + SIM_REMOTE_HEIGHT; 103 + } 104 + else 105 + #endif 106 + { 107 + width = SIM_LCD_WIDTH; 108 + height = SIM_LCD_HEIGHT; 109 + } 110 + } 111 + 112 + 113 + if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) { 114 + panicf("%s", SDL_GetError()); 115 + } 116 + 117 + SDL_WM_SetCaption(UI_TITLE, NULL); 118 + 119 + sim_lcd_init(); 120 + #ifdef HAVE_REMOTE_LCD 121 + if (showremote) 122 + sim_lcd_remote_init(); 123 + #endif 124 + 125 + if (background && picture_surface != NULL) { 126 + SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); 127 + SDL_UpdateRect(gui_surface, 0, 0, 0, 0); 128 + } 129 + } 130 + 131 + void system_exception_wait(void) 132 + { 133 + sim_thread_exception_wait(); 134 + } 135 + 136 + void system_reboot(void) 137 + { 138 + sim_thread_exception_wait(); 139 + } 140 + 141 + void sys_handle_argv(int argc, char *argv[]) 142 + { 143 + if (argc >= 1) 144 + { 145 + int x; 146 + for (x = 1; x < argc; x++) 147 + { 148 + #ifdef DEBUG 149 + if (!strcmp("--debugaudio", argv[x])) 150 + { 151 + debug_audio = true; 152 + printf("Writing debug audio file.\n"); 153 + } 154 + else 155 + #endif 156 + if (!strcmp("--debugwps", argv[x])) 157 + { 158 + debug_wps = true; 159 + printf("WPS debug mode enabled.\n"); 160 + } 161 + else if (!strcmp("--nobackground", argv[x])) 162 + { 163 + background = false; 164 + printf("Disabling background image.\n"); 165 + } 166 + #ifdef HAVE_REMOTE_LCD 167 + else if (!strcmp("--noremote", argv[x])) 168 + { 169 + showremote = false; 170 + background = false; 171 + printf("Disabling remote image.\n"); 172 + } 173 + #endif 174 + else if (!strcmp("--old_lcd", argv[x])) 175 + { 176 + having_new_lcd = false; 177 + printf("Using old LCD layout.\n"); 178 + } 179 + else if (!strcmp("--zoom", argv[x])) 180 + { 181 + x++; 182 + if(x < argc) 183 + display_zoom=atoi(argv[x]); 184 + else 185 + display_zoom = 2; 186 + printf("Window zoom is %d\n", display_zoom); 187 + } 188 + else if (!strcmp("--alarm", argv[x])) 189 + { 190 + sim_alarm_wakeup = true; 191 + printf("Simulating alarm wakeup.\n"); 192 + } 193 + else if (!strcmp("--root", argv[x])) 194 + { 195 + x++; 196 + if (x < argc) 197 + { 198 + sim_root_dir = argv[x]; 199 + printf("Root directory: %s\n", sim_root_dir); 200 + } 201 + } 202 + else if (!strcmp("--mapping", argv[x])) 203 + { 204 + mapping = true; 205 + printf("Printing click coords with drag radii.\n"); 206 + } 207 + else if (!strcmp("--debugbuttons", argv[x])) 208 + { 209 + debug_buttons = true; 210 + printf("Printing background button clicks.\n"); 211 + } 212 + else 213 + { 214 + printf("rockboxui\n"); 215 + printf("Arguments:\n"); 216 + #ifdef DEBUG 217 + printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n"); 218 + #endif 219 + printf(" --debugwps \t Print advanced WPS debug info\n"); 220 + printf(" --nobackground \t Disable the background image\n"); 221 + #ifdef HAVE_REMOTE_LCD 222 + printf(" --noremote \t Disable the remote image (will disable backgrounds)\n"); 223 + #endif 224 + printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); 225 + printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n"); 226 + printf(" --alarm \t Simulate a wake-up on alarm\n"); 227 + printf(" --root [DIR]\t Set root directory\n"); 228 + printf(" --mapping \t Output coordinates and radius for mapping backgrounds\n"); 229 + exit(0); 230 + } 231 + } 232 + } 233 + if (display_zoom > 1) { 234 + background = false; 235 + } 236 + }
+4
tools/configure
··· 2973 2973 2974 2974 if test -n "$t_cpu"; then 2975 2975 TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model" 2976 + if [ "$simulator" = "yes" ]; then # a few more includes for the sim target tree 2977 + TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/" 2978 + TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/" 2979 + fi 2976 2980 TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer" 2977 2981 TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu" 2978 2982 GCCOPTS="$GCCOPTS"
+2 -2
uisimulator/common/io.c
··· 233 233 { 234 234 /* Allow other rockbox threads to run */ 235 235 io.accum = 0; 236 - mythread = thread_sdl_thread_unlock(); 236 + mythread = sim_thread_unlock(); 237 237 } 238 238 239 239 switch (cmd) ··· 249 249 /* Regain our status as current */ 250 250 if (mythread != NULL) 251 251 { 252 - thread_sdl_thread_lock(mythread); 252 + sim_thread_lock(mythread); 253 253 } 254 254 255 255 return result;
-4
uisimulator/common/powermgmt-sim.c
··· 157 157 { 158 158 } 159 159 160 - void sys_poweroff(void) 161 - { 162 - } 163 - 164 160 void cancel_shutdown(void) 165 161 { 166 162 }
-16
uisimulator/common/stubs.c
··· 314 314 (void)enabled; 315 315 } 316 316 317 - void button_set_flip(bool yesno) 318 - { 319 - (void)yesno; 320 - } 321 - 322 317 #ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING 323 318 void touchpad_set_sensitivity(int level) 324 319 { 325 320 (void)level; 326 321 } 327 322 #endif 328 - 329 - void system_exception_wait(void) 330 - { 331 - thread_sdl_exception_wait(); 332 - } 333 - 334 - void system_reboot(void) 335 - { 336 - thread_sdl_exception_wait(); 337 - } 338 -
-64
uisimulator/sdl/Makefile
··· 1 - ############################################################################ 2 - # __________ __ ___. 3 - # Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - # \/ \/ \/ \/ \/ 8 - # $Id$ 9 - # 10 - # Copyright (C) 2002, 2008 by Daniel Stenberg <daniel@haxx.se> 11 - # 12 - # All files in this archive are subject to the GNU General Public License. 13 - # See the file COPYING in the source tree root for full license agreement. 14 - # 15 - # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 16 - # KIND, either express or implied. 17 - # 18 - ############################################################################ 19 - 20 - SIMCOMMON = ../common 21 - 22 - DEPFILE = $(OBJDIR)/dep-sim 23 - 24 - RM = rm -f 25 - DEBUG = -g 26 - 27 - # Use this for simulator-only files 28 - INCLUDES = -I. -I$(SIMCOMMON) -I$(OBJDIR) $(TARGET_INC) -I$(FIRMDIR)/export \ 29 - -I$(APPSDIR) -I$(BUILDDIR) 30 - 31 - # This sets up 'SRC' based on the files mentioned in SOURCES 32 - include $(TOOLSDIR)/makesrc.inc 33 - 34 - OBJS := $(SRC:%.c=$(OBJDIR)/%.o) 35 - 36 - DEFINES := -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \ 37 - $(TARGET) -DAPPSVERSION=\"$(VERSION)\" -DMEM=${MEMORYSIZE} $(EXTRA_DEFINES) 38 - 39 - SOURCES = $(SRC) 40 - 41 - DIRS = . 42 - 43 - CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS) -W -Wall 44 - 45 - OUTFILE = $(BUILDDIR)/libsim.a 46 - 47 - all: $(OUTFILE) 48 - 49 - include $(TOOLSDIR)/make.inc 50 - 51 - $(OUTFILE): $(OBJS) $(BUILDDIR)/UI256.bmp 52 - $(call PRINTS,AR+RANLIB $(@F))$(AR) ruv $@ $(OBJS) >/dev/null 2>&1 53 - $(SILENT)$(RANLIB) $@ 54 - 55 - clean: 56 - $(call PRINTS,cleaning sim)$(RM) $(OBJS) *~ core $(OUTFILE) $(DEPFILE) \ 57 - $(BUILDDIR)/UI256.bmp $(DEPFILE) 58 - $(SILENT)$(MAKE) -C $(SIMCOMMON) clean 59 - 60 - ################## Specific dependencies ################## 61 - $(BUILDDIR)/UI256.bmp: UI-$(MODELNAME).bmp 62 - $(call PRINTS,UI)cp $< $@ 63 - 64 - -include $(DEPFILE)
-6
uisimulator/sdl/README
··· 1 - To build: 2 - 3 - $ ../tools/configure 4 - [answer questions] 5 - $ make 6 - $ ./rockboxui
-15
uisimulator/sdl/SOURCES
··· 1 - button.c 2 - kernel-sdl.c 3 - #ifdef HAVE_LCD_BITMAP 4 - lcd-bitmap.c 5 - #elif defined(HAVE_LCD_CHARCELLS) 6 - lcd-charcells.c 7 - #endif 8 - #ifdef HAVE_REMOTE_LCD 9 - lcd-remote-bitmap.c 10 - #endif 11 - lcd-sdl.c 12 - sound.c 13 - timer.c 14 - thread-sdl.c 15 - uisdl.c
-46
uisimulator/sdl/button-sdl.h
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 10 - * Copyright (C) 2009 by Thomas Martitz 11 - * 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. 16 - * 17 - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 - * KIND, either express or implied. 19 - * 20 - ****************************************************************************/ 21 - 22 - 23 - #ifndef _BUTTON_SDL_H_ 24 - #define _BUTTON_SDL_H_ 25 - 26 - #include <stdbool.h> 27 - #include "config.h" 28 - #include "button-target.h" 29 - 30 - #undef HAVE_LCD_FLIP 31 - 32 - #undef button_init_device 33 - #define button_init_device() 34 - 35 - struct button_map { 36 - int button, x, y, radius; 37 - char *description; 38 - }; 39 - 40 - int xy2button( int x, int y); 41 - bool button_hold(void); 42 - void button_init_sdl(void); 43 - #undef button_init_device 44 - #define button_init_device() button_init_sdl() 45 - 46 - #endif
+116 -5
uisimulator/sdl/button.c firmware/target/hosted/sdl/button-sdl.c
··· 19 19 * 20 20 ****************************************************************************/ 21 21 22 - #include "uisdl.h" 22 + #include <math.h> 23 + #include "sim-ui-defines.h" 23 24 #include "lcd-charcells.h" 24 25 #include "lcd-remote.h" 25 26 #include "config.h" ··· 61 62 } 62 63 #endif 63 64 65 + static int xy2button(int x, int y); 66 + 64 67 struct event_queue button_queue; 65 68 66 69 static int btn = 0; /* Hopefully keeps track of currently pressed keys... */ ··· 78 81 return remote_hold_button_state; 79 82 } 80 83 #endif 84 + static void button_event(int key, bool pressed); 85 + extern bool debug_wps; 86 + extern bool mapping; 87 + static void gui_message_loop(void) 88 + { 89 + SDL_Event event; 90 + static int x,y,xybutton = 0; 81 91 82 - void button_event(int key, bool pressed) 92 + if (SDL_PollEvent(&event)) 93 + { 94 + switch(event.type) 95 + { 96 + case SDL_KEYDOWN: 97 + button_event(event.key.keysym.sym, true); 98 + break; 99 + case SDL_KEYUP: 100 + button_event(event.key.keysym.sym, false); 101 + case SDL_MOUSEBUTTONDOWN: 102 + switch ( event.button.button ) { 103 + #ifdef HAVE_SCROLLWHEEL 104 + case SDL_BUTTON_WHEELUP: 105 + button_event( SDLK_UP, true ); 106 + break; 107 + case SDL_BUTTON_WHEELDOWN: 108 + button_event( SDLK_DOWN, true ); 109 + break; 110 + #endif 111 + case SDL_BUTTON_LEFT: 112 + case SDL_BUTTON_MIDDLE: 113 + if ( mapping && background ) { 114 + x = event.button.x; 115 + y = event.button.y; 116 + } 117 + if ( background ) { 118 + xybutton = xy2button( event.button.x, event.button.y ); 119 + if( xybutton ) 120 + button_event( xybutton, true ); 121 + } 122 + break; 123 + default: 124 + break; 125 + } 126 + 127 + if (debug_wps && event.button.button == 1) 128 + { 129 + if ( background ) 130 + #ifdef HAVE_REMOTE 131 + if ( event.button.y < UI_REMOTE_POSY ) /* Main Screen */ 132 + printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 ); 133 + else 134 + printf("Mouse at: (%d, %d)\n", event.button.x - UI_REMOTE_POSX -1 , event.button.y - UI_REMOTE_POSY - 1 ); 135 + #else 136 + printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 ); 137 + #endif 138 + else 139 + if ( event.button.y/display_zoom < LCD_HEIGHT ) /* Main Screen */ 140 + printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom ); 141 + #ifdef HAVE_REMOTE 142 + else 143 + printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom - LCD_HEIGHT ); 144 + #endif 145 + } 146 + break; 147 + case SDL_MOUSEBUTTONUP: 148 + switch ( event.button.button ) { 149 + /* The scrollwheel button up events are ignored as they are queued immediately */ 150 + case SDL_BUTTON_LEFT: 151 + case SDL_BUTTON_MIDDLE: 152 + if ( mapping && background ) { 153 + printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, 154 + #define SQUARE(x) ((x)*(x)) 155 + y, (int)sqrt( SQUARE(x-(int)event.button.x) 156 + + SQUARE(y-(int)event.button.y)) ); 157 + } 158 + if ( background && xybutton ) { 159 + button_event( xybutton, false ); 160 + xybutton = 0; 161 + } 162 + #ifdef HAVE_TOUCHSCREEN 163 + else { 164 + button_event(BUTTON_TOUCHSCREEN, false); 165 + } 166 + #endif 167 + break; 168 + default: 169 + break; 170 + } 171 + break; 172 + 173 + 174 + case SDL_QUIT: 175 + { 176 + exit(EXIT_SUCCESS); 177 + break; 178 + } 179 + default: 180 + /*printf("Unhandled event\n"); */ 181 + break; 182 + } 183 + } 184 + } 185 + 186 + static void button_event(int key, bool pressed) 83 187 { 84 188 int new_btn = 0; 85 189 static bool usb_connected = false; ··· 1380 1484 int button_read_device(void) 1381 1485 { 1382 1486 #endif 1383 - 1384 1487 #ifdef HAS_BUTTON_HOLD 1385 1488 int hold_button = button_hold(); 1386 1489 ··· 1396 1499 1397 1500 if (hold_button) 1398 1501 return BUTTON_NONE; 1502 + else 1399 1503 #endif 1504 + gui_message_loop(); 1400 1505 1401 1506 return btn; 1402 1507 } ··· 1430 1535 } 1431 1536 #endif 1432 1537 1433 - void button_init_sdl(void) 1538 + void button_init_device(void) 1434 1539 { 1540 + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 1435 1541 #ifdef HAVE_TOUCHSCREEN 1436 1542 tick_add_task(mouse_tick_task); 1437 1543 #endif ··· 1441 1547 /* Run sim with --mapping to get coordinates */ 1442 1548 /* or --debugbuttons to check */ 1443 1549 /* The First matching button is returned */ 1550 + struct button_map { 1551 + int button, x, y, radius; 1552 + char *description; 1553 + }; 1444 1554 1445 1555 #ifdef SANSA_FUZE 1446 1556 struct button_map bm[] = { ··· 1892 2002 }; 1893 2003 #endif 1894 2004 1895 - int xy2button( int x, int y) { 2005 + static int xy2button( int x, int y) 2006 + { 1896 2007 int i; 1897 2008 extern bool debug_buttons; 1898 2009
+12 -5
uisimulator/sdl/kernel-sdl.c firmware/target/hosted/sdl/kernel-sdl.c
··· 20 20 ****************************************************************************/ 21 21 22 22 #include <stdlib.h> 23 + #include <stdio.h> 23 24 #include <SDL.h> 24 25 #include <SDL_thread.h> 25 26 #include "memory.h" 26 27 #include "system-sdl.h" 27 - #include "uisdl.h" 28 + #include "thread-sdl.h" 28 29 #include "kernel.h" 29 - #include "thread-sdl.h" 30 30 #include "thread.h" 31 + #include "panic.h" 31 32 #include "debug.h" 32 33 33 34 static SDL_TimerID tick_timer_id; ··· 90 91 SDL_UnlockMutex(sim_irq_mtx); 91 92 } 92 93 93 - bool sim_kernel_init(void) 94 + static bool sim_kernel_init(void) 94 95 { 95 96 sim_irq_mtx = SDL_CreateMutex(); 96 97 if (sim_irq_mtx == NULL) 97 98 { 98 - fprintf(stderr, "Cannot create sim_handler_mtx\n"); 99 + panicf("Cannot create sim_handler_mtx\n"); 99 100 return false; 100 101 } 101 102 102 103 sim_thread_cond = SDL_CreateCond(); 103 104 if (sim_thread_cond == NULL) 104 105 { 105 - fprintf(stderr, "Cannot create sim_thread_cond\n"); 106 + panicf("Cannot create sim_thread_cond\n"); 106 107 return false; 107 108 } 108 109 ··· 141 142 142 143 void tick_start(unsigned int interval_in_ms) 143 144 { 145 + if (!sim_kernel_init()) 146 + { 147 + panicf("Could not initialize kernel!"); 148 + exit(-1); 149 + } 150 + 144 151 if (tick_timer_id != NULL) 145 152 { 146 153 SDL_RemoveTimer(tick_timer_id);
+2 -1
uisimulator/sdl/lcd-bitmap.c firmware/target/hosted/sdl/lcd-bitmap.c
··· 20 20 ****************************************************************************/ 21 21 22 22 #include "debug.h" 23 - #include "uisdl.h" 23 + #include "sim-ui-defines.h" 24 + #include "system.h" 24 25 #include "lcd-sdl.h" 25 26 #include "screendump.h" 26 27
uisimulator/sdl/lcd-bitmap.h firmware/target/hosted/sdl/lcd-bitmap.h
+5 -4
uisimulator/sdl/lcd-charcells.c firmware/target/hosted/sdl/lcd-charcells.c
··· 19 19 * 20 20 ****************************************************************************/ 21 21 22 + #include <string.h> 23 + #include <unistd.h> 24 + #include <fcntl.h> 25 + #include "system.h" 22 26 #include "debug.h" 23 27 #include "lcd.h" 24 28 #include "lcd-charcell.h" 25 29 #include "screendump.h" 26 30 #include "general.h" 27 - #include <string.h> 28 - #include <unistd.h> 29 - #include <fcntl.h> 30 31 31 32 #include "lcd-playersim.h" 32 - #include "uisdl.h" 33 + #include "sim-ui-defines.h" 33 34 #include "lcd-sdl.h" 34 35 35 36 /* can't include file.h here */
uisimulator/sdl/lcd-charcells.h firmware/target/hosted/sdl/lcd-charcells.h
+2 -1
uisimulator/sdl/lcd-remote-bitmap.c firmware/target/hosted/sdl/lcd-remote-bitmap.c
··· 19 19 * 20 20 ****************************************************************************/ 21 21 22 - #include "uisdl.h" 22 + #include "sim-ui-defines.h" 23 23 #include "lcd-sdl.h" 24 24 #include "lcd-remote-bitmap.h" 25 25 #include "screendump.h" 26 + #include "system.h" /* background */ 26 27 27 28 SDL_Surface *remote_surface = 0; 28 29
uisimulator/sdl/lcd-remote-bitmap.h firmware/target/hosted/sdl/lcd-remote-bitmap.h
+2 -1
uisimulator/sdl/lcd-sdl.c firmware/target/hosted/sdl/lcd-sdl.c
··· 19 19 * 20 20 ****************************************************************************/ 21 21 22 + #include <SDL.h> 22 23 #include "lcd-sdl.h" 23 - #include "uisdl.h" 24 + #include "sim-ui-defines.h" 24 25 #include "system.h" /* for MIN() and MAX() */ 25 26 26 27 int display_zoom = 1;
+1
uisimulator/sdl/lcd-sdl.h firmware/target/hosted/sdl/lcd-sdl.h
··· 27 27 28 28 /* Default display zoom level */ 29 29 extern int display_zoom; 30 + extern SDL_Surface *gui_surface; 30 31 31 32 void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, 32 33 int height, int max_x, int max_y,
+39 -92
uisimulator/sdl/sound.c firmware/target/hosted/sdl/pcm-sdl.c
··· 8 8 * $Id$ 9 9 * 10 10 * Copyright (C) 2005 by Nick Lanham 11 + * Copyright (C) 2010 by Thomas Martitz 11 12 * 12 13 * This program is free software; you can redistribute it and/or 13 14 * modify it under the terms of the GNU General Public License ··· 23 24 24 25 #include <stdlib.h> 25 26 #include <stdbool.h> 26 - #include <memory.h> 27 - #include "kernel.h" 27 + #include <SDL.h> 28 + #include "config.h" 29 + #include "debug.h" 28 30 #include "sound.h" 29 31 #include "audiohw.h" 32 + #include "system.h" 30 33 31 34 #include "pcm.h" 32 35 #include "pcm_sampr.h" 33 - #include "SDL.h" 34 36 35 - /*#define LOGF_ENABLE*/ 36 - #include "logf.h" 37 + #ifdef DEBUG 38 + #include <stdio.h> 39 + extern bool debug_audio; 40 + #endif 37 41 38 42 static int sim_volume = 0; 39 43 ··· 45 49 static size_t pcm_sample_bytes; 46 50 static size_t pcm_channel_bytes; 47 51 48 - static struct pcm_udata 52 + struct pcm_udata 49 53 { 50 54 Uint8 *stream; 51 55 Uint32 num_in; 52 56 Uint32 num_out; 57 + #ifdef DEBUG 53 58 FILE *debug; 59 + #endif 54 60 } udata; 55 61 56 62 static SDL_AudioSpec obtained; 57 63 static SDL_AudioCVT cvt; 58 - 59 - extern bool debug_audio; 60 - 61 - #ifndef MIN 62 - #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 63 - #endif 64 64 65 65 void pcm_play_lock(void) 66 66 { ··· 102 102 void pcm_play_dma_stop(void) 103 103 { 104 104 SDL_PauseAudio(1); 105 + #ifdef DEBUG 105 106 if (udata.debug != NULL) { 106 107 fclose(udata.debug); 107 108 udata.debug = NULL; 108 109 DEBUGF("Audio debug file closed\n"); 109 110 } 111 + #endif 110 112 } 111 113 112 114 void pcm_play_dma_pause(bool pause) ··· 122 124 return pcm_data_size; 123 125 } 124 126 125 - extern int sim_volume; /* in firmware/sound.c */ 126 - static void write_to_soundcard(struct pcm_udata *udata) { 127 + void write_to_soundcard(struct pcm_udata *udata) 128 + { 129 + #ifdef DEBUG 127 130 if (debug_audio && (udata->debug == NULL)) { 128 131 udata->debug = fopen("audiodebug.raw", "ab"); 129 132 DEBUGF("Audio debug file open\n"); 130 133 } 131 - 134 + #endif 132 135 if (cvt.needed) { 133 136 Uint32 rd = udata->num_in; 134 137 Uint32 wr = (double)rd * cvt.len_ratio; ··· 162 165 udata->num_in = cvt.len / pcm_sample_bytes; 163 166 udata->num_out = cvt.len_cvt / pcm_sample_bytes; 164 167 168 + #ifdef DEBUG 165 169 if (udata->debug != NULL) { 166 170 fwrite(cvt.buf, sizeof(Uint8), cvt.len_cvt, udata->debug); 167 171 } 168 - 172 + #endif 169 173 free(cvt.buf); 170 174 } 171 175 else { ··· 191 195 break; 192 196 } 193 197 } 194 - 198 + #ifdef DEBUG 195 199 if (udata->debug != NULL) { 196 200 fwrite(udata->stream, sizeof(Uint8), wr, udata->debug); 197 201 } 202 + #endif 198 203 } 199 204 } else { 200 205 udata->num_in = udata->num_out = MIN(udata->num_in, udata->num_out); 201 206 SDL_MixAudio(udata->stream, pcm_data, 202 207 udata->num_out * pcm_sample_bytes, sim_volume); 203 - 208 + #ifdef DEBUG 204 209 if (udata->debug != NULL) { 205 210 fwrite(pcm_data, sizeof(Uint8), udata->num_out * pcm_sample_bytes, 206 211 udata->debug); 207 212 } 213 + #endif 208 214 } 209 215 } 210 216 211 - static void sdl_audio_callback(struct pcm_udata *udata, Uint8 *stream, int len) 217 + void sdl_audio_callback(struct pcm_udata *udata, Uint8 *stream, int len) 212 218 { 213 - logf("sdl_audio_callback: len %d, pcm %d\n", len, pcm_data_size); 214 219 udata->stream = stream; 215 220 216 221 /* Write what we have in the PCM buffer */ ··· 221 226 while (len > 0) { 222 227 if ((ssize_t)pcm_data_size <= 0) { 223 228 pcm_data_size = 0; 229 + 224 230 if (pcm_callback_for_more) 225 231 pcm_callback_for_more(&pcm_data, &pcm_data_size); 226 232 } ··· 302 308 303 309 void pcm_play_dma_init(void) 304 310 { 311 + if (SDL_InitSubSystem(SDL_INIT_AUDIO)) 312 + { 313 + DEBUGF("Could not initialize SDL audio subsystem!\n"); 314 + return; 315 + } 316 + 305 317 SDL_AudioSpec wanted_spec; 318 + #ifdef DEBUG 306 319 udata.debug = NULL; 307 - 308 320 if (debug_audio) { 309 321 udata.debug = fopen("audiodebug.raw", "wb"); 310 322 DEBUGF("Audio debug file open\n"); 311 323 } 312 - 324 + #endif 313 325 /* Set 16-bit stereo audio at 44Khz */ 314 326 wanted_spec.freq = 44100; 315 327 wanted_spec.format = AUDIO_S16SYS; ··· 322 334 323 335 /* Open the audio device and start playing sound! */ 324 336 if(SDL_OpenAudio(&wanted_spec, &obtained) < 0) { 325 - fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); 337 + DEBUGF("Unable to open audio: %s\n", SDL_GetError()); 326 338 return; 327 339 } 328 340 ··· 339 351 pcm_channel_bytes = 2; 340 352 break; 341 353 default: 342 - fprintf(stderr, "Unknown sample format obtained: %u\n", 354 + DEBUGF("Unknown sample format obtained: %u\n", 343 355 (unsigned)obtained.format); 344 356 return; 345 357 } ··· 353 365 { 354 366 } 355 367 356 - #endif /* CONFIG_CODEC == SWCODEC */ 357 - 358 - /** 359 - * Audio Hardware api. Make them do nothing as we cannot properly simulate with 360 - * SDL. if we used DSP we would run code that doesn't actually run on the target 361 - **/ 362 - void audiohw_set_volume(int volume) 368 + void pcm_set_mixer_volume(int volume) 363 369 { 364 - sim_volume = SDL_MIX_MAXVOLUME * ((volume - VOLUME_MIN) / 10) / (VOLUME_RANGE / 10); 365 - } 366 - #if defined(AUDIOHW_HAVE_PRESCALER) 367 - void audiohw_set_prescaler(int value) { (void)value; } 368 - #endif 369 - #if defined(AUDIOHW_HAVE_BALANCE) 370 - void audiohw_set_balance(int value) { (void)value; } 371 - #endif 372 - #if defined(AUDIOHW_HAVE_BASS) 373 - void audiohw_set_bass(int value) { (void)value; } 374 - #endif 375 - #if defined(AUDIOHW_HAVE_TREBLE) 376 - void audiohw_set_treble(int value) { (void)value; } 377 - #endif 378 - #if CONFIG_CODEC != SWCODEC 379 - void audiohw_set_channel(int value) { (void)value; } 380 - void audiohw_set_stereo_width(int value){ (void)value; } 381 - #endif 382 - #if defined(AUDIOHW_HAVE_BASS_CUTOFF) 383 - void audiohw_set_bass_cutoff(int value) { (void)value; } 384 - #endif 385 - #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF) 386 - void audiohw_set_treble_cutoff(int value){ (void)value; } 387 - #endif 388 - /* EQ-based tone controls */ 389 - #if defined(AUDIOHW_HAVE_EQ) 390 - void audiohw_set_eq_band_gain(unsigned int band, int value) 391 - { (void)band; (void)value; } 392 - #endif 393 - #if defined(AUDIOHW_HAVE_EQ_FREQUENCY) 394 - void audiohw_set_eq_band_frequency(unsigned int band, int value) 395 - { (void)band; (void)value; } 396 - #endif 397 - #if defined(AUDIOHW_HAVE_EQ_WIDTH) 398 - void audiohw_set_eq_band_width(unsigned int band, int value) 399 - { (void)band; (void)value; } 400 - #endif 401 - #if defined(AUDIOHW_HAVE_DEPTH_3D) 402 - void audiohw_set_depth_3d(int value) 403 - { (void)value; } 404 - #endif 405 - #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) 406 - int mas_codec_readreg(int reg) 407 - { 408 - (void)reg; 409 - return 0; 370 + sim_volume = volume; 410 371 } 411 372 412 - int mas_codec_writereg(int reg, unsigned int val) 413 - { 414 - (void)reg; 415 - (void)val; 416 - return 0; 417 - } 418 - int mas_writemem(int bank, int addr, const unsigned long* src, int len) 419 - { 420 - (void)bank; 421 - (void)addr; 422 - (void)src; 423 - (void)len; 424 - return 0; 425 - } 426 - #endif 373 + #endif /* CONFIG_CODEC == SWCODEC */
+17 -9
uisimulator/sdl/sound.h firmware/target/hosted/sdl/button-sdl.h
··· 1 1 /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 2 + * __________ __ ___. 3 + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + * \/ \/ \/ \/ \/ 8 8 * $Id$ 9 9 * 10 - * Copyright (C) 2005 by Daniel Stenberg <daniel@haxx.se> 10 + * Copyright (C) 2009 by Thomas Martitz 11 11 * 12 12 * This program is free software; you can redistribute it and/or 13 13 * modify it under the terms of the GNU General Public License ··· 19 19 * 20 20 ****************************************************************************/ 21 21 22 - int sound_playback_thread(void* p); 22 + 23 + #ifndef __BUTTON_SDL_H__ 24 + #define __BUTTON_SDL_H__ 25 + 26 + #include <stdbool.h> 27 + #include "config.h" 23 28 24 - extern void (*sound_get_pcm)(unsigned char** start, long* size); 29 + bool button_hold(void); 30 + void button_init_device(void); 31 + 32 + #endif /* __BUTTON_SDL_H__ */
+4 -1
uisimulator/sdl/system-sdl.h firmware/target/hosted/sdl/system-sdl.h
··· 41 41 42 42 void sim_enter_irq_handler(void); 43 43 void sim_exit_irq_handler(void); 44 - bool sim_kernel_init(void); 45 44 void sim_kernel_shutdown(void); 45 + void sys_poweroff(void); 46 + void sys_handle_argv(int argc, char *argv[]); 46 47 48 + extern bool background; /* True if the background image is enabled */ 49 + extern int display_zoom; 47 50 extern long start_tick; 48 51 49 52 #endif /* _SYSTEM_SDL_H_ */
+13 -52
uisimulator/sdl/thread-sdl.c firmware/target/hosted/sdl/thread-sdl.c
··· 56 56 * in their start routines responding to messages so this is the only 57 57 * way to get them back in there so they may exit */ 58 58 static jmp_buf thread_jmpbufs[MAXTHREADS]; 59 + /* this mutex locks out other Rockbox threads while one runs, 60 + * that enables us to simulate a cooperative environment even if 61 + * the host is preemptive */ 59 62 static SDL_mutex *m; 60 63 static volatile bool threads_exit = false; 61 64 62 65 extern long start_tick; 63 66 64 - void thread_sdl_shutdown(void) 67 + void sim_thread_shutdown(void) 65 68 { 66 69 int i; 67 70 ··· 79 82 for (i = 0; i < MAXTHREADS; i++) 80 83 { 81 84 struct thread_entry *thread = &threads[i]; 85 + /* exit all current threads, except the main one */ 82 86 if (thread->context.t != NULL) 83 87 { 84 88 /* Signal thread on delay or block */ ··· 128 132 return thread; 129 133 } 130 134 131 - /* Do main thread creation in this file scope to avoid the need to double- 132 - return to a prior call-level which would be unaware of the fact setjmp 133 - was used */ 134 - extern void app_main(void *param); 135 - static int thread_sdl_app_main(void *param) 136 - { 137 - SDL_LockMutex(m); 138 - cores[CURRENT_CORE].running = &threads[0]; 139 - 140 - /* Set the jump address for return */ 141 - if (setjmp(thread_jmpbufs[0]) == 0) 142 - { 143 - app_main(param); 144 - /* should not ever be reached but... */ 145 - THREAD_PANICF("app_main returned!\n"); 146 - } 147 - 148 - /* Unlock and exit */ 149 - SDL_UnlockMutex(m); 150 - return 0; 151 - } 152 135 153 136 /* Initialize SDL threading */ 154 - bool thread_sdl_init(void *param) 137 + void init_threads(void) 155 138 { 156 139 struct thread_entry *thread; 157 140 int n; ··· 164 147 if (SDL_LockMutex(m) == -1) 165 148 { 166 149 fprintf(stderr, "Couldn't lock mutex\n"); 167 - return false; 150 + return; 168 151 } 169 152 170 153 /* Initialize all IDs */ ··· 180 163 thread->name = "main"; 181 164 thread->state = STATE_RUNNING; 182 165 thread->context.s = SDL_CreateSemaphore(0); 166 + thread->context.t = NULL; /* NULL for the implicit main thread */ 183 167 cores[CURRENT_CORE].running = thread; 184 168 185 169 if (thread->context.s == NULL) 186 170 { 187 171 fprintf(stderr, "Failed to create main semaphore\n"); 188 - return false; 189 - } 190 - 191 - thread->context.t = SDL_CreateThread(thread_sdl_app_main, param); 192 - 193 - if (thread->context.t == NULL) 194 - { 195 - SDL_DestroySemaphore(thread->context.s); 196 - fprintf(stderr, "Failed to create main thread\n"); 197 - return false; 172 + return; 198 173 } 199 174 200 175 THREAD_SDL_DEBUGF("Main thread: %p\n", thread); 201 176 202 - SDL_UnlockMutex(m); 203 - return true; 177 + return; 204 178 } 205 179 206 - void thread_sdl_exception_wait(void) 180 + void sim_thread_exception_wait(void) 207 181 { 208 182 while (1) 209 183 { ··· 214 188 } 215 189 216 190 /* A way to yield and leave the threading system for extended periods */ 217 - void thread_sdl_thread_lock(void *me) 191 + void sim_thread_lock(void *me) 218 192 { 219 193 SDL_LockMutex(m); 220 194 cores[CURRENT_CORE].running = (struct thread_entry *)me; ··· 223 197 thread_exit(); 224 198 } 225 199 226 - void * thread_sdl_thread_unlock(void) 200 + void * sim_thread_unlock(void) 227 201 { 228 202 struct thread_entry *current = cores[CURRENT_CORE].running; 229 203 SDL_UnlockMutex(m); ··· 527 501 thread - threads, THREAD_SDL_GET_NAME(thread)); 528 502 529 503 return thread->id; 530 - } 531 - 532 - void init_threads(void) 533 - { 534 - /* Main thread is already initialized */ 535 - if (cores[CURRENT_CORE].running != &threads[0]) 536 - { 537 - THREAD_PANICF("Wrong main thread in init_threads: %p\n", 538 - cores[CURRENT_CORE].running); 539 - } 540 - 541 - THREAD_SDL_DEBUGF("First Thread: %d (%s)\n", 542 - 0, THREAD_SDL_GET_NAME(&threads[0])); 543 504 } 544 505 545 506 #ifndef ALLOW_REMOVE_THREAD
+5 -10
uisimulator/sdl/thread-sdl.h firmware/target/hosted/sdl/thread-sdl.h
··· 22 22 #ifndef __THREADSDL_H__ 23 23 #define __THREADSDL_H__ 24 24 25 - #include "SDL_thread.h" 26 - 27 - extern SDL_Thread *gui_thread; /* The "main" thread */ 28 - void thread_sdl_thread_lock(void *me); 29 - void * thread_sdl_thread_unlock(void); 30 - void thread_sdl_exception_wait(void); 31 - bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */ 32 - void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */ 33 - void thread_sdl_lock(void); /* Sync with SDL threads */ 34 - void thread_sdl_unlock(void); /* Sync with SDL threads */ 25 + /* extra thread functions that only apply when running on hosting platforms */ 26 + void sim_thread_lock(void *me); 27 + void * sim_thread_unlock(void); 28 + void sim_thread_exception_wait(void); 29 + void sim_thread_shutdown(void); /* Shut down all kernel threads gracefully */ 35 30 36 31 #endif /* #ifndef __THREADSDL_H__ */ 37 32
-7
uisimulator/sdl/timefuncs.h
··· 1 - #include <time.h> 2 - #include <stdbool.h> 3 - 4 - /* struct tm defined */ 5 - struct tm *get_time(void); 6 - int set_time(const struct tm *tm); 7 - bool valid_time(const struct tm *tm);
uisimulator/sdl/timer.c firmware/target/hosted/sdl/timer-sdl.c
-368
uisimulator/sdl/uisdl.c
··· 1 - /*************************************************************************** 2 - * __________ __ ___. 3 - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 - * \/ \/ \/ \/ \/ 8 - * $Id$ 9 - * 10 - * Copyright (C) 2006 by Daniel Everton <dan@iocaine.org> 11 - * 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. 16 - * 17 - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 - * KIND, either express or implied. 19 - * 20 - ****************************************************************************/ 21 - 22 - #include <stdlib.h> 23 - #include <string.h> 24 - #include <setjmp.h> 25 - #include "autoconf.h" 26 - #include "button.h" 27 - #include "system-sdl.h" 28 - #include "thread.h" 29 - #include "kernel.h" 30 - #include "uisdl.h" 31 - #include "lcd-sdl.h" 32 - #ifdef HAVE_LCD_BITMAP 33 - #include "lcd-bitmap.h" 34 - #elif defined(HAVE_LCD_CHARCELLS) 35 - #include "lcd-charcells.h" 36 - #endif 37 - #ifdef HAVE_REMOTE_LCD 38 - #include "lcd-remote-bitmap.h" 39 - #endif 40 - #include "thread-sdl.h" 41 - #include "SDL_mutex.h" 42 - #include "SDL_thread.h" 43 - #include "math.h" 44 - 45 - 46 - /* extern functions */ 47 - extern void new_key(int key); 48 - extern int xy2button( int x, int y); 49 - void button_event(int key, bool pressed); 50 - 51 - SDL_Surface *gui_surface; 52 - bool background = true; /* use backgrounds by default */ 53 - #ifdef HAVE_REMOTE_LCD 54 - static bool showremote = true; /* include remote by default */ 55 - #endif 56 - bool mapping = false; 57 - bool debug_buttons = false; 58 - 59 - bool lcd_display_redraw = true; /* Used for player simulator */ 60 - char having_new_lcd = true; /* Used for player simulator */ 61 - bool sim_alarm_wakeup = false; 62 - const char *sim_root_dir = NULL; 63 - 64 - bool debug_audio = false; 65 - 66 - bool debug_wps = false; 67 - int wps_verbose_level = 3; 68 - 69 - 70 - void irq_button_event(int key, bool pressed) { 71 - sim_enter_irq_handler(); 72 - button_event( key, pressed ); 73 - sim_exit_irq_handler(); 74 - } 75 - 76 - int sqr( int a ) { 77 - return a*a; 78 - } 79 - 80 - void gui_message_loop(void) 81 - { 82 - SDL_Event event; 83 - bool done = false; 84 - static int x,y,xybutton = 0; 85 - 86 - while(!done && SDL_WaitEvent(&event)) 87 - { 88 - switch(event.type) 89 - { 90 - case SDL_KEYDOWN: 91 - irq_button_event(event.key.keysym.sym, true); 92 - break; 93 - case SDL_KEYUP: 94 - irq_button_event(event.key.keysym.sym, false); 95 - case SDL_MOUSEBUTTONDOWN: 96 - switch ( event.button.button ) { 97 - #ifdef HAVE_SCROLLWHEEL 98 - case SDL_BUTTON_WHEELUP: 99 - irq_button_event( SDLK_UP, true ); 100 - break; 101 - case SDL_BUTTON_WHEELDOWN: 102 - irq_button_event( SDLK_DOWN, true ); 103 - break; 104 - #endif 105 - case SDL_BUTTON_LEFT: 106 - case SDL_BUTTON_MIDDLE: 107 - if ( mapping && background ) { 108 - x = event.button.x; 109 - y = event.button.y; 110 - } 111 - if ( background ) { 112 - xybutton = xy2button( event.button.x, event.button.y ); 113 - if( xybutton ) 114 - irq_button_event( xybutton, true ); 115 - } 116 - break; 117 - default: 118 - break; 119 - } 120 - 121 - if (debug_wps && event.button.button == 1) 122 - { 123 - if ( background ) 124 - #ifdef HAVE_REMOTE 125 - if ( event.button.y < UI_REMOTE_POSY ) /* Main Screen */ 126 - printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 ); 127 - else 128 - printf("Mouse at: (%d, %d)\n", event.button.x - UI_REMOTE_POSX -1 , event.button.y - UI_REMOTE_POSY - 1 ); 129 - #else 130 - printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 ); 131 - #endif 132 - else 133 - if ( event.button.y/display_zoom < LCD_HEIGHT ) /* Main Screen */ 134 - printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom ); 135 - #ifdef HAVE_REMOTE 136 - else 137 - printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom - LCD_HEIGHT ); 138 - #endif 139 - } 140 - break; 141 - case SDL_MOUSEBUTTONUP: 142 - switch ( event.button.button ) { 143 - /* The scrollwheel button up events are ignored as they are queued immediately */ 144 - case SDL_BUTTON_LEFT: 145 - case SDL_BUTTON_MIDDLE: 146 - if ( mapping && background ) { 147 - printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, y, (int)sqrt( sqr(x-(int)event.button.x) + sqr(y-(int)event.button.y)) ); 148 - } 149 - if ( background && xybutton ) { 150 - irq_button_event( xybutton, false ); 151 - xybutton = 0; 152 - } 153 - #ifdef HAVE_TOUCHSCREEN 154 - else { 155 - irq_button_event(BUTTON_TOUCHSCREEN, false); 156 - } 157 - #endif 158 - break; 159 - default: 160 - break; 161 - } 162 - break; 163 - 164 - 165 - case SDL_QUIT: 166 - done = true; 167 - break; 168 - default: 169 - /*printf("Unhandled event\n"); */ 170 - break; 171 - } 172 - } 173 - } 174 - 175 - bool gui_startup(void) 176 - { 177 - SDL_Surface *picture_surface; 178 - int width, height; 179 - 180 - if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER)) { 181 - fprintf(stderr, "fatal: %s\n", SDL_GetError()); 182 - return false; 183 - } 184 - 185 - atexit(SDL_Quit); 186 - 187 - /* Try and load the background image. If it fails go without */ 188 - if (background) { 189 - picture_surface = SDL_LoadBMP("UI256.bmp"); 190 - if (picture_surface == NULL) { 191 - background = false; 192 - fprintf(stderr, "warn: %s\n", SDL_GetError()); 193 - } 194 - } 195 - 196 - /* Set things up */ 197 - if (background) 198 - { 199 - width = UI_WIDTH; 200 - height = UI_HEIGHT; 201 - } 202 - else 203 - { 204 - #ifdef HAVE_REMOTE_LCD 205 - if (showremote) 206 - { 207 - width = SIM_LCD_WIDTH > SIM_REMOTE_WIDTH ? SIM_LCD_WIDTH : SIM_REMOTE_WIDTH; 208 - height = SIM_LCD_HEIGHT + SIM_REMOTE_HEIGHT; 209 - } 210 - else 211 - #endif 212 - { 213 - width = SIM_LCD_WIDTH; 214 - height = SIM_LCD_HEIGHT; 215 - } 216 - } 217 - 218 - 219 - if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) { 220 - fprintf(stderr, "fatal: %s\n", SDL_GetError()); 221 - return false; 222 - } 223 - 224 - SDL_WM_SetCaption(UI_TITLE, NULL); 225 - 226 - sim_lcd_init(); 227 - #ifdef HAVE_REMOTE_LCD 228 - if (showremote) 229 - sim_lcd_remote_init(); 230 - #endif 231 - 232 - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 233 - 234 - if (background && picture_surface != NULL) { 235 - SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); 236 - SDL_UpdateRect(gui_surface, 0, 0, 0, 0); 237 - } 238 - 239 - return true; 240 - } 241 - 242 - bool gui_shutdown(void) 243 - { 244 - /* Order here is relevent to prevent deadlocks and use of destroyed 245 - sync primitives by kernel threads */ 246 - thread_sdl_shutdown(); 247 - sim_kernel_shutdown(); 248 - return true; 249 - } 250 - 251 - #if defined(WIN32) && defined(main) 252 - /* Don't use SDL_main on windows -> no more stdio redirection */ 253 - #undef main 254 - #endif 255 - 256 - int main(int argc, char *argv[]) 257 - { 258 - if (argc >= 1) 259 - { 260 - int x; 261 - for (x = 1; x < argc; x++) 262 - { 263 - if (!strcmp("--debugaudio", argv[x])) 264 - { 265 - debug_audio = true; 266 - printf("Writing debug audio file.\n"); 267 - } 268 - else if (!strcmp("--debugwps", argv[x])) 269 - { 270 - debug_wps = true; 271 - printf("WPS debug mode enabled.\n"); 272 - } 273 - else if (!strcmp("--nobackground", argv[x])) 274 - { 275 - background = false; 276 - printf("Disabling background image.\n"); 277 - } 278 - #ifdef HAVE_REMOTE_LCD 279 - else if (!strcmp("--noremote", argv[x])) 280 - { 281 - showremote = false; 282 - background = false; 283 - printf("Disabling remote image.\n"); 284 - } 285 - #endif 286 - else if (!strcmp("--old_lcd", argv[x])) 287 - { 288 - having_new_lcd = false; 289 - printf("Using old LCD layout.\n"); 290 - } 291 - else if (!strcmp("--zoom", argv[x])) 292 - { 293 - x++; 294 - if(x < argc) 295 - display_zoom=atoi(argv[x]); 296 - else 297 - display_zoom = 2; 298 - printf("Window zoom is %d\n", display_zoom); 299 - } 300 - else if (!strcmp("--alarm", argv[x])) 301 - { 302 - sim_alarm_wakeup = true; 303 - printf("Simulating alarm wakeup.\n"); 304 - } 305 - else if (!strcmp("--root", argv[x])) 306 - { 307 - x++; 308 - if (x < argc) 309 - { 310 - sim_root_dir = argv[x]; 311 - printf("Root directory: %s\n", sim_root_dir); 312 - } 313 - } 314 - else if (!strcmp("--mapping", argv[x])) 315 - { 316 - mapping = true; 317 - printf("Printing click coords with drag radii.\n"); 318 - } 319 - else if (!strcmp("--debugbuttons", argv[x])) 320 - { 321 - debug_buttons = true; 322 - printf("Printing background button clicks.\n"); 323 - } 324 - else 325 - { 326 - printf("rockboxui\n"); 327 - printf("Arguments:\n"); 328 - printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n"); 329 - printf(" --debugwps \t Print advanced WPS debug info\n"); 330 - printf(" --nobackground \t Disable the background image\n"); 331 - #ifdef HAVE_REMOTE_LCD 332 - printf(" --noremote \t Disable the remote image (will disable backgrounds)\n"); 333 - #endif 334 - printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); 335 - printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n"); 336 - printf(" --alarm \t Simulate a wake-up on alarm\n"); 337 - printf(" --root [DIR]\t Set root directory\n"); 338 - printf(" --mapping \t Output coordinates and radius for mapping backgrounds\n"); 339 - exit(0); 340 - } 341 - } 342 - } 343 - 344 - if (display_zoom > 1) { 345 - background = false; 346 - } 347 - 348 - if (!sim_kernel_init()) { 349 - fprintf(stderr, "sim_kernel_init failed\n"); 350 - return -1; 351 - } 352 - 353 - if (!gui_startup()) { 354 - fprintf(stderr, "gui_startup failed\n"); 355 - return -1; 356 - } 357 - 358 - /* app_main will be called by the new main thread */ 359 - if (!thread_sdl_init(NULL)) { 360 - fprintf(stderr, "thread_sdl_init failed\n"); 361 - return -1; 362 - } 363 - 364 - gui_message_loop(); 365 - 366 - return gui_shutdown(); 367 - } 368 -
+1 -4
uisimulator/sdl/uisdl.h firmware/target/hosted/sdl/sim-ui-defines.h
··· 397 397 #define UI_LCD_POSX 101 398 398 #define UI_LCD_POSY 195 399 399 400 - #else 400 + #elif defined(SIMULATOR) 401 401 #error no UI defines 402 402 #endif 403 - extern SDL_Surface *gui_surface; 404 - extern bool background; /* True if the background image is enabled */ 405 - extern int display_zoom; 406 403 407 404 #endif /* #ifndef __UISDL_H__ */ 408 405
+2 -5
uisimulator/uisimulator.make
··· 8 8 # 9 9 10 10 INCLUDES += -I$(ROOTDIR)/uisimulator/sdl -I$(ROOTDIR)/uisimulator/common \ 11 + -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) 11 12 12 - SIMINCLUDES += -I$(ROOTDIR)/uisimulator/sdl -I$(ROOTDIR)/uisimulator/common \ 13 - -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) 13 + SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) 14 14 15 - SIMFLAGS += $(SIMINCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) 16 - 17 - SIMSRC += $(call preprocess, $(ROOTDIR)/uisimulator/sdl/SOURCES) 18 15 SIMSRC += $(call preprocess, $(ROOTDIR)/uisimulator/common/SOURCES) 19 16 SIMOBJ = $(call c2obj,$(SIMSRC)) 20 17 OTHER_SRC += $(SIMSRC)