input.cpp revision fe9f8ab03a63b1037f07dd85799fbea80ec6adaa
1a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn/*
2a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Copyright (C) 2009 The Android Open Source Project
3a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn *
4a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License");
5a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * you may not use this file except in compliance with the License.
6a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * You may obtain a copy of the License at
7a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn *
8a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn *      http://www.apache.org/licenses/LICENSE-2.0
9a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn *
10a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * Unless required by applicable law or agreed to in writing, software
11a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS,
12a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * See the License for the specific language governing permissions and
14a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn * limitations under the License.
15a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn */
16a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
17a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#define LOG_TAG "input"
18a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#include <utils/Log.h>
19a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
20a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#include <android/input.h>
21a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#include <ui/Input.h>
22a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#include <ui/InputTransport.h>
234fe6c3e51be77e35f40872cdbca6c80f8f8b7ecbJeff Brown#include <utils/Looper.h>
246d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown#include <utils/RefBase.h>
256d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown#include <utils/Vector.h>
26a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
27d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn#include <android_runtime/android_app_NativeActivity.h>
28d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn
29a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn#include <poll.h>
306d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brown#include <errno.h>
31a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
32a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackbornusing android::InputEvent;
33a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackbornusing android::KeyEvent;
34a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackbornusing android::MotionEvent;
356d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownusing android::InputDeviceInfo;
366d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownusing android::sp;
376d0fec2de3601821f4f44eeb7d7deedebb2b7117Jeff Brownusing android::Vector;
38a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
392e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AInputEvent_getType(const AInputEvent* event) {
40a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const InputEvent*>(event)->getType();
41a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
42a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
432e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AInputEvent_getDeviceId(const AInputEvent* event) {
44a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const InputEvent*>(event)->getDeviceId();
45a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
46a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
47c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownint32_t AInputEvent_getSource(const AInputEvent* event) {
48c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const InputEvent*>(event)->getSource();
49a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
50a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
512e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getAction(const AInputEvent* key_event) {
52a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getAction();
53a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
54a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
552e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getFlags(const AInputEvent* key_event) {
56a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getFlags();
57a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
58a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
592e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getKeyCode(const AInputEvent* key_event) {
60a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getKeyCode();
61a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
62a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
632e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getScanCode(const AInputEvent* key_event) {
64a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getScanCode();
65a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
66a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
672e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getMetaState(const AInputEvent* key_event) {
68a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getMetaState();
69a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
702e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event) {
71a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getRepeatCount();
72a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
73a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
742e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AKeyEvent_getDownTime(const AInputEvent* key_event) {
75a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getDownTime();
76a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
77a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
78c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
792e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AKeyEvent_getEventTime(const AInputEvent* key_event) {
80a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const KeyEvent*>(key_event)->getEventTime();
81a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
82a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
832e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getAction(const AInputEvent* motion_event) {
84a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getAction();
85a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
86a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
8785a3176704b5bfbeece9bd928369fbb76eec7dc6Jeff Brownint32_t AMotionEvent_getFlags(const AInputEvent* motion_event) {
8885a3176704b5bfbeece9bd928369fbb76eec7dc6Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getFlags();
8985a3176704b5bfbeece9bd928369fbb76eec7dc6Jeff Brown}
9085a3176704b5bfbeece9bd928369fbb76eec7dc6Jeff Brown
912e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getMetaState(const AInputEvent* motion_event) {
92a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getMetaState();
93a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
94a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
95fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brownint32_t AMotionEvent_getButtonState(const AInputEvent* motion_event) {
96fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brown    return static_cast<const MotionEvent*>(motion_event)->getButtonState();
97fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brown}
98fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brown
992e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event) {
100a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return reinterpret_cast<const MotionEvent*>(motion_event)->getEdgeFlags();
101a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
102a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1032e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AMotionEvent_getDownTime(const AInputEvent* motion_event) {
104a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getDownTime();
105a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
106a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1072e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AMotionEvent_getEventTime(const AInputEvent* motion_event) {
108a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getEventTime();
109a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
110a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1112e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getXOffset(const AInputEvent* motion_event) {
112a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getXOffset();
113a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
114a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1152e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getYOffset(const AInputEvent* motion_event) {
116a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getYOffset();
117a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
118a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1192e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getXPrecision(const AInputEvent* motion_event) {
120a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getXPrecision();
121a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
122a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1232e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getYPrecision(const AInputEvent* motion_event) {
124a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getYPrecision();
125a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
126a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1272e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornsize_t AMotionEvent_getPointerCount(const AInputEvent* motion_event) {
128a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getPointerCount();
129a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
130a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1312e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index) {
132a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getPointerId(pointer_index);
133a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
134a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
135fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brownint32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index) {
136fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brown    return static_cast<const MotionEvent*>(motion_event)->getToolType(pointer_index);
137fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brown}
138fe9f8ab03a63b1037f07dd85799fbea80ec6adaaJeff Brown
1392e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index) {
140a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getRawX(pointer_index);
141a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
142a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1432e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index) {
144a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getRawY(pointer_index);
145a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
146a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1472e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index) {
148a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getX(pointer_index);
149a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
150a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1512e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index) {
152a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getY(pointer_index);
153a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
154a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1552e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index) {
156a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getPressure(pointer_index);
157a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
158a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1592e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index) {
160a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getSize(pointer_index);
161a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
162a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
163c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index) {
164c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getTouchMajor(pointer_index);
165c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
166c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
167c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index) {
168c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getTouchMinor(pointer_index);
169c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
170c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
171c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index) {
172c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getToolMajor(pointer_index);
173c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
174c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
175c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index) {
176c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getToolMinor(pointer_index);
177c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
178c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
179c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index) {
180c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getOrientation(pointer_index);
181c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
182c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
18391c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brownfloat AMotionEvent_getAxisValue(const AInputEvent* motion_event,
18491c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown        int32_t axis, size_t pointer_index) {
18591c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getAxisValue(axis, pointer_index);
18691c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown}
18791c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown
1882e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornsize_t AMotionEvent_getHistorySize(const AInputEvent* motion_event) {
189a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistorySize();
190a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
191a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1922e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event,
193a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
194a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalEventTime(
195a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            history_index);
196a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
197a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
1982e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalRawX(AInputEvent* motion_event, size_t pointer_index,
199a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
200a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalRawX(
201a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            pointer_index, history_index);
202a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
203a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2042e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalRawY(AInputEvent* motion_event, size_t pointer_index,
205a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
206a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalRawY(
207a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            pointer_index, history_index);
208a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
209a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2102e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index,
211a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
212a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalX(
213a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            pointer_index, history_index);
214a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
215a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2162e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index,
217a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
218a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalY(
219a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            pointer_index, history_index);
220a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
221a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2222e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index,
223a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
224a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalPressure(
225a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            pointer_index, history_index);
226a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
227a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2282e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornfloat AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
229a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn        size_t history_index) {
230a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn    return static_cast<const MotionEvent*>(motion_event)->getHistoricalSize(
231a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn            pointer_index, history_index);
232a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
233a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
234c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalTouchMajor(AInputEvent* motion_event, size_t pointer_index,
235c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index) {
236c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getHistoricalTouchMajor(
237c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown            pointer_index, history_index);
238c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
239c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
240c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalTouchMinor(AInputEvent* motion_event, size_t pointer_index,
241c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index) {
242c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getHistoricalTouchMinor(
243c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown            pointer_index, history_index);
244c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
245c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
246c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalToolMajor(AInputEvent* motion_event, size_t pointer_index,
247c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index) {
248c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getHistoricalToolMajor(
249c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown            pointer_index, history_index);
250c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
251c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
252c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalToolMinor(AInputEvent* motion_event, size_t pointer_index,
253c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index) {
254c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getHistoricalToolMinor(
255c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown            pointer_index, history_index);
256c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
257c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
258c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brownfloat AMotionEvent_getHistoricalOrientation(AInputEvent* motion_event, size_t pointer_index,
259c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown        size_t history_index) {
260c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getHistoricalOrientation(
261c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown            pointer_index, history_index);
262c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown}
263c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
26491c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brownfloat AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event,
26591c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown        int32_t axis, size_t pointer_index, size_t history_index) {
26691c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown    return static_cast<const MotionEvent*>(motion_event)->getHistoricalAxisValue(
26791c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown            axis, pointer_index, history_index);
26891c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown}
26991c69ab01539f7ba28708f41ec1835cc2920d0a0Jeff Brown
270c5ed5910c9ef066cec6a13bbb404ec57b1e92637Jeff Brown
271682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackbornvoid AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper,
2724fe6c3e51be77e35f40872cdbca6c80f8f8b7ecbJeff Brown        int ident, ALooper_callbackFunc callback, void* data) {
27342c03e579aade011b451e2a13ea3f44a2ef0056aDianne Hackborn    queue->attachLooper(looper, ident, callback, data);
274682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn}
275682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackborn
276682674154e3fe88f6061245145f934f25f1a2eb8Dianne Hackbornvoid AInputQueue_detachLooper(AInputQueue* queue) {
277d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn    queue->detachLooper();
278a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
279a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2802c6081ce3593712f30dacd990a97209c791d6cedDianne Hackbornint32_t AInputQueue_hasEvents(AInputQueue* queue) {
281d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn    return queue->hasEvents();
282a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
283a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn
2842e9f93e8db509d5236229dc8540e0904c5dbb9f5Dianne Hackbornint32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent) {
285d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn    return queue->getEvent(outEvent);
286d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn}
287d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackborn
2882c6081ce3593712f30dacd990a97209c791d6cedDianne Hackbornint32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event) {
2892c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn    return queue->preDispatchEvent(event) ? 1 : 0;
2902c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn}
2912c6081ce3593712f30dacd990a97209c791d6cedDianne Hackborn
292d76b67c340d1564abf8d14d976fdaf83bf2b3320Dianne Hackbornvoid AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) {
2933915bb845b032dc184dba5e60970b803390ca3edJeff Brown    queue->finishEvent(event, handled != 0, false);
294a95e4cb62f3642cb190d032dbf7dc40d9ecc6973Dianne Hackborn}
295