diff options
author | 2020-04-07 19:38:15 -0700 | |
---|---|---|
committer | 2020-04-14 11:14:02 -0700 | |
commit | 1aaa212641edc9367f937c53b85a3a4b8d2ed153 (patch) | |
tree | f985840e7939a59566b78ecd6cba53f55d226a5a /include/android/input.h | |
parent | 9d9918d9f831bf359b41f083a717aaa5ba18f0ba (diff) |
Add java-to-native converters for input events.
Add java-to-native converters for android.view.KeyEvent,
android.view.MotionEvent.
Bug: 116830907
Test: atest KeyEventTest, atest MotionEventTest
Change-Id: I66a2f1dbd627c03b5dc923713be74ee9c2b73e1a
Diffstat (limited to 'include/android/input.h')
-rw-r--r-- | include/android/input.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/android/input.h b/include/android/input.h index dbfd61eb05..7c392348b7 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -55,6 +55,7 @@ #include <sys/types.h> #include <android/keycodes.h> #include <android/looper.h> +#include <jni.h> #if !defined(__INTRODUCED_IN) #define __INTRODUCED_IN(__api_level) /* nothing */ @@ -931,6 +932,15 @@ int32_t AInputEvent_getDeviceId(const AInputEvent* event); /** Get the input event source. */ int32_t AInputEvent_getSource(const AInputEvent* event); +/** + * Releases interface objects created by {@link AKeyEvent_fromJava()} + * and {@link AMotionEvent_fromJava()}. + * After returning, the specified AInputEvent* object becomes invalid and should no longer be used. + * The underlying Java object remains valid and does not change its state. + */ + +void AInputEvent_release(const AInputEvent* event); + /*** Accessors for key events only. ***/ /** Get the key event action. */ @@ -977,6 +987,15 @@ int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); */ int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); +/** + * Creates a native AInputEvent* object associated with the specified Java android.view.KeyEvent. + * The result may be used with generic and KeyEvent-specific AInputEvent_* functions. + * The object returned by this function must be disposed using {@link AInputEvent_release()}. + * User must guarantee that lifetime for object referenced by keyEvent is prolongated + * up to release of returned AInputEvent*. + */ +const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent); + /*** Accessors for motion events only. ***/ /** Get the combined motion event action code and pointer index. */ @@ -1292,6 +1311,14 @@ float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, siz float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, int32_t axis, size_t pointer_index, size_t history_index); +/** + * Creates a native AInputEvent* object associated with the specified Java android.view.MotionEvent. + * The result may be used with generic and MotionEvent-specific AInputEvent_* functions. + * The object returned by this function must be disposed using {@link AInputEvent_release()}. + * User must guarantee that object referenced by motionEvent won't be recycled and + * its lifetime is prolongated up to release of returned AInputEvent*. + */ +const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent); struct AInputQueue; /** |