diff options
Diffstat (limited to 'services/jni/com_android_server_KeyInputQueue.cpp')
-rw-r--r-- | services/jni/com_android_server_KeyInputQueue.cpp | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/services/jni/com_android_server_KeyInputQueue.cpp b/services/jni/com_android_server_KeyInputQueue.cpp index 63830d5..c92f8df 100644 --- a/services/jni/com_android_server_KeyInputQueue.cpp +++ b/services/jni/com_android_server_KeyInputQueue.cpp @@ -110,6 +110,23 @@ android_server_KeyInputQueue_getDeviceName(JNIEnv* env, jobject clazz, return NULL; } +static void +android_server_KeyInputQueue_addExcludedDevice(JNIEnv* env, jobject clazz, + jstring deviceName) +{ + gLock.lock(); + sp<EventHub> hub = gHub; + if (hub == NULL) { + hub = new EventHub; + gHub = hub; + } + gLock.unlock(); + + const char* nameStr = env->GetStringUTFChars(deviceName, NULL); + gHub->addExcludedDevice(nameStr); + env->ReleaseStringUTFChars(deviceName, nameStr); +} + static jboolean android_server_KeyInputQueue_getAbsoluteInfo(JNIEnv* env, jobject clazz, jint deviceId, jint axis, @@ -205,6 +222,23 @@ android_server_KeyInputQueue_getKeycodeStateDevice(JNIEnv* env, jobject clazz, return st; } +static jint +android_server_KeyInputQueue_scancodeToKeycode(JNIEnv* env, jobject clazz, + jint deviceId, jint scancode) +{ + jint res = 0; + gLock.lock(); + if (gHub != NULL) { + int32_t keycode; + uint32_t flags; + gHub->scancodeToKeycode(deviceId, scancode, &keycode, &flags); + res = keycode; + } + gLock.unlock(); + + return res; +} + static jboolean android_server_KeyInputQueue_hasKeys(JNIEnv* env, jobject clazz, jintArray keyCodes, jbooleanArray outFlags) @@ -238,22 +272,26 @@ static JNINativeMethod gInputMethods[] = { (void*) android_server_KeyInputQueue_getDeviceClasses }, { "getDeviceName", "(I)Ljava/lang/String;", (void*) android_server_KeyInputQueue_getDeviceName }, + { "addExcludedDevice", "(Ljava/lang/String;)V", + (void*) android_server_KeyInputQueue_addExcludedDevice }, { "getAbsoluteInfo", "(IILcom/android/server/InputDevice$AbsoluteInfo;)Z", (void*) android_server_KeyInputQueue_getAbsoluteInfo }, { "getSwitchState", "(I)I", (void*) android_server_KeyInputQueue_getSwitchState }, { "getSwitchState", "(II)I", (void*) android_server_KeyInputQueue_getSwitchStateDevice }, - { "getScancodeState", "(I)I", + { "nativeGetScancodeState", "(I)I", (void*) android_server_KeyInputQueue_getScancodeState }, - { "getScancodeState", "(II)I", + { "nativeGetScancodeState", "(II)I", (void*) android_server_KeyInputQueue_getScancodeStateDevice }, - { "getKeycodeState", "(I)I", + { "nativeGetKeycodeState", "(I)I", (void*) android_server_KeyInputQueue_getKeycodeState }, - { "getKeycodeState", "(II)I", + { "nativeGetKeycodeState", "(II)I", (void*) android_server_KeyInputQueue_getKeycodeStateDevice }, { "hasKeys", "([I[Z)Z", (void*) android_server_KeyInputQueue_hasKeys }, + { "scancodeToKeycode", "(II)I", + (void*) android_server_KeyInputQueue_scancodeToKeycode }, }; int register_android_server_KeyInputQueue(JNIEnv* env) |