summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/main.c13
-rw-r--r--firmware/SOURCES21
-rw-r--r--firmware/drivers/audio/sdl.c186
-rw-r--r--firmware/drivers/button.c9
-rw-r--r--firmware/export/audiohw.h6
-rw-r--r--firmware/export/config/sim.h4
-rw-r--r--firmware/export/system.h1
-rw-r--r--firmware/kernel.c5
-rw-r--r--firmware/libc/include/stdlib.h3
-rw-r--r--firmware/sound.c85
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c (renamed from uisimulator/sdl/button.c)121
-rw-r--r--firmware/target/hosted/sdl/button-sdl.h (renamed from uisimulator/sdl/sound.h)26
-rw-r--r--firmware/target/hosted/sdl/kernel-sdl.c (renamed from uisimulator/sdl/kernel-sdl.c)17
-rw-r--r--firmware/target/hosted/sdl/lcd-bitmap.c (renamed from uisimulator/sdl/lcd-bitmap.c)3
-rw-r--r--firmware/target/hosted/sdl/lcd-bitmap.h (renamed from uisimulator/sdl/lcd-bitmap.h)0
-rw-r--r--firmware/target/hosted/sdl/lcd-charcells.c (renamed from uisimulator/sdl/lcd-charcells.c)9
-rw-r--r--firmware/target/hosted/sdl/lcd-charcells.h (renamed from uisimulator/sdl/lcd-charcells.h)0
-rw-r--r--firmware/target/hosted/sdl/lcd-remote-bitmap.c (renamed from uisimulator/sdl/lcd-remote-bitmap.c)3
-rw-r--r--firmware/target/hosted/sdl/lcd-remote-bitmap.h (renamed from uisimulator/sdl/lcd-remote-bitmap.h)0
-rw-r--r--firmware/target/hosted/sdl/lcd-sdl.c (renamed from uisimulator/sdl/lcd-sdl.c)3
-rw-r--r--firmware/target/hosted/sdl/lcd-sdl.h (renamed from uisimulator/sdl/lcd-sdl.h)1
-rw-r--r--firmware/target/hosted/sdl/pcm-sdl.c (renamed from uisimulator/sdl/sound.c)131
-rw-r--r--firmware/target/hosted/sdl/sim-ui-defines.h (renamed from uisimulator/sdl/uisdl.h)5
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c (renamed from uisimulator/sdl/uisdl.c)218
-rw-r--r--firmware/target/hosted/sdl/system-sdl.h (renamed from uisimulator/sdl/system-sdl.h)5
-rw-r--r--firmware/target/hosted/sdl/thread-sdl.c (renamed from uisimulator/sdl/thread-sdl.c)65
-rw-r--r--firmware/target/hosted/sdl/thread-sdl.h (renamed from uisimulator/sdl/thread-sdl.h)15
-rw-r--r--firmware/target/hosted/sdl/timer-sdl.c (renamed from uisimulator/sdl/timer.c)0
-rwxr-xr-xtools/configure4
-rw-r--r--uisimulator/common/io.c4
-rw-r--r--uisimulator/common/powermgmt-sim.c4
-rw-r--r--uisimulator/common/stubs.c16
-rw-r--r--uisimulator/sdl/Makefile64
-rw-r--r--uisimulator/sdl/README6
-rw-r--r--uisimulator/sdl/SOURCES15
-rw-r--r--uisimulator/sdl/button-sdl.h46
-rw-r--r--uisimulator/sdl/timefuncs.h7
-rw-r--r--uisimulator/uisimulator.make7
38 files changed, 505 insertions, 623 deletions
diff --git a/apps/main.c b/apps/main.c
index b043dacede..e4b9286b4e 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -124,8 +124,14 @@ const char appsversion[]=APPSVERSION;
static void init(void);
-#ifdef SIMULATOR
-void app_main(void)
+#ifdef HAVE_SDL
+#if defined(WIN32) && defined(main)
+/* Don't use SDL_main on windows -> no more stdio redirection */
+#undef main
+#endif
+int main(int argc, char *argv[])
+{
+ sys_handle_argv(argc, argv);
#else
/* main(), and various functions called by main() and init() may be
* be INIT_ATTR. These functions must not be called after the final call
@@ -133,8 +139,8 @@ void app_main(void)
* see definition of INIT_ATTR in config.h */
int main(void) INIT_ATTR __attribute__((noreturn));
int main(void)
-#endif
{
+#endif
int i;
CHART(">init");
init();
@@ -313,6 +319,7 @@ static void init_tagcache(void)
static void init(void)
{
+ system_init();
kernel_init();
buffer_init();
enable_irq();
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 68074dbbec..47249a2d6d 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -18,6 +18,22 @@ rolo.c
thread.c
timer.c
#endif /* SIMULATOR */
+#ifdef HAVE_SDL
+target/hosted/sdl/button-sdl.c
+target/hosted/sdl/kernel-sdl.c
+#ifdef HAVE_LCD_BITMAP
+target/hosted/sdl/lcd-bitmap.c
+#elif defined(HAVE_LCD_CHARCELLS)
+target/hosted/sdl/lcd-charcells.c
+#endif
+#ifdef HAVE_REMOTE_LCD
+target/hosted/sdl/lcd-remote-bitmap.c
+#endif
+target/hosted/sdl/lcd-sdl.c
+target/hosted/sdl/system-sdl.c
+target/hosted/sdl/thread-sdl.c
+target/hosted/sdl/timer-sdl.c
+#endif
panic.c
debug.c
@@ -292,6 +308,11 @@ drivers/audio/ak4537.c
#elif defined(HAVE_UDA1341)
drivers/audio/uda1341.c
#endif /* defined(HAVE_*) */
+#elif defined(HAVE_SDL_AUDIO)
+drivers/audio/sdl.c
+#if CONFIG_CODEC == SWCODEC
+target/hosted/sdl/pcm-sdl.c
+#endif
#endif /* !defined(SIMULATOR) && !defined(BOOTLOADER) */
/* USB Stack */
diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c
new file mode 100644
index 0000000000..c063192873
--- /dev/null
+++ b/firmware/drivers/audio/sdl.c
@@ -0,0 +1,186 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright © 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <SDL_audio.h>
+#include "config.h"
+#include "audiohw.h"
+
+/**
+ * Audio Hardware api. Make them do nothing as we cannot properly simulate with
+ * SDL. if we used DSP we would run code that doesn't actually run on the target
+ **/
+
+extern void pcm_set_mixer_volume(int);
+
+void audiohw_set_volume(int volume)
+{
+#if CONFIG_CODEC == SWCODEC
+ pcm_set_mixer_volume(
+ SDL_MIX_MAXVOLUME * ((volume - VOLUME_MIN) / 10) / (VOLUME_RANGE / 10));
+#else
+ (void)volume;
+#endif
+}
+
+const struct sound_settings_info audiohw_settings[] = {
+ [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25},
+/* Bass and treble tone controls */
+#ifdef AUDIOHW_HAVE_BASS
+ [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
+#endif
+#ifdef AUDIOHW_HAVE_TREBLE
+ [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
+#endif
+ [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
+ [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
+ [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
+#if defined(HAVE_RECORDING)
+ [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
+ [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
+ [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
+#endif
+#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
+ [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
+ [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_DEPTH_3D)
+ [SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0},
+#endif
+/* Hardware EQ tone controls */
+#if defined(AUDIOHW_HAVE_EQ_BAND1)
+ [SOUND_EQ_BAND1_GAIN] = {"dB", 0, 1, -12, 12, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND2)
+ [SOUND_EQ_BAND2_GAIN] = {"dB", 0, 1, -12, 12, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND3)
+ [SOUND_EQ_BAND3_GAIN] = {"dB", 0, 1, -12, 12, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND4)
+ [SOUND_EQ_BAND4_GAIN] = {"dB", 0, 1, -12, 12, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND5)
+ [SOUND_EQ_BAND5_GAIN] = {"dB", 0, 1, -12, 12, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
+ [SOUND_EQ_BAND1_FREQUENCY] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
+ [SOUND_EQ_BAND2_FREQUENCY] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
+ [SOUND_EQ_BAND3_FREQUENCY] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
+ [SOUND_EQ_BAND4_FREQUENCY] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
+ [SOUND_EQ_BAND5_FREQUENCY] = {"", 0, 1, 1, 4, 1},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
+ [SOUND_EQ_BAND2_WIDTH] = {"", 0, 1, 0, 1, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
+ [SOUND_EQ_BAND3_WIDTH] = {"", 0, 1, 0, 1, 0},
+#endif
+#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
+ [SOUND_EQ_BAND4_WIDTH] = {"", 0, 1, 0, 1, 0},
+#endif
+
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+ [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0},
+ [SOUND_AVC] = {"", 0, 1, -1, 4, 0},
+ [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48},
+ [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50},
+ [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60},
+ [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90},
+ [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0},
+ [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0},
+#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
+};
+
+/**
+ * stubs here, for the simulator
+ **/
+
+#if defined(AUDIOHW_HAVE_PRESCALER)
+void audiohw_set_prescaler(int value) { (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_BALANCE)
+void audiohw_set_balance(int value) { (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_BASS)
+void audiohw_set_bass(int value) { (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_TREBLE)
+void audiohw_set_treble(int value) { (void)value; }
+#endif
+#if CONFIG_CODEC != SWCODEC
+void audiohw_set_channel(int value) { (void)value; }
+void audiohw_set_stereo_width(int value){ (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
+void audiohw_set_bass_cutoff(int value) { (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
+void audiohw_set_treble_cutoff(int value){ (void)value; }
+#endif
+/* EQ-based tone controls */
+#if defined(AUDIOHW_HAVE_EQ)
+void audiohw_set_eq_band_gain(unsigned int band, int value)
+ { (void)band; (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
+void audiohw_set_eq_band_frequency(unsigned int band, int value)
+ { (void)band; (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_EQ_WIDTH)
+void audiohw_set_eq_band_width(unsigned int band, int value)
+ { (void)band; (void)value; }
+#endif
+#if defined(AUDIOHW_HAVE_DEPTH_3D)
+void audiohw_set_depth_3d(int value)
+ { (void)value; }
+#endif
+#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
+int mas_codec_readreg(int reg)
+{
+ (void)reg;
+ return 0;
+}
+
+int mas_codec_writereg(int reg, unsigned int val)
+{
+ (void)reg;
+ (void)val;
+ return 0;
+}
+int mas_writemem(int bank, int addr, const unsigned long* src, int len)
+{
+ (void)bank;
+ (void)addr;
+ (void)src;
+ (void)len;
+ return 0;
+}
+#endif
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 100957b77a..f116ad646e 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -429,7 +429,6 @@ void button_init(void)
tick_add_task(button_tick);
}
-#ifndef SIMULATOR
#ifdef BUTTON_DRIVER_CLOSE
void button_close(void)
{
@@ -443,9 +442,10 @@ void button_close(void)
*/
static int button_flip(int button)
{
- int newbutton;
+ int newbutton = button;
- newbutton = button &
+#ifndef SIMULATOR
+ newbutton &=
~(BUTTON_LEFT | BUTTON_RIGHT
#if defined(BUTTON_UP) && defined(BUTTON_DOWN)
| BUTTON_UP | BUTTON_DOWN
@@ -503,7 +503,7 @@ static int button_flip(int button)
if (button & BUTTON_PREV)
newbutton |= BUTTON_NEXT;
#endif
-
+#endif /* !SIMULATOR */
return newbutton;
}
@@ -523,7 +523,6 @@ void button_set_flip(bool flip)
}
}
#endif /* HAVE_LCD_FLIP */
-#endif /* SIMULATOR */
#ifdef HAVE_BACKLIGHT
void set_backlight_filter_keypress(bool value)
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index d7ee551e40..b8214e67b9 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -66,6 +66,10 @@
#elif defined(HAVE_AK4537)
#include "ak4537.h"
#endif
+#if defined(HAVE_SDL_AUDIO)
+/* #include <SDL_audio.h> gives errors in other code areas,
+ * we don't really need it here, so don't. but it should maybe be fixed */
+#endif
@@ -369,7 +373,7 @@ void audiohw_postinit(void);
*/
void audiohw_close(void);
-#ifdef AUDIOHW_HAVE_CLIPPING
+#if defined(AUDIOHW_HAVE_CLIPPING) || defined(HAVE_SDL_AUDIO)
/**
* Set new volume value
* @param val to set.
diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index 6d2e6d24ea..d65b0fbbf8 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -80,6 +80,8 @@
#undef HAVE_SPEAKER
+#undef BUTTON_DRIVER_CLOSE
+
#if CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG
#undef CONFIG_BACKLIGHT_FADING
/* simulate SW_SETTING, as we handle sdl very similary */
@@ -97,4 +99,6 @@
#define DEFAULT_BRIGHTNESS_SETTING MAX_BRIGHTNESS_SETTING
#endif
+#define HAVE_SDL
+#define HAVE_SDL_AUDIO
#define _ISOC99_SOURCE 1
diff --git a/firmware/export/system.h b/firmware/export/system.h
index bd31c03028..fc582aac03 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -235,6 +235,7 @@ enum {
#if !defined(SIMULATOR) && !defined(__PCTOOL__)
#include "system-target.h"
#else /* SIMULATOR */
+#include "system-sdl.h"
static inline uint16_t swap16(uint16_t value)
/*
result[15..8] = value[ 7..0];
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 64c8142540..d8c67e8485 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -22,14 +22,11 @@
#include <string.h>
#include "config.h"
#include "kernel.h"
-#ifdef SIMULATOR
-#include "system-sdl.h"
-#include "debug.h"
-#endif
#include "thread.h"
#include "cpu.h"
#include "system.h"
#include "panic.h"
+#include "debug.h"
/* Make this nonzero to enable more elaborate checks on objects */
#if defined(DEBUG) || defined(SIMULATOR)
diff --git a/firmware/libc/include/stdlib.h b/firmware/libc/include/stdlib.h
index 5f6db6da8a..57553367c4 100644
--- a/firmware/libc/include/stdlib.h
+++ b/firmware/libc/include/stdlib.h
@@ -29,6 +29,7 @@ void *malloc(size_t);
void *calloc (size_t nmemb, size_t size);
void free(void *);
void *realloc(void *, size_t);
+int atexit(void (*)(void));
#define RAND_MAX INT_MAX
@@ -51,7 +52,7 @@ void exit(int status);
#endif
int atoi (const char *str);
-
+
#ifdef __cplusplus
}
#endif
diff --git a/firmware/sound.c b/firmware/sound.c
index fb2f353d71..dccca12264 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -43,89 +43,6 @@
extern bool audio_is_initialized;
-#ifdef SIMULATOR
-extern void audiohw_set_volume(int value);
-/* dummy for sim */
-const struct sound_settings_info audiohw_settings[] = {
- [SOUND_VOLUME] = {"dB", 0, 1, VOLUME_MIN / 10, VOLUME_MAX / 10, -25},
-/* Bass and treble tone controls */
-#ifdef AUDIOHW_HAVE_BASS
- [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
-#endif
-#ifdef AUDIOHW_HAVE_TREBLE
- [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
-#endif
- [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
- [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
- [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
-#if defined(HAVE_RECORDING)
- [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
- [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
- [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
-#endif
-#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
- [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
- [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_DEPTH_3D)
- [SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0},
-#endif
-/* Hardware EQ tone controls */
-#if defined(AUDIOHW_HAVE_EQ_BAND1)
- [SOUND_EQ_BAND1_GAIN] = {"dB", 0, 1, -12, 12, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND2)
- [SOUND_EQ_BAND2_GAIN] = {"dB", 0, 1, -12, 12, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND3)
- [SOUND_EQ_BAND3_GAIN] = {"dB", 0, 1, -12, 12, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND4)
- [SOUND_EQ_BAND4_GAIN] = {"dB", 0, 1, -12, 12, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND5)
- [SOUND_EQ_BAND5_GAIN] = {"dB", 0, 1, -12, 12, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
- [SOUND_EQ_BAND1_FREQUENCY] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
- [SOUND_EQ_BAND2_FREQUENCY] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
- [SOUND_EQ_BAND3_FREQUENCY] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
- [SOUND_EQ_BAND4_FREQUENCY] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
- [SOUND_EQ_BAND5_FREQUENCY] = {"", 0, 1, 1, 4, 1},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
- [SOUND_EQ_BAND2_WIDTH] = {"", 0, 1, 0, 1, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
- [SOUND_EQ_BAND3_WIDTH] = {"", 0, 1, 0, 1, 0},
-#endif
-#if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
- [SOUND_EQ_BAND4_WIDTH] = {"", 0, 1, 0, 1, 0},
-#endif
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0},
- [SOUND_AVC] = {"", 0, 1, -1, 4, 0},
- [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48},
- [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50},
- [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60},
- [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90},
- [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0},
- [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0},
-#endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-};
-#endif
-
const char *sound_unit(int setting)
{
return audiohw_settings[setting].unit;
@@ -356,7 +273,7 @@ static void set_prescaled_volume(void)
#elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985)
audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r));
-#elif defined(HAVE_JZ4740_CODEC)
+#elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO)
audiohw_set_volume(current_volume);
#endif
#else /* SIMULATOR */
diff --git a/uisimulator/sdl/button.c b/firmware/target/hosted/sdl/button-sdl.c
index 2bb7764782..51ba8cff92 100644
--- a/uisimulator/sdl/button.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -19,7 +19,8 @@
*
****************************************************************************/
-#include "uisdl.h"
+#include <math.h>
+#include "sim-ui-defines.h"
#include "lcd-charcells.h"
#include "lcd-remote.h"
#include "config.h"
@@ -61,6 +62,8 @@ int remote_type(void)
}
#endif
+static int xy2button(int x, int y);
+
struct event_queue button_queue;
static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
@@ -78,8 +81,109 @@ bool remote_button_hold(void) {
return remote_hold_button_state;
}
#endif
+static void button_event(int key, bool pressed);
+extern bool debug_wps;
+extern bool mapping;
+static void gui_message_loop(void)
+{
+ SDL_Event event;
+ static int x,y,xybutton = 0;
+
+ if (SDL_PollEvent(&event))
+ {
+ switch(event.type)
+ {
+ case SDL_KEYDOWN:
+ button_event(event.key.keysym.sym, true);
+ break;
+ case SDL_KEYUP:
+ button_event(event.key.keysym.sym, false);
+ case SDL_MOUSEBUTTONDOWN:
+ switch ( event.button.button ) {
+#ifdef HAVE_SCROLLWHEEL
+ case SDL_BUTTON_WHEELUP:
+ button_event( SDLK_UP, true );
+ break;
+ case SDL_BUTTON_WHEELDOWN:
+ button_event( SDLK_DOWN, true );
+ break;
+#endif
+ case SDL_BUTTON_LEFT:
+ case SDL_BUTTON_MIDDLE:
+ if ( mapping && background ) {
+ x = event.button.x;
+ y = event.button.y;
+ }
+ if ( background ) {
+ xybutton = xy2button( event.button.x, event.button.y );
+ if( xybutton )
+ button_event( xybutton, true );
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (debug_wps && event.button.button == 1)
+ {
+ if ( background )
+#ifdef HAVE_REMOTE
+ if ( event.button.y < UI_REMOTE_POSY ) /* Main Screen */
+ printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 );
+ else
+ printf("Mouse at: (%d, %d)\n", event.button.x - UI_REMOTE_POSX -1 , event.button.y - UI_REMOTE_POSY - 1 );
+#else
+ printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 );
+#endif
+ else
+ if ( event.button.y/display_zoom < LCD_HEIGHT ) /* Main Screen */
+ printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom );
+#ifdef HAVE_REMOTE
+ else
+ printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom - LCD_HEIGHT );
+#endif
+ }
+ break;
+ case SDL_MOUSEBUTTONUP:
+ switch ( event.button.button ) {
+ /* The scrollwheel button up events are ignored as they are queued immediately */
+ case SDL_BUTTON_LEFT:
+ case SDL_BUTTON_MIDDLE:
+ if ( mapping && background ) {
+ printf(" { SDLK_, %d, %d, %d, \"\" },\n", x,
+#define SQUARE(x) ((x)*(x))
+ y, (int)sqrt( SQUARE(x-(int)event.button.x)
+ + SQUARE(y-(int)event.button.y)) );
+ }
+ if ( background && xybutton ) {
+ button_event( xybutton, false );
+ xybutton = 0;
+ }
+#ifdef HAVE_TOUCHSCREEN
+ else {
+ button_event(BUTTON_TOUCHSCREEN, false);
+ }
+#endif
+ break;
+ default:
+ break;
+ }
+ break;
+
+
+ case SDL_QUIT:
+ {
+ exit(EXIT_SUCCESS);
+ break;
+ }
+ default:
+ /*printf("Unhandled event\n"); */
+ break;
+ }
+ }
+}
-void button_event(int key, bool pressed)
+static void button_event(int key, bool pressed)
{
int new_btn = 0;
static bool usb_connected = false;
@@ -1380,7 +1484,6 @@ int button_read_device(int* data)
int button_read_device(void)
{
#endif
-
#ifdef HAS_BUTTON_HOLD
int hold_button = button_hold();
@@ -1396,7 +1499,9 @@ int button_read_device(void)
if (hold_button)
return BUTTON_NONE;
+ else
#endif
+ gui_message_loop();
return btn;
}
@@ -1430,8 +1535,9 @@ void mouse_tick_task(void)
}
#endif
-void button_init_sdl(void)
+void button_init_device(void)
{
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
#ifdef HAVE_TOUCHSCREEN
tick_add_task(mouse_tick_task);
#endif
@@ -1441,6 +1547,10 @@ void button_init_sdl(void)
/* Run sim with --mapping to get coordinates */
/* or --debugbuttons to check */
/* The First matching button is returned */
+struct button_map {
+ int button, x, y, radius;
+ char *description;
+};
#ifdef SANSA_FUZE
struct button_map bm[] = {
@@ -1892,7 +2002,8 @@ struct button_map bm[] = {
};
#endif
-int xy2button( int x, int y) {
+static int xy2button( int x, int y)
+{
int i;
extern bool debug_buttons;
diff --git a/uisimulator/sdl/sound.h b/firmware/target/hosted/sdl/button-sdl.h
index 5f4cc6eaf0..75a68c49bc 100644
--- a/uisimulator/sdl/sound.h
+++ b/firmware/target/hosted/sdl/button-sdl.h
@@ -1,13 +1,13 @@
/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2005 by Daniel Stenberg <daniel@haxx.se>
+ * Copyright (C) 2009 by Thomas Martitz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -19,6 +19,14 @@
*
****************************************************************************/
-int sound_playback_thread(void* p);
-extern void (*sound_get_pcm)(unsigned char** start, long* size);
+#ifndef __BUTTON_SDL_H__
+#define __BUTTON_SDL_H__
+
+#include <stdbool.h>
+#include "config.h"
+
+bool button_hold(void);
+void button_init_device(void);
+
+#endif /* __BUTTON_SDL_H__ */
diff --git a/uisimulator/sdl/kernel-sdl.c b/firmware/target/hosted/sdl/kernel-sdl.c
index 3288a6f97a..d796921e35 100644
--- a/uisimulator/sdl/kernel-sdl.c
+++ b/firmware/target/hosted/sdl/kernel-sdl.c
@@ -20,14 +20,15 @@
****************************************************************************/
#include <stdlib.h>
+#include <stdio.h>
#include <SDL.h>
#include <SDL_thread.h>
#include "memory.h"
#include "system-sdl.h"
-#include "uisdl.h"
-#include "kernel.h"
#include "thread-sdl.h"
+#include "kernel.h"
#include "thread.h"
+#include "panic.h"
#include "debug.h"
static SDL_TimerID tick_timer_id;
@@ -90,19 +91,19 @@ void sim_exit_irq_handler(void)
SDL_UnlockMutex(sim_irq_mtx);
}
-bool sim_kernel_init(void)
+static bool sim_kernel_init(void)
{
sim_irq_mtx = SDL_CreateMutex();
if (sim_irq_mtx == NULL)
{
- fprintf(stderr, "Cannot create sim_handler_mtx\n");
+ panicf("Cannot create sim_handler_mtx\n");
return false;
}
sim_thread_cond = SDL_CreateCond();
if (sim_thread_cond == NULL)
{
- fprintf(stderr, "Cannot create sim_thread_cond\n");
+ panicf("Cannot create sim_thread_cond\n");
return false;
}
@@ -141,6 +142,12 @@ Uint32 tick_timer(Uint32 interval, void *param)
void tick_start(unsigned int interval_in_ms)
{
+ if (!sim_kernel_init())
+ {
+ panicf("Could not initialize kernel!");
+ exit(-1);
+ }
+
if (tick_timer_id != NULL)
{
SDL_RemoveTimer(tick_timer_id);
diff --git a/uisimulator/sdl/lcd-bitmap.c b/firmware/target/hosted/sdl/lcd-bitmap.c
index 0bd90196e4..6dfbffff37 100644
--- a/uisimulator/sdl/lcd-bitmap.c
+++ b/firmware/target/hosted/sdl/lcd-bitmap.c
@@ -20,7 +20,8 @@
****************************************************************************/
#include "debug.h"
-#include "uisdl.h"
+#include "sim-ui-defines.h"
+#include "system.h"
#include "lcd-sdl.h"
#include "screendump.h"
diff --git a/uisimulator/sdl/lcd-bitmap.h b/firmware/target/hosted/sdl/lcd-bitmap.h
index a898744b41..a898744b41 100644
--- a/uisimulator/sdl/lcd-bitmap.h
+++ b/firmware/target/hosted/sdl/lcd-bitmap.h
diff --git a/uisimulator/sdl/lcd-charcells.c b/firmware/target/hosted/sdl/lcd-charcells.c
index 05513ab266..900cbb04dd 100644
--- a/uisimulator/sdl/lcd-charcells.c
+++ b/firmware/target/hosted/sdl/lcd-charcells.c
@@ -19,17 +19,18 @@
*
****************************************************************************/
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "system.h"
#include "debug.h"
#include "lcd.h"
#include "lcd-charcell.h"
#include "screendump.h"
#include "general.h"
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
#include "lcd-playersim.h"
-#include "uisdl.h"
+#include "sim-ui-defines.h"
#include "lcd-sdl.h"
/* can't include file.h here */
diff --git a/uisimulator/sdl/lcd-charcells.h b/firmware/target/hosted/sdl/lcd-charcells.h
index 890594f766..890594f766 100644
--- a/uisimulator/sdl/lcd-charcells.h
+++ b/firmware/target/hosted/sdl/lcd-charcells.h
diff --git a/uisimulator/sdl/lcd-remote-bitmap.c b/firmware/target/hosted/sdl/lcd-remote-bitmap.c
index c44e476288..9972f3e423 100644
--- a/uisimulator/sdl/lcd-remote-bitmap.c
+++ b/firmware/target/hosted/sdl/lcd-remote-bitmap.c
@@ -19,10 +19,11 @@
*
****************************************************************************/
-#include "uisdl.h"
+#include "sim-ui-defines.h"
#include "lcd-sdl.h"
#include "lcd-remote-bitmap.h"
#include "screendump.h"
+#include "system.h" /* background */
SDL_Surface *remote_surface = 0;
diff --git a/uisimulator/sdl/lcd-remote-bitmap.h b/firmware/target/hosted/sdl/lcd-remote-bitmap.h
index 0a92ee6b79..0a92ee6b79 100644
--- a/uisimulator/sdl/lcd-remote-bitmap.h
+++ b/firmware/target/hosted/sdl/lcd-remote-bitmap.h
diff --git a/uisimulator/sdl/lcd-sdl.c b/firmware/target/hosted/sdl/lcd-sdl.c
index f1ffe8a76a..15e4ba95c3 100644
--- a/uisimulator/sdl/lcd-sdl.c
+++ b/firmware/target/hosted/sdl/lcd-sdl.c
@@ -19,8 +19,9 @@
*
****************************************************************************/
+#include <SDL.h>
#include "lcd-sdl.h"
-#include "uisdl.h"
+#include "sim-ui-defines.h"
#include "system.h" /* for MIN() and MAX() */
int display_zoom = 1;
diff --git a/uisimulator/sdl/lcd-sdl.h b/firmware/target/hosted/sdl/lcd-sdl.h
index 9ffa5246cf..1f57b06b95 100644
--- a/uisimulator/sdl/lcd-sdl.h
+++ b/firmware/target/hosted/sdl/lcd-sdl.h
@@ -27,6 +27,7 @@
/* Default display zoom level */
extern int display_zoom;
+extern SDL_Surface *gui_surface;
void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width,
int height, int max_x, int max_y,
diff --git a/uisimulator/sdl/sound.c b/firmware/target/hosted/sdl/pcm-sdl.c
index 0f8d5d4934..1772db94f4 100644
--- a/uisimulator/sdl/sound.c
+++ b/firmware/target/hosted/sdl/pcm-sdl.c
@@ -8,6 +8,7 @@
* $Id$
*
* Copyright (C) 2005 by Nick Lanham
+ * Copyright (C) 2010 by Thomas Martitz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,17 +24,20 @@
#include <stdlib.h>
#include <stdbool.h>
-#include <memory.h>
-#include "kernel.h"
+#include <SDL.h>
+#include "config.h"
+#include "debug.h"
#include "sound.h"
#include "audiohw.h"
+#include "system.h"
#include "pcm.h"
#include "pcm_sampr.h"
-#include "SDL.h"
-/*#define LOGF_ENABLE*/
-#include "logf.h"
+#ifdef DEBUG
+#include <stdio.h>
+extern bool debug_audio;
+#endif
static int sim_volume = 0;
@@ -45,23 +49,19 @@ static size_t pcm_data_size;
static size_t pcm_sample_bytes;
static size_t pcm_channel_bytes;
-static struct pcm_udata
+struct pcm_udata
{
Uint8 *stream;
Uint32 num_in;
Uint32 num_out;
+#ifdef DEBUG
FILE *debug;
+#endif
} udata;
static SDL_AudioSpec obtained;
static SDL_AudioCVT cvt;
-extern bool debug_audio;
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
void pcm_play_lock(void)
{
SDL_LockAudio();
@@ -102,11 +102,13 @@ void pcm_play_dma_start(const void *addr, size_t size)
void pcm_play_dma_stop(void)
{
SDL_PauseAudio(1);
+#ifdef DEBUG
if (udata.debug != NULL) {
fclose(udata.debug);
udata.debug = NULL;
DEBUGF("Audio debug file closed\n");
}
+#endif
}
void pcm_play_dma_pause(bool pause)
@@ -122,13 +124,14 @@ size_t pcm_get_bytes_waiting(void)
return pcm_data_size;
}
-extern int sim_volume; /* in firmware/sound.c */
-static void write_to_soundcard(struct pcm_udata *udata) {
+void write_to_soundcard(struct pcm_udata *udata)
+{
+#ifdef DEBUG
if (debug_audio && (udata->debug == NULL)) {
udata->debug = fopen("audiodebug.raw", "ab");
DEBUGF("Audio debug file open\n");
}
-
+#endif
if (cvt.needed) {
Uint32 rd = udata->num_in;
Uint32 wr = (double)rd * cvt.len_ratio;
@@ -162,10 +165,11 @@ static void write_to_soundcard(struct pcm_udata *udata) {
udata->num_in = cvt.len / pcm_sample_bytes;
udata->num_out = cvt.len_cvt / pcm_sample_bytes;
+#ifdef DEBUG
if (udata->debug != NULL) {
fwrite(cvt.buf, sizeof(Uint8), cvt.len_cvt, udata->debug);
}
-
+#endif
free(cvt.buf);
}
else {
@@ -191,26 +195,27 @@ static void write_to_soundcard(struct pcm_udata *udata) {
break;
}
}
-
+#ifdef DEBUG
if (udata->debug != NULL) {
fwrite(udata->stream, sizeof(Uint8), wr, udata->debug);
}
+#endif
}
} else {
udata->num_in = udata->num_out = MIN(udata->num_in, udata->num_out);
SDL_MixAudio(udata->stream, pcm_data,
udata->num_out * pcm_sample_bytes, sim_volume);
-
+#ifdef DEBUG
if (udata->debug != NULL) {
fwrite(pcm_data, sizeof(Uint8), udata->num_out * pcm_sample_bytes,
udata->debug);
}
+#endif
}
}
-static void sdl_audio_callback(struct pcm_udata *udata, Uint8 *stream, int len)
+void sdl_audio_callback(struct pcm_udata *udata, Uint8 *stream, int len)
{
- logf("sdl_audio_callback: len %d, pcm %d\n", len, pcm_data_size);
udata->stream = stream;
/* Write what we have in the PCM buffer */
@@ -221,6 +226,7 @@ static void sdl_audio_callback(struct pcm_udata *udata, Uint8 *stream, int len)
while (len > 0) {
if ((ssize_t)pcm_data_size <= 0) {
pcm_data_size = 0;
+
if (pcm_callback_for_more)
pcm_callback_for_more(&pcm_data, &pcm_data_size);
}
@@ -302,14 +308,20 @@ const void * pcm_rec_dma_get_peak_buffer(void)
void pcm_play_dma_init(void)
{
+ if (SDL_InitSubSystem(SDL_INIT_AUDIO))
+ {
+ DEBUGF("Could not initialize SDL audio subsystem!\n");
+ return;
+ }
+
SDL_AudioSpec wanted_spec;
+#ifdef DEBUG
udata.debug = NULL;
-
if (debug_audio) {
udata.debug = fopen("audiodebug.raw", "wb");
DEBUGF("Audio debug file open\n");
}
-
+#endif
/* Set 16-bit stereo audio at 44Khz */
wanted_spec.freq = 44100;
wanted_spec.format = AUDIO_S16SYS;
@@ -322,7 +334,7 @@ void pcm_play_dma_init(void)
/* Open the audio device and start playing sound! */
if(SDL_OpenAudio(&wanted_spec, &obtained) < 0) {
- fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
+ DEBUGF("Unable to open audio: %s\n", SDL_GetError());
return;
}
@@ -339,7 +351,7 @@ void pcm_play_dma_init(void)
pcm_channel_bytes = 2;
break;
default:
- fprintf(stderr, "Unknown sample format obtained: %u\n",
+ DEBUGF("Unknown sample format obtained: %u\n",
(unsigned)obtained.format);
return;
}
@@ -353,74 +365,9 @@ void pcm_postinit(void)
{
}
-#endif /* CONFIG_CODEC == SWCODEC */
-
-/**
- * Audio Hardware api. Make them do nothing as we cannot properly simulate with
- * SDL. if we used DSP we would run code that doesn't actually run on the target
- **/
-void audiohw_set_volume(int volume)
+void pcm_set_mixer_volume(int volume)
{
- sim_volume = SDL_MIX_MAXVOLUME * ((volume - VOLUME_MIN) / 10) / (VOLUME_RANGE / 10);
-}
-#if defined(AUDIOHW_HAVE_PRESCALER)
-void audiohw_set_prescaler(int value) { (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_BALANCE)
-void audiohw_set_balance(int value) { (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_BASS)
-void audiohw_set_bass(int value) { (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_TREBLE)
-void audiohw_set_treble(int value) { (void)value; }
-#endif
-#if CONFIG_CODEC != SWCODEC
-void audiohw_set_channel(int value) { (void)value; }
-void audiohw_set_stereo_width(int value){ (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_BASS_CUTOFF)
-void audiohw_set_bass_cutoff(int value) { (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
-void audiohw_set_treble_cutoff(int value){ (void)value; }
-#endif
-/* EQ-based tone controls */
-#if defined(AUDIOHW_HAVE_EQ)
-void audiohw_set_eq_band_gain(unsigned int band, int value)
- { (void)band; (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
-void audiohw_set_eq_band_frequency(unsigned int band, int value)
- { (void)band; (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_EQ_WIDTH)
-void audiohw_set_eq_band_width(unsigned int band, int value)
- { (void)band; (void)value; }
-#endif
-#if defined(AUDIOHW_HAVE_DEPTH_3D)
-void audiohw_set_depth_3d(int value)
- { (void)value; }
-#endif
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
-int mas_codec_readreg(int reg)
-{
- (void)reg;
- return 0;
+ sim_volume = volume;
}
-int mas_codec_writereg(int reg, unsigned int val)
-{
- (void)reg;
- (void)val;
- return 0;
-}
-int mas_writemem(int bank, int addr, const unsigned long* src, int len)
-{
- (void)bank;
- (void)addr;
- (void)src;
- (void)len;
- return 0;
-}
-#endif
+#endif /* CONFIG_CODEC == SWCODEC */
diff --git a/uisimulator/sdl/uisdl.h b/firmware/target/hosted/sdl/sim-ui-defines.h
index dac84ffb74..567a618fc3 100644
--- a/uisimulator/sdl/uisdl.h
+++ b/firmware/target/hosted/sdl/sim-ui-defines.h
@@ -397,12 +397,9 @@
#define UI_LCD_POSX 101
#define UI_LCD_POSY 195
-#else
+#elif defined(SIMULATOR)
#error no UI defines
#endif
-extern SDL_Surface *gui_surface;
-extern bool background; /* True if the background image is enabled */
-extern int display_zoom;
#endif /* #ifndef __UISDL_H__ */
diff --git a/uisimulator/sdl/uisdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 8cf4b42ba0..693e8d1b57 100644
--- a/uisimulator/sdl/uisdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -19,15 +19,13 @@
*
****************************************************************************/
+#include <SDL.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
-#include "autoconf.h"
-#include "button.h"
#include "system-sdl.h"
-#include "thread.h"
-#include "kernel.h"
-#include "uisdl.h"
+#include "thread-sdl.h"
+#include "sim-ui-defines.h"
#include "lcd-sdl.h"
#ifdef HAVE_LCD_BITMAP
#include "lcd-bitmap.h"
@@ -37,162 +35,58 @@
#ifdef HAVE_REMOTE_LCD
#include "lcd-remote-bitmap.h"
#endif
-#include "thread-sdl.h"
-#include "SDL_mutex.h"
-#include "SDL_thread.h"
-#include "math.h"
+#include "panic.h"
+#include "debug.h"
+SDL_Surface *gui_surface;
-/* extern functions */
-extern void new_key(int key);
-extern int xy2button( int x, int y);
-void button_event(int key, bool pressed);
-
-SDL_Surface *gui_surface;
-bool background = true; /* use backgrounds by default */
+bool background = true; /* use backgrounds by default */
#ifdef HAVE_REMOTE_LCD
-static bool showremote = true; /* include remote by default */
+bool showremote = true; /* include remote by default */
#endif
-bool mapping = false;
-bool debug_buttons = false;
+bool mapping = false;
+bool debug_buttons = false;
-bool lcd_display_redraw = true; /* Used for player simulator */
-char having_new_lcd = true; /* Used for player simulator */
-bool sim_alarm_wakeup = false;
-const char *sim_root_dir = NULL;
+bool lcd_display_redraw = true; /* Used for player simulator */
+char having_new_lcd = true; /* Used for player simulator */
+bool sim_alarm_wakeup = false;
+const char *sim_root_dir = NULL;
+extern int display_zoom;
+#ifdef DEBUG
bool debug_audio = false;
+#endif
bool debug_wps = false;
int wps_verbose_level = 3;
-void irq_button_event(int key, bool pressed) {
- sim_enter_irq_handler();
- button_event( key, pressed );
- sim_exit_irq_handler();
-}
-
-int sqr( int a ) {
- return a*a;
-}
-
-void gui_message_loop(void)
+void sys_poweroff(void)
{
- SDL_Event event;
- bool done = false;
- static int x,y,xybutton = 0;
-
- while(!done && SDL_WaitEvent(&event))
- {
- switch(event.type)
- {
- case SDL_KEYDOWN:
- irq_button_event(event.key.keysym.sym, true);
- break;
- case SDL_KEYUP:
- irq_button_event(event.key.keysym.sym, false);
- case SDL_MOUSEBUTTONDOWN:
- switch ( event.button.button ) {
-#ifdef HAVE_SCROLLWHEEL
- case SDL_BUTTON_WHEELUP:
- irq_button_event( SDLK_UP, true );
- break;
- case SDL_BUTTON_WHEELDOWN:
- irq_button_event( SDLK_DOWN, true );
- break;
-#endif
- case SDL_BUTTON_LEFT:
- case SDL_BUTTON_MIDDLE:
- if ( mapping && background ) {
- x = event.button.x;
- y = event.button.y;
- }
- if ( background ) {
- xybutton = xy2button( event.button.x, event.button.y );
- if( xybutton )
- irq_button_event( xybutton, true );
- }
- break;
- default:
- break;
- }
-
- if (debug_wps && event.button.button == 1)
- {
- if ( background )
-#ifdef HAVE_REMOTE
- if ( event.button.y < UI_REMOTE_POSY ) /* Main Screen */
- printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 );
- else
- printf("Mouse at: (%d, %d)\n", event.button.x - UI_REMOTE_POSX -1 , event.button.y - UI_REMOTE_POSY - 1 );
-#else
- printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 );
-#endif
- else
- if ( event.button.y/display_zoom < LCD_HEIGHT ) /* Main Screen */
- printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom );
-#ifdef HAVE_REMOTE
- else
- printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom - LCD_HEIGHT );
-#endif
- }
- break;
- case SDL_MOUSEBUTTONUP:
- switch ( event.button.button ) {
- /* The scrollwheel button up events are ignored as they are queued immediately */
- case SDL_BUTTON_LEFT:
- case SDL_BUTTON_MIDDLE:
- if ( mapping && background ) {
- printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, y, (int)sqrt( sqr(x-(int)event.button.x) + sqr(y-(int)event.button.y)) );
- }
- if ( background && xybutton ) {
- irq_button_event( xybutton, false );
- xybutton = 0;
- }
-#ifdef HAVE_TOUCHSCREEN
- else {
- irq_button_event(BUTTON_TOUCHSCREEN, false);
- }
-#endif
- break;
- default:
- break;
- }
- break;
-
-
- case SDL_QUIT:
- done = true;
- break;
- default:
- /*printf("Unhandled event\n"); */
- break;
- }
- }
+ /* Order here is relevent to prevent deadlocks and use of destroyed
+ sync primitives by kernel threads */
+ sim_thread_shutdown();
+ sim_kernel_shutdown();
+ SDL_Quit();
}
-bool gui_startup(void)
+void system_init(void)
{
SDL_Surface *picture_surface;
int width, height;
- if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER)) {
- fprintf(stderr, "fatal: %s\n", SDL_GetError());
- return false;
- }
-
- atexit(SDL_Quit);
+ if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER))
+ panicf("%s", SDL_GetError());
/* Try and load the background image. If it fails go without */
if (background) {
picture_surface = SDL_LoadBMP("UI256.bmp");
if (picture_surface == NULL) {
background = false;
- fprintf(stderr, "warn: %s\n", SDL_GetError());
+ DEBUGF("warn: %s\n", SDL_GetError());
}
}
-
+
/* Set things up */
if (background)
{
@@ -217,8 +111,7 @@ bool gui_startup(void)
if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) {
- fprintf(stderr, "fatal: %s\n", SDL_GetError());
- return false;
+ panicf("%s", SDL_GetError());
}
SDL_WM_SetCaption(UI_TITLE, NULL);
@@ -229,43 +122,38 @@ bool gui_startup(void)
sim_lcd_remote_init();
#endif
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-
if (background && picture_surface != NULL) {
SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
SDL_UpdateRect(gui_surface, 0, 0, 0, 0);
}
-
- return true;
}
-bool gui_shutdown(void)
+void system_exception_wait(void)
{
- /* Order here is relevent to prevent deadlocks and use of destroyed
- sync primitives by kernel threads */
- thread_sdl_shutdown();
- sim_kernel_shutdown();
- return true;
+ sim_thread_exception_wait();
}
-#if defined(WIN32) && defined(main)
-/* Don't use SDL_main on windows -> no more stdio redirection */
-#undef main
-#endif
+void system_reboot(void)
+{
+ sim_thread_exception_wait();
+}
-int main(int argc, char *argv[])
+void sys_handle_argv(int argc, char *argv[])
{
if (argc >= 1)
{
int x;
for (x = 1; x < argc; x++)
{
+#ifdef DEBUG
if (!strcmp("--debugaudio", argv[x]))
{
debug_audio = true;
printf("Writing debug audio file.\n");
- }
- else if (!strcmp("--debugwps", argv[x]))
+ }
+ else
+#endif
+ if (!strcmp("--debugwps", argv[x]))
{
debug_wps = true;
printf("WPS debug mode enabled.\n");
@@ -325,7 +213,9 @@ int main(int argc, char *argv[])
{
printf("rockboxui\n");
printf("Arguments:\n");
+#ifdef DEBUG
printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n");
+#endif
printf(" --debugwps \t Print advanced WPS debug info\n");
printf(" --nobackground \t Disable the background image\n");
#ifdef HAVE_REMOTE_LCD
@@ -340,29 +230,7 @@ int main(int argc, char *argv[])
}
}
}
-
if (display_zoom > 1) {
background = false;
}
-
- if (!sim_kernel_init()) {
- fprintf(stderr, "sim_kernel_init failed\n");
- return -1;
- }
-
- if (!gui_startup()) {
- fprintf(stderr, "gui_startup failed\n");
- return -1;
- }
-
- /* app_main will be called by the new main thread */
- if (!thread_sdl_init(NULL)) {
- fprintf(stderr, "thread_sdl_init failed\n");
- return -1;
- }
-
- gui_message_loop();
-
- return gui_shutdown();
}
-
diff --git a/uisimulator/sdl/system-sdl.h b/firmware/target/hosted/sdl/system-sdl.h
index 04e033e330..917e6e89da 100644
--- a/uisimulator/sdl/system-sdl.h
+++ b/firmware/target/hosted/sdl/system-sdl.h
@@ -41,9 +41,12 @@ int set_irq_level(int level);
void sim_enter_irq_handler(void);
void sim_exit_irq_handler(void);
-bool sim_kernel_init(void);
void sim_kernel_shutdown(void);
+void sys_poweroff(void);
+void sys_handle_argv(int argc, char *argv[]);
+extern bool background; /* True if the background image is enabled */
+extern int display_zoom;
extern long start_tick;
#endif /* _SYSTEM_SDL_H_ */
diff --git a/uisimulator/sdl/thread-sdl.c b/firmware/target/hosted/sdl/thread-sdl.c
index e9b5fc205d..fbe2621d40 100644
--- a/uisimulator/sdl/thread-sdl.c
+++ b/firmware/target/hosted/sdl/thread-sdl.c
@@ -56,12 +56,15 @@ struct thread_entry threads[MAXTHREADS];
* in their start routines responding to messages so this is the only
* way to get them back in there so they may exit */
static jmp_buf thread_jmpbufs[MAXTHREADS];
+/* this mutex locks out other Rockbox threads while one runs,
+ * that enables us to simulate a cooperative environment even if
+ * the host is preemptive */
static SDL_mutex *m;
static volatile bool threads_exit = false;
extern long start_tick;
-void thread_sdl_shutdown(void)
+void sim_thread_shutdown(void)
{
int i;
@@ -79,6 +82,7 @@ void thread_sdl_shutdown(void)
for (i = 0; i < MAXTHREADS; i++)
{
struct thread_entry *thread = &threads[i];
+ /* exit all current threads, except the main one */
if (thread->context.t != NULL)
{
/* Signal thread on delay or block */
@@ -128,30 +132,9 @@ static struct thread_entry * find_empty_thread_slot(void)
return thread;
}
-/* Do main thread creation in this file scope to avoid the need to double-
- return to a prior call-level which would be unaware of the fact setjmp
- was used */
-extern void app_main(void *param);
-static int thread_sdl_app_main(void *param)
-{
- SDL_LockMutex(m);
- cores[CURRENT_CORE].running = &threads[0];
-
- /* Set the jump address for return */
- if (setjmp(thread_jmpbufs[0]) == 0)
- {
- app_main(param);
- /* should not ever be reached but... */
- THREAD_PANICF("app_main returned!\n");
- }
-
- /* Unlock and exit */
- SDL_UnlockMutex(m);
- return 0;
-}
/* Initialize SDL threading */
-bool thread_sdl_init(void *param)
+void init_threads(void)
{
struct thread_entry *thread;
int n;
@@ -164,7 +147,7 @@ bool thread_sdl_init(void *param)
if (SDL_LockMutex(m) == -1)
{
fprintf(stderr, "Couldn't lock mutex\n");
- return false;
+ return;
}
/* Initialize all IDs */
@@ -180,30 +163,21 @@ bool thread_sdl_init(void *param)
thread->name = "main";
thread->state = STATE_RUNNING;
thread->context.s = SDL_CreateSemaphore(0);
+ thread->context.t = NULL; /* NULL for the implicit main thread */
cores[CURRENT_CORE].running = thread;
if (thread->context.s == NULL)
{
fprintf(stderr, "Failed to create main semaphore\n");
- return false;
- }
-
- thread->context.t = SDL_CreateThread(thread_sdl_app_main, param);
-
- if (thread->context.t == NULL)
- {
- SDL_DestroySemaphore(thread->context.s);
- fprintf(stderr, "Failed to create main thread\n");
- return false;
+ return;
}
THREAD_SDL_DEBUGF("Main thread: %p\n", thread);
- SDL_UnlockMutex(m);
- return true;
+ return;
}
-void thread_sdl_exception_wait(void)
+void sim_thread_exception_wait(void)
{
while (1)
{
@@ -214,7 +188,7 @@ void thread_sdl_exception_wait(void)
}
/* A way to yield and leave the threading system for extended periods */
-void thread_sdl_thread_lock(void *me)
+void sim_thread_lock(void *me)
{
SDL_LockMutex(m);
cores[CURRENT_CORE].running = (struct thread_entry *)me;
@@ -223,7 +197,7 @@ void thread_sdl_thread_lock(void *me)
thread_exit();
}
-void * thread_sdl_thread_unlock(void)
+void * sim_thread_unlock(void)
{
struct thread_entry *current = cores[CURRENT_CORE].running;
SDL_UnlockMutex(m);
@@ -529,19 +503,6 @@ unsigned int create_thread(void (*function)(void),
return thread->id;
}
-void init_threads(void)
-{
- /* Main thread is already initialized */
- if (cores[CURRENT_CORE].running != &threads[0])
- {
- THREAD_PANICF("Wrong main thread in init_threads: %p\n",
- cores[CURRENT_CORE].running);
- }
-
- THREAD_SDL_DEBUGF("First Thread: %d (%s)\n",
- 0, THREAD_SDL_GET_NAME(&threads[0]));
-}
-
#ifndef ALLOW_REMOVE_THREAD
static void remove_thread(unsigned int thread_id)
#else
diff --git a/uisimulator/sdl/thread-sdl.h b/firmware/target/hosted/sdl/thread-sdl.h
index f221aa5a72..9384e6060d 100644
--- a/uisimulator/sdl/thread-sdl.h
+++ b/firmware/target/hosted/sdl/thread-sdl.h
@@ -22,16 +22,11 @@
#ifndef __THREADSDL_H__
#define __THREADSDL_H__
-#include "SDL_thread.h"
-
-extern SDL_Thread *gui_thread; /* The "main" thread */
-void thread_sdl_thread_lock(void *me);
-void * thread_sdl_thread_unlock(void);
-void thread_sdl_exception_wait(void);
-bool thread_sdl_init(void *param); /* Init the sim threading API - thread created calls app_main */
-void thread_sdl_shutdown(void); /* Shut down all kernel threads gracefully */
-void thread_sdl_lock(void); /* Sync with SDL threads */
-void thread_sdl_unlock(void); /* Sync with SDL threads */
+/* extra thread functions that only apply when running on hosting platforms */
+void sim_thread_lock(void *me);
+void * sim_thread_unlock(void);
+void sim_thread_exception_wait(void);
+void sim_thread_shutdown(void); /* Shut down all kernel threads gracefully */
#endif /* #ifndef __THREADSDL_H__ */
diff --git a/uisimulator/sdl/timer.c b/firmware/target/hosted/sdl/timer-sdl.c
index 369aeab929..369aeab929 100644
--- a/uisimulator/sdl/timer.c
+++ b/firmware/target/hosted/sdl/timer-sdl.c
diff --git a/tools/configure b/tools/configure
index 6b58e432ed..bf49be8a9e 100755
--- a/tools/configure
+++ b/tools/configure
@@ -2973,6 +2973,10 @@ EOF
if test -n "$t_cpu"; then
TARGET_INC="-I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer/$t_model"
+ if [ "$simulator" = "yes" ]; then # a few more includes for the sim target tree
+ TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/"
+ TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/"
+ fi
TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer"
TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu"
GCCOPTS="$GCCOPTS"
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index cddb19c9a8..bdcc7e6ca1 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -233,7 +233,7 @@ static ssize_t io_trigger_and_wait(int cmd)
{
/* Allow other rockbox threads to run */
io.accum = 0;
- mythread = thread_sdl_thread_unlock();
+ mythread = sim_thread_unlock();
}
switch (cmd)
@@ -249,7 +249,7 @@ static ssize_t io_trigger_and_wait(int cmd)
/* Regain our status as current */
if (mythread != NULL)
{
- thread_sdl_thread_lock(mythread);
+ sim_thread_lock(mythread);
}
return result;
diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c
index e2ce8c10d2..dbd3149fbb 100644
--- a/uisimulator/common/powermgmt-sim.c
+++ b/uisimulator/common/powermgmt-sim.c
@@ -157,10 +157,6 @@ void shutdown_hw(void)
{
}
-void sys_poweroff(void)
-{
-}
-
void cancel_shutdown(void)
{
}
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index d1ec4ec6c2..d4a9af126c 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -314,25 +314,9 @@ void cpu_sleep(bool enabled)
(void)enabled;
}
-void button_set_flip(bool yesno)
-{
- (void)yesno;
-}
-
#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
void touchpad_set_sensitivity(int level)
{
(void)level;
}
#endif
-
-void system_exception_wait(void)
-{
- thread_sdl_exception_wait();
-}
-
-void system_reboot(void)
-{
- thread_sdl_exception_wait();
-}
-
diff --git a/uisimulator/sdl/Makefile b/uisimulator/sdl/Makefile
deleted file mode 100644
index dc76b35d68..0000000000
--- a/uisimulator/sdl/Makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-############################################################################
-# __________ __ ___.
-# Open \______ \ ____ ____ | | _\_ |__ _______ ___
-# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
-# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
-# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
-# \/ \/ \/ \/ \/
-# $Id$
-#
-# Copyright (C) 2002, 2008 by Daniel Stenberg <daniel@haxx.se>
-#
-# All files in this archive are subject to the GNU General Public License.
-# See the file COPYING in the source tree root for full license agreement.
-#
-# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-# KIND, either express or implied.
-#
-############################################################################
-
-SIMCOMMON = ../common
-
-DEPFILE = $(OBJDIR)/dep-sim
-
-RM = rm -f
-DEBUG = -g
-
-# Use this for simulator-only files
-INCLUDES = -I. -I$(SIMCOMMON) -I$(OBJDIR) $(TARGET_INC) -I$(FIRMDIR)/export \
--I$(APPSDIR) -I$(BUILDDIR)
-
-# This sets up 'SRC' based on the files mentioned in SOURCES
-include $(TOOLSDIR)/makesrc.inc
-
-OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
-
-DEFINES := -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
-$(TARGET) -DAPPSVERSION=\"$(VERSION)\" -DMEM=${MEMORYSIZE} $(EXTRA_DEFINES)
-
-SOURCES = $(SRC)
-
-DIRS = .
-
-CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS) -W -Wall
-
-OUTFILE = $(BUILDDIR)/libsim.a
-
-all: $(OUTFILE)
-
-include $(TOOLSDIR)/make.inc
-
-$(OUTFILE): $(OBJS) $(BUILDDIR)/UI256.bmp
- $(call PRINTS,AR+RANLIB $(@F))$(AR) ruv $@ $(OBJS) >/dev/null 2>&1
- $(SILENT)$(RANLIB) $@
-
-clean:
- $(call PRINTS,cleaning sim)$(RM) $(OBJS) *~ core $(OUTFILE) $(DEPFILE) \
- $(BUILDDIR)/UI256.bmp $(DEPFILE)
- $(SILENT)$(MAKE) -C $(SIMCOMMON) clean
-
-################## Specific dependencies ##################
-$(BUILDDIR)/UI256.bmp: UI-$(MODELNAME).bmp
- $(call PRINTS,UI)cp $< $@
-
--include $(DEPFILE)
diff --git a/uisimulator/sdl/README b/uisimulator/sdl/README
deleted file mode 100644
index 0a293f6ad2..0000000000
--- a/uisimulator/sdl/README
+++ /dev/null
@@ -1,6 +0,0 @@
-To build:
-
- $ ../tools/configure
- [answer questions]
- $ make
- $ ./rockboxui
diff --git a/uisimulator/sdl/SOURCES b/uisimulator/sdl/SOURCES
deleted file mode 100644
index 1d5b498248..0000000000
--- a/uisimulator/sdl/SOURCES
+++ /dev/null
@@ -1,15 +0,0 @@
-button.c
-kernel-sdl.c
-#ifdef HAVE_LCD_BITMAP
-lcd-bitmap.c
-#elif defined(HAVE_LCD_CHARCELLS)
-lcd-charcells.c
-#endif
-#ifdef HAVE_REMOTE_LCD
-lcd-remote-bitmap.c
-#endif
-lcd-sdl.c
-sound.c
-timer.c
-thread-sdl.c
-uisdl.c
diff --git a/uisimulator/sdl/button-sdl.h b/uisimulator/sdl/button-sdl.h
deleted file mode 100644
index 948af62c5b..0000000000
--- a/uisimulator/sdl/button-sdl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2009 by Thomas Martitz
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-
-#ifndef _BUTTON_SDL_H_
-#define _BUTTON_SDL_H_
-
-#include <stdbool.h>
-#include "config.h"
-#include "button-target.h"
-
-#undef HAVE_LCD_FLIP
-
-#undef button_init_device
-#define button_init_device()
-
-struct button_map {
- int button, x, y, radius;
- char *description;
-};
-
-int xy2button( int x, int y);
-bool button_hold(void);
-void button_init_sdl(void);
-#undef button_init_device
-#define button_init_device() button_init_sdl()
-
-#endif
diff --git a/uisimulator/sdl/timefuncs.h b/uisimulator/sdl/timefuncs.h
deleted file mode 100644
index de17fcdc73..0000000000
--- a/uisimulator/sdl/timefuncs.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <time.h>
-#include <stdbool.h>
-
-/* struct tm defined */
-struct tm *get_time(void);
-int set_time(const struct tm *tm);
-bool valid_time(const struct tm *tm);
diff --git a/uisimulator/uisimulator.make b/uisimulator/uisimulator.make
index 121f31e0f6..86fcb2a3d2 100644
--- a/uisimulator/uisimulator.make
+++ b/uisimulator/uisimulator.make
@@ -8,13 +8,10 @@
#
INCLUDES += -I$(ROOTDIR)/uisimulator/sdl -I$(ROOTDIR)/uisimulator/common \
+ -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
-SIMINCLUDES += -I$(ROOTDIR)/uisimulator/sdl -I$(ROOTDIR)/uisimulator/common \
- -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
+SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
-SIMFLAGS += $(SIMINCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
-
-SIMSRC += $(call preprocess, $(ROOTDIR)/uisimulator/sdl/SOURCES)
SIMSRC += $(call preprocess, $(ROOTDIR)/uisimulator/common/SOURCES)
SIMOBJ = $(call c2obj,$(SIMSRC))
OTHER_SRC += $(SIMSRC)