Update NDK for pre-key-dispatching changes.
The same code now calls the appropriate function as part of
its key processing.
Change-Id: Ie6fbcd802b098b85d8113fe0a49473134721009b
diff --git a/ndk/platforms/android-9/arch-arm/usr/include/android/asset_manager.h b/ndk/platforms/android-9/arch-arm/usr/include/android/asset_manager.h
new file mode 100644
index 0000000..89989f8
--- /dev/null
+++ b/ndk/platforms/android-9/arch-arm/usr/include/android/asset_manager.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef ANDROID_ASSET_MANAGER_H
+#define ANDROID_ASSET_MANAGER_H
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct AAssetManager;
+typedef struct AAssetManager AAssetManager;
+
+struct AAssetDir;
+typedef struct AAssetDir AAssetDir;
+
+struct AAsset;
+typedef struct AAsset AAsset;
+
+/* Available modes for opening assets */
+enum {
+ AASSET_MODE_UNKNOWN = 0,
+ AASSET_MODE_RANDOM = 1,
+ AASSET_MODE_STREAMING = 2,
+ AASSET_MODE_BUFFER = 3
+};
+
+
+/**
+ * Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager
+ * object. Note that the caller is responsible for obtaining and holding a VM reference
+ * to the jobject to prevent its being garbage collected while the native object is
+ * in use.
+ */
+AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager);
+
+/**
+ * Open the named directory within the asset hierarchy. The directory can then
+ * be inspected with the AAssetDir functions. To open the top-level directory,
+ * pass in "" as the dirName.
+ *
+ * The object returned here should be freed by calling AAssetDir_close().
+ */
+AAssetDir* AAssetManager_openDir(AAssetManager* mgr, const char* dirName);
+
+/**
+ * Open an asset.
+ *
+ * The object returned here should be freed by calling AAsset_close().
+ */
+AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode);
+
+/**
+ * Iterate over the files in an asset directory. A NULL string is returned
+ * when all the file names have been returned.
+ *
+ * The returned file name is suitable for passing to AAssetManager_open().
+ *
+ * The string returned here is owned by the AssetDir implementation and is not
+ * guaranteed to remain valid if any other calls are made on this AAssetDir
+ * instance.
+ */
+const char* AAssetDir_getNextFileName(AAssetDir* assetDir);
+
+/**
+ * Reset the iteration state of AAssetDir_getNextFileName() to the beginning.
+ */
+void AAssetDir_rewind(AAssetDir* assetDir);
+
+/**
+ * Close an opened AAssetDir, freeing any related resources.
+ */
+void AAssetDir_close(AAssetDir* assetDir);
+
+/**
+ * Attempt to read 'count' bytes of data from the current offset.
+ *
+ * Returns the number of bytes read, zero on EOF, or < 0 on error.
+ */
+int AAsset_read(AAsset* asset, void* buf, size_t count);
+
+/**
+ * Seek to the specified offset within the asset data. 'whence' uses the
+ * same constants as lseek()/fseek().
+ *
+ * Returns the new position on success, or (off_t) -1 on error.
+ */
+off_t AAsset_seek(AAsset* asset, off_t offset, int whence);
+
+/**
+ * Close the asset, freeing all associated resources.
+ */
+void AAsset_close(AAsset* asset);
+
+/**
+ * Get a pointer to a buffer holding the entire contents of the assset.
+ *
+ * Returns NULL on failure.
+ */
+const void* AAsset_getBuffer(AAsset* asset);
+
+/**
+ * Report the total size of the asset data.
+ */
+off_t AAsset_getLength(AAsset* asset);
+
+/**
+ * Report the total amount of asset data that can be read from the current position.
+ */
+off_t AAsset_getRemainingLength(AAsset* asset);
+
+/**
+ * Open a new file descriptor that can be used to read the asset data.
+ *
+ * Returns < 0 if direct fd access is not possible (for example, if the asset is
+ * compressed).
+ */
+int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength);
+
+/**
+ * Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not
+ * mmapped).
+ */
+int AAsset_isAllocated(AAsset* asset);
+
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // ANDROID_ASSET_MANAGER_H
diff --git a/ndk/platforms/android-9/arch-arm/usr/include/android/input.h b/ndk/platforms/android-9/arch-arm/usr/include/android/input.h
index 25dd68e..0b8c7e4 100644
--- a/ndk/platforms/android-9/arch-arm/usr/include/android/input.h
+++ b/ndk/platforms/android-9/arch-arm/usr/include/android/input.h
@@ -49,49 +49,21 @@
#endif
/*
- * Input device classes.
- */
-enum {
- /* The input device is a keyboard. */
- INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
-
- /* The input device is an alpha-numeric keyboard (not just a dial pad). */
- INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
-
- /* The input device is a touchscreen (either single-touch or multi-touch). */
- INPUT_DEVICE_CLASS_TOUCHSCREEN = 0x00000004,
-
- /* The input device is a trackball. */
- INPUT_DEVICE_CLASS_TRACKBALL = 0x00000008,
-
- /* The input device is a multi-touch touchscreen. */
- INPUT_DEVICE_CLASS_TOUCHSCREEN_MT= 0x00000010,
-
- /* The input device is a directional pad. */
- INPUT_DEVICE_CLASS_DPAD = 0x00000020,
-
- /* The input device is a gamepad (implies keyboard). */
- INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040
-};
-
-/*
* Key states (may be returned by queries about the current state of a
* particular key code, scan code or switch).
- *
- * XXX should we call this BUTTON_STATE_XXX?
*/
enum {
/* The key state is unknown or the requested key itself is not supported. */
- KEY_STATE_UNKNOWN = -1,
+ AKEY_STATE_UNKNOWN = -1,
/* The key is up. */
- KEY_STATE_UP = 0,
+ AKEY_STATE_UP = 0,
/* The key is down. */
- KEY_STATE_DOWN = 1,
+ AKEY_STATE_DOWN = 1,
/* The key is down but is a virtual key press that is being emulated by the system. */
- KEY_STATE_VIRTUAL = 2
+ AKEY_STATE_VIRTUAL = 2
};
/*
@@ -99,28 +71,28 @@
*/
enum {
/* No meta keys are pressed. */
- META_NONE = 0,
+ AMETA_NONE = 0,
/* This mask is used to check whether one of the ALT meta keys is pressed. */
- META_ALT_ON = 0x02,
+ AMETA_ALT_ON = 0x02,
/* This mask is used to check whether the left ALT meta key is pressed. */
- META_ALT_LEFT_ON = 0x10,
+ AMETA_ALT_LEFT_ON = 0x10,
/* This mask is used to check whether the right ALT meta key is pressed. */
- META_ALT_RIGHT_ON = 0x20,
+ AMETA_ALT_RIGHT_ON = 0x20,
/* This mask is used to check whether one of the SHIFT meta keys is pressed. */
- META_SHIFT_ON = 0x01,
+ AMETA_SHIFT_ON = 0x01,
/* This mask is used to check whether the left SHIFT meta key is pressed. */
- META_SHIFT_LEFT_ON = 0x40,
+ AMETA_SHIFT_LEFT_ON = 0x40,
/* This mask is used to check whether the right SHIFT meta key is pressed. */
- META_SHIFT_RIGHT_ON = 0x80,
+ AMETA_SHIFT_RIGHT_ON = 0x80,
/* This mask is used to check whether the SYM meta key is pressed. */
- META_SYM_ON = 0x04
+ AMETA_SYM_ON = 0x04
};
/*
@@ -137,10 +109,10 @@
*/
enum {
/* Indicates that the input event is a key event. */
- INPUT_EVENT_TYPE_KEY = 1,
+ AINPUT_EVENT_TYPE_KEY = 1,
/* Indicates that the input event is a motion event. */
- INPUT_EVENT_TYPE_MOTION = 2
+ AINPUT_EVENT_TYPE_MOTION = 2
};
/*
@@ -148,16 +120,16 @@
*/
enum {
/* The key has been pressed down. */
- KEY_EVENT_ACTION_DOWN = 0,
+ AKEY_EVENT_ACTION_DOWN = 0,
/* The key has been released. */
- KEY_EVENT_ACTION_UP = 1,
+ AKEY_EVENT_ACTION_UP = 1,
/* Multiple duplicate key events have occurred in a row, or a complex string is
* being delivered. The repeat_count property of the key event contains the number
* of times the given key code should be executed.
*/
- KEY_EVENT_ACTION_MULTIPLE = 2
+ AKEY_EVENT_ACTION_MULTIPLE = 2
};
/*
@@ -165,25 +137,25 @@
*/
enum {
/* This mask is set if the device woke because of this key event. */
- KEY_EVENT_FLAG_WOKE_HERE = 0x1,
+ AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
/* This mask is set if the key event was generated by a software keyboard. */
- KEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
+ AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
/* This mask is set if we don't want the key event to cause us to leave touch mode. */
- KEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
+ AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
/* This mask is set if an event was known to come from a trusted part
* of the system. That is, the event is known to come from the user,
* and could not have been spoofed by a third party component. */
- KEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
+ AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
/* This mask is used for compatibility, to identify enter keys that are
* coming from an IME whose enter key has been auto-labelled "next" or
* "done". This allows TextView to dispatch these as normal enter keys
* for old applications, but still do the appropriate action when
* receiving them. */
- KEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
+ AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
/* When associated with up key events, this indicates that the key press
* has been canceled. Typically this is used with virtual touch screen
@@ -193,26 +165,26 @@
* key. Note that for this to work, the application can not perform an
* action for a key until it receives an up or the long press timeout has
* expired. */
- KEY_EVENT_FLAG_CANCELED = 0x20,
+ AKEY_EVENT_FLAG_CANCELED = 0x20,
/* This key event was generated by a virtual (on-screen) hard key area.
* Typically this is an area of the touchscreen, outside of the regular
* display, dedicated to "hardware" buttons. */
- KEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
+ AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
/* This flag is set for the first key repeat that occurs after the
* long press timeout. */
- KEY_EVENT_FLAG_LONG_PRESS = 0x80,
+ AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
- /* Set when a key event has KEY_EVENT_FLAG_CANCELED set because a long
+ /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
* press action was executed while it was down. */
- KEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
+ AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
- /* Set for KEY_EVENT_ACTION_UP when this event's key code is still being
+ /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
* tracked from its initial down. That is, somebody requested that tracking
* started on the key down and a long press has not caused
* the tracking to be canceled. */
- KEY_EVENT_FLAG_TRACKING = 0x200
+ AKEY_EVENT_FLAG_TRACKING = 0x200
};
/*
@@ -220,57 +192,57 @@
*/
/* Bit shift for the action bits holding the pointer index as
- * defined by MOTION_EVENT_ACTION_POINTER_INDEX_MASK.
+ * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
*/
-#define MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
+#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
enum {
/* Bit mask of the parts of the action code that are the action itself.
*/
- MOTION_EVENT_ACTION_MASK = 0xff,
+ AMOTION_EVENT_ACTION_MASK = 0xff,
/* Bits in the action code that represent a pointer index, used with
- * MOTION_EVENT_ACTION_POINTER_DOWN and MOTION_EVENT_ACTION_POINTER_UP. Shifting
- * down by MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
+ * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting
+ * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
* index where the data for the pointer going up or down can be found.
*/
- MOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
+ AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00,
/* A pressed gesture has started, the motion contains the initial starting location.
*/
- MOTION_EVENT_ACTION_DOWN = 0,
+ AMOTION_EVENT_ACTION_DOWN = 0,
/* A pressed gesture has finished, the motion contains the final release location
* as well as any intermediate points since the last down or move event.
*/
- MOTION_EVENT_ACTION_UP = 1,
+ AMOTION_EVENT_ACTION_UP = 1,
- /* A change has happened during a press gesture (between MOTION_EVENT_ACTION_DOWN and
- * MOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
+ /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
+ * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
* any intermediate points since the last down or move event.
*/
- MOTION_EVENT_ACTION_MOVE = 2,
+ AMOTION_EVENT_ACTION_MOVE = 2,
/* The current gesture has been aborted.
* You will not receive any more points in it. You should treat this as
* an up event, but not perform any action that you normally would.
*/
- MOTION_EVENT_ACTION_CANCEL = 3,
+ AMOTION_EVENT_ACTION_CANCEL = 3,
/* A movement has happened outside of the normal bounds of the UI element.
* This does not provide a full gesture, but only the initial location of the movement/touch.
*/
- MOTION_EVENT_ACTION_OUTSIDE = 4,
+ AMOTION_EVENT_ACTION_OUTSIDE = 4,
/* A non-primary pointer has gone down.
- * The bits in MOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
+ * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
*/
- MOTION_EVENT_ACTION_POINTER_DOWN = 5,
+ AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
/* A non-primary pointer has gone up.
- * The bits in MOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
+ * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
*/
- MOTION_EVENT_ACTION_POINTER_UP = 6
+ AMOTION_EVENT_ACTION_POINTER_UP = 6
};
/*
@@ -278,39 +250,50 @@
*/
enum {
/* No edges intersected */
- MOTION_EVENT_EDGE_FLAG_NONE = 0,
+ AMOTION_EVENT_EDGE_FLAG_NONE = 0,
/* Flag indicating the motion event intersected the top edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_TOP = 0x01,
+ AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
/* Flag indicating the motion event intersected the bottom edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
+ AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
/* Flag indicating the motion event intersected the left edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
+ AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
/* Flag indicating the motion event intersected the right edge of the screen. */
- MOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
+ AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
};
/*
- * Specifies the logical nature of an input event.
- * For example, the nature distinguishes between motion events that represent touches and
- * those that represent trackball moves.
+ * Input sources.
*
- * XXX This concept is tentative. Another idea would be to associate events with logical
- * controllers rather than physical devices. The interpretation of an event would
- * be made with respect to the nature of the controller that is considered the logical
- * source of an event. The decoupling is beneficial since multiple physical (and virtual)
- * devices could be responsible for producing events that would be associated with
- * various logical controllers. For example, the hard keyboard, on screen keyboard,
- * and peripheral keyboard could be mapped onto a single logical "keyboard" controller
- * (or treated independently, if desired).
+ * The appropriate interpretation for an input event depends on its source.
+ * Refer to the documentation on android.view.InputDevice for more details about input sources
+ * and their correct interpretation.
*/
enum {
- INPUT_EVENT_NATURE_KEY = 1,
- INPUT_EVENT_NATURE_TOUCH = 2,
- INPUT_EVENT_NATURE_TRACKBALL = 3
+ AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
+
+ AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
+ AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
+ AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
+ AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
+ AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
+};
+
+enum {
+ AINPUT_SOURCE_UNKNOWN = 0x00000000,
+
+ AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
+ AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
+ AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
+ AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
+ AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
+ AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
+ AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
+ AINPUT_SOURCE_JOYSTICK_LEFT = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
+ AINPUT_SOURCE_JOYSTICK_RIGHT = 0x02000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
};
/*
@@ -337,8 +320,8 @@
*/
int32_t AInputEvent_getDeviceId(const AInputEvent* event);
-/* Get the input event nature. */
-int32_t AInputEvent_getNature(const AInputEvent* event);
+/* Get the input event source. */
+int32_t AInputEvent_getSource(const AInputEvent* event);
/*** Accessors for key events only. ***/
@@ -466,11 +449,41 @@
* determine fat touch events. */
float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
+/* Get the current length of the major axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index. */
+float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current length of the minor axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index. */
+float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current length of the major axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current length of the minor axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
+
+/* Get the current orientation of the touch area and tool area in radians clockwise from
+ * vertical for the given pointer index.
+ * An angle of 0 degrees indicates that the major axis of contact is oriented
+ * upwards, is perfectly circular or is of unknown orientation. A positive angle
+ * indicates that the major axis of contact is oriented to the right. A negative angle
+ * indicates that the major axis of contact is oriented to the left.
+ * The full range is from -PI/4 radians (finger pointing fully left) to PI/4 radians
+ * (finger pointing fully right). */
+float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
+
/* Get the number of historical points in this event. These are movements that
* have occurred between this event and the previous event. This only applies
- * to MOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
+ * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
* Historical samples are indexed from oldest to newest. */
-size_t AMotionEvent_get_history_size(const AInputEvent* motion_event);
+size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
/* Get the time that a historical movement occurred between this event and
* the previous event, in the java.lang.System.nanoTime() time base. */
@@ -527,6 +540,47 @@
float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
size_t history_index);
+/* Get the historical length of the major axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index that
+ * occurred between this event and the previous motion event. */
+float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical length of the minor axis of an ellipse that describes the touch area
+ * at the point of contact for the given pointer index that
+ * occurred between this event and the previous motion event. */
+float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical length of the major axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index that
+ * occurred between this event and the previous motion event.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical length of the minor axis of an ellipse that describes the size
+ * of the approaching tool for the given pointer index that
+ * occurred between this event and the previous motion event.
+ * The tool area represents the estimated size of the finger or pen that is
+ * touching the device independent of its actual touch area at the point of contact. */
+float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+/* Get the historical orientation of the touch area and tool area in radians clockwise from
+ * vertical for the given pointer index that
+ * occurred between this event and the previous motion event.
+ * An angle of 0 degrees indicates that the major axis of contact is oriented
+ * upwards, is perfectly circular or is of unknown orientation. A positive angle
+ * indicates that the major axis of contact is oriented to the right. A negative angle
+ * indicates that the major axis of contact is oriented to the left.
+ * The full range is from -PI/4 radians (finger pointing fully left) to PI/4 radians
+ * (finger pointing fully right). */
+float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
+ size_t history_index);
+
+
/*
* Input queue
*
@@ -553,7 +607,7 @@
* input queue. Returns 1 if the queue has events; 0 if
* it does not have events; and a negative value if there is an error.
*/
-int AInputQueue_hasEvents(AInputQueue* queue);
+int32_t AInputQueue_hasEvents(AInputQueue* queue);
/*
* Returns the next available event from the queue. Returns a negative
@@ -562,6 +616,16 @@
int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
/*
+ * Sends the key for standard pre-dispatching -- that is, possibly deliver
+ * it to the current IME to be consumed before the app. Returns 0 if it
+ * was not pre-dispatched, meaning you can process it right now. If non-zero
+ * is returned, you must abandon the current event processing and allow the
+ * event to appear again in the event queue (if it does not get consumed during
+ * pre-dispatching).
+ */
+int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
+
+/*
* Report that dispatching has finished with the given event.
* This must be called after receiving an event with AInputQueue_get_event().
*/
diff --git a/ndk/platforms/android-9/arch-arm/usr/include/android/native_activity.h b/ndk/platforms/android-9/arch-arm/usr/include/android/native_activity.h
index d4df05b..ee4204d 100644
--- a/ndk/platforms/android-9/arch-arm/usr/include/android/native_activity.h
+++ b/ndk/platforms/android-9/arch-arm/usr/include/android/native_activity.h
@@ -73,7 +73,7 @@
* Path to this application's external (removable/mountable) data directory.
*/
const char* externalDataPath;
-
+
/**
* The platform's SDK version code.
*/
diff --git a/ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h b/ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h
new file mode 100644
index 0000000..4291d3e
--- /dev/null
+++ b/ndk/platforms/android-9/arch-arm/usr/include/android/sensor.h
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef ANDROID_SENSOR_H
+#define ANDROID_SENSOR_H
+
+/******************************************************************
+ *
+ * IMPORTANT NOTICE:
+ *
+ * This file is part of Android's set of stable system headers
+ * exposed by the Android NDK (Native Development Kit).
+ *
+ * Third-party source AND binary code relies on the definitions
+ * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
+ *
+ * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
+ * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
+ * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
+ * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
+ */
+
+/*
+ * Structures and functions to receive and process sensor events in
+ * native code.
+ *
+ */
+
+#include <sys/types.h>
+
+#include <android/looper.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Sensor types
+ * (keep in sync with hardware/sensor.h)
+ */
+
+enum {
+ ASENSOR_TYPE_ACCELEROMETER = 1,
+ ASENSOR_TYPE_MAGNETIC_FIELD = 2,
+ ASENSOR_TYPE_GYROSCOPE = 4,
+ ASENSOR_TYPE_LIGHT = 5,
+ ASENSOR_TYPE_PROXIMITY = 8
+};
+
+/*
+ * Sensor accuracy measure
+ */
+enum {
+ ASENSOR_STATUS_UNRELIABLE = 0,
+ ASENSOR_STATUS_ACCURACY_LOW = 1,
+ ASENSOR_STATUS_ACCURACY_MEDIUM = 2,
+ ASENSOR_STATUS_ACCURACY_HIGH = 3
+};
+
+/*
+ * A few useful constants
+ */
+
+/* Earth's gravity in m/s^2 */
+#define ASENSOR_STANDARD_GRAVITY (9.80665f)
+/* Maximum magnetic field on Earth's surface in uT */
+#define ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f)
+/* Minimum magnetic field on Earth's surface in uT*/
+#define ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f)
+
+/*
+ * A sensor event.
+ */
+
+typedef struct ASensorVector {
+ union {
+ float v[3];
+ struct {
+ float x;
+ float y;
+ float z;
+ };
+ };
+ int8_t status;
+ uint8_t reserved[3];
+} ASensorVector;
+
+typedef struct ASensorEvent {
+ int sensor;
+ int32_t reserved0;
+ union {
+ float data[16];
+ ASensorVector acceleration;
+ ASensorVector magnetic;
+ float temperature;
+ float distance;
+ float light;
+ };
+ int64_t timestamp;
+ int32_t reserved1[4];
+} ASensorEvent;
+
+
+struct ASensorManager;
+typedef struct ASensorManager ASensorManager;
+
+struct ASensorEventQueue;
+typedef struct ASensorEventQueue ASensorEventQueue;
+
+struct ASensor;
+typedef struct ASensor ASensor;
+
+/*****************************************************************************/
+
+/*
+ * Get a reference to the sensor manager. ASensorManager is a singleton.
+ *
+ * Example:
+ *
+ * ASensorManager* sensorManager = ASensorManager_getInstance();
+ *
+ */
+ASensorManager* ASensorManager_getInstance();
+
+
+/*
+ * Returns the list of available sensors.
+ */
+int ASensorManager_getSensorList(ASensorManager* manager, ASensor** list);
+
+/*
+ * Returns the default sensor for the given type, or NULL if no sensor
+ * of that type exist.
+ */
+ASensor* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
+
+/*
+ * Creates a new sensor event queue and associate it with a looper.
+ */
+ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager,
+ ALooper* looper, ALooper_callbackFunc* callback, void* data);
+
+/*
+ * Destroys the event queue and free all resources associated to it.
+ */
+int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);
+
+
+/*****************************************************************************/
+
+/*
+ * Enable the selected sensor. Returns a negative error code on failure.
+ */
+int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor* sensor);
+
+/*
+ * Disable the selected sensor. Returns a negative error code on failure.
+ */
+int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor* sensor);
+
+/*
+ * Sets the delivery rate of events in microseconds for the given sensor.
+ * Note that this is a hint only, generally event will arrive at a higher
+ * rate.
+ * Returns a negative error code on failure.
+ */
+int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor* sensor, int32_t usec);
+
+/*
+ * Returns true if there are one or more events available in the
+ * sensor queue. Returns 1 if the queue has events; 0 if
+ * it does not have events; and a negative value if there is an error.
+ */
+int ASensorEventQueue_hasEvents(ASensorEventQueue* queue);
+
+/*
+ * Returns the next available events from the queue. Returns a negative
+ * value if no events are available or an error has occurred, otherwise
+ * the number of events returned.
+ *
+ * Examples:
+ * ASensorEvent event;
+ * ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1);
+ *
+ * ASensorEvent eventBuffer[8];
+ * ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8);
+ *
+ */
+ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue,
+ ASensorEvent* events, size_t count);
+
+
+/*****************************************************************************/
+
+/*
+ * Returns this sensor's name (non localized)
+ */
+const char* ASensor_getName(ASensor* sensor);
+
+/*
+ * Returns this sensor's vendor's name (non localized)
+ */
+const char* ASensor_getVendor(ASensor* sensor);
+
+/*
+ * Return this sensor's type
+ */
+int ASensor_getType(ASensor* sensor);
+
+/*
+ * Returns this sensors's resolution
+ */
+float ASensor_getResolution(ASensor* sensor);
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // ANDROID_SENSOR_H
diff --git a/ndk/platforms/android-9/arch-arm/usr/lib/libandroid.so b/ndk/platforms/android-9/arch-arm/usr/lib/libandroid.so
index d79ec89..04a1e58 100644
--- a/ndk/platforms/android-9/arch-arm/usr/lib/libandroid.so
+++ b/ndk/platforms/android-9/arch-arm/usr/lib/libandroid.so
Binary files differ
diff --git a/ndk/samples/native-activity/jni/main.c b/ndk/samples/native-activity/jni/main.c
index c52c959..83f55a9 100644
--- a/ndk/samples/native-activity/jni/main.c
+++ b/ndk/samples/native-activity/jni/main.c
@@ -133,6 +133,9 @@
AInputEvent* event = NULL;
if (AInputQueue_getEvent(engine->app->inputQueue, &event) >= 0) {
LOGI("New input event: type=%d\n", AInputEvent_getType(event));
+ if (AInputQueue_preDispatchEvent(engine->app->inputQueue, event)) {
+ return 1;
+ }
if (AInputEvent_getType(event) == INPUT_EVENT_TYPE_MOTION) {
engine->animating = 1;
engine->x = AMotionEvent_getX(event, 0);
diff --git a/ndk/samples/native-plasma/jni/plasma.c b/ndk/samples/native-plasma/jni/plasma.c
index 0ef9788..90d6bd7 100644
--- a/ndk/samples/native-plasma/jni/plasma.c
+++ b/ndk/samples/native-plasma/jni/plasma.c
@@ -414,6 +414,9 @@
static int engine_do_ui_event(struct engine* engine) {
AInputEvent* event = NULL;
if (AInputQueue_getEvent(engine->app->inputQueue, &event) >= 0) {
+ if (AInputQueue_preDispatchEvent(engine->app->inputQueue, event)) {
+ return 1;
+ }
if (AInputEvent_getType(event) == INPUT_EVENT_TYPE_MOTION) {
engine->animating = 1;
AInputQueue_finishEvent(engine->app->inputQueue, event, 1);