input.h revision 6d0fec2de3601821f4f44eeb7d7deedebb2b7117
146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Copyright (C) 2010 The Android Open Source Project
346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Licensed under the Apache License, Version 2.0 (the "License");
546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * you may not use this file except in compliance with the License.
646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * You may obtain a copy of the License at
746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *      http://www.apache.org/licenses/LICENSE-2.0
946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
1046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Unless required by applicable law or agreed to in writing, software
1146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * distributed under the License is distributed on an "AS IS" BASIS,
1246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * See the License for the specific language governing permissions and
1446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * limitations under the License.
1546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
1646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
1746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#ifndef _ANDROID_INPUT_H
1846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#define _ANDROID_INPUT_H
1946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
2046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/******************************************************************
2146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
2246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * IMPORTANT NOTICE:
2346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
2446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   This file is part of Android's set of stable system headers
2546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   exposed by the Android NDK (Native Development Kit).
2646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
2746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   Third-party source AND binary code relies on the definitions
2846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
2946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
3046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
3146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
3246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
3346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
3446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
3546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
3646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
3746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Structures and functions to receive and process input events in
3846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * native code.
3946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
4046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * NOTE: These functions MUST be implemented by /system/lib/libui.so
4146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
4246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
4346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#include <sys/types.h>
4446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#include <android/keycodes.h>
45682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn#include <android/looper.h>
4646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
4746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#ifdef __cplusplus
4846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownextern "C" {
4946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#endif
5046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
5146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
5246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Key states (may be returned by queries about the current state of a
5346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * particular key code, scan code or switch).
5446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
5546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
5646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The key state is unknown or the requested key itself is not supported. */
57c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_STATE_UNKNOWN = -1,
5846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
5946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The key is up. */
60c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_STATE_UP = 0,
6146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
6246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The key is down. */
63c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_STATE_DOWN = 1,
6446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
6546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The key is down but is a virtual key press that is being emulated by the system. */
66c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_STATE_VIRTUAL = 2
6746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
6846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
6946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
7046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Meta key / modifer state.
7146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
7246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
7346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* No meta keys are pressed. */
74c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_NONE = 0,
7546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
7646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether one of the ALT meta keys is pressed. */
77c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_ALT_ON = 0x02,
7846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
7946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether the left ALT meta key is pressed. */
80c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_ALT_LEFT_ON = 0x10,
8146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
8246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether the right ALT meta key is pressed. */
83c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_ALT_RIGHT_ON = 0x20,
8446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
8546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether one of the SHIFT meta keys is pressed. */
86c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_SHIFT_ON = 0x01,
8746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
8846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether the left SHIFT meta key is pressed. */
89c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_SHIFT_LEFT_ON = 0x40,
9046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
9146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether the right SHIFT meta key is pressed. */
92c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_SHIFT_RIGHT_ON = 0x80,
9346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
9446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used to check whether the SYM meta key is pressed. */
95c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMETA_SYM_ON = 0x04
9646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
9746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
9846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
9946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Input events.
10046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
10146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Input events are opaque structures.  Use the provided accessors functions to
10246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * read their properties.
10346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
1042e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornstruct AInputEvent;
1052e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef struct AInputEvent AInputEvent;
10646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
10746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
10846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Input event types.
10946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
11046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
11146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Indicates that the input event is a key event. */
112c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_EVENT_TYPE_KEY = 1,
11346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
11446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Indicates that the input event is a motion event. */
115c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_EVENT_TYPE_MOTION = 2
11646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
11746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
11846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
11946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Key event actions.
12046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
12146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
12246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The key has been pressed down. */
123c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_ACTION_DOWN = 0,
12446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
12546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The key has been released. */
126c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_ACTION_UP = 1,
12746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
12846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Multiple duplicate key events have occurred in a row, or a complex string is
12946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * being delivered.  The repeat_count property of the key event contains the number
13046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * of times the given key code should be executed.
13146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
132c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_ACTION_MULTIPLE = 2
13346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
13446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
13546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
13646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Key event flags.
13746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
13846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
13946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is set if the device woke because of this key event. */
140c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
14146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
14246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is set if the key event was generated by a software keyboard. */
143c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
14446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
14546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is set if we don't want the key event to cause us to leave touch mode. */
146c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
14746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
14846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is set if an event was known to come from a trusted part
14946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * of the system.  That is, the event is known to come from the user,
15046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * and could not have been spoofed by a third party component. */
151c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
15246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
15346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This mask is used for compatibility, to identify enter keys that are
15446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * coming from an IME whose enter key has been auto-labelled "next" or
15546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * "done".  This allows TextView to dispatch these as normal enter keys
15646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * for old applications, but still do the appropriate action when
15746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * receiving them. */
158c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
15946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
16046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* When associated with up key events, this indicates that the key press
16146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * has been canceled.  Typically this is used with virtual touch screen
16246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * keys, where the user can slide from the virtual key area on to the
16346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * display: in that case, the application will receive a canceled up
16446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * event and should not perform the action normally associated with the
16546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * key.  Note that for this to work, the application can not perform an
16646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * action for a key until it receives an up or the long press timeout has
16746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * expired. */
168c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_CANCELED = 0x20,
16946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
17046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This key event was generated by a virtual (on-screen) hard key area.
17146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * Typically this is an area of the touchscreen, outside of the regular
17246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * display, dedicated to "hardware" buttons. */
173c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
17446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
17546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* This flag is set for the first key repeat that occurs after the
17646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * long press timeout. */
177c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
17846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
179c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
18046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * press action was executed while it was down. */
181c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
18246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
183c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
18446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * tracked from its initial down.  That is, somebody requested that tracking
18546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * started on the key down and a long press has not caused
18646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * the tracking to be canceled. */
187c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AKEY_EVENT_FLAG_TRACKING = 0x200
18846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
18946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
19046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
19146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Motion event actions.
19246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
19346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
19446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Bit shift for the action bits holding the pointer index as
195c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
19646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
197c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
19846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
19946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
20046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Bit mask of the parts of the action code that are the action itself.
20146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
202c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_MASK = 0xff,
20346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
20446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Bits in the action code that represent a pointer index, used with
205c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown     * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP.  Shifting
206c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown     * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
20746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * index where the data for the pointer going up or down can be found.
20846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
209c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_POINTER_INDEX_MASK  = 0xff00,
21046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
21146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* A pressed gesture has started, the motion contains the initial starting location.
21246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
213c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_DOWN = 0,
21446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
21546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* A pressed gesture has finished, the motion contains the final release location
21646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * as well as any intermediate points since the last down or move event.
21746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
218c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_UP = 1,
21946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
220c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
221c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown     * AMOTION_EVENT_ACTION_UP).  The motion contains the most recent point, as well as
22246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * any intermediate points since the last down or move event.
22346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
224c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_MOVE = 2,
22546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
22646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* The current gesture has been aborted.
22746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * You will not receive any more points in it.  You should treat this as
22846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * an up event, but not perform any action that you normally would.
22946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
230c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_CANCEL = 3,
23146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
23246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* A movement has happened outside of the normal bounds of the UI element.
23346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     * This does not provide a full gesture, but only the initial location of the movement/touch.
23446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
235c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_OUTSIDE = 4,
23646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
23746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* A non-primary pointer has gone down.
238c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown     * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
23946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
240c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
24146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
24246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* A non-primary pointer has gone up.
243c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown     * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
24446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown     */
245c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_ACTION_POINTER_UP = 6
24646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
24746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
24846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
24946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Motion event edge touch flags.
25046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
25146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
25246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* No edges intersected */
253c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_EDGE_FLAG_NONE = 0,
25446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
25546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Flag indicating the motion event intersected the top edge of the screen. */
256c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
25746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
25846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Flag indicating the motion event intersected the bottom edge of the screen. */
259c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
26046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
26146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Flag indicating the motion event intersected the left edge of the screen. */
262c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
26346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
26446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown    /* Flag indicating the motion event intersected the right edge of the screen. */
265c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
26646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
26746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
26846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
269c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * Input sources.
27046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
271c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * Refer to the documentation on android.view.InputDevice for more details about input sources
272c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * and their correct interpretation.
27346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
27446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brownenum {
275c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
276c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
277c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
278c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
279c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
280c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
281c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
282c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown};
283c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
284c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownenum {
285c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_UNKNOWN = 0x00000000,
286c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
287c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
288c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
289c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
290c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
291c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
292c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
293c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
294c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_JOYSTICK_LEFT = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
295c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    AINPUT_SOURCE_JOYSTICK_RIGHT = 0x02000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
29646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown};
29746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
29846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*
2996d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Keyboard types.
3006d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown *
3016d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Refer to the documentation on android.view.InputDevice for more details.
3026d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
3036d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownenum {
3046d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_KEYBOARD_TYPE_NONE = 0,
3056d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
3066d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
3076d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown};
3086d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
3096d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
3106d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Constants used to retrieve information about the range of motion for a particular
3116d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * coordinate of a motion event.
3126d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown *
3136d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Refer to the documentation on android.view.InputDevice for more details about input sources
3146d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * and their correct interpretation.
3156d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
3166d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownenum {
3176d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_X = 0,
3186d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_Y = 1,
3196d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_PRESSURE = 2,
3206d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_SIZE = 3,
3216d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_TOUCH_MAJOR = 4,
3226d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_TOUCH_MINOR = 5,
3236d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_TOOL_MAJOR = 6,
3246d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_TOOL_MINOR = 7,
3256d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown    AINPUT_MOTION_RANGE_ORIENTATION = 8,
3266d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown};
3276d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
3286d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
3296d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
33046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Input event accessors.
33146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
33246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Note that most functions can only be used on input events that are of a given type.
33346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Calling these functions on input events of other types will yield undefined behavior.
33446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
33546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
33646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*** Accessors for all input events. ***/
33746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
33846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the input event type. */
3392e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AInputEvent_getType(const AInputEvent* event);
34046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
34146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the id for the device that an input event came from.
34246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
34346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Input events can be generated by multiple different input devices.
34446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Use the input device id to obtain information about the input
34546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * device that was responsible for generating a particular event.
34646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown *
34746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * An input device id of 0 indicates that the event didn't come from a physical device;
34846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * other numbers are arbitrary and you shouldn't depend on the values.
34946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Use the provided input device query API to obtain information about input devices.
35046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown */
3512e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AInputEvent_getDeviceId(const AInputEvent* event);
35246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
353c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the input event source. */
354c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownint32_t AInputEvent_getSource(const AInputEvent* event);
35546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
35646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*** Accessors for key events only. ***/
35746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
35846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the key event action. */
3592e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getAction(const AInputEvent* key_event);
36046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
36146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the key event flags. */
3622e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getFlags(const AInputEvent* key_event);
36346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
36446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the key code of the key event.
36546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * This is the physical key that was pressed, not the Unicode character. */
3662e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
36746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
36846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the hardware key id of this key event.
36946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * These values are not reliable and vary from device to device. */
3702e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
37146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
37246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the meta key state. */
3732e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
37446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
37546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the repeat count of the event.
37646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * For both key up an key down events, this is the number of times the key has
37746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * repeated with the first down starting at 0 and counting up from there.  For
37846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * multiple key events, this is the number of down/up pairs that have occurred. */
3792e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
38046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
38146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the time of the most recent key down event, in the
38246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * java.lang.System.nanoTime() time base.  If this is a down event,
38346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * this will be the same as eventTime.
38446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Note that when chording keys, this value is the down time of the most recently
38546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * pressed key, which may not be the same physical key of this event. */
3862e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
38746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
38846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the time this event occurred, in the
38946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * java.lang.System.nanoTime() time base. */
3902e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
39146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
39246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/*** Accessors for motion events only. ***/
39346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
39446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the combined motion event action code and pointer index. */
3952e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getAction(const AInputEvent* motion_event);
39646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
39746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the state of any meta / modifier keys that were in effect when the
39846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * event was generated. */
3992e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
40046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
40146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get a bitfield indicating which edges, if any, were touched by this motion event.
40246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * For touch events, clients can use this to determine if the user's finger was
40346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * touching the edge of the display. */
4042e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
40546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
40646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the time when the user originally pressed down to start a stream of
40746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * position events, in the java.lang.System.nanoTime() time base. */
4082e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
40946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
41046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the time when this specific event was generated,
41146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * in the java.lang.System.nanoTime() time base. */
4122e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
41346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
4145c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown/* Get the X coordinate offset.
4155c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * For touch events on the screen, this is the delta that was added to the raw
4165c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * screen coordinates to adjust for the absolute position of the containing windows
4175c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * and views. */
4182e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getXOffset(const AInputEvent* motion_event);
4195c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown
4205c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown/* Get the precision of the Y coordinates being reported.
4215c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * For touch events on the screen, this is the delta that was added to the raw
4225c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * screen coordinates to adjust for the absolute position of the containing windows
4235c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * and views. */
4242e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getYOffset(const AInputEvent* motion_event);
4255c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown
42646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the precision of the X coordinates being reported.
42746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * You can multiply this number with an X coordinate sample to find the
42846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * actual hardware value of the X coordinate. */
4292e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getXPrecision(const AInputEvent* motion_event);
43046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
43146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the precision of the Y coordinates being reported.
43246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * You can multiply this number with a Y coordinate sample to find the
43346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * actual hardware value of the Y coordinate. */
4342e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getYPrecision(const AInputEvent* motion_event);
43546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
43646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the number of pointers of data contained in this event.
43746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Always >= 1. */
4382e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornsize_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
43946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
44046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the pointer identifier associated with a particular pointer
44146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * data index is this event.  The identifier tells you the actual pointer
44246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * number associated with the data, accounting for individual pointers
44346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * going up and down since the start of the current gesture. */
4442e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
44546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
4465c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown/* Get the original raw X coordinate of this event.
4475c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * For touch events on the screen, this is the original location of the event
44846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * on the screen, before it had been adjusted for the containing window
44946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * and views. */
4502e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
45146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
4525c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown/* Get the original raw X coordinate of this event.
4535c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * For touch events on the screen, this is the original location of the event
45446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * on the screen, before it had been adjusted for the containing window
45546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * and views. */
4562e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
45746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
45846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the current X coordinate of this event for the given pointer index.
45946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Whole numbers are pixels; the value may have a fraction for input devices
46046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * that are sub-pixel precise. */
4612e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
46246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
46346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the current Y coordinate of this event for the given pointer index.
46446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Whole numbers are pixels; the value may have a fraction for input devices
46546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * that are sub-pixel precise. */
4662e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
46746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
46846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the current pressure of this event for the given pointer index.
46946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
47046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * however values higher than 1 may be generated depending on the calibration of
47146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * the input device. */
4722e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
47346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
47446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the current scaled value of the approximate size for the given pointer index.
47546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * This represents some approximation of the area of the screen being
47646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * pressed; the actual value in pixels corresponding to the
47746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * touch is normalized with the device specific range of values
47846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * and scaled to a value between 0 and 1.  The value of size can be used to
47946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * determine fat touch events. */
4802e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
48146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
482c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the current length of the major axis of an ellipse that describes the touch area
483c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * at the point of contact for the given pointer index. */
484c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index);
485c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
486c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the current length of the minor axis of an ellipse that describes the touch area
487c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * at the point of contact for the given pointer index. */
488c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index);
489c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
490c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the current length of the major axis of an ellipse that describes the size
491c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * of the approaching tool for the given pointer index.
492c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * The tool area represents the estimated size of the finger or pen that is
493c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * touching the device independent of its actual touch area at the point of contact. */
494c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index);
495c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
496c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the current length of the minor axis of an ellipse that describes the size
497c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * of the approaching tool for the given pointer index.
498c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * The tool area represents the estimated size of the finger or pen that is
499c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * touching the device independent of its actual touch area at the point of contact. */
500c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index);
501c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
502c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the current orientation of the touch area and tool area in radians clockwise from
503c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * vertical for the given pointer index.
504c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * An angle of 0 degrees indicates that the major axis of contact is oriented
505c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * upwards, is perfectly circular or is of unknown orientation.  A positive angle
506c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * indicates that the major axis of contact is oriented to the right.  A negative angle
507c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * indicates that the major axis of contact is oriented to the left.
5086d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
509c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * (finger pointing fully right). */
510c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
511c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
51246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the number of historical points in this event.  These are movements that
51346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * have occurred between this event and the previous event.  This only applies
514c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
51546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Historical samples are indexed from oldest to newest. */
516c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownsize_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
51746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
51846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the time that a historical movement occurred between this event and
51946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * the previous event, in the java.lang.System.nanoTime() time base. */
5202e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event,
52146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown        size_t history_index);
52246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
5235c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown/* Get the historical raw X coordinate of this event for the given pointer index that
5245c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * occurred between this event and the previous motion event.
5255c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * For touch events on the screen, this is the original location of the event
5265c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * on the screen, before it had been adjusted for the containing window
5275c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * and views.
5285c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * Whole numbers are pixels; the value may have a fraction for input devices
5295c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * that are sub-pixel precise. */
5302e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index);
5315c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown
5325c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown/* Get the historical raw Y coordinate of this event for the given pointer index that
5335c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * occurred between this event and the previous motion event.
5345c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * For touch events on the screen, this is the original location of the event
5355c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * on the screen, before it had been adjusted for the containing window
5365c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * and views.
5375c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * Whole numbers are pixels; the value may have a fraction for input devices
5385c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown * that are sub-pixel precise. */
5392e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index);
5405c225b1680e696ae8bbf505a1997d6f720672f74Jeff Brown
54146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the historical X coordinate of this event for the given pointer index that
54246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * occurred between this event and the previous motion event.
54346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Whole numbers are pixels; the value may have a fraction for input devices
54446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * that are sub-pixel precise. */
5452e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index,
54646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown        size_t history_index);
54746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
54846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the historical Y coordinate of this event for the given pointer index that
54946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * occurred between this event and the previous motion event.
55046b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * Whole numbers are pixels; the value may have a fraction for input devices
55146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * that are sub-pixel precise. */
5522e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index,
55346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown        size_t history_index);
55446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
55546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the historical pressure of this event for the given pointer index that
55646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * occurred between this event and the previous motion event.
55746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
55846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * however values higher than 1 may be generated depending on the calibration of
55946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * the input device. */
5602e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index,
56146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown        size_t history_index);
56246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
56346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown/* Get the current scaled value of the approximate size for the given pointer index that
56446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * occurred between this event and the previous motion event.
56546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * This represents some approximation of the area of the screen being
56646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * pressed; the actual value in pixels corresponding to the
56746b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * touch is normalized with the device specific range of values
56846b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * and scaled to a value between 0 and 1.  The value of size can be used to
56946b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown * determine fat touch events. */
5702e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
57146b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown        size_t history_index);
57246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
573c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the historical length of the major axis of an ellipse that describes the touch area
574c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * at the point of contact for the given pointer index that
575c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * occurred between this event and the previous motion event. */
576c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
577c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index);
578c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
579c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the historical length of the minor axis of an ellipse that describes the touch area
580c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * at the point of contact for the given pointer index that
581c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * occurred between this event and the previous motion event. */
582c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
583c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index);
584c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
585c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the historical length of the major axis of an ellipse that describes the size
586c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * of the approaching tool for the given pointer index that
587c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * occurred between this event and the previous motion event.
588c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * The tool area represents the estimated size of the finger or pen that is
589c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * touching the device independent of its actual touch area at the point of contact. */
590c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
591c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index);
592c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
593c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the historical length of the minor axis of an ellipse that describes the size
594c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * of the approaching tool for the given pointer index that
595c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * occurred between this event and the previous motion event.
596c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * The tool area represents the estimated size of the finger or pen that is
597c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * touching the device independent of its actual touch area at the point of contact. */
598c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
599c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index);
600c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
601c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown/* Get the historical orientation of the touch area and tool area in radians clockwise from
602c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * vertical for the given pointer index that
603c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * occurred between this event and the previous motion event.
604c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * An angle of 0 degrees indicates that the major axis of contact is oriented
605c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * upwards, is perfectly circular or is of unknown orientation.  A positive angle
606c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * indicates that the major axis of contact is oriented to the right.  A negative angle
607c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * indicates that the major axis of contact is oriented to the left.
6086d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
609c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown * (finger pointing fully right). */
610c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
611c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index);
612c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
613c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
614a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn/*
615a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Input queue
616a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn *
617a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * An input queue is the facility through which you retrieve input
618a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * events.
619a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */
6202e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornstruct AInputQueue;
6212e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborntypedef struct AInputQueue AInputQueue;
622a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
623a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn/*
62485448bbecd4e0909eecfab15b7c3605f114d0427Dianne Hackborn * Add this input queue to a looper for processing.  See
62585448bbecd4e0909eecfab15b7c3605f114d0427Dianne Hackborn * ALooper_addFd() for information on the callback and data params.
626a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */
627682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackbornvoid AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
62885448bbecd4e0909eecfab15b7c3605f114d0427Dianne Hackborn        ALooper_callbackFunc* callback, void* data);
629682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn
630682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn/*
631682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn * Remove the input queue from the looper it is currently attached to.
632682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn */
633682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackbornvoid AInputQueue_detachLooper(AInputQueue* queue);
634a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
635a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn/*
636a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Returns true if there are one or more events available in the
637a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * input queue.  Returns 1 if the queue has events; 0 if
638a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * it does not have events; and a negative value if there is an error.
639a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */
6402c6081ce3593712f30dacd990a97209c791d6cedDianne Hackbornint32_t AInputQueue_hasEvents(AInputQueue* queue);
641a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
642a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn/*
643a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Returns the next available event from the queue.  Returns a negative
644a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * value if no events are available or an error has occurred.
645a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */
6462e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
647a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
648a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn/*
6492c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn * Sends the key for standard pre-dispatching -- that is, possibly deliver
6502c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn * it to the current IME to be consumed before the app.  Returns 0 if it
6512c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn * was not pre-dispatched, meaning you can process it right now.  If non-zero
6522c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn * is returned, you must abandon the current event processing and allow the
6532c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn * event to appear again in the event queue (if it does not get consumed during
6542c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn * pre-dispatching).
6552c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn */
6562c6081ce3593712f30dacd990a97209c791d6cedDianne Hackbornint32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
6572c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn
6582c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn/*
659a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Report that dispatching has finished with the given event.
6602e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackborn * This must be called after receiving an event with AInputQueue_get_event().
661a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */
6622e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornvoid AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
663a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
6646d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
6656d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Input devices.
6666d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown *
6676d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * These functions provide a mechanism for querying the set of available input devices
6686d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * and their characteristics and capabilities.
6696d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
6706d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownstruct AInputDevice;
6716d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Browntypedef struct AInputDevice AInputDevice;
6726d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
6736d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
6746d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Populates the supplied array with the ids of all input devices in the system.
6756d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Sets nActual to the actual number of devices.
6766d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Returns zero if enumeration was successful.
6776d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Returns non-zero if the actual number of devices is greater than nMax, in which case the
6786d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * client should call the method again with a larger id buffer.
6796d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
6806d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownint32_t AInputDevice_getDeviceIds(int32_t* idBuf, size_t nMax, size_t* nActual);
6816d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
6826d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
6836d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Acquires a device by id.
6846d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Returns NULL if the device was not found.
6856d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown *
6866d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Note: The returned object must be freed using AInputDevice_release when no longer needed.
6876d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
6886d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff BrownAInputDevice* AInputDevice_acquire(int32_t deviceId);
6896d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
6906d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
6916d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Releases a device previously acquired by AInputDevice_acquire.
6926d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * If device is NULL, this function does nothing.
6936d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
6946d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownvoid AInputDevice_release(AInputDevice* device);
6956d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
6966d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
6976d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Gets the name of an input device.
6986d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown *
6996d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Note: The caller should copy the name into a private buffer since the returned pointer
7006d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * will become invalid when the device object is released.
7016d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
7026d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownconst char* AInputDevice_getName(AInputDevice* device);
7036d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
7046d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
7056d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Gets the combination of input sources provided by the input device.
7066d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
7076d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownuint32_t AInputDevice_getSources(AInputDevice* device);
7086d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
7096d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/*
7106d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Gets the keyboard type.
7116d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown */
7126d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownint32_t AInputDevice_getKeyboardType(AInputDevice* device);
7136d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
7146d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown/* Gets the minimum value, maximum value, flat position and error tolerance for a
7156d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * particular motion coodinate.
7166d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown * Returns zero if the device supports the specified motion range. */
7176d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownint32_t AInputDevice_getMotionRange(AInputDevice* device, int32_t rangeType,
7186d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown        float* outMin, float* outMax, float* outFlat, float* outFuzz);
7196d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
7206d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown//TODO hasKey, keymap stuff, etc...
7216d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown
72246b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#ifdef __cplusplus
72346b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown}
72446b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#endif
72546b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown
72646b9ac0ae2162309774a7478cd9d4e578747bfc2Jeff Brown#endif // _ANDROID_INPUT_H
727