diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-10-31 15:32:57 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-10-31 15:32:57 +0000 |
commit | 49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc (patch) | |
tree | b185e604dcea64865389f5b149e754ba8ffd3f75 /firmware/target/hosted | |
parent | dbe2ac1ec6f4ed88f267d2a4df024b6dc42a87ff (diff) | |
download | rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.tar.gz rockbox-49f1ec8e8ad0b4c06df01fcdd4b18037fbe3ebcc.zip |
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/target/hosted')
-rw-r--r-- | firmware/target/hosted/android/app/button-application.c | 21 | ||||
-rw-r--r-- | firmware/target/hosted/android/app/button-target.h | 1 | ||||
-rw-r--r-- | firmware/target/hosted/android/button-android.c | 19 |
3 files changed, 37 insertions, 4 deletions
diff --git a/firmware/target/hosted/android/app/button-application.c b/firmware/target/hosted/android/app/button-application.c index 47798a6096..a7d75ef172 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) | |||
45 | return BUTTON_MENU; | 45 | return BUTTON_MENU; |
46 | } | 46 | } |
47 | } | 47 | } |
48 | |||
49 | unsigned multimedia_to_button(int keyboard_key) | ||
50 | { | ||
51 | switch (keyboard_key) | ||
52 | { | ||
53 | case KEYCODE_MEDIA_PLAY_PAUSE: | ||
54 | return BUTTON_MULTIMEDIA_PLAYPAUSE; | ||
55 | case KEYCODE_MEDIA_STOP: | ||
56 | return BUTTON_MULTIMEDIA_STOP; | ||
57 | case KEYCODE_MEDIA_NEXT: | ||
58 | return BUTTON_MULTIMEDIA_NEXT; | ||
59 | case KEYCODE_MEDIA_PREVIOUS: | ||
60 | return BUTTON_MULTIMEDIA_PREV; | ||
61 | case KEYCODE_MEDIA_REWIND: | ||
62 | return BUTTON_MULTIMEDIA_REW; | ||
63 | case KEYCODE_MEDIA_FAST_FORWARD: | ||
64 | return BUTTON_MULTIMEDIA_FFWD; | ||
65 | default: | ||
66 | return 0; | ||
67 | } | ||
68 | } | ||
diff --git a/firmware/target/hosted/android/app/button-target.h b/firmware/target/hosted/android/app/button-target.h index 6c7bd271e9..ca306d4fef 100644 --- a/firmware/target/hosted/android/app/button-target.h +++ b/firmware/target/hosted/android/app/button-target.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #undef button_init_device | 28 | #undef button_init_device |
29 | void button_init_device(void); | 29 | void button_init_device(void); |
30 | int button_read_device(int *data); | 30 | int button_read_device(int *data); |
31 | unsigned multimedia_to_button(int keyboard_key); | ||
31 | 32 | ||
32 | /* Main unit's buttons */ | 33 | /* Main unit's buttons */ |
33 | #define BUTTON_MENU 0x00000001 | 34 | #define BUTTON_MENU 0x00000001 |
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c index c072e3e38b..9bf15c25a2 100644 --- a/firmware/target/hosted/android/button-android.c +++ b/firmware/target/hosted/android/button-android.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "system.h" | 29 | #include "system.h" |
30 | #include "touchscreen.h" | 30 | #include "touchscreen.h" |
31 | 31 | #include "debug.h" | |
32 | static int last_y, last_x; | 32 | static int last_y, last_x; |
33 | static int last_btns; | 33 | static int last_btns; |
34 | static long last_button_tick; | 34 | static long last_button_tick; |
@@ -44,7 +44,7 @@ static enum { | |||
44 | * began or stopped the touch action + where (pixel coordinates) */ | 44 | * began or stopped the touch action + where (pixel coordinates) */ |
45 | JNIEXPORT void JNICALL | 45 | JNIEXPORT void JNICALL |
46 | Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, | 46 | Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, |
47 | bool down, int x, int y) | 47 | jboolean down, jint x, jint y) |
48 | { | 48 | { |
49 | (void)env; | 49 | (void)env; |
50 | (void)this; | 50 | (void)this; |
@@ -63,12 +63,23 @@ Java_org_rockbox_RockboxFramebuffer_touchHandler(JNIEnv*env, jobject this, | |||
63 | * generated by pressing/releasing them to a variable */ | 63 | * generated by pressing/releasing them to a variable */ |
64 | JNIEXPORT bool JNICALL | 64 | JNIEXPORT bool JNICALL |
65 | Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this, | 65 | Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jobject this, |
66 | int keycode, bool state) | 66 | jint keycode, jboolean state) |
67 | { | 67 | { |
68 | (void)env; | 68 | (void)env; |
69 | (void)this; | 69 | (void)this; |
70 | 70 | ||
71 | int button = key_to_button(keycode); | 71 | unsigned button = 0; |
72 | |||
73 | if (!state) | ||
74 | button = multimedia_to_button((int)keycode); | ||
75 | |||
76 | if (button) | ||
77 | { /* multimeida buttons are handled differently */ | ||
78 | queue_post(&button_queue, button, 0); | ||
79 | return true; | ||
80 | } | ||
81 | |||
82 | button = key_to_button(keycode); | ||
72 | 83 | ||
73 | if (button == BUTTON_NONE) | 84 | if (button == BUTTON_NONE) |
74 | return false; | 85 | return false; |