summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-10-20 21:54:59 +0000
committerThomas Martitz <kugel@rockbox.org>2009-10-20 21:54:59 +0000
commitd85c3ec41020a6c56b0d5d95a9ed790f57d73c6e (patch)
tree2f51ed47fee689024ed8c145634044362c8ed7d5 /apps
parent774bacc692b4d5c7b769bb88d24e182db9e4656f (diff)
downloadrockbox-d85c3ec41020a6c56b0d5d95a9ed790f57d73c6e.tar.gz
rockbox-d85c3ec41020a6c56b0d5d95a9ed790f57d73c6e.zip
Convert lcd_activation callbacks to use the event system to allow for multiple parallel callbacks (for custom statusbar).
Increase maximum event count as we need more (I actually had a report about it during custom statusbar testing). Removed corresponding functions from the core and plugin api. Bump min version and sort. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23302 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/wps.c13
-rw-r--r--apps/plugin.c8
-rw-r--r--apps/plugin.h14
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c7
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c9
5 files changed, 25 insertions, 26 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 11ce946e98..6d9d8443dd 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -562,8 +562,9 @@ static void play_hop(int direction)
* we suppress updates until the wps is activated again (the lcd driver will
* call this hook to issue an instant update)
* */
-static void wps_lcd_activation_hook(void)
+static void wps_lcd_activation_hook(void *param)
{
+ (void)param;
wps_state.do_full_update = true;
/* force timeout in wps main loop, so that the update is instantly */
queue_post(&button_queue, BUTTON_NONE, 0);
@@ -585,7 +586,7 @@ static void gwps_leave_wps(void)
viewportmanager_set_statusbar(oldbars);
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* Play safe and unregister the hook */
- lcd_activation_set_hook(NULL);
+ remove_event(LCD_EVENT_ACTIVATION, wps_lcd_activation_hook);
#endif
/* unhandle statusbar update delay */
sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY);
@@ -1164,13 +1165,9 @@ long gui_wps_show(void)
FOR_NB_SCREENS(i)
{
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- if (lcd_active()
-#ifdef HAVE_REMOTE_LCD
/* currently, all remotes are readable without backlight
* so still update those */
- || (i == SCREEN_REMOTE)
-#endif
- )
+ if (lcd_active() || (i != SCREEN_MAIN))
#endif
{
skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC);
@@ -1193,7 +1190,7 @@ long gui_wps_show(void)
restore = false;
restoretimer = RESTORE_WPS_INSTANTLY;
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- lcd_activation_set_hook(wps_lcd_activation_hook);
+ add_event(LCD_EVENT_ACTIVATION, false, wps_lcd_activation_hook);
#endif
/* we remove the update delay since it's not very usable in the wps,
* e.g. during volume changing or ffwd/rewind */
diff --git a/apps/plugin.c b/apps/plugin.c
index 77fb925ba2..ae889d68fd 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -155,7 +155,6 @@ static const struct plugin_api rockbox_api = {
lcd_set_mode,
#endif
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- lcd_activation_set_hook,
&button_queue,
#endif
bidi_l2v,
@@ -255,6 +254,7 @@ static const struct plugin_api rockbox_api = {
button_status,
#ifdef HAVE_BUTTON_DATA
button_get_data,
+ button_status_wdata,
#endif
button_clear_queue,
button_queue_count,
@@ -376,6 +376,9 @@ static const struct plugin_api rockbox_api = {
__cyg_profile_func_enter,
__cyg_profile_func_exit,
#endif
+ add_event,
+ remove_event,
+ send_event,
#ifdef SIMULATOR
/* special simulator hooks */
@@ -668,9 +671,6 @@ static const struct plugin_api rockbox_api = {
appsversion,
/* new stuff at the end, sort into place next time
the API gets incompatible */
-#ifdef HAVE_BUTTON_DATA
- button_status_wdata,
-#endif
};
int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 6ff7e7e568..7ea1943395 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -133,12 +133,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 172
+#define PLUGIN_API_VERSION 173
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 172
+#define PLUGIN_MIN_API_VERSION 173
/* plugin return codes */
enum plugin_status {
@@ -244,7 +244,6 @@ struct plugin_api {
#endif
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- void (*lcd_activation_set_hook)(void (*enable_hook)(void));
struct event_queue *button_queue;
#endif
unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
@@ -367,6 +366,7 @@ struct plugin_api {
int (*button_status)(void);
#ifdef HAVE_BUTTON_DATA
intptr_t (*button_get_data)(void);
+ int (*button_status_wdata)(int *pdata);
#endif
void (*button_clear_queue)(void);
int (*button_queue_count)(void);
@@ -500,6 +500,10 @@ struct plugin_api {
void (*profile_func_enter)(void *this_fn, void *call_site);
void (*profile_func_exit)(void *this_fn, void *call_site);
#endif
+ /* event api */
+ bool (*add_event)(unsigned short id, bool oneshot, void (*handler)(void *data));
+ void (*remove_event)(unsigned short id, void (*handler)(void *data));
+ void (*send_event)(unsigned short id, void *data);
#ifdef SIMULATOR
/* special simulator hooks */
@@ -837,10 +841,6 @@ struct plugin_api {
const char *appsversion;
/* new stuff at the end, sort into place next time
the API gets incompatible */
-
-#ifdef HAVE_BUTTON_DATA
- int (*button_status_wdata)(int *pdata);
-#endif
};
/* plugin header */
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index df926f4c17..eb55c1444e 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -599,8 +599,9 @@ static uint32_t increment_time(uint32_t val, int32_t amount, uint32_t range)
}
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
-static void get_start_time_lcd_enable_hook(void)
+static void get_start_time_lcd_enable_hook(void *param)
{
+ (void)param;
rb->queue_post(rb->button_queue, LCD_ENABLE_EVENT_0, 0);
}
#endif /* HAVE_LCD_ENABLE */
@@ -619,7 +620,7 @@ static int get_start_time(uint32_t duration)
lcd_(update)();
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
- rb->lcd_activation_set_hook(get_start_time_lcd_enable_hook);
+ rb->add_event(LCD_EVENT_ACTIVATION, false, get_start_time_lcd_enable_hook);
#endif
draw_slider(0, 100, &rc_bound);
@@ -810,7 +811,7 @@ static int get_start_time(uint32_t duration)
}
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- rb->lcd_activation_set_hook(NULL);
+ rb->remove_event(LCD_EVENT_ACTIVATION, get_start_time_lcd_enable_hook);
#endif
#ifndef HAVE_LCD_COLOR
stream_gray_show(false);
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 0cb5f94d19..7c52a47260 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -652,8 +652,9 @@ static void draw_putsxy_oriented(int x, int y, const char *str)
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* So we can refresh the overlay */
-static void wvs_lcd_enable_hook(void)
+static void wvs_lcd_enable_hook(void* param)
{
+ (void)param;
rb->queue_post(rb->button_queue, LCD_ENABLE_EVENT_1, 0);
}
#endif
@@ -665,11 +666,11 @@ static void wvs_backlight_on_video_mode(bool video_on)
/* backlight control in lib/helper.c */
backlight_force_on();
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- rb->lcd_activation_set_hook(NULL);
+ rb->remove_event(LCD_EVENT_ACTIVATION, wvs_lcd_enable_hook);
#endif
} else {
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
- rb->lcd_activation_set_hook(wvs_lcd_enable_hook);
+ rb->add_event(LCD_EVENT_ACTIVATION, false, wvs_lcd_enable_hook);
#endif
/* Revert to user's backlight settings */
backlight_use_settings();
@@ -1671,7 +1672,7 @@ static void button_loop(void)
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* Be sure hook is removed before exiting since the stop will put it
* back because of the backlight restore. */
- rb->lcd_activation_set_hook(NULL);
+ rb->remove_event(LCD_EVENT_ACTIVATION, wvs_lcd_enable_hook);
#endif
rb->lcd_setfont(FONT_UI);