diff options
Diffstat (limited to 'firmware/target/hosted/android/button-android.c')
-rw-r--r-- | firmware/target/hosted/android/button-android.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c index 61d7256a11..dfc5bd0fb3 100644 --- a/firmware/target/hosted/android/button-android.c +++ b/firmware/target/hosted/android/button-android.c | |||
@@ -31,6 +31,10 @@ | |||
31 | #include "powermgmt.h" | 31 | #include "powermgmt.h" |
32 | 32 | ||
33 | extern JNIEnv *env_ptr; | 33 | extern JNIEnv *env_ptr; |
34 | extern jclass RockboxService_class; | ||
35 | extern jobject RockboxService_instance; | ||
36 | |||
37 | static jfieldID _headphone_state; | ||
34 | static int last_y, last_x; | 38 | static int last_y, last_x; |
35 | static int last_btns; | 39 | static int last_btns; |
36 | 40 | ||
@@ -110,6 +114,20 @@ Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jclass class, | |||
110 | 114 | ||
111 | void button_init_device(void) | 115 | void button_init_device(void) |
112 | { | 116 | { |
117 | jmethodID initHeadphoneMonitor = (*env_ptr)->GetMethodID(env_ptr, | ||
118 | RockboxService_class, | ||
119 | "initHeadphoneMonitor", | ||
120 | "()V"); | ||
121 | /* start the monitor */ | ||
122 | (*env_ptr)->CallVoidMethod(env_ptr, | ||
123 | RockboxService_instance, | ||
124 | initHeadphoneMonitor); | ||
125 | |||
126 | /* cache the headphone state field id */ | ||
127 | _headphone_state = (*env_ptr)->GetFieldID(env_ptr, | ||
128 | RockboxService_class, | ||
129 | "headphone_state", | ||
130 | "I"); | ||
113 | } | 131 | } |
114 | 132 | ||
115 | int button_read_device(int *data) | 133 | int button_read_device(int *data) |
@@ -127,3 +145,13 @@ int button_read_device(int *data) | |||
127 | 145 | ||
128 | return btn; | 146 | return btn; |
129 | } | 147 | } |
148 | |||
149 | |||
150 | /* Tell if anything is in the jack. */ | ||
151 | bool headphones_inserted(void) | ||
152 | { | ||
153 | int state = (*env_ptr)->GetIntField(env_ptr, RockboxService_instance, _headphone_state); | ||
154 | /* 0 is disconnected, 1 and 2 are connected */ | ||
155 | return (state == 0) ? false : true; | ||
156 | } | ||
157 | |||