Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "input" |
| 18 | #include <utils/Log.h> |
| 19 | |
| 20 | #include <android/input.h> |
Jeff Brown | 9d3b1a4 | 2013-07-01 19:07:15 -0700 | [diff] [blame] | 21 | #include <input/Input.h> |
| 22 | #include <input/InputTransport.h> |
Jeff Brown | 4fe6c3e | 2010-09-13 23:17:30 -0700 | [diff] [blame] | 23 | #include <utils/Looper.h> |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 24 | #include <utils/RefBase.h> |
| 25 | #include <utils/Vector.h> |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 26 | |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 27 | #include <android_runtime/android_app_NativeActivity.h> |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 28 | #include <android_runtime/android_view_InputQueue.h> |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 29 | |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 30 | #include <poll.h> |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 31 | #include <errno.h> |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 32 | |
| 33 | using android::InputEvent; |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 34 | using android::InputQueue; |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 35 | using android::KeyEvent; |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 36 | using android::Looper; |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 37 | using android::MotionEvent; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 38 | using android::sp; |
| 39 | using android::Vector; |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 40 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 41 | int32_t AInputEvent_getType(const AInputEvent* event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 42 | return static_cast<const InputEvent*>(event)->getType(); |
| 43 | } |
| 44 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 45 | int32_t AInputEvent_getDeviceId(const AInputEvent* event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 46 | return static_cast<const InputEvent*>(event)->getDeviceId(); |
| 47 | } |
| 48 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 49 | int32_t AInputEvent_getSource(const AInputEvent* event) { |
| 50 | return static_cast<const InputEvent*>(event)->getSource(); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 53 | int32_t AKeyEvent_getAction(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 54 | return static_cast<const KeyEvent*>(key_event)->getAction(); |
| 55 | } |
| 56 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 57 | int32_t AKeyEvent_getFlags(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 58 | return static_cast<const KeyEvent*>(key_event)->getFlags(); |
| 59 | } |
| 60 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 61 | int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 62 | return static_cast<const KeyEvent*>(key_event)->getKeyCode(); |
| 63 | } |
| 64 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 65 | int32_t AKeyEvent_getScanCode(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 66 | return static_cast<const KeyEvent*>(key_event)->getScanCode(); |
| 67 | } |
| 68 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 69 | int32_t AKeyEvent_getMetaState(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 70 | return static_cast<const KeyEvent*>(key_event)->getMetaState(); |
| 71 | } |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 72 | int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 73 | return static_cast<const KeyEvent*>(key_event)->getRepeatCount(); |
| 74 | } |
| 75 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 76 | int64_t AKeyEvent_getDownTime(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 77 | return static_cast<const KeyEvent*>(key_event)->getDownTime(); |
| 78 | } |
| 79 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 80 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 81 | int64_t AKeyEvent_getEventTime(const AInputEvent* key_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 82 | return static_cast<const KeyEvent*>(key_event)->getEventTime(); |
| 83 | } |
| 84 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 85 | int32_t AMotionEvent_getAction(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 86 | return static_cast<const MotionEvent*>(motion_event)->getAction(); |
| 87 | } |
| 88 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 89 | int32_t AMotionEvent_getFlags(const AInputEvent* motion_event) { |
| 90 | return static_cast<const MotionEvent*>(motion_event)->getFlags(); |
| 91 | } |
| 92 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 93 | int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 94 | return static_cast<const MotionEvent*>(motion_event)->getMetaState(); |
| 95 | } |
| 96 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 97 | int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event) { |
| 98 | return static_cast<const MotionEvent*>(motion_event)->getButtonState(); |
| 99 | } |
| 100 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 101 | int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 102 | return reinterpret_cast<const MotionEvent*>(motion_event)->getEdgeFlags(); |
| 103 | } |
| 104 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 105 | int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 106 | return static_cast<const MotionEvent*>(motion_event)->getDownTime(); |
| 107 | } |
| 108 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 109 | int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 110 | return static_cast<const MotionEvent*>(motion_event)->getEventTime(); |
| 111 | } |
| 112 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 113 | float AMotionEvent_getXOffset(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 114 | return static_cast<const MotionEvent*>(motion_event)->getXOffset(); |
| 115 | } |
| 116 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 117 | float AMotionEvent_getYOffset(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 118 | return static_cast<const MotionEvent*>(motion_event)->getYOffset(); |
| 119 | } |
| 120 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 121 | float AMotionEvent_getXPrecision(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 122 | return static_cast<const MotionEvent*>(motion_event)->getXPrecision(); |
| 123 | } |
| 124 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 125 | float AMotionEvent_getYPrecision(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 126 | return static_cast<const MotionEvent*>(motion_event)->getYPrecision(); |
| 127 | } |
| 128 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 129 | size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 130 | return static_cast<const MotionEvent*>(motion_event)->getPointerCount(); |
| 131 | } |
| 132 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 133 | int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 134 | return static_cast<const MotionEvent*>(motion_event)->getPointerId(pointer_index); |
| 135 | } |
| 136 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 137 | int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index) { |
| 138 | return static_cast<const MotionEvent*>(motion_event)->getToolType(pointer_index); |
| 139 | } |
| 140 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 141 | float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 142 | return static_cast<const MotionEvent*>(motion_event)->getRawX(pointer_index); |
| 143 | } |
| 144 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 145 | float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 146 | return static_cast<const MotionEvent*>(motion_event)->getRawY(pointer_index); |
| 147 | } |
| 148 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 149 | float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 150 | return static_cast<const MotionEvent*>(motion_event)->getX(pointer_index); |
| 151 | } |
| 152 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 153 | float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 154 | return static_cast<const MotionEvent*>(motion_event)->getY(pointer_index); |
| 155 | } |
| 156 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 157 | float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 158 | return static_cast<const MotionEvent*>(motion_event)->getPressure(pointer_index); |
| 159 | } |
| 160 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 161 | float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 162 | return static_cast<const MotionEvent*>(motion_event)->getSize(pointer_index); |
| 163 | } |
| 164 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 165 | float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index) { |
| 166 | return static_cast<const MotionEvent*>(motion_event)->getTouchMajor(pointer_index); |
| 167 | } |
| 168 | |
| 169 | float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index) { |
| 170 | return static_cast<const MotionEvent*>(motion_event)->getTouchMinor(pointer_index); |
| 171 | } |
| 172 | |
| 173 | float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index) { |
| 174 | return static_cast<const MotionEvent*>(motion_event)->getToolMajor(pointer_index); |
| 175 | } |
| 176 | |
| 177 | float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index) { |
| 178 | return static_cast<const MotionEvent*>(motion_event)->getToolMinor(pointer_index); |
| 179 | } |
| 180 | |
| 181 | float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index) { |
| 182 | return static_cast<const MotionEvent*>(motion_event)->getOrientation(pointer_index); |
| 183 | } |
| 184 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 185 | float AMotionEvent_getAxisValue(const AInputEvent* motion_event, |
| 186 | int32_t axis, size_t pointer_index) { |
| 187 | return static_cast<const MotionEvent*>(motion_event)->getAxisValue(axis, pointer_index); |
| 188 | } |
| 189 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 190 | size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event) { |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 191 | return static_cast<const MotionEvent*>(motion_event)->getHistorySize(); |
| 192 | } |
| 193 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 194 | int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 195 | size_t history_index) { |
| 196 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalEventTime( |
| 197 | history_index); |
| 198 | } |
| 199 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 200 | float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 201 | size_t history_index) { |
| 202 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalRawX( |
| 203 | pointer_index, history_index); |
| 204 | } |
| 205 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 206 | float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 207 | size_t history_index) { |
| 208 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalRawY( |
| 209 | pointer_index, history_index); |
| 210 | } |
| 211 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 212 | float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 213 | size_t history_index) { |
| 214 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalX( |
| 215 | pointer_index, history_index); |
| 216 | } |
| 217 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 218 | float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 219 | size_t history_index) { |
| 220 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalY( |
| 221 | pointer_index, history_index); |
| 222 | } |
| 223 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 224 | float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 225 | size_t history_index) { |
| 226 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalPressure( |
| 227 | pointer_index, history_index); |
| 228 | } |
| 229 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 230 | float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index, |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 231 | size_t history_index) { |
| 232 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalSize( |
| 233 | pointer_index, history_index); |
| 234 | } |
| 235 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 236 | float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 237 | size_t history_index) { |
| 238 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalTouchMajor( |
| 239 | pointer_index, history_index); |
| 240 | } |
| 241 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 242 | float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 243 | size_t history_index) { |
| 244 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalTouchMinor( |
| 245 | pointer_index, history_index); |
| 246 | } |
| 247 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 248 | float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 249 | size_t history_index) { |
| 250 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalToolMajor( |
| 251 | pointer_index, history_index); |
| 252 | } |
| 253 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 254 | float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 255 | size_t history_index) { |
| 256 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalToolMinor( |
| 257 | pointer_index, history_index); |
| 258 | } |
| 259 | |
Andrew Hsieh | c01e1ed | 2013-05-27 12:27:10 +0800 | [diff] [blame] | 260 | float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 261 | size_t history_index) { |
| 262 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalOrientation( |
| 263 | pointer_index, history_index); |
| 264 | } |
| 265 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 266 | float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, |
| 267 | int32_t axis, size_t pointer_index, size_t history_index) { |
| 268 | return static_cast<const MotionEvent*>(motion_event)->getHistoricalAxisValue( |
| 269 | axis, pointer_index, history_index); |
| 270 | } |
| 271 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 272 | |
Dianne Hackborn | 6826741 | 2010-07-02 18:52:01 -0700 | [diff] [blame] | 273 | void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, |
Jeff Brown | 4fe6c3e | 2010-09-13 23:17:30 -0700 | [diff] [blame] | 274 | int ident, ALooper_callbackFunc callback, void* data) { |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 275 | InputQueue* iq = static_cast<InputQueue*>(queue); |
Brian Carlstrom | 82b007d | 2013-12-12 23:12:55 -0800 | [diff] [blame] | 276 | Looper* l = reinterpret_cast<Looper*>(looper); |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 277 | iq->attachLooper(l, ident, callback, data); |
Dianne Hackborn | 6826741 | 2010-07-02 18:52:01 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | void AInputQueue_detachLooper(AInputQueue* queue) { |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 281 | InputQueue* iq = static_cast<InputQueue*>(queue); |
| 282 | iq->detachLooper(); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Dianne Hackborn | 2c6081c | 2010-07-15 17:44:53 -0700 | [diff] [blame] | 285 | int32_t AInputQueue_hasEvents(AInputQueue* queue) { |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 286 | InputQueue* iq = static_cast<InputQueue*>(queue); |
| 287 | return iq->hasEvents(); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Dianne Hackborn | 2e9f93e | 2010-06-28 15:27:30 -0700 | [diff] [blame] | 290 | int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent) { |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 291 | InputQueue* iq = static_cast<InputQueue*>(queue); |
| 292 | InputEvent* event; |
| 293 | int32_t res = iq->getEvent(&event); |
| 294 | *outEvent = event; |
| 295 | return res; |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Dianne Hackborn | 2c6081c | 2010-07-15 17:44:53 -0700 | [diff] [blame] | 298 | int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event) { |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 299 | InputQueue* iq = static_cast<InputQueue*>(queue); |
| 300 | InputEvent* e = static_cast<InputEvent*>(event); |
| 301 | return iq->preDispatchEvent(e) ? 1 : 0; |
Dianne Hackborn | 2c6081c | 2010-07-15 17:44:53 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 304 | void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled) { |
Michael Wright | a44dd26 | 2013-04-10 21:12:00 -0700 | [diff] [blame] | 305 | InputQueue* iq = static_cast<InputQueue*>(queue); |
| 306 | InputEvent* e = static_cast<InputEvent*>(event); |
| 307 | iq->finishEvent(e, handled != 0); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 308 | } |