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 61d7256..dfc5bd0 100644 --- a/firmware/target/hosted/android/button-android.c +++ b/firmware/target/hosted/android/button-android.c @@ -31,6 +31,10 @@ #include "powermgmt.h" extern JNIEnv *env_ptr; +extern jclass RockboxService_class; +extern jobject RockboxService_instance; + +static jfieldID _headphone_state; static int last_y, last_x; static int last_btns; @@ -110,6 +114,20 @@ Java_org_rockbox_RockboxFramebuffer_buttonHandler(JNIEnv*env, jclass class, void button_init_device(void) { + jmethodID initHeadphoneMonitor = (*env_ptr)->GetMethodID(env_ptr, + RockboxService_class, + "initHeadphoneMonitor", + "()V"); + /* start the monitor */ + (*env_ptr)->CallVoidMethod(env_ptr, + RockboxService_instance, + initHeadphoneMonitor); + + /* cache the headphone state field id */ + _headphone_state = (*env_ptr)->GetFieldID(env_ptr, + RockboxService_class, + "headphone_state", + "I"); } int button_read_device(int *data) @@ -127,3 +145,13 @@ int button_read_device(int *data) return btn; } + + +/* Tell if anything is in the jack. */ +bool headphones_inserted(void) +{ + int state = (*env_ptr)->GetIntField(env_ptr, RockboxService_instance, _headphone_state); + /* 0 is disconnected, 1 and 2 are connected */ + return (state == 0) ? false : true; +} + |