111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Copyright (C) 2010 The Android Open Source Project
311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Licensed under the Apache License, Version 2.0 (the "License");
511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * you may not use this file except in compliance with the License.
611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * You may obtain a copy of the License at
711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *      http://www.apache.org/licenses/LICENSE-2.0
911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
1011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Unless required by applicable law or agreed to in writing, software
1111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * distributed under the License is distributed on an "AS IS" BASIS,
1211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * See the License for the specific language governing permissions and
1411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * limitations under the License.
1511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
1611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
1711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef _ANDROID_INPUT_H
1811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define _ANDROID_INPUT_H
1911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
2011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/******************************************************************
2111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
2211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * IMPORTANT NOTICE:
2311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
2411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   This file is part of Android's set of stable system headers
2511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   exposed by the Android NDK (Native Development Kit).
2611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
2711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   Third-party source AND binary code relies on the definitions
2811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
2911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
3011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
3111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
3211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
3311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
3411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
3511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
3611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
3711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Structures and functions to receive and process input events in
3811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * native code.
3911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
4011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * NOTE: These functions MUST be implemented by /system/lib/libui.so
4111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
4211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
4311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <stdint.h>
4411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <sys/types.h>
4511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <android/keycodes.h>
4611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <android/looper.h>
4711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
4811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifdef __cplusplus
4911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern "C" {
5011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif
5111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
5211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
5311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Key states (may be returned by queries about the current state of a
5411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * particular key code, scan code or switch).
5511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
5611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
5711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The key state is unknown or the requested key itself is not supported. */
5811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_STATE_UNKNOWN = -1,
5911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
6011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The key is up. */
6111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_STATE_UP = 0,
6211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
6311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The key is down. */
6411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_STATE_DOWN = 1,
6511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
6611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The key is down but is a virtual key press that is being emulated by the system. */
6711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_STATE_VIRTUAL = 2
6811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
6911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
7011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
7111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Meta key / modifer state.
7211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
7311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
7411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* No meta keys are pressed. */
7511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_NONE = 0,
7611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
7711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether one of the ALT meta keys is pressed. */
7811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_ALT_ON = 0x02,
7911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the left ALT meta key is pressed. */
8111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_ALT_LEFT_ON = 0x10,
8211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the right ALT meta key is pressed. */
8411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_ALT_RIGHT_ON = 0x20,
8511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether one of the SHIFT meta keys is pressed. */
8711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_SHIFT_ON = 0x01,
8811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the left SHIFT meta key is pressed. */
9011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_SHIFT_LEFT_ON = 0x40,
9111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
9211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the right SHIFT meta key is pressed. */
9311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_SHIFT_RIGHT_ON = 0x80,
9411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
9511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the SYM meta key is pressed. */
9611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_SYM_ON = 0x04,
9711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
9811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the FUNCTION meta key is pressed. */
9911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_FUNCTION_ON = 0x08,
10011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
10111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether one of the CTRL meta keys is pressed. */
10211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_CTRL_ON = 0x1000,
10311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
10411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the left CTRL meta key is pressed. */
10511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_CTRL_LEFT_ON = 0x2000,
10611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
10711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the right CTRL meta key is pressed. */
10811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_CTRL_RIGHT_ON = 0x4000,
10911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
11011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether one of the META meta keys is pressed. */
11111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_META_ON = 0x10000,
11211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
11311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the left META meta key is pressed. */
11411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_META_LEFT_ON = 0x20000,
11511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
11611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the right META meta key is pressed. */
11711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_META_RIGHT_ON = 0x40000,
11811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
11911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the CAPS LOCK meta key is on. */
12011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_CAPS_LOCK_ON = 0x100000,
12111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
12211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the NUM LOCK meta key is on. */
12311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_NUM_LOCK_ON = 0x200000,
12411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
12511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used to check whether the SCROLL LOCK meta key is on. */
12611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMETA_SCROLL_LOCK_ON = 0x400000,
12711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
12811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
12911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
13011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input events.
13111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
13211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input events are opaque structures.  Use the provided accessors functions to
13311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * read their properties.
13411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
13511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertstruct AInputEvent;
13611cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef struct AInputEvent AInputEvent;
13711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
13811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
13911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input event types.
14011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
14111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
14211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Indicates that the input event is a key event. */
14311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_EVENT_TYPE_KEY = 1,
14411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
14511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Indicates that the input event is a motion event. */
14611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_EVENT_TYPE_MOTION = 2
14711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
14811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
14911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
15011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Key event actions.
15111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
15211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
15311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The key has been pressed down. */
15411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_ACTION_DOWN = 0,
15511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
15611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The key has been released. */
15711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_ACTION_UP = 1,
15811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
15911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Multiple duplicate key events have occurred in a row, or a complex string is
16011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * being delivered.  The repeat_count property of the key event contains the number
16111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * of times the given key code should be executed.
16211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
16311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_ACTION_MULTIPLE = 2
16411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
16511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
16611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
16711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Key event flags.
16811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
16911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
17011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is set if the device woke because of this key event. */
17111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_WOKE_HERE = 0x1,
17211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
17311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is set if the key event was generated by a software keyboard. */
17411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2,
17511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
17611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is set if we don't want the key event to cause us to leave touch mode. */
17711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4,
17811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
17911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is set if an event was known to come from a trusted part
18011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * of the system.  That is, the event is known to come from the user,
18111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * and could not have been spoofed by a third party component. */
18211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8,
18311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
18411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This mask is used for compatibility, to identify enter keys that are
18511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * coming from an IME whose enter key has been auto-labelled "next" or
18611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * "done".  This allows TextView to dispatch these as normal enter keys
18711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * for old applications, but still do the appropriate action when
18811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * receiving them. */
18911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10,
19011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
19111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* When associated with up key events, this indicates that the key press
19211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * has been canceled.  Typically this is used with virtual touch screen
19311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * keys, where the user can slide from the virtual key area on to the
19411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * display: in that case, the application will receive a canceled up
19511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * event and should not perform the action normally associated with the
19611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * key.  Note that for this to work, the application can not perform an
19711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * action for a key until it receives an up or the long press timeout has
19811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * expired. */
19911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_CANCELED = 0x20,
20011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
20111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This key event was generated by a virtual (on-screen) hard key area.
20211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * Typically this is an area of the touchscreen, outside of the regular
20311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * display, dedicated to "hardware" buttons. */
20411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40,
20511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
20611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This flag is set for the first key repeat that occurs after the
20711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * long press timeout. */
20811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_LONG_PRESS = 0x80,
20911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
21011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long
21111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * press action was executed while it was down. */
21211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100,
21311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
21411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Set for AKEY_EVENT_ACTION_UP when this event's key code is still being
21511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * tracked from its initial down.  That is, somebody requested that tracking
21611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * started on the key down and a long press has not caused
21711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * the tracking to be canceled. */
21811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_TRACKING = 0x200,
21911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
22011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Set when a key event has been synthesized to implement default behavior
22111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * for an event that the application did not handle.
22211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * Fallback key events are generated by unhandled trackball motions
22311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * (to emulate a directional keypad) and by certain unhandled key presses
22411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * that are declared in the key map (such as special function numeric keypad
22511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * keys when numlock is off). */
22611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AKEY_EVENT_FLAG_FALLBACK = 0x400,
22711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
22811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
22911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
23011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Motion event actions.
23111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
23211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
23311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Bit shift for the action bits holding the pointer index as
23411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK.
23511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
23611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8
23711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
23811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
23911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Bit mask of the parts of the action code that are the action itself.
24011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
24111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_MASK = 0xff,
24211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
24311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Bits in the action code that represent a pointer index, used with
24411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP.  Shifting
24511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer
24611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * index where the data for the pointer going up or down can be found.
24711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
24811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_POINTER_INDEX_MASK  = 0xff00,
24911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
25011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A pressed gesture has started, the motion contains the initial starting location.
25111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
25211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_DOWN = 0,
25311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
25411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A pressed gesture has finished, the motion contains the final release location
25511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * as well as any intermediate points since the last down or move event.
25611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
25711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_UP = 1,
25811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
25911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and
26011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * AMOTION_EVENT_ACTION_UP).  The motion contains the most recent point, as well as
26111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * any intermediate points since the last down or move event.
26211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
26311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_MOVE = 2,
26411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
26511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The current gesture has been aborted.
26611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * You will not receive any more points in it.  You should treat this as
26711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * an up event, but not perform any action that you normally would.
26811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
26911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_CANCEL = 3,
27011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
27111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A movement has happened outside of the normal bounds of the UI element.
27211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * This does not provide a full gesture, but only the initial location of the movement/touch.
27311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
27411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_OUTSIDE = 4,
27511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
27611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A non-primary pointer has gone down.
27711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
27811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
27911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_POINTER_DOWN = 5,
28011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
28111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A non-primary pointer has gone up.
28211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
28311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
28411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_POINTER_UP = 6,
28511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
28611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE).
28711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * The motion contains the most recent point, as well as any intermediate points since
28811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * the last hover move event.
28911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
29011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_HOVER_MOVE = 7,
29111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
29211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* The motion event contains relative vertical and/or horizontal scroll offsets.
29311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL
29411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * and AMOTION_EVENT_AXIS_HSCROLL.
29511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * The pointer may or may not be down when this event is dispatched.
29611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * This action is always delivered to the winder under the pointer, which
29711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * may not be the window currently touched.
29811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
29911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_ACTION_SCROLL = 8,
30011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
30111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
30211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
30311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Motion event flags.
30411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
30511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
30611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* This flag indicates that the window that received this motion event is partly
30711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * or wholly obscured by another visible window above it.  This flag is set to true
30811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * even if the event did not directly pass through the obscured area.
30911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * A security sensitive application can check this flag to identify situations in which
31011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * a malicious application may have covered up part of its content for the purpose
31111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * of misleading the user or hijacking touches.  An appropriate response might be
31211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * to drop the suspect touches or to take additional precautions to confirm the user's
31311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     * actual intent.
31411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert     */
31511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1,
31611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
31711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
31811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
31911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Motion event edge touch flags.
32011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
32111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
32211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* No edges intersected */
32311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_EDGE_FLAG_NONE = 0,
32411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
32511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Flag indicating the motion event intersected the top edge of the screen. */
32611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_EDGE_FLAG_TOP = 0x01,
32711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
32811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Flag indicating the motion event intersected the bottom edge of the screen. */
32911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02,
33011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
33111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Flag indicating the motion event intersected the left edge of the screen. */
33211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04,
33311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
33411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    /* Flag indicating the motion event intersected the right edge of the screen. */
33511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08
33611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
33711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
33811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
33911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Constants that identify each individual axis of a motion event.
34011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Refer to the documentation on the MotionEvent class for descriptions of each axis.
34111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
34211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
34311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_X = 0,
34411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_Y = 1,
34511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_PRESSURE = 2,
34611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_SIZE = 3,
34711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4,
34811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_TOUCH_MINOR = 5,
34911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_TOOL_MAJOR = 6,
35011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_TOOL_MINOR = 7,
35111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_ORIENTATION = 8,
35211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_VSCROLL = 9,
35311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_HSCROLL = 10,
35411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_Z = 11,
35511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_RX = 12,
35611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_RY = 13,
35711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_RZ = 14,
35811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_HAT_X = 15,
35911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_HAT_Y = 16,
36011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_LTRIGGER = 17,
36111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_RTRIGGER = 18,
36211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_THROTTLE = 19,
36311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_RUDDER = 20,
36411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_WHEEL = 21,
36511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GAS = 22,
36611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_BRAKE = 23,
36711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_1 = 32,
36811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_2 = 33,
36911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_3 = 34,
37011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_4 = 35,
37111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_5 = 36,
37211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_6 = 37,
37311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_7 = 38,
37411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_8 = 39,
37511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_9 = 40,
37611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_10 = 41,
37711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_11 = 42,
37811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_12 = 43,
37911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_13 = 44,
38011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_14 = 45,
38111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_15 = 46,
38211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AMOTION_EVENT_AXIS_GENERIC_16 = 47,
38311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
38411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    // NOTE: If you add a new axis here you must also add it to several other files.
38511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    //       Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
38611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
38711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
38811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
38911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input sources.
39011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
39111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Refer to the documentation on android.view.InputDevice for more details about input sources
39211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and their correct interpretation.
39311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
39411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
39511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_CLASS_MASK = 0x000000ff,
39611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
39711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_CLASS_BUTTON = 0x00000001,
39811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_CLASS_POINTER = 0x00000002,
39911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004,
40011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_CLASS_POSITION = 0x00000008,
40111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010,
40211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
40311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
40411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
40511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_UNKNOWN = 0x00000000,
40611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
40711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON,
40811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON,
40911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON,
41011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER,
41111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER,
41211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION,
41311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION,
41411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK,
41511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
41611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_SOURCE_ANY = 0xffffff00,
41711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
41811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
41911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
42011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Keyboard types.
42111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
42211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Refer to the documentation on android.view.InputDevice for more details.
42311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
42411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
42511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_KEYBOARD_TYPE_NONE = 0,
42611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1,
42711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2,
42811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
42911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
43011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
43111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Constants used to retrieve information about the range of motion for a particular
43211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * coordinate of a motion event.
43311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
43411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Refer to the documentation on android.view.InputDevice for more details about input sources
43511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and their correct interpretation.
43611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
43711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * DEPRECATION NOTICE: These constants are deprecated.  Use AMOTION_EVENT_AXIS_* constants instead.
43811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
43911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertenum {
44011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X,
44111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y,
44211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE,
44311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE,
44411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR,
44511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR,
44611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR,
44711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR,
44811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert    AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION,
44911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert} __attribute__ ((deprecated));
45011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
45111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
45211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
45311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input event accessors.
45411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
45511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Note that most functions can only be used on input events that are of a given type.
45611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Calling these functions on input events of other types will yield undefined behavior.
45711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
45811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
45911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*** Accessors for all input events. ***/
46011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
46111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the input event type. */
46211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AInputEvent_getType(const AInputEvent* event);
46311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
46411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the id for the device that an input event came from.
46511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
46611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input events can be generated by multiple different input devices.
46711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Use the input device id to obtain information about the input
46811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * device that was responsible for generating a particular event.
46911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
47011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * An input device id of 0 indicates that the event didn't come from a physical device;
47111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * other numbers are arbitrary and you shouldn't depend on the values.
47211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Use the provided input device query API to obtain information about input devices.
47311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
47411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AInputEvent_getDeviceId(const AInputEvent* event);
47511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
47611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the input event source. */
47711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AInputEvent_getSource(const AInputEvent* event);
47811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
47911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*** Accessors for key events only. ***/
48011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
48111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the key event action. */
48211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AKeyEvent_getAction(const AInputEvent* key_event);
48311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
48411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the key event flags. */
48511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AKeyEvent_getFlags(const AInputEvent* key_event);
48611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
48711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the key code of the key event.
48811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * This is the physical key that was pressed, not the Unicode character. */
48911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
49011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
49111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the hardware key id of this key event.
49211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * These values are not reliable and vary from device to device. */
49311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
49411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
49511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the meta key state. */
49611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
49711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
49811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the repeat count of the event.
49911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For both key up an key down events, this is the number of times the key has
50011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * repeated with the first down starting at 0 and counting up from there.  For
50111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * multiple key events, this is the number of down/up pairs that have occurred. */
50211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
50311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
50411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the time of the most recent key down event, in the
50511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * java.lang.System.nanoTime() time base.  If this is a down event,
50611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * this will be the same as eventTime.
50711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Note that when chording keys, this value is the down time of the most recently
50811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * pressed key, which may not be the same physical key of this event. */
50911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
51011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
51111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the time this event occurred, in the
51211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * java.lang.System.nanoTime() time base. */
51311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
51411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
51511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*** Accessors for motion events only. ***/
51611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
51711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the combined motion event action code and pointer index. */
51811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AMotionEvent_getAction(const AInputEvent* motion_event);
51911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
52011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the motion event flags. */
52111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AMotionEvent_getFlags(const AInputEvent* motion_event);
52211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
52311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the state of any meta / modifier keys that were in effect when the
52411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * event was generated. */
52511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
52611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
52711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get a bitfield indicating which edges, if any, were touched by this motion event.
52811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events, clients can use this to determine if the user's finger was
52911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touching the edge of the display. */
53011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
53111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
53211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the time when the user originally pressed down to start a stream of
53311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * position events, in the java.lang.System.nanoTime() time base. */
53411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
53511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
53611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the time when this specific event was generated,
53711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * in the java.lang.System.nanoTime() time base. */
53811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
53911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
54011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the X coordinate offset.
54111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events on the screen, this is the delta that was added to the raw
54211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * screen coordinates to adjust for the absolute position of the containing windows
54311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and views. */
54411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getXOffset(const AInputEvent* motion_event) __NDK_FPABI__;
54511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
54611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the Y coordinate offset.
54711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events on the screen, this is the delta that was added to the raw
54811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * screen coordinates to adjust for the absolute position of the containing windows
54911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and views. */
55011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getYOffset(const AInputEvent* motion_event) __NDK_FPABI__;
55111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
55211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the precision of the X coordinates being reported.
55311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * You can multiply this number with an X coordinate sample to find the
55411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * actual hardware value of the X coordinate. */
55511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getXPrecision(const AInputEvent* motion_event) __NDK_FPABI__;
55611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
55711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the precision of the Y coordinates being reported.
55811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * You can multiply this number with a Y coordinate sample to find the
55911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * actual hardware value of the Y coordinate. */
56011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getYPrecision(const AInputEvent* motion_event) __NDK_FPABI__;
56111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
56211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the number of pointers of data contained in this event.
56311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Always >= 1. */
56411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertsize_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
56511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
56611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the pointer identifier associated with a particular pointer
56711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * data index is this event.  The identifier tells you the actual pointer
56811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * number associated with the data, accounting for individual pointers
56911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * going up and down since the start of the current gesture. */
57011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
57111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
57211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the original raw X coordinate of this event.
57311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events on the screen, this is the original location of the event
57411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * on the screen, before it had been adjusted for the containing window
57511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and views. */
57611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
57711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
57811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the original raw X coordinate of this event.
57911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events on the screen, this is the original location of the event
58011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * on the screen, before it had been adjusted for the containing window
58111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and views. */
58211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
58311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
58411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current X coordinate of this event for the given pointer index.
58511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Whole numbers are pixels; the value may have a fraction for input devices
58611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that are sub-pixel precise. */
58711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
58811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
58911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current Y coordinate of this event for the given pointer index.
59011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Whole numbers are pixels; the value may have a fraction for input devices
59111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that are sub-pixel precise. */
59211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
59311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
59411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current pressure of this event for the given pointer index.
59511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
59611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * although values higher than 1 may be generated depending on the calibration of
59711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * the input device. */
59811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
59911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
60011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current scaled value of the approximate size for the given pointer index.
60111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * This represents some approximation of the area of the screen being
60211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * pressed; the actual value in pixels corresponding to the
60311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touch is normalized with the device specific range of values
60411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and scaled to a value between 0 and 1.  The value of size can be used to
60511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * determine fat touch events. */
60611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
60711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
60811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current length of the major axis of an ellipse that describes the touch area
60911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * at the point of contact for the given pointer index. */
61011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
61111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
61211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current length of the minor axis of an ellipse that describes the touch area
61311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * at the point of contact for the given pointer index. */
61411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
61511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
61611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current length of the major axis of an ellipse that describes the size
61711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * of the approaching tool for the given pointer index.
61811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The tool area represents the estimated size of the finger or pen that is
61911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touching the device independent of its actual touch area at the point of contact. */
62011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
62111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
62211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current length of the minor axis of an ellipse that describes the size
62311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * of the approaching tool for the given pointer index.
62411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The tool area represents the estimated size of the finger or pen that is
62511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touching the device independent of its actual touch area at the point of contact. */
62611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
62711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
62811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current orientation of the touch area and tool area in radians clockwise from
62911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * vertical for the given pointer index.
63011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * An angle of 0 degrees indicates that the major axis of contact is oriented
63111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * upwards, is perfectly circular or is of unknown orientation.  A positive angle
63211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * indicates that the major axis of contact is oriented to the right.  A negative angle
63311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * indicates that the major axis of contact is oriented to the left.
63411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
63511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * (finger pointing fully right). */
63611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index) __NDK_FPABI__;
63711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
63811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the value of the request axis for the given pointer index. */
63911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getAxisValue(const AInputEvent* motion_event,
64011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        int32_t axis, size_t pointer_index) __NDK_FPABI__;
64111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
64211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the number of historical points in this event.  These are movements that
64311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * have occurred between this event and the previous event.  This only applies
64411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
64511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Historical samples are indexed from oldest to newest. */
64611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertsize_t AMotionEvent_getHistorySize(const AInputEvent* motion_event);
64711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
64811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the time that a historical movement occurred between this event and
64911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * the previous event, in the java.lang.System.nanoTime() time base. */
65011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event,
65111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index);
65211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
65311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical raw X coordinate of this event for the given pointer index that
65411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
65511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events on the screen, this is the original location of the event
65611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * on the screen, before it had been adjusted for the containing window
65711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and views.
65811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Whole numbers are pixels; the value may have a fraction for input devices
65911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that are sub-pixel precise. */
66011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index,
66111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
66211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
66311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical raw Y coordinate of this event for the given pointer index that
66411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
66511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * For touch events on the screen, this is the original location of the event
66611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * on the screen, before it had been adjusted for the containing window
66711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and views.
66811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Whole numbers are pixels; the value may have a fraction for input devices
66911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that are sub-pixel precise. */
67011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index,
67111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
67211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
67311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical X coordinate of this event for the given pointer index that
67411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
67511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Whole numbers are pixels; the value may have a fraction for input devices
67611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that are sub-pixel precise. */
67711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index,
67811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
67911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
68011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical Y coordinate of this event for the given pointer index that
68111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
68211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Whole numbers are pixels; the value may have a fraction for input devices
68311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that are sub-pixel precise. */
68411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index,
68511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
68611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
68711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical pressure of this event for the given pointer index that
68811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
68911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
69011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * although values higher than 1 may be generated depending on the calibration of
69111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * the input device. */
69211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index,
69311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
69411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
69511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the current scaled value of the approximate size for the given pointer index that
69611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
69711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * This represents some approximation of the area of the screen being
69811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * pressed; the actual value in pixels corresponding to the
69911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touch is normalized with the device specific range of values
70011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * and scaled to a value between 0 and 1.  The value of size can be used to
70111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * determine fat touch events. */
70211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index,
70311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
70411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
70511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical length of the major axis of an ellipse that describes the touch area
70611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * at the point of contact for the given pointer index that
70711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event. */
70811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index,
70911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
71011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
71111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical length of the minor axis of an ellipse that describes the touch area
71211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * at the point of contact for the given pointer index that
71311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event. */
71411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index,
71511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
71611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
71711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical length of the major axis of an ellipse that describes the size
71811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * of the approaching tool for the given pointer index that
71911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
72011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The tool area represents the estimated size of the finger or pen that is
72111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touching the device independent of its actual touch area at the point of contact. */
72211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index,
72311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
72411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
72511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical length of the minor axis of an ellipse that describes the size
72611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * of the approaching tool for the given pointer index that
72711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
72811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The tool area represents the estimated size of the finger or pen that is
72911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * touching the device independent of its actual touch area at the point of contact. */
73011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index,
73111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
73211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
73311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical orientation of the touch area and tool area in radians clockwise from
73411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * vertical for the given pointer index that
73511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * occurred between this event and the previous motion event.
73611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * An angle of 0 degrees indicates that the major axis of contact is oriented
73711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * upwards, is perfectly circular or is of unknown orientation.  A positive angle
73811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * indicates that the major axis of contact is oriented to the right.  A negative angle
73911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * indicates that the major axis of contact is oriented to the left.
74011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
74111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * (finger pointing fully right). */
74211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
74311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        size_t history_index) __NDK_FPABI__;
74411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
74511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Get the historical value of the request axis for the given pointer index
74611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * that occurred between this event and the previous motion event. */
74711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertfloat AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
74811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        int32_t axis, size_t pointer_index, size_t history_index) __NDK_FPABI__;
74911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
75011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
75111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
75211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Input queue
75311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
75411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * An input queue is the facility through which you retrieve input
75511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * events.
75611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
75711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertstruct AInputQueue;
75811cd02dfb91661c65134cac258cf5924270e9d2Dan Alberttypedef struct AInputQueue AInputQueue;
75911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
76011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
76111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Add this input queue to a looper for processing.  See
76211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * ALooper_addFd() for information on the ident, callback, and data params.
76311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
76411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertvoid AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
76511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert        int ident, ALooper_callbackFunc callback, void* data);
76611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
76711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
76811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Remove the input queue from the looper it is currently attached to.
76911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
77011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertvoid AInputQueue_detachLooper(AInputQueue* queue);
77111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
77211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
77311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Returns true if there are one or more events available in the
77411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * input queue.  Returns 1 if the queue has events; 0 if
77511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * it does not have events; and a negative value if there is an error.
77611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
77711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AInputQueue_hasEvents(AInputQueue* queue);
77811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
77911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
78011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Returns the next available event from the queue.  Returns a negative
78111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * value if no events are available or an error has occurred.
78211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
78311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
78411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
78511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
78611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Sends the key for standard pre-dispatching -- that is, possibly deliver
78711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * it to the current IME to be consumed before the app.  Returns 0 if it
78811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * was not pre-dispatched, meaning you can process it right now.  If non-zero
78911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * is returned, you must abandon the current event processing and allow the
79011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * event to appear again in the event queue (if it does not get consumed during
79111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * pre-dispatching).
79211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
79311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertint32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event);
79411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
79511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
79611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Report that dispatching has finished with the given event.
79711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * This must be called after receiving an event with AInputQueue_get_event().
79811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
79911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertvoid AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
80011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
80111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifdef __cplusplus
80211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert}
80311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif
80411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
80511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif // _ANDROID_INPUT_H
806