forked from len0rd/rockbox
Extended default_event_handler() that calls a callback function prior to actually handling the event.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5263 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a7aa17ac1b
commit
0dc52d5c36
4 changed files with 21 additions and 8 deletions
12
apps/misc.c
12
apps/misc.c
|
|
@ -230,20 +230,30 @@ bool clean_shutdown(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int default_event_handler(int event)
|
int default_event_handler_ex(int event, void (*callback)(void *), void *parameter)
|
||||||
{
|
{
|
||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case SYS_USB_CONNECTED:
|
case SYS_USB_CONNECTED:
|
||||||
|
if (callback != NULL)
|
||||||
|
callback(parameter);
|
||||||
#ifdef HAVE_MMC
|
#ifdef HAVE_MMC
|
||||||
if (!mmc_detect() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
|
if (!mmc_detect() || (mmc_remove_request() == SYS_MMC_EXTRACTED))
|
||||||
#endif
|
#endif
|
||||||
usb_screen();
|
usb_screen();
|
||||||
return SYS_USB_CONNECTED;
|
return SYS_USB_CONNECTED;
|
||||||
case SYS_POWEROFF:
|
case SYS_POWEROFF:
|
||||||
|
if (callback != NULL)
|
||||||
|
callback(parameter);
|
||||||
if (!clean_shutdown())
|
if (!clean_shutdown())
|
||||||
return SYS_POWEROFF;
|
return SYS_POWEROFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int default_event_handler(int event)
|
||||||
|
{
|
||||||
|
return default_event_handler_ex(event, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ void screen_dump(void);
|
||||||
|
|
||||||
bool settings_parseline(char* line, char** name, char** value);
|
bool settings_parseline(char* line, char** name, char** value);
|
||||||
bool clean_shutdown(void);
|
bool clean_shutdown(void);
|
||||||
|
int default_event_handler_ex(int event, void (*callback)(void *), void *parameter);
|
||||||
int default_event_handler(int event);
|
int default_event_handler(int event);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
system_memory_guard,
|
system_memory_guard,
|
||||||
#endif
|
#endif
|
||||||
|
default_event_handler_ex,
|
||||||
};
|
};
|
||||||
|
|
||||||
int plugin_load(const char* plugin, void* parameter)
|
int plugin_load(const char* plugin, void* parameter)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* increase this every time the api struct changes */
|
/* increase this every time the api struct changes */
|
||||||
#define PLUGIN_API_VERSION 27
|
#define PLUGIN_API_VERSION 28
|
||||||
|
|
||||||
/* update this to latest version if a change to the api struct breaks
|
/* update this to latest version if a change to the api struct breaks
|
||||||
backwards compatibility (and please take the opportunity to sort in any
|
backwards compatibility (and please take the opportunity to sort in any
|
||||||
|
|
@ -289,15 +289,16 @@ struct plugin_api {
|
||||||
void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
|
void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
|
||||||
int style);
|
int style);
|
||||||
#endif
|
#endif
|
||||||
void (*mpeg_flush_and_reload_tracks)(void);
|
void (*mpeg_flush_and_reload_tracks)(void);
|
||||||
int (*strncasecmp)(const char *s1, const char *s2, size_t n);
|
int (*strncasecmp)(const char *s1, const char *s2, size_t n);
|
||||||
int (*mpeg_get_file_pos)(void);
|
int (*mpeg_get_file_pos)(void);
|
||||||
unsigned long (*find_next_frame)(int fd, int *offset,
|
unsigned long (*find_next_frame)(int fd, int *offset,
|
||||||
int max_offset, unsigned long last_header);
|
int max_offset, unsigned long last_header);
|
||||||
unsigned long (*mpeg_get_last_header)(void);
|
unsigned long (*mpeg_get_last_header)(void);
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
int (*system_memory_guard)(int newmode);
|
int (*system_memory_guard)(int newmode);
|
||||||
#endif
|
#endif
|
||||||
|
int (*default_event_handler_ex)(int event, void (*callback)(void *), void *parameter);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* defined by the plugin loader (plugin.c) */
|
/* defined by the plugin loader (plugin.c) */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue