summaryrefslogtreecommitdiff
path: root/firmware
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 /firmware
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 'firmware')
-rw-r--r--firmware/export/button.h15
-rw-r--r--firmware/export/config/application.h1
-rw-r--r--firmware/target/hosted/android/app/button-application.c21
-rw-r--r--firmware/target/hosted/android/app/button-target.h1
-rw-r--r--firmware/target/hosted/android/button-android.c19
5 files changed, 53 insertions, 4 deletions
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 097f50a..3847d2a 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -69,6 +69,21 @@ int button_apply_acceleration(const unsigned int data);
#define BUTTON_REL 0x02000000
#define BUTTON_REPEAT 0x04000000
#define BUTTON_TOUCHSCREEN 0x08000000
+#define BUTTON_MULTIMEDIA 0x10000000
+
+#define BUTTON_MULTIMEDIA_PLAYPAUSE (BUTTON_MULTIMEDIA|0x01)
+#define BUTTON_MULTIMEDIA_STOP (BUTTON_MULTIMEDIA|0x02)
+#define BUTTON_MULTIMEDIA_PREV (BUTTON_MULTIMEDIA|0x04)
+#define BUTTON_MULTIMEDIA_NEXT (BUTTON_MULTIMEDIA|0x08)
+#define BUTTON_MULTIMEDIA_REW (BUTTON_MULTIMEDIA|0x10)
+#define BUTTON_MULTIMEDIA_FFWD (BUTTON_MULTIMEDIA|0x20)
+
+#define BUTTON_MULTIMEDIA_ALL (BUTTON_MULTIMEDIA_PLAYPAUSE| \
+ BUTTON_MULTIMEDIA_STOP| \
+ BUTTON_MULTIMEDIA_PREV| \
+ BUTTON_MULTIMEDIA_NEXT| \
+ BUTTON_MULTIMEDIA_REW | \
+ BUTTON_MULTIMEDIA_FFWD)
#ifdef HAVE_TOUCHSCREEN
int touchscreen_last_touch(void);
diff --git a/firmware/export/config/application.h b/firmware/export/config/application.h
index 4dc34c1..b731f0c 100644
--- a/firmware/export/config/application.h
+++ b/firmware/export/config/application.h
@@ -77,6 +77,7 @@
#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
#define CONFIG_KEYPAD ANDROID_PAD
+#define HAVE_MULTIMEDIA_KEYS
#elif (CONFIG_PLATFORM & PLATFORM_SDL)
#define HAVE_SCROLLWHEEL
#define CONFIG_KEYPAD SDL_PAD
diff --git a/firmware/target/hosted/android/app/button-application.c b/firmware/target/hosted/android/app/button-application.c
index 47798a6..a7d75ef 100644
--- a/firmware/target/hosted/android/app/button-application.c
+++ b/firmware/target/hosted/android/app/button-application.c
@@ -45,3 +45,24 @@ int key_to_button(int keyboard_key)
return BUTTON_MENU;
}
}
+
+unsigned multimedia_to_button(int keyboard_key)
+{
+ switch (keyboard_key)
+ {
+ case KEYCODE_MEDIA_PLAY_PAUSE:
+ return BUTTON_MULTIMEDIA_PLAYPAUSE;
+ case KEYCODE_MEDIA_STOP:
+ return BUTTON_MULTIMEDIA_STOP;
+ case KEYCODE_MEDIA_NEXT:
+ return BUTTON_MULTIMEDIA_NEXT;
+ case KEYCODE_MEDIA_PREVIOUS:
+ return BUTTON_MULTIMEDIA_PREV;
+ case KEYCODE_MEDIA_REWIND:
+ return BUTTON_MULTIMEDIA_REW;
+ case KEYCODE_MEDIA_FAST_FORWARD:
+ return BUTTON_MULTIMEDIA_FFWD;
+ default:
+ return 0;
+ }
+}
diff --git a/firmware/target/hosted/android/app/button-target.h b/firmware/target/hosted/android/app/button-target.h
index 6c7bd27..ca306d4 100644
--- a/firmware/target/hosted/android/app/button-target.h
+++ b/firmware/target/hosted/android/app/button-target.h
@@ -28,6 +28,7 @@
#undef button_init_device
void button_init_device(void);
int button_read_device(int *data);
+unsigned multimedia_to_button(int keyboard_key);
/* Main unit's buttons */
#define BUTTON_MENU 0x00000001
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c
index c072e3e..9bf15c2 100644
--- a/firmware/target/hosted/android/button-android.c
+++ b/firmware/target/hosted/android/button-android.c
@@ -28,7 +28,7 @@
#include "kernel.h"
#include "system.h"
#include "touchscreen.h"
-
+#include "debug.h"
static int last_y, last_x;
static int last_btns;
static long last_button_tick;
@@ -44,7 +44,7 @@ static enum {
* began or stopped the touch action + where (pixel coordinates) */
JNIEXPORT void JNICALL
Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
- bool down, int x, int y)
+ jboolean down, jint x, jint y)
{
(void)env;
(void)this;
@@ -63,12 +63,23 @@ Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this,
* generated by pressing/releasing them to a variable */
JNIEXPORT bool JNICALL
Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this,
- int keycode, bool state)
+ jint keycode, jboolean state)
{
(void)env;
(void)this;
- int button = key_to_button(keycode);
+ unsigned button = 0;
+
+ if (!state)
+ button = multimedia_to_button((int)keycode);
+
+ if (button)
+ { /* multimeida buttons are handled differently */
+ queue_post(&button_queue, button, 0);
+ return true;
+ }
+
+ button = key_to_button(keycode);
if (button == BUTTON_NONE)
return false;