summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-10-31 15:32:57 +0000
committerThomas Martitz <kugel@rockbox.org>2010-10-31 15:32:57 +0000
commit49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc (patch)
treeb185e604dcea64865389f5b149e754ba8ffd3f75 /apps
parentdbe2ac1ec6f4ed88f267d2a4df024b6dc42a87ff (diff)
downloadrockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.zip
rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.tar.gz
rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.tar.bz2
rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.tar.xz
Add support multimedia keys/buttons to the core, and adapt Rockbox on android for it (multimedia buttons are found on wired headsets and the lock screen in cyanogenmod).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28421 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/action.c5
-rw-r--r--apps/gui/wps.c14
-rw-r--r--apps/menu.c16
-rw-r--r--apps/misc.c37
4 files changed, 59 insertions, 13 deletions
diff --git a/apps/action.c b/apps/action.c
index 8f427c8..d61930a 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -183,8 +183,9 @@ static int get_action_worker(int context, int timeout,
else
button = button_get_w_tmo(timeout);
- /* Data from sys events can be pulled with button_get_data */
- if (button == BUTTON_NONE || button & SYS_EVENT)
+ /* Data from sys events can be pulled with button_get_data
+ * multimedia button presses don't go through the action system */
+ if (button == BUTTON_NONE || button & (SYS_EVENT|BUTTON_MULTIMEDIA))
return button;
/* Don't send any buttons through untill we see the release event */
if (wait_for_release)
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index a5fe304..7d633ad 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -1045,18 +1045,18 @@ long gui_wps_show(void)
exit = true;
break;
#endif
- case SYS_POWEROFF:
- default_event_handler(SYS_POWEROFF);
- break;
case ACTION_WPS_VIEW_PLAYLIST:
gwps_leave_wps();
return GO_TO_PLAYLIST_VIEWER;
break;
default:
- if(default_event_handler(button) == SYS_USB_CONNECTED)
- {
- gwps_leave_wps();
- return GO_TO_ROOT;
+ switch(default_event_handler(button))
+ { /* music has been stopped by the default handler */
+ case SYS_USB_CONNECTED:
+ case SYS_CALL_INCOMING:
+ case BUTTON_MULTIMEDIA_STOP:
+ gwps_leave_wps();
+ return GO_TO_ROOT;
}
update = true;
break;
diff --git a/apps/menu.c b/apps/menu.c
index 9d67c7b..5839a51 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -650,10 +650,20 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
}
#endif
}
- else if(default_event_handler(action) == SYS_USB_CONNECTED)
+ else
{
- ret = MENU_ATTACHED_USB;
- done = true;
+ switch(default_event_handler(action))
+ {
+ case SYS_USB_CONNECTED:
+ ret = MENU_ATTACHED_USB;
+ done = true;
+ break;
+ case SYS_CALL_HUNG_UP:
+ case BUTTON_MULTIMEDIA_PLAYPAUSE:
+ /* remove splash from playlist_resume() */
+ redraw_lists = true;
+ break;
+ }
}
if (redraw_lists && !done)
diff --git a/apps/misc.c b/apps/misc.c
index 8d0ca79..c41f634 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -529,6 +529,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
#if CONFIG_PLATFORM & PLATFORM_ANDROID
static bool resume = false;
#endif
+
switch(event)
{
case SYS_BATTERY_UPDATE:
@@ -629,11 +630,45 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
if (resume && playlist_resume() != -1)
{
playlist_start(global_status.resume_index,
- global_status.resume_offset);
+ global_status.resume_offset);
}
resume = false;
return SYS_CALL_HUNG_UP;
#endif
+#ifdef HAVE_MULTIMEDIA_KEYS
+ /* multimedia keys on keyboards, headsets */
+ case BUTTON_MULTIMEDIA_PLAYPAUSE:
+ {
+ int status = audio_status();
+ if (status & AUDIO_STATUS_PLAY)
+ {
+ if (status & AUDIO_STATUS_PAUSE)
+ audio_resume();
+ else
+ audio_pause();
+ }
+ else
+ if (playlist_resume() != -1)
+ {
+ playlist_start(global_status.resume_index,
+ global_status.resume_offset);
+ }
+ return event;
+ }
+ case BUTTON_MULTIMEDIA_NEXT:
+ audio_next();
+ return event;
+ case BUTTON_MULTIMEDIA_PREV:
+ audio_prev();
+ return event;
+ case BUTTON_MULTIMEDIA_STOP:
+ list_stop_handler();
+ return event;
+ case BUTTON_MULTIMEDIA_REW:
+ case BUTTON_MULTIMEDIA_FFWD:
+ /* not supported yet, needs to be done in the WPS */
+ return 0;
+#endif
}
return 0;
}