| 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "VerifiedMotion-JNI" |
| 18 | |
| 19 | #include "android_view_VerifiedMotionEvent.h" |
| 20 | #include <input/Input.h> |
| 21 | #include "core_jni_helpers.h" |
| 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | static struct { |
| 26 | jclass clazz; |
| 27 | |
| 28 | jmethodID constructor; |
| 29 | } gVerifiedMotionEventClassInfo; |
| 30 | |
| 31 | // ---------------------------------------------------------------------------- |
| 32 | |
| 33 | jobject android_view_VerifiedMotionEvent(JNIEnv* env, const VerifiedMotionEvent& event) { |
| 34 | return env->NewObject(gVerifiedMotionEventClassInfo.clazz, |
| 35 | gVerifiedMotionEventClassInfo.constructor, event.deviceId, |
| 36 | event.eventTimeNanos, event.source, event.displayId, event.rawX, |
| 37 | event.rawY, event.actionMasked, event.downTimeNanos, event.flags, |
| 38 | event.metaState, event.buttonState); |
| 39 | } |
| 40 | |
| 41 | int register_android_view_VerifiedMotionEvent(JNIEnv* env) { |
| 42 | jclass clazz = FindClassOrDie(env, "android/view/VerifiedMotionEvent"); |
| 43 | gVerifiedMotionEventClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); |
| 44 | |
| 45 | gVerifiedMotionEventClassInfo.constructor = |
| 46 | GetMethodIDOrDie(env, clazz, "<init>", "(IJIIFFIJIII)V"); |
| 47 | |
| 48 | return OK; |
| 49 | } |
| 50 | |
| 51 | } // namespace android |