summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-04-29 22:24:40 +0000
committerThomas Martitz <kugel@rockbox.org>2009-04-29 22:24:40 +0000
commita7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1 (patch)
tree56e877c510c54d67688680f72ed2384389b4a3c7 /uisimulator
parentecd4394f624b9f10b091bc90a63fd80653f85fad (diff)
downloadrockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.tar.gz
rockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.tar.bz2
rockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.zip
Simulate lcd_enable and lcd_sleep in the simulator. Therefore, turn backlight-sim.h into a .c too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20829 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/SOURCES1
-rw-r--r--uisimulator/common/backlight-sim.c84
-rw-r--r--uisimulator/common/backlight-sim.h54
-rw-r--r--uisimulator/common/lcd-common.c55
-rw-r--r--uisimulator/common/stubs.c13
-rw-r--r--uisimulator/uisimulator.make2
6 files changed, 157 insertions, 52 deletions
diff --git a/uisimulator/common/SOURCES b/uisimulator/common/SOURCES
index bda79b66b9..c1865513f9 100644
--- a/uisimulator/common/SOURCES
+++ b/uisimulator/common/SOURCES
@@ -9,4 +9,5 @@ sim_icons.c
sim_tasks.c
stubs.c
powermgmt-sim.c
+backlight-sim.c
diff --git a/uisimulator/common/backlight-sim.c b/uisimulator/common/backlight-sim.c
new file mode 100644
index 0000000000..ec50249dde
--- /dev/null
+++ b/uisimulator/common/backlight-sim.c
@@ -0,0 +1,84 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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.
+ *
+ ****************************************************************************/
+
+#include <stdbool.h>
+#include "config.h"
+#include "backlight.h"
+#include "lcd.h"
+
+#ifdef HAVE_LCD_SLEEP
+extern void lcd_awake(void);
+#endif
+/* in uisimulator/sdl/lcd-bitmap.c and lcd-charcell.c */
+extern void sim_backlight(int value);
+
+void _backlight_on(void)
+{
+ sim_backlight(100);
+#if defined(HAVE_LCD_ENABLE)
+ lcd_enable(true);
+#elif defined(HAVE_LCD_SLEEP)
+ lcd_awake();
+#endif
+}
+
+void _backlight_off(void)
+{
+ sim_backlight(0);
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(false);
+#endif
+}
+
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+void _backlight_set_brightness(int val)
+{
+ (void)val;
+}
+#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
+#ifdef HAVE_BUTTON_LIGHT
+void _buttonlight_on(void)
+{
+}
+
+void _buttonlight_off(void)
+{
+}
+
+#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
+void _buttonlight_set_brightness(int val)
+{
+ (void)val;
+}
+#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
+#endif /* HAVE_BUTTON_LIGHT */
+
+#ifdef HAVE_REMOTE_LCD
+void _remote_backlight_on(void)
+{
+ sim_remote_backlight(100);
+}
+
+void _remote_backlight_off(void)
+{
+ sim_remote_backlight(0);
+}
+#endif /* HAVE_REMOTE_LCD */
diff --git a/uisimulator/common/backlight-sim.h b/uisimulator/common/backlight-sim.h
index 59abe36f7d..366ebf8096 100644
--- a/uisimulator/common/backlight-sim.h
+++ b/uisimulator/common/backlight-sim.h
@@ -5,9 +5,8 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id$
+ * $Id:$
*
- * Copyright (C) 2002 by Linus Nielsen Feltzing
* Copyright (C) 2009 by Thomas Martitz
*
* This program is free software; you can redistribute it and/or
@@ -19,50 +18,31 @@
* KIND, either express or implied.
*
****************************************************************************/
-#ifdef SIMULATOR
-static inline void _backlight_on(void)
-{
- sim_backlight(100);
-}
+#ifndef BACKLIGHT_SIM_H
+#define BACKLIGHT_SIM_H
+
+#include "config.h"
+
+void _backlight_on(void);
+void _backlight_off(void);
-static inline void _backlight_off(void)
-{
- sim_backlight(0);
-}
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
-static inline void _backlight_set_brightness(int val)
-{
- (void)val;
-}
+void _backlight_set_brightness(int val);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTON_LIGHT
-static inline void _buttonlight_on(void)
-{
-}
-
-static inline void _buttonlight_off(void)
-{
-}
-
+void _buttonlight_on(void);
+void _buttonlight_off(void);
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
-static inline void _buttonlight_set_brightness(int val)
-{
- (void)val;
-}
+void _buttonlight_set_brightness(int val);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#endif /* HAVE_BUTTON_LIGHT */
#ifdef HAVE_REMOTE_LCD
-static inline void _remote_backlight_on(void)
-{
- sim_remote_backlight(100);
-}
-
-static inline void _remote_backlight_off(void)
-{
- sim_remote_backlight(0);
-}
+void _remote_backlight_on(void);
+void _remote_backlight_off(void);
#endif /* HAVE_REMOTE_LCD */
-#endif /* SIMULATOR */
+
+#endif /* BACKLIGHT_SIM_H */
+
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c
index 7d40f36b0f..52db776856 100644
--- a/uisimulator/common/lcd-common.c
+++ b/uisimulator/common/lcd-common.c
@@ -22,8 +22,15 @@
*
****************************************************************************/
+#include "config.h"
#include "lcd.h"
-#include "lcd-sdl.h"
+
+#ifdef HAVE_LCD_ENABLE
+static bool lcd_enabled = false;
+#endif
+#ifdef HAVE_LCD_SLEEP
+static bool lcd_sleeping = true;
+#endif
void lcd_set_flip(bool yesno)
{
@@ -64,3 +71,49 @@ void lcd_remote_set_invert_display(bool invert)
(void)invert;
}
#endif
+
+#ifdef HAVE_LCD_SLEEP
+void lcd_sleep(void)
+{
+ lcd_sleeping = true;
+}
+
+void lcd_awake(void)
+{
+ if (lcd_sleeping)
+ {
+ lcd_activation_call_hook();
+ lcd_sleeping = false;
+ }
+}
+#endif
+#ifdef HAVE_LCD_ENABLE
+void lcd_enable(bool on)
+{
+ if (on && !lcd_enabled)
+ {
+#ifdef HAVE_LCD_SLEEP
+ /* lcd_awake will handle the activation call */
+ lcd_awake();
+#else
+ lcd_activation_call_hook();
+#endif
+ }
+ lcd_enabled = on;
+}
+#endif
+
+#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
+bool lcd_active(void)
+{
+ bool retval = false;
+#ifdef HAVE_LCD_ENABLE
+ retval = lcd_enabled;
+#endif
+#ifdef HAVE_LCD_SLEEP
+ if (!retval)
+ retval = !lcd_sleeping;
+#endif
+ return retval;
+}
+#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 5d3c54a8d0..1d0d6c51d8 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -202,19 +202,6 @@ bool headphones_inserted(void)
}
#endif
-#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
-bool lcd_active(void)
-{
- return true;
-}
-#endif
-
-#ifdef HAVE_LCD_SLEEP
-void lcd_sleep(void)
-{
-}
-#endif
-
#ifdef HAVE_SPDIF_POWER
void spdif_power_enable(bool on)
{
diff --git a/uisimulator/uisimulator.make b/uisimulator/uisimulator.make
index f39d6e0265..9aeb02cd3d 100644
--- a/uisimulator/uisimulator.make
+++ b/uisimulator/uisimulator.make
@@ -28,7 +28,7 @@ $(SIMLIB): $$(SIMOBJ) $(UIBMP)
$(SILENT)$(shell rm -f $@)
$(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
-$(BUILDDIR)/$(BINARY): $$(OBJ) $(SIMLIB) $(VOICESPEEXLIB) $(FIRMLIB)
+$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(SIMLIB) $(VOICESPEEXLIB)
$(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS)
$(BUILDDIR)/uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c