The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | package android.view; |
| 18 | |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 19 | import static android.view.Display.DEFAULT_DISPLAY; |
| 20 | |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 21 | import static java.lang.annotation.RetentionPolicy.SOURCE; |
| 22 | |
| 23 | import android.annotation.IntDef; |
Kirill Grouchnikov | c0b0ba5 | 2016-09-13 16:09:37 -0700 | [diff] [blame] | 24 | import android.annotation.TestApi; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 25 | import android.annotation.UnsupportedAppUsage; |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 26 | import android.graphics.Matrix; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.os.Parcel; |
| 28 | import android.os.Parcelable; |
| 29 | import android.os.SystemClock; |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 30 | import android.util.Log; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 31 | import android.util.SparseArray; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 33 | import dalvik.annotation.optimization.CriticalNative; |
| 34 | import dalvik.annotation.optimization.FastNative; |
| 35 | |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 36 | import java.lang.annotation.Retention; |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 37 | import java.util.Objects; |
| 38 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 40 | * Object used to report movement (mouse, pen, finger, trackball) events. |
| 41 | * Motion events may hold either absolute or relative movements and other data, |
| 42 | * depending on the type of device. |
| 43 | * |
| 44 | * <h3>Overview</h3> |
Jeff Brown | dc1ab4b | 2010-09-14 18:03:38 -0700 | [diff] [blame] | 45 | * <p> |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 46 | * Motion events describe movements in terms of an action code and a set of axis values. |
| 47 | * The action code specifies the state change that occurred such as a pointer going |
| 48 | * down or up. The axis values describe the position and other movement properties. |
| 49 | * </p><p> |
| 50 | * For example, when the user first touches the screen, the system delivers a touch |
| 51 | * event to the appropriate {@link View} with the action code {@link #ACTION_DOWN} |
| 52 | * and a set of axis values that include the X and Y coordinates of the touch and |
| 53 | * information about the pressure, size and orientation of the contact area. |
| 54 | * </p><p> |
| 55 | * Some devices can report multiple movement traces at the same time. Multi-touch |
| 56 | * screens emit one movement trace for each finger. The individual fingers or |
| 57 | * other objects that generate movement traces are referred to as <em>pointers</em>. |
| 58 | * Motion events contain information about all of the pointers that are currently active |
| 59 | * even if some of them have not moved since the last event was delivered. |
| 60 | * </p><p> |
| 61 | * The number of pointers only ever changes by one as individual pointers go up and down, |
| 62 | * except when the gesture is canceled. |
| 63 | * </p><p> |
| 64 | * Each pointer has a unique id that is assigned when it first goes down |
| 65 | * (indicated by {@link #ACTION_DOWN} or {@link #ACTION_POINTER_DOWN}). A pointer id |
| 66 | * remains valid until the pointer eventually goes up (indicated by {@link #ACTION_UP} |
| 67 | * or {@link #ACTION_POINTER_UP}) or when the gesture is canceled (indicated by |
| 68 | * {@link #ACTION_CANCEL}). |
| 69 | * </p><p> |
| 70 | * The MotionEvent class provides many methods to query the position and other properties of |
| 71 | * pointers, such as {@link #getX(int)}, {@link #getY(int)}, {@link #getAxisValue}, |
| 72 | * {@link #getPointerId(int)}, {@link #getToolType(int)}, and many others. Most of these |
| 73 | * methods accept the pointer index as a parameter rather than the pointer id. |
| 74 | * The pointer index of each pointer in the event ranges from 0 to one less than the value |
| 75 | * returned by {@link #getPointerCount()}. |
| 76 | * </p><p> |
| 77 | * The order in which individual pointers appear within a motion event is undefined. |
| 78 | * Thus the pointer index of a pointer can change from one event to the next but |
| 79 | * the pointer id of a pointer is guaranteed to remain constant as long as the pointer |
| 80 | * remains active. Use the {@link #getPointerId(int)} method to obtain the |
| 81 | * pointer id of a pointer to track it across all subsequent motion events in a gesture. |
| 82 | * Then for successive motion events, use the {@link #findPointerIndex(int)} method |
| 83 | * to obtain the pointer index for a given pointer id in that motion event. |
| 84 | * </p><p> |
| 85 | * Mouse and stylus buttons can be retrieved using {@link #getButtonState()}. It is a |
| 86 | * good idea to check the button state while handling {@link #ACTION_DOWN} as part |
| 87 | * of a touch event. The application may choose to perform some different action |
| 88 | * if the touch event starts due to a secondary button click, such as presenting a |
| 89 | * context menu. |
| 90 | * </p> |
| 91 | * |
| 92 | * <h3>Batching</h3> |
| 93 | * <p> |
| 94 | * For efficiency, motion events with {@link #ACTION_MOVE} may batch together |
| 95 | * multiple movement samples within a single object. The most current |
| 96 | * pointer coordinates are available using {@link #getX(int)} and {@link #getY(int)}. |
| 97 | * Earlier coordinates within the batch are accessed using {@link #getHistoricalX(int, int)} |
| 98 | * and {@link #getHistoricalY(int, int)}. The coordinates are "historical" only |
| 99 | * insofar as they are older than the current coordinates in the batch; however, |
| 100 | * they are still distinct from any other coordinates reported in prior motion events. |
| 101 | * To process all coordinates in the batch in time order, first consume the historical |
| 102 | * coordinates then consume the current coordinates. |
| 103 | * </p><p> |
| 104 | * Example: Consuming all samples for all pointers in a motion event in time order. |
| 105 | * </p><p><pre><code> |
| 106 | * void printSamples(MotionEvent ev) { |
| 107 | * final int historySize = ev.getHistorySize(); |
| 108 | * final int pointerCount = ev.getPointerCount(); |
| 109 | * for (int h = 0; h < historySize; h++) { |
| 110 | * System.out.printf("At time %d:", ev.getHistoricalEventTime(h)); |
| 111 | * for (int p = 0; p < pointerCount; p++) { |
| 112 | * System.out.printf(" pointer %d: (%f,%f)", |
| 113 | * ev.getPointerId(p), ev.getHistoricalX(p, h), ev.getHistoricalY(p, h)); |
| 114 | * } |
| 115 | * } |
| 116 | * System.out.printf("At time %d:", ev.getEventTime()); |
| 117 | * for (int p = 0; p < pointerCount; p++) { |
| 118 | * System.out.printf(" pointer %d: (%f,%f)", |
| 119 | * ev.getPointerId(p), ev.getX(p), ev.getY(p)); |
| 120 | * } |
| 121 | * } |
| 122 | * </code></pre></p> |
| 123 | * |
| 124 | * <h3>Device Types</h3> |
| 125 | * <p> |
| 126 | * The interpretation of the contents of a MotionEvent varies significantly depending |
| 127 | * on the source class of the device. |
| 128 | * </p><p> |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 129 | * On pointing devices with source class {@link InputDevice#SOURCE_CLASS_POINTER} |
| 130 | * such as touch screens, the pointer coordinates specify absolute |
Jeff Brown | dc1ab4b | 2010-09-14 18:03:38 -0700 | [diff] [blame] | 131 | * positions such as view X/Y coordinates. Each complete gesture is represented |
| 132 | * by a sequence of motion events with actions that describe pointer state transitions |
| 133 | * and movements. A gesture starts with a motion event with {@link #ACTION_DOWN} |
| 134 | * that provides the location of the first pointer down. As each additional |
| 135 | * pointer that goes down or up, the framework will generate a motion event with |
| 136 | * {@link #ACTION_POINTER_DOWN} or {@link #ACTION_POINTER_UP} accordingly. |
| 137 | * Pointer movements are described by motion events with {@link #ACTION_MOVE}. |
| 138 | * Finally, a gesture end either when the final pointer goes up as represented |
| 139 | * by a motion event with {@link #ACTION_UP} or when gesture is canceled |
| 140 | * with {@link #ACTION_CANCEL}. |
| 141 | * </p><p> |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 142 | * Some pointing devices such as mice may support vertical and/or horizontal scrolling. |
| 143 | * A scroll event is reported as a generic motion event with {@link #ACTION_SCROLL} that |
| 144 | * includes the relative scroll offset in the {@link #AXIS_VSCROLL} and |
| 145 | * {@link #AXIS_HSCROLL} axes. See {@link #getAxisValue(int)} for information |
| 146 | * about retrieving these additional axes. |
| 147 | * </p><p> |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 148 | * On trackball devices with source class {@link InputDevice#SOURCE_CLASS_TRACKBALL}, |
| 149 | * the pointer coordinates specify relative movements as X/Y deltas. |
Jeff Brown | dc1ab4b | 2010-09-14 18:03:38 -0700 | [diff] [blame] | 150 | * A trackball gesture consists of a sequence of movements described by motion |
| 151 | * events with {@link #ACTION_MOVE} interspersed with occasional {@link #ACTION_DOWN} |
| 152 | * or {@link #ACTION_UP} motion events when the trackball button is pressed or released. |
| 153 | * </p><p> |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 154 | * On joystick devices with source class {@link InputDevice#SOURCE_CLASS_JOYSTICK}, |
| 155 | * the pointer coordinates specify the absolute position of the joystick axes. |
| 156 | * The joystick axis values are normalized to a range of -1.0 to 1.0 where 0.0 corresponds |
| 157 | * to the center position. More information about the set of available axes and the |
| 158 | * range of motion can be obtained using {@link InputDevice#getMotionRange}. |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 159 | * Some common joystick axes are {@link #AXIS_X}, {@link #AXIS_Y}, |
| 160 | * {@link #AXIS_HAT_X}, {@link #AXIS_HAT_Y}, {@link #AXIS_Z} and {@link #AXIS_RZ}. |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 161 | * </p><p> |
Jeff Brown | dc1ab4b | 2010-09-14 18:03:38 -0700 | [diff] [blame] | 162 | * Refer to {@link InputDevice} for more information about how different kinds of |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 163 | * input devices and sources represent pointer coordinates. |
Jeff Brown | dc1ab4b | 2010-09-14 18:03:38 -0700 | [diff] [blame] | 164 | * </p> |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 165 | * |
| 166 | * <h3>Consistency Guarantees</h3> |
| 167 | * <p> |
| 168 | * Motion events are always delivered to views as a consistent stream of events. |
| 169 | * What constitutes a consistent stream varies depending on the type of device. |
| 170 | * For touch events, consistency implies that pointers go down one at a time, |
| 171 | * move around as a group and then go up one at a time or are canceled. |
| 172 | * </p><p> |
| 173 | * While the framework tries to deliver consistent streams of motion events to |
| 174 | * views, it cannot guarantee it. Some events may be dropped or modified by |
| 175 | * containing views in the application before they are delivered thereby making |
| 176 | * the stream of events inconsistent. Views should always be prepared to |
| 177 | * handle {@link #ACTION_CANCEL} and should tolerate anomalous |
| 178 | * situations such as receiving a new {@link #ACTION_DOWN} without first having |
| 179 | * received an {@link #ACTION_UP} for the prior gesture. |
| 180 | * </p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 181 | */ |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 182 | public final class MotionEvent extends InputEvent implements Parcelable { |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 183 | private static final String TAG = "MotionEvent"; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 184 | private static final long NS_PER_MS = 1000000; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 185 | private static final String LABEL_PREFIX = "AXIS_"; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 186 | |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 187 | private static final boolean DEBUG_CONCISE_TOSTRING = false; |
| 188 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 189 | /** |
| 190 | * An invalid pointer id. |
| 191 | * |
| 192 | * This value (-1) can be used as a placeholder to indicate that a pointer id |
| 193 | * has not been assigned or is not available. It cannot appear as |
| 194 | * a pointer id inside a {@link MotionEvent}. |
| 195 | */ |
| 196 | public static final int INVALID_POINTER_ID = -1; |
| 197 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 198 | /** |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 199 | * Bit mask of the parts of the action code that are the action itself. |
| 200 | */ |
| 201 | public static final int ACTION_MASK = 0xff; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 202 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 203 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 204 | * Constant for {@link #getActionMasked}: A pressed gesture has started, the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | * motion contains the initial starting location. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 206 | * <p> |
| 207 | * This is also a good time to check the button state to distinguish |
| 208 | * secondary and tertiary button clicks and handle them appropriately. |
| 209 | * Use {@link #getButtonState} to retrieve the button state. |
| 210 | * </p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | */ |
| 212 | public static final int ACTION_DOWN = 0; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 213 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 215 | * Constant for {@link #getActionMasked}: A pressed gesture has finished, the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 216 | * motion contains the final release location as well as any intermediate |
| 217 | * points since the last down or move event. |
| 218 | */ |
| 219 | public static final int ACTION_UP = 1; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 220 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 221 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 222 | * Constant for {@link #getActionMasked}: A change has happened during a |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | * press gesture (between {@link #ACTION_DOWN} and {@link #ACTION_UP}). |
| 224 | * The motion contains the most recent point, as well as any intermediate |
| 225 | * points since the last down or move event. |
| 226 | */ |
| 227 | public static final int ACTION_MOVE = 2; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 228 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 230 | * Constant for {@link #getActionMasked}: The current gesture has been aborted. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 231 | * You will not receive any more points in it. You should treat this as |
| 232 | * an up event, but not perform any action that you normally would. |
| 233 | */ |
| 234 | public static final int ACTION_CANCEL = 3; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 235 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 237 | * Constant for {@link #getActionMasked}: A movement has happened outside of the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 238 | * normal bounds of the UI element. This does not provide a full gesture, |
| 239 | * but only the initial location of the movement/touch. |
Siarhei Vishniakou | 6ad0e39 | 2017-06-02 17:20:34 -0700 | [diff] [blame] | 240 | * <p> |
| 241 | * Note: Because the location of any event will be outside the |
| 242 | * bounds of the view hierarchy, it will not get dispatched to |
| 243 | * any children of a ViewGroup by default. Therefore, |
| 244 | * movements with ACTION_OUTSIDE should be handled in either the |
| 245 | * root {@link View} or in the appropriate {@link Window.Callback} |
| 246 | * (e.g. {@link android.app.Activity} or {@link android.app.Dialog}). |
| 247 | * </p> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 248 | */ |
| 249 | public static final int ACTION_OUTSIDE = 4; |
| 250 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 251 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 252 | * Constant for {@link #getActionMasked}: A non-primary pointer has gone down. |
| 253 | * <p> |
| 254 | * Use {@link #getActionIndex} to retrieve the index of the pointer that changed. |
| 255 | * </p><p> |
| 256 | * The index is encoded in the {@link #ACTION_POINTER_INDEX_MASK} bits of the |
| 257 | * unmasked action returned by {@link #getAction}. |
| 258 | * </p> |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 259 | */ |
| 260 | public static final int ACTION_POINTER_DOWN = 5; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 261 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 262 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 263 | * Constant for {@link #getActionMasked}: A non-primary pointer has gone up. |
| 264 | * <p> |
| 265 | * Use {@link #getActionIndex} to retrieve the index of the pointer that changed. |
| 266 | * </p><p> |
| 267 | * The index is encoded in the {@link #ACTION_POINTER_INDEX_MASK} bits of the |
| 268 | * unmasked action returned by {@link #getAction}. |
| 269 | * </p> |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 270 | */ |
| 271 | public static final int ACTION_POINTER_UP = 6; |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 272 | |
| 273 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 274 | * Constant for {@link #getActionMasked}: A change happened but the pointer |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 275 | * is not down (unlike {@link #ACTION_MOVE}). The motion contains the most |
| 276 | * recent point, as well as any intermediate points since the last |
| 277 | * hover move event. |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 278 | * <p> |
Jeff Brown | a032cc0 | 2011-03-07 16:56:21 -0800 | [diff] [blame] | 279 | * This action is always delivered to the window or view under the pointer. |
| 280 | * </p><p> |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 281 | * This action is not a touch event so it is delivered to |
| 282 | * {@link View#onGenericMotionEvent(MotionEvent)} rather than |
| 283 | * {@link View#onTouchEvent(MotionEvent)}. |
| 284 | * </p> |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 285 | */ |
| 286 | public static final int ACTION_HOVER_MOVE = 7; |
| 287 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 288 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 289 | * Constant for {@link #getActionMasked}: The motion event contains relative |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 290 | * vertical and/or horizontal scroll offsets. Use {@link #getAxisValue(int)} |
| 291 | * to retrieve the information from {@link #AXIS_VSCROLL} and {@link #AXIS_HSCROLL}. |
| 292 | * The pointer may or may not be down when this event is dispatched. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 293 | * <p> |
Jeff Brown | a032cc0 | 2011-03-07 16:56:21 -0800 | [diff] [blame] | 294 | * This action is always delivered to the window or view under the pointer, which |
| 295 | * may not be the window or view currently touched. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 296 | * </p><p> |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 297 | * This action is not a touch event so it is delivered to |
| 298 | * {@link View#onGenericMotionEvent(MotionEvent)} rather than |
| 299 | * {@link View#onTouchEvent(MotionEvent)}. |
| 300 | * </p> |
| 301 | */ |
| 302 | public static final int ACTION_SCROLL = 8; |
| 303 | |
| 304 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 305 | * Constant for {@link #getActionMasked}: The pointer is not down but has entered the |
Jeff Brown | a032cc0 | 2011-03-07 16:56:21 -0800 | [diff] [blame] | 306 | * boundaries of a window or view. |
| 307 | * <p> |
| 308 | * This action is always delivered to the window or view under the pointer. |
| 309 | * </p><p> |
| 310 | * This action is not a touch event so it is delivered to |
| 311 | * {@link View#onGenericMotionEvent(MotionEvent)} rather than |
| 312 | * {@link View#onTouchEvent(MotionEvent)}. |
| 313 | * </p> |
| 314 | */ |
| 315 | public static final int ACTION_HOVER_ENTER = 9; |
| 316 | |
| 317 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 318 | * Constant for {@link #getActionMasked}: The pointer is not down but has exited the |
Jeff Brown | a032cc0 | 2011-03-07 16:56:21 -0800 | [diff] [blame] | 319 | * boundaries of a window or view. |
| 320 | * <p> |
| 321 | * This action is always delivered to the window or view that was previously under the pointer. |
| 322 | * </p><p> |
| 323 | * This action is not a touch event so it is delivered to |
| 324 | * {@link View#onGenericMotionEvent(MotionEvent)} rather than |
| 325 | * {@link View#onTouchEvent(MotionEvent)}. |
| 326 | * </p> |
| 327 | */ |
| 328 | public static final int ACTION_HOVER_EXIT = 10; |
| 329 | |
| 330 | /** |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 331 | * Constant for {@link #getActionMasked}: A button has been pressed. |
| 332 | * |
| 333 | * <p> |
| 334 | * Use {@link #getActionButton()} to get which button was pressed. |
| 335 | * </p><p> |
| 336 | * This action is not a touch event so it is delivered to |
| 337 | * {@link View#onGenericMotionEvent(MotionEvent)} rather than |
| 338 | * {@link View#onTouchEvent(MotionEvent)}. |
| 339 | * </p> |
| 340 | */ |
| 341 | public static final int ACTION_BUTTON_PRESS = 11; |
| 342 | |
| 343 | /** |
| 344 | * Constant for {@link #getActionMasked}: A button has been released. |
| 345 | * |
| 346 | * <p> |
| 347 | * Use {@link #getActionButton()} to get which button was released. |
| 348 | * </p><p> |
| 349 | * This action is not a touch event so it is delivered to |
| 350 | * {@link View#onGenericMotionEvent(MotionEvent)} rather than |
| 351 | * {@link View#onTouchEvent(MotionEvent)}. |
| 352 | * </p> |
| 353 | */ |
| 354 | public static final int ACTION_BUTTON_RELEASE = 12; |
| 355 | |
| 356 | /** |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 357 | * Bits in the action code that represent a pointer index, used with |
| 358 | * {@link #ACTION_POINTER_DOWN} and {@link #ACTION_POINTER_UP}. Shifting |
| 359 | * down by {@link #ACTION_POINTER_INDEX_SHIFT} provides the actual pointer |
| 360 | * index where the data for the pointer going up or down can be found; you can |
| 361 | * get its identifier with {@link #getPointerId(int)} and the actual |
| 362 | * data with {@link #getX(int)} etc. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 363 | * |
| 364 | * @see #getActionIndex |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 365 | */ |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 366 | public static final int ACTION_POINTER_INDEX_MASK = 0xff00; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 367 | |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 368 | /** |
| 369 | * Bit shift for the action bits holding the pointer index as |
| 370 | * defined by {@link #ACTION_POINTER_INDEX_MASK}. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 371 | * |
| 372 | * @see #getActionIndex |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 373 | */ |
| 374 | public static final int ACTION_POINTER_INDEX_SHIFT = 8; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 375 | |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 376 | /** |
| 377 | * @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the |
| 378 | * data index associated with {@link #ACTION_POINTER_DOWN}. |
| 379 | */ |
| 380 | @Deprecated |
| 381 | public static final int ACTION_POINTER_1_DOWN = ACTION_POINTER_DOWN | 0x0000; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 382 | |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 383 | /** |
| 384 | * @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the |
| 385 | * data index associated with {@link #ACTION_POINTER_DOWN}. |
| 386 | */ |
| 387 | @Deprecated |
| 388 | public static final int ACTION_POINTER_2_DOWN = ACTION_POINTER_DOWN | 0x0100; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 389 | |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 390 | /** |
| 391 | * @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the |
| 392 | * data index associated with {@link #ACTION_POINTER_DOWN}. |
| 393 | */ |
| 394 | @Deprecated |
| 395 | public static final int ACTION_POINTER_3_DOWN = ACTION_POINTER_DOWN | 0x0200; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 396 | |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 397 | /** |
| 398 | * @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the |
| 399 | * data index associated with {@link #ACTION_POINTER_UP}. |
| 400 | */ |
| 401 | @Deprecated |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 402 | public static final int ACTION_POINTER_1_UP = ACTION_POINTER_UP | 0x0000; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 403 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 404 | /** |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 405 | * @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the |
| 406 | * data index associated with {@link #ACTION_POINTER_UP}. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 407 | */ |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 408 | @Deprecated |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 409 | public static final int ACTION_POINTER_2_UP = ACTION_POINTER_UP | 0x0100; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 410 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 411 | /** |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 412 | * @deprecated Use {@link #ACTION_POINTER_INDEX_MASK} to retrieve the |
| 413 | * data index associated with {@link #ACTION_POINTER_UP}. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 414 | */ |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 415 | @Deprecated |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 416 | public static final int ACTION_POINTER_3_UP = ACTION_POINTER_UP | 0x0200; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 417 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 418 | /** |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 419 | * @deprecated Renamed to {@link #ACTION_POINTER_INDEX_MASK} to match |
| 420 | * the actual data contained in these bits. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 421 | */ |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 422 | @Deprecated |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 423 | public static final int ACTION_POINTER_ID_MASK = 0xff00; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 424 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 425 | /** |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 426 | * @deprecated Renamed to {@link #ACTION_POINTER_INDEX_SHIFT} to match |
| 427 | * the actual data contained in these bits. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 428 | */ |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 429 | @Deprecated |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 430 | public static final int ACTION_POINTER_ID_SHIFT = 8; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 431 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 432 | /** |
| 433 | * This flag indicates that the window that received this motion event is partly |
Siarhei Vishniakou | 3a6a411 | 2019-01-30 10:15:12 -0800 | [diff] [blame] | 434 | * or wholly obscured by another visible window above it. This flag is set to true |
| 435 | * if the event directly passed through the obscured area. |
| 436 | * |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 437 | * A security sensitive application can check this flag to identify situations in which |
| 438 | * a malicious application may have covered up part of its content for the purpose |
| 439 | * of misleading the user or hijacking touches. An appropriate response might be |
| 440 | * to drop the suspect touches or to take additional precautions to confirm the user's |
| 441 | * actual intent. |
| 442 | */ |
| 443 | public static final int FLAG_WINDOW_IS_OBSCURED = 0x1; |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 444 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | /** |
Michael Wright | 0625e11 | 2016-03-30 17:31:48 -0700 | [diff] [blame] | 446 | * This flag indicates that the window that received this motion event is partly |
Siarhei Vishniakou | 3a6a411 | 2019-01-30 10:15:12 -0800 | [diff] [blame] | 447 | * or wholly obscured by another visible window above it. This flag is set to true |
Michael Wright | 0625e11 | 2016-03-30 17:31:48 -0700 | [diff] [blame] | 448 | * even if the event did not directly pass through the obscured area. |
Siarhei Vishniakou | 3a6a411 | 2019-01-30 10:15:12 -0800 | [diff] [blame] | 449 | * |
Michael Wright | 0625e11 | 2016-03-30 17:31:48 -0700 | [diff] [blame] | 450 | * A security sensitive application can check this flag to identify situations in which |
| 451 | * a malicious application may have covered up part of its content for the purpose |
| 452 | * of misleading the user or hijacking touches. An appropriate response might be |
| 453 | * to drop the suspect touches or to take additional precautions to confirm the user's |
| 454 | * actual intent. |
| 455 | * |
Siarhei Vishniakou | 3a6a411 | 2019-01-30 10:15:12 -0800 | [diff] [blame] | 456 | * Unlike FLAG_WINDOW_IS_OBSCURED, this is true even if the window that received this event is |
| 457 | * obstructed in areas other than the touched location. |
Michael Wright | 0625e11 | 2016-03-30 17:31:48 -0700 | [diff] [blame] | 458 | */ |
| 459 | public static final int FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2; |
| 460 | |
| 461 | /** |
Vladislav Kaznacheev | 5a77c37 | 2016-10-10 16:11:15 -0700 | [diff] [blame] | 462 | * This private flag is only set on {@link #ACTION_HOVER_MOVE} events and indicates that |
| 463 | * this event will be immediately followed by a {@link #ACTION_HOVER_EXIT}. It is used to |
| 464 | * prevent generating redundant {@link #ACTION_HOVER_ENTER} events. |
| 465 | * @hide |
| 466 | */ |
| 467 | public static final int FLAG_HOVER_EXIT_PENDING = 0x4; |
| 468 | |
| 469 | /** |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 470 | * This flag indicates that the event has been generated by a gesture generator. It |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 471 | * provides a hint to the GestureDetector to not apply any touch slop. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 472 | * |
| 473 | * @hide |
| 474 | */ |
| 475 | public static final int FLAG_IS_GENERATED_GESTURE = 0x8; |
| 476 | |
| 477 | /** |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 478 | * Private flag that indicates when the system has detected that this motion event |
| 479 | * may be inconsistent with respect to the sequence of previously delivered motion events, |
| 480 | * such as when a pointer move event is sent but the pointer is not down. |
| 481 | * |
| 482 | * @hide |
| 483 | * @see #isTainted |
| 484 | * @see #setTainted |
| 485 | */ |
| 486 | public static final int FLAG_TAINTED = 0x80000000; |
| 487 | |
| 488 | /** |
Svetoslav | ded133c | 2015-01-30 20:28:41 -0800 | [diff] [blame] | 489 | * Private flag indicating that this event was synthesized by the system and |
| 490 | * should be delivered to the accessibility focused view first. When being |
| 491 | * dispatched such an event is not handled by predecessors of the accessibility |
| 492 | * focused view and after the event reaches that view the flag is cleared and |
| 493 | * normal event dispatch is performed. This ensures that the platform can click |
| 494 | * on any view that has accessibility focus which is semantically equivalent to |
| 495 | * asking the view to perform a click accessibility action but more generic as |
| 496 | * views not implementing click action correctly can still be activated. |
| 497 | * |
| 498 | * @hide |
| 499 | * @see #isTargetAccessibilityFocus() |
| 500 | * @see #setTargetAccessibilityFocus(boolean) |
| 501 | */ |
| 502 | public static final int FLAG_TARGET_ACCESSIBILITY_FOCUS = 0x40000000; |
| 503 | |
| 504 | |
| 505 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | * Flag indicating the motion event intersected the top edge of the screen. |
| 507 | */ |
| 508 | public static final int EDGE_TOP = 0x00000001; |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 509 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | /** |
| 511 | * Flag indicating the motion event intersected the bottom edge of the screen. |
| 512 | */ |
| 513 | public static final int EDGE_BOTTOM = 0x00000002; |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 514 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | /** |
| 516 | * Flag indicating the motion event intersected the left edge of the screen. |
| 517 | */ |
| 518 | public static final int EDGE_LEFT = 0x00000004; |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 519 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | /** |
| 521 | * Flag indicating the motion event intersected the right edge of the screen. |
| 522 | */ |
| 523 | public static final int EDGE_RIGHT = 0x00000008; |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 524 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 525 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 526 | * Axis constant: X axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 527 | * <p> |
| 528 | * <ul> |
| 529 | * <li>For a touch screen, reports the absolute X screen position of the center of |
| 530 | * the touch contact area. The units are display pixels. |
| 531 | * <li>For a touch pad, reports the absolute X surface position of the center of the touch |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 532 | * contact area. The units are device-dependent; use {@link InputDevice#getMotionRange(int)} |
| 533 | * to query the effective range of values. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 534 | * <li>For a mouse, reports the absolute X screen position of the mouse pointer. |
| 535 | * The units are display pixels. |
| 536 | * <li>For a trackball, reports the relative horizontal displacement of the trackball. |
| 537 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 538 | * <li>For a joystick, reports the absolute X position of the joystick. |
| 539 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 540 | * </ul> |
| 541 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 542 | * |
| 543 | * @see #getX(int) |
| 544 | * @see #getHistoricalX(int, int) |
| 545 | * @see MotionEvent.PointerCoords#x |
| 546 | * @see InputDevice#getMotionRange |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 547 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 548 | public static final int AXIS_X = 0; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 549 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 550 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 551 | * Axis constant: Y axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 552 | * <p> |
| 553 | * <ul> |
| 554 | * <li>For a touch screen, reports the absolute Y screen position of the center of |
| 555 | * the touch contact area. The units are display pixels. |
| 556 | * <li>For a touch pad, reports the absolute Y surface position of the center of the touch |
| 557 | * contact area. The units are device-dependent; use {@link InputDevice#getMotionRange(int)} |
| 558 | * to query the effective range of values. |
| 559 | * <li>For a mouse, reports the absolute Y screen position of the mouse pointer. |
| 560 | * The units are display pixels. |
| 561 | * <li>For a trackball, reports the relative vertical displacement of the trackball. |
| 562 | * The value is normalized to a range from -1.0 (up) to 1.0 (down). |
| 563 | * <li>For a joystick, reports the absolute Y position of the joystick. |
| 564 | * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near). |
| 565 | * </ul> |
| 566 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 567 | * |
| 568 | * @see #getY(int) |
| 569 | * @see #getHistoricalY(int, int) |
| 570 | * @see MotionEvent.PointerCoords#y |
| 571 | * @see InputDevice#getMotionRange |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 572 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 573 | public static final int AXIS_Y = 1; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 574 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 575 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 576 | * Axis constant: Pressure axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 577 | * <p> |
| 578 | * <ul> |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 579 | * <li>For a touch screen or touch pad, reports the approximate pressure applied to the surface |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 580 | * by a finger or other tool. The value is normalized to a range from |
| 581 | * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 |
| 582 | * may be generated depending on the calibration of the input device. |
| 583 | * <li>For a trackball, the value is set to 1 if the trackball button is pressed |
| 584 | * or 0 otherwise. |
| 585 | * <li>For a mouse, the value is set to 1 if the primary mouse button is pressed |
| 586 | * or 0 otherwise. |
| 587 | * </ul> |
| 588 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 589 | * |
| 590 | * @see #getPressure(int) |
| 591 | * @see #getHistoricalPressure(int, int) |
| 592 | * @see MotionEvent.PointerCoords#pressure |
| 593 | * @see InputDevice#getMotionRange |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 594 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 595 | public static final int AXIS_PRESSURE = 2; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 596 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 597 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 598 | * Axis constant: Size axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 599 | * <p> |
| 600 | * <ul> |
| 601 | * <li>For a touch screen or touch pad, reports the approximate size of the contact area in |
| 602 | * relation to the maximum detectable size for the device. The value is normalized |
| 603 | * to a range from 0 (smallest detectable size) to 1 (largest detectable size), |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 604 | * although it is not a linear scale. This value is of limited use. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 605 | * To obtain calibrated size information, use |
| 606 | * {@link #AXIS_TOUCH_MAJOR} or {@link #AXIS_TOOL_MAJOR}. |
| 607 | * </ul> |
| 608 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 609 | * |
| 610 | * @see #getSize(int) |
| 611 | * @see #getHistoricalSize(int, int) |
| 612 | * @see MotionEvent.PointerCoords#size |
| 613 | * @see InputDevice#getMotionRange |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 614 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 615 | public static final int AXIS_SIZE = 3; |
| 616 | |
| 617 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 618 | * Axis constant: TouchMajor axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 619 | * <p> |
| 620 | * <ul> |
| 621 | * <li>For a touch screen, reports the length of the major axis of an ellipse that |
| 622 | * represents the touch area at the point of contact. |
| 623 | * The units are display pixels. |
| 624 | * <li>For a touch pad, reports the length of the major axis of an ellipse that |
| 625 | * represents the touch area at the point of contact. |
| 626 | * The units are device-dependent; use {@link InputDevice#getMotionRange(int)} |
| 627 | * to query the effective range of values. |
| 628 | * </ul> |
| 629 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 630 | * |
| 631 | * @see #getTouchMajor(int) |
| 632 | * @see #getHistoricalTouchMajor(int, int) |
| 633 | * @see MotionEvent.PointerCoords#touchMajor |
| 634 | * @see InputDevice#getMotionRange |
Dianne Hackborn | 1e8dfc7 | 2009-08-06 12:43:01 -0700 | [diff] [blame] | 635 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 636 | public static final int AXIS_TOUCH_MAJOR = 4; |
| 637 | |
| 638 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 639 | * Axis constant: TouchMinor axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 640 | * <p> |
| 641 | * <ul> |
| 642 | * <li>For a touch screen, reports the length of the minor axis of an ellipse that |
| 643 | * represents the touch area at the point of contact. |
| 644 | * The units are display pixels. |
| 645 | * <li>For a touch pad, reports the length of the minor axis of an ellipse that |
| 646 | * represents the touch area at the point of contact. |
| 647 | * The units are device-dependent; use {@link InputDevice#getMotionRange(int)} |
| 648 | * to query the effective range of values. |
| 649 | * </ul> |
| 650 | * </p><p> |
| 651 | * When the touch is circular, the major and minor axis lengths will be equal to one another. |
| 652 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 653 | * |
| 654 | * @see #getTouchMinor(int) |
| 655 | * @see #getHistoricalTouchMinor(int, int) |
| 656 | * @see MotionEvent.PointerCoords#touchMinor |
| 657 | * @see InputDevice#getMotionRange |
Jeff Brown | 9e2ad36 | 2010-07-30 19:20:11 -0700 | [diff] [blame] | 658 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 659 | public static final int AXIS_TOUCH_MINOR = 5; |
| 660 | |
| 661 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 662 | * Axis constant: ToolMajor axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 663 | * <p> |
| 664 | * <ul> |
| 665 | * <li>For a touch screen, reports the length of the major axis of an ellipse that |
| 666 | * represents the size of the approaching finger or tool used to make contact. |
| 667 | * <li>For a touch pad, reports the length of the major axis of an ellipse that |
| 668 | * represents the size of the approaching finger or tool used to make contact. |
| 669 | * The units are device-dependent; use {@link InputDevice#getMotionRange(int)} |
| 670 | * to query the effective range of values. |
| 671 | * </ul> |
| 672 | * </p><p> |
| 673 | * When the touch is circular, the major and minor axis lengths will be equal to one another. |
| 674 | * </p><p> |
| 675 | * The tool size may be larger than the touch size since the tool may not be fully |
| 676 | * in contact with the touch sensor. |
| 677 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 678 | * |
| 679 | * @see #getToolMajor(int) |
| 680 | * @see #getHistoricalToolMajor(int, int) |
| 681 | * @see MotionEvent.PointerCoords#toolMajor |
| 682 | * @see InputDevice#getMotionRange |
| 683 | */ |
| 684 | public static final int AXIS_TOOL_MAJOR = 6; |
| 685 | |
| 686 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 687 | * Axis constant: ToolMinor axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 688 | * <p> |
| 689 | * <ul> |
| 690 | * <li>For a touch screen, reports the length of the minor axis of an ellipse that |
| 691 | * represents the size of the approaching finger or tool used to make contact. |
| 692 | * <li>For a touch pad, reports the length of the minor axis of an ellipse that |
| 693 | * represents the size of the approaching finger or tool used to make contact. |
| 694 | * The units are device-dependent; use {@link InputDevice#getMotionRange(int)} |
| 695 | * to query the effective range of values. |
| 696 | * </ul> |
| 697 | * </p><p> |
| 698 | * When the touch is circular, the major and minor axis lengths will be equal to one another. |
| 699 | * </p><p> |
| 700 | * The tool size may be larger than the touch size since the tool may not be fully |
| 701 | * in contact with the touch sensor. |
| 702 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 703 | * |
| 704 | * @see #getToolMinor(int) |
| 705 | * @see #getHistoricalToolMinor(int, int) |
| 706 | * @see MotionEvent.PointerCoords#toolMinor |
| 707 | * @see InputDevice#getMotionRange |
| 708 | */ |
| 709 | public static final int AXIS_TOOL_MINOR = 7; |
| 710 | |
| 711 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 712 | * Axis constant: Orientation axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 713 | * <p> |
| 714 | * <ul> |
| 715 | * <li>For a touch screen or touch pad, reports the orientation of the finger |
| 716 | * or tool in radians relative to the vertical plane of the device. |
| 717 | * An angle of 0 radians indicates that the major axis of contact is oriented |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 718 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 719 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 720 | * indicates that the major axis of contact is oriented to the left. |
| 721 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
| 722 | * (finger pointing fully right). |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame] | 723 | * <li>For a stylus, the orientation indicates the direction in which the stylus |
| 724 | * is pointing in relation to the vertical axis of the current orientation of the screen. |
| 725 | * The range is from -PI radians to PI radians, where 0 is pointing up, |
| 726 | * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians |
| 727 | * is pointing right. See also {@link #AXIS_TILT}. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 728 | * </ul> |
| 729 | * </p> |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 730 | * |
| 731 | * @see #getOrientation(int) |
| 732 | * @see #getHistoricalOrientation(int, int) |
| 733 | * @see MotionEvent.PointerCoords#orientation |
| 734 | * @see InputDevice#getMotionRange |
| 735 | */ |
| 736 | public static final int AXIS_ORIENTATION = 8; |
| 737 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 738 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 739 | * Axis constant: Vertical Scroll axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 740 | * <p> |
| 741 | * <ul> |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 742 | * <li>For a mouse, reports the relative movement of the vertical scroll wheel. |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 743 | * The value is normalized to a range from -1.0 (down) to 1.0 (up). |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 744 | * </ul> |
| 745 | * </p><p> |
| 746 | * This axis should be used to scroll views vertically. |
| 747 | * </p> |
| 748 | * |
| 749 | * @see #getAxisValue(int, int) |
| 750 | * @see #getHistoricalAxisValue(int, int, int) |
| 751 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 752 | * @see InputDevice#getMotionRange |
| 753 | */ |
| 754 | public static final int AXIS_VSCROLL = 9; |
| 755 | |
| 756 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 757 | * Axis constant: Horizontal Scroll axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 758 | * <p> |
| 759 | * <ul> |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 760 | * <li>For a mouse, reports the relative movement of the horizontal scroll wheel. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 761 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 762 | * </ul> |
| 763 | * </p><p> |
| 764 | * This axis should be used to scroll views horizontally. |
| 765 | * </p> |
| 766 | * |
| 767 | * @see #getAxisValue(int, int) |
| 768 | * @see #getHistoricalAxisValue(int, int, int) |
| 769 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 770 | * @see InputDevice#getMotionRange |
| 771 | */ |
| 772 | public static final int AXIS_HSCROLL = 10; |
| 773 | |
| 774 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 775 | * Axis constant: Z axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 776 | * <p> |
| 777 | * <ul> |
| 778 | * <li>For a joystick, reports the absolute Z position of the joystick. |
| 779 | * The value is normalized to a range from -1.0 (high) to 1.0 (low). |
| 780 | * <em>On game pads with two analog joysticks, this axis is often reinterpreted |
| 781 | * to report the absolute X position of the second joystick instead.</em> |
| 782 | * </ul> |
| 783 | * </p> |
| 784 | * |
| 785 | * @see #getAxisValue(int, int) |
| 786 | * @see #getHistoricalAxisValue(int, int, int) |
| 787 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 788 | * @see InputDevice#getMotionRange |
| 789 | */ |
| 790 | public static final int AXIS_Z = 11; |
| 791 | |
| 792 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 793 | * Axis constant: X Rotation axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 794 | * <p> |
| 795 | * <ul> |
| 796 | * <li>For a joystick, reports the absolute rotation angle about the X axis. |
| 797 | * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). |
| 798 | * </ul> |
| 799 | * </p> |
| 800 | * |
| 801 | * @see #getAxisValue(int, int) |
| 802 | * @see #getHistoricalAxisValue(int, int, int) |
| 803 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 804 | * @see InputDevice#getMotionRange |
| 805 | */ |
| 806 | public static final int AXIS_RX = 12; |
| 807 | |
| 808 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 809 | * Axis constant: Y Rotation axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 810 | * <p> |
| 811 | * <ul> |
| 812 | * <li>For a joystick, reports the absolute rotation angle about the Y axis. |
| 813 | * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). |
| 814 | * </ul> |
| 815 | * </p> |
| 816 | * |
| 817 | * @see #getAxisValue(int, int) |
| 818 | * @see #getHistoricalAxisValue(int, int, int) |
| 819 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 820 | * @see InputDevice#getMotionRange |
| 821 | */ |
| 822 | public static final int AXIS_RY = 13; |
| 823 | |
| 824 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 825 | * Axis constant: Z Rotation axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 826 | * <p> |
| 827 | * <ul> |
| 828 | * <li>For a joystick, reports the absolute rotation angle about the Z axis. |
| 829 | * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). |
| 830 | * <em>On game pads with two analog joysticks, this axis is often reinterpreted |
| 831 | * to report the absolute Y position of the second joystick instead.</em> |
| 832 | * </ul> |
| 833 | * </p> |
| 834 | * |
| 835 | * @see #getAxisValue(int, int) |
| 836 | * @see #getHistoricalAxisValue(int, int, int) |
| 837 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 838 | * @see InputDevice#getMotionRange |
| 839 | */ |
| 840 | public static final int AXIS_RZ = 14; |
| 841 | |
| 842 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 843 | * Axis constant: Hat X axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 844 | * <p> |
| 845 | * <ul> |
| 846 | * <li>For a joystick, reports the absolute X position of the directional hat control. |
| 847 | * The value is normalized to a range from -1.0 (left) to 1.0 (right). |
| 848 | * </ul> |
| 849 | * </p> |
| 850 | * |
| 851 | * @see #getAxisValue(int, int) |
| 852 | * @see #getHistoricalAxisValue(int, int, int) |
| 853 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 854 | * @see InputDevice#getMotionRange |
| 855 | */ |
| 856 | public static final int AXIS_HAT_X = 15; |
| 857 | |
| 858 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 859 | * Axis constant: Hat Y axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 860 | * <p> |
| 861 | * <ul> |
| 862 | * <li>For a joystick, reports the absolute Y position of the directional hat control. |
| 863 | * The value is normalized to a range from -1.0 (up) to 1.0 (down). |
| 864 | * </ul> |
| 865 | * </p> |
| 866 | * |
| 867 | * @see #getAxisValue(int, int) |
| 868 | * @see #getHistoricalAxisValue(int, int, int) |
| 869 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 870 | * @see InputDevice#getMotionRange |
| 871 | */ |
| 872 | public static final int AXIS_HAT_Y = 16; |
| 873 | |
| 874 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 875 | * Axis constant: Left Trigger axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 876 | * <p> |
| 877 | * <ul> |
| 878 | * <li>For a joystick, reports the absolute position of the left trigger control. |
| 879 | * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). |
| 880 | * </ul> |
| 881 | * </p> |
| 882 | * |
| 883 | * @see #getAxisValue(int, int) |
| 884 | * @see #getHistoricalAxisValue(int, int, int) |
| 885 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 886 | * @see InputDevice#getMotionRange |
| 887 | */ |
| 888 | public static final int AXIS_LTRIGGER = 17; |
| 889 | |
| 890 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 891 | * Axis constant: Right Trigger axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 892 | * <p> |
| 893 | * <ul> |
| 894 | * <li>For a joystick, reports the absolute position of the right trigger control. |
| 895 | * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). |
| 896 | * </ul> |
| 897 | * </p> |
| 898 | * |
| 899 | * @see #getAxisValue(int, int) |
| 900 | * @see #getHistoricalAxisValue(int, int, int) |
| 901 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 902 | * @see InputDevice#getMotionRange |
| 903 | */ |
| 904 | public static final int AXIS_RTRIGGER = 18; |
| 905 | |
| 906 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 907 | * Axis constant: Throttle axis of a motion event. |
Jeff Brown | 3a22fa0 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 908 | * <p> |
| 909 | * <ul> |
| 910 | * <li>For a joystick, reports the absolute position of the throttle control. |
| 911 | * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed). |
| 912 | * </ul> |
| 913 | * </p> |
| 914 | * |
| 915 | * @see #getAxisValue(int, int) |
| 916 | * @see #getHistoricalAxisValue(int, int, int) |
| 917 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 918 | * @see InputDevice#getMotionRange |
| 919 | */ |
| 920 | public static final int AXIS_THROTTLE = 19; |
| 921 | |
| 922 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 923 | * Axis constant: Rudder axis of a motion event. |
Jeff Brown | 3a22fa0 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 924 | * <p> |
| 925 | * <ul> |
| 926 | * <li>For a joystick, reports the absolute position of the rudder control. |
| 927 | * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). |
| 928 | * </ul> |
| 929 | * </p> |
| 930 | * |
| 931 | * @see #getAxisValue(int, int) |
| 932 | * @see #getHistoricalAxisValue(int, int, int) |
| 933 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 934 | * @see InputDevice#getMotionRange |
| 935 | */ |
| 936 | public static final int AXIS_RUDDER = 20; |
| 937 | |
| 938 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 939 | * Axis constant: Wheel axis of a motion event. |
Jeff Brown | 3a22fa0 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 940 | * <p> |
| 941 | * <ul> |
| 942 | * <li>For a joystick, reports the absolute position of the steering wheel control. |
| 943 | * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). |
| 944 | * </ul> |
| 945 | * </p> |
| 946 | * |
| 947 | * @see #getAxisValue(int, int) |
| 948 | * @see #getHistoricalAxisValue(int, int, int) |
| 949 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 950 | * @see InputDevice#getMotionRange |
| 951 | */ |
| 952 | public static final int AXIS_WHEEL = 21; |
| 953 | |
| 954 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 955 | * Axis constant: Gas axis of a motion event. |
Jeff Brown | 3a22fa0 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 956 | * <p> |
| 957 | * <ul> |
| 958 | * <li>For a joystick, reports the absolute position of the gas (accelerator) control. |
| 959 | * The value is normalized to a range from 0.0 (no acceleration) |
| 960 | * to 1.0 (maximum acceleration). |
| 961 | * </ul> |
| 962 | * </p> |
| 963 | * |
| 964 | * @see #getAxisValue(int, int) |
| 965 | * @see #getHistoricalAxisValue(int, int, int) |
| 966 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 967 | * @see InputDevice#getMotionRange |
| 968 | */ |
| 969 | public static final int AXIS_GAS = 22; |
| 970 | |
| 971 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 972 | * Axis constant: Brake axis of a motion event. |
Jeff Brown | 3a22fa0 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 973 | * <p> |
| 974 | * <ul> |
| 975 | * <li>For a joystick, reports the absolute position of the brake control. |
| 976 | * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking). |
| 977 | * </ul> |
| 978 | * </p> |
| 979 | * |
| 980 | * @see #getAxisValue(int, int) |
| 981 | * @see #getHistoricalAxisValue(int, int, int) |
| 982 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 983 | * @see InputDevice#getMotionRange |
| 984 | */ |
| 985 | public static final int AXIS_BRAKE = 23; |
| 986 | |
| 987 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 988 | * Axis constant: Distance axis of a motion event. |
| 989 | * <p> |
| 990 | * <ul> |
| 991 | * <li>For a stylus, reports the distance of the stylus from the screen. |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame] | 992 | * A value of 0.0 indicates direct contact and larger values indicate increasing |
| 993 | * distance from the surface. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 994 | * </ul> |
| 995 | * </p> |
| 996 | * |
| 997 | * @see #getAxisValue(int, int) |
| 998 | * @see #getHistoricalAxisValue(int, int, int) |
| 999 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1000 | * @see InputDevice#getMotionRange |
| 1001 | */ |
| 1002 | public static final int AXIS_DISTANCE = 24; |
| 1003 | |
| 1004 | /** |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame] | 1005 | * Axis constant: Tilt axis of a motion event. |
| 1006 | * <p> |
| 1007 | * <ul> |
| 1008 | * <li>For a stylus, reports the tilt angle of the stylus in radians where |
| 1009 | * 0 radians indicates that the stylus is being held perpendicular to the |
| 1010 | * surface, and PI/2 radians indicates that the stylus is being held flat |
| 1011 | * against the surface. |
| 1012 | * </ul> |
| 1013 | * </p> |
| 1014 | * |
| 1015 | * @see #getAxisValue(int, int) |
| 1016 | * @see #getHistoricalAxisValue(int, int, int) |
| 1017 | * @see MotionEvent.PointerCoords#getAxisValue(int, int) |
| 1018 | * @see InputDevice#getMotionRange |
| 1019 | */ |
| 1020 | public static final int AXIS_TILT = 25; |
| 1021 | |
| 1022 | /** |
Prashant Malani | 67322b1 | 2015-08-25 17:41:34 -0700 | [diff] [blame] | 1023 | * Axis constant: Generic scroll axis of a motion event. |
| 1024 | * <p> |
| 1025 | * <ul> |
| 1026 | * <li>Reports the relative movement of the generic scrolling device. |
| 1027 | * </ul> |
| 1028 | * </p><p> |
| 1029 | * This axis should be used for scroll events that are neither strictly vertical nor horizontal. |
| 1030 | * A good example would be the rotation of a rotary encoder input device. |
| 1031 | * </p> |
| 1032 | * |
| 1033 | * @see #getAxisValue(int, int) |
Prashant Malani | 67322b1 | 2015-08-25 17:41:34 -0700 | [diff] [blame] | 1034 | */ |
| 1035 | public static final int AXIS_SCROLL = 26; |
| 1036 | |
| 1037 | /** |
Jun Mukai | 347e5d4 | 2015-12-03 01:13:31 -0800 | [diff] [blame] | 1038 | * Axis constant: The movement of x position of a motion event. |
| 1039 | * <p> |
| 1040 | * <ul> |
| 1041 | * <li>For a mouse, reports a difference of x position between the previous position. |
| 1042 | * This is useful when pointer is captured, in that case the mouse pointer doesn't change |
| 1043 | * the location but this axis reports the difference which allows the app to see |
| 1044 | * how the mouse is moved. |
| 1045 | * </ul> |
| 1046 | * </p> |
| 1047 | * |
| 1048 | * @see #getAxisValue(int, int) |
| 1049 | * @see #getHistoricalAxisValue(int, int, int) |
| 1050 | * @see MotionEvent.PointerCoords#getAxisValue(int, int) |
| 1051 | * @see InputDevice#getMotionRange |
| 1052 | */ |
| 1053 | public static final int AXIS_RELATIVE_X = 27; |
| 1054 | |
| 1055 | /** |
| 1056 | * Axis constant: The movement of y position of a motion event. |
| 1057 | * <p> |
| 1058 | * This is similar to {@link #AXIS_RELATIVE_X} but for y-axis. |
| 1059 | * </p> |
| 1060 | * |
| 1061 | * @see #getAxisValue(int, int) |
| 1062 | * @see #getHistoricalAxisValue(int, int, int) |
| 1063 | * @see MotionEvent.PointerCoords#getAxisValue(int, int) |
| 1064 | * @see InputDevice#getMotionRange |
| 1065 | */ |
| 1066 | public static final int AXIS_RELATIVE_Y = 28; |
| 1067 | |
| 1068 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1069 | * Axis constant: Generic 1 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1070 | * The interpretation of a generic axis is device-specific. |
| 1071 | * |
| 1072 | * @see #getAxisValue(int, int) |
| 1073 | * @see #getHistoricalAxisValue(int, int, int) |
| 1074 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1075 | * @see InputDevice#getMotionRange |
| 1076 | */ |
| 1077 | public static final int AXIS_GENERIC_1 = 32; |
| 1078 | |
| 1079 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1080 | * Axis constant: Generic 2 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1081 | * The interpretation of a generic axis is device-specific. |
| 1082 | * |
| 1083 | * @see #getAxisValue(int, int) |
| 1084 | * @see #getHistoricalAxisValue(int, int, int) |
| 1085 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1086 | * @see InputDevice#getMotionRange |
| 1087 | */ |
| 1088 | public static final int AXIS_GENERIC_2 = 33; |
| 1089 | |
| 1090 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1091 | * Axis constant: Generic 3 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1092 | * The interpretation of a generic axis is device-specific. |
| 1093 | * |
| 1094 | * @see #getAxisValue(int, int) |
| 1095 | * @see #getHistoricalAxisValue(int, int, int) |
| 1096 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1097 | * @see InputDevice#getMotionRange |
| 1098 | */ |
| 1099 | public static final int AXIS_GENERIC_3 = 34; |
| 1100 | |
| 1101 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1102 | * Axis constant: Generic 4 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1103 | * The interpretation of a generic axis is device-specific. |
| 1104 | * |
| 1105 | * @see #getAxisValue(int, int) |
| 1106 | * @see #getHistoricalAxisValue(int, int, int) |
| 1107 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1108 | * @see InputDevice#getMotionRange |
| 1109 | */ |
| 1110 | public static final int AXIS_GENERIC_4 = 35; |
| 1111 | |
| 1112 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1113 | * Axis constant: Generic 5 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1114 | * The interpretation of a generic axis is device-specific. |
| 1115 | * |
| 1116 | * @see #getAxisValue(int, int) |
| 1117 | * @see #getHistoricalAxisValue(int, int, int) |
| 1118 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1119 | * @see InputDevice#getMotionRange |
| 1120 | */ |
| 1121 | public static final int AXIS_GENERIC_5 = 36; |
| 1122 | |
| 1123 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1124 | * Axis constant: Generic 6 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1125 | * The interpretation of a generic axis is device-specific. |
| 1126 | * |
| 1127 | * @see #getAxisValue(int, int) |
| 1128 | * @see #getHistoricalAxisValue(int, int, int) |
| 1129 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1130 | * @see InputDevice#getMotionRange |
| 1131 | */ |
| 1132 | public static final int AXIS_GENERIC_6 = 37; |
| 1133 | |
| 1134 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1135 | * Axis constant: Generic 7 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1136 | * The interpretation of a generic axis is device-specific. |
| 1137 | * |
| 1138 | * @see #getAxisValue(int, int) |
| 1139 | * @see #getHistoricalAxisValue(int, int, int) |
| 1140 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1141 | * @see InputDevice#getMotionRange |
| 1142 | */ |
| 1143 | public static final int AXIS_GENERIC_7 = 38; |
| 1144 | |
| 1145 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1146 | * Axis constant: Generic 8 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1147 | * The interpretation of a generic axis is device-specific. |
| 1148 | * |
| 1149 | * @see #getAxisValue(int, int) |
| 1150 | * @see #getHistoricalAxisValue(int, int, int) |
| 1151 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1152 | * @see InputDevice#getMotionRange |
| 1153 | */ |
| 1154 | public static final int AXIS_GENERIC_8 = 39; |
| 1155 | |
| 1156 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1157 | * Axis constant: Generic 9 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1158 | * The interpretation of a generic axis is device-specific. |
| 1159 | * |
| 1160 | * @see #getAxisValue(int, int) |
| 1161 | * @see #getHistoricalAxisValue(int, int, int) |
| 1162 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1163 | * @see InputDevice#getMotionRange |
| 1164 | */ |
| 1165 | public static final int AXIS_GENERIC_9 = 40; |
| 1166 | |
| 1167 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1168 | * Axis constant: Generic 10 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1169 | * The interpretation of a generic axis is device-specific. |
| 1170 | * |
| 1171 | * @see #getAxisValue(int, int) |
| 1172 | * @see #getHistoricalAxisValue(int, int, int) |
| 1173 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1174 | * @see InputDevice#getMotionRange |
| 1175 | */ |
| 1176 | public static final int AXIS_GENERIC_10 = 41; |
| 1177 | |
| 1178 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1179 | * Axis constant: Generic 11 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1180 | * The interpretation of a generic axis is device-specific. |
| 1181 | * |
| 1182 | * @see #getAxisValue(int, int) |
| 1183 | * @see #getHistoricalAxisValue(int, int, int) |
| 1184 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1185 | * @see InputDevice#getMotionRange |
| 1186 | */ |
| 1187 | public static final int AXIS_GENERIC_11 = 42; |
| 1188 | |
| 1189 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1190 | * Axis constant: Generic 12 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1191 | * The interpretation of a generic axis is device-specific. |
| 1192 | * |
| 1193 | * @see #getAxisValue(int, int) |
| 1194 | * @see #getHistoricalAxisValue(int, int, int) |
| 1195 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1196 | * @see InputDevice#getMotionRange |
| 1197 | */ |
| 1198 | public static final int AXIS_GENERIC_12 = 43; |
| 1199 | |
| 1200 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1201 | * Axis constant: Generic 13 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1202 | * The interpretation of a generic axis is device-specific. |
| 1203 | * |
| 1204 | * @see #getAxisValue(int, int) |
| 1205 | * @see #getHistoricalAxisValue(int, int, int) |
| 1206 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1207 | * @see InputDevice#getMotionRange |
| 1208 | */ |
| 1209 | public static final int AXIS_GENERIC_13 = 44; |
| 1210 | |
| 1211 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1212 | * Axis constant: Generic 14 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1213 | * The interpretation of a generic axis is device-specific. |
| 1214 | * |
| 1215 | * @see #getAxisValue(int, int) |
| 1216 | * @see #getHistoricalAxisValue(int, int, int) |
| 1217 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1218 | * @see InputDevice#getMotionRange |
| 1219 | */ |
| 1220 | public static final int AXIS_GENERIC_14 = 45; |
| 1221 | |
| 1222 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1223 | * Axis constant: Generic 15 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1224 | * The interpretation of a generic axis is device-specific. |
| 1225 | * |
| 1226 | * @see #getAxisValue(int, int) |
| 1227 | * @see #getHistoricalAxisValue(int, int, int) |
| 1228 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1229 | * @see InputDevice#getMotionRange |
| 1230 | */ |
| 1231 | public static final int AXIS_GENERIC_15 = 46; |
| 1232 | |
| 1233 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1234 | * Axis constant: Generic 16 axis of a motion event. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1235 | * The interpretation of a generic axis is device-specific. |
| 1236 | * |
| 1237 | * @see #getAxisValue(int, int) |
| 1238 | * @see #getHistoricalAxisValue(int, int, int) |
| 1239 | * @see MotionEvent.PointerCoords#getAxisValue(int) |
| 1240 | * @see InputDevice#getMotionRange |
| 1241 | */ |
| 1242 | public static final int AXIS_GENERIC_16 = 47; |
| 1243 | |
| 1244 | // NOTE: If you add a new axis here you must also add it to: |
| 1245 | // native/include/android/input.h |
| 1246 | // frameworks/base/include/ui/KeycodeLabels.h |
| 1247 | |
| 1248 | // Symbolic names of all axes. |
| 1249 | private static final SparseArray<String> AXIS_SYMBOLIC_NAMES = new SparseArray<String>(); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1250 | static { |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1251 | SparseArray<String> names = AXIS_SYMBOLIC_NAMES; |
| 1252 | names.append(AXIS_X, "AXIS_X"); |
| 1253 | names.append(AXIS_Y, "AXIS_Y"); |
| 1254 | names.append(AXIS_PRESSURE, "AXIS_PRESSURE"); |
| 1255 | names.append(AXIS_SIZE, "AXIS_SIZE"); |
| 1256 | names.append(AXIS_TOUCH_MAJOR, "AXIS_TOUCH_MAJOR"); |
| 1257 | names.append(AXIS_TOUCH_MINOR, "AXIS_TOUCH_MINOR"); |
| 1258 | names.append(AXIS_TOOL_MAJOR, "AXIS_TOOL_MAJOR"); |
| 1259 | names.append(AXIS_TOOL_MINOR, "AXIS_TOOL_MINOR"); |
| 1260 | names.append(AXIS_ORIENTATION, "AXIS_ORIENTATION"); |
| 1261 | names.append(AXIS_VSCROLL, "AXIS_VSCROLL"); |
| 1262 | names.append(AXIS_HSCROLL, "AXIS_HSCROLL"); |
| 1263 | names.append(AXIS_Z, "AXIS_Z"); |
| 1264 | names.append(AXIS_RX, "AXIS_RX"); |
| 1265 | names.append(AXIS_RY, "AXIS_RY"); |
| 1266 | names.append(AXIS_RZ, "AXIS_RZ"); |
| 1267 | names.append(AXIS_HAT_X, "AXIS_HAT_X"); |
| 1268 | names.append(AXIS_HAT_Y, "AXIS_HAT_Y"); |
| 1269 | names.append(AXIS_LTRIGGER, "AXIS_LTRIGGER"); |
| 1270 | names.append(AXIS_RTRIGGER, "AXIS_RTRIGGER"); |
Jeff Brown | 3a22fa0 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1271 | names.append(AXIS_THROTTLE, "AXIS_THROTTLE"); |
| 1272 | names.append(AXIS_RUDDER, "AXIS_RUDDER"); |
| 1273 | names.append(AXIS_WHEEL, "AXIS_WHEEL"); |
| 1274 | names.append(AXIS_GAS, "AXIS_GAS"); |
| 1275 | names.append(AXIS_BRAKE, "AXIS_BRAKE"); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1276 | names.append(AXIS_DISTANCE, "AXIS_DISTANCE"); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame] | 1277 | names.append(AXIS_TILT, "AXIS_TILT"); |
Prashant Malani | 67322b1 | 2015-08-25 17:41:34 -0700 | [diff] [blame] | 1278 | names.append(AXIS_SCROLL, "AXIS_SCROLL"); |
Jun Mukai | 347e5d4 | 2015-12-03 01:13:31 -0800 | [diff] [blame] | 1279 | names.append(AXIS_RELATIVE_X, "AXIS_REALTIVE_X"); |
| 1280 | names.append(AXIS_RELATIVE_Y, "AXIS_REALTIVE_Y"); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1281 | names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1"); |
| 1282 | names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2"); |
| 1283 | names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3"); |
| 1284 | names.append(AXIS_GENERIC_4, "AXIS_GENERIC_4"); |
| 1285 | names.append(AXIS_GENERIC_5, "AXIS_GENERIC_5"); |
| 1286 | names.append(AXIS_GENERIC_6, "AXIS_GENERIC_6"); |
| 1287 | names.append(AXIS_GENERIC_7, "AXIS_GENERIC_7"); |
| 1288 | names.append(AXIS_GENERIC_8, "AXIS_GENERIC_8"); |
| 1289 | names.append(AXIS_GENERIC_9, "AXIS_GENERIC_9"); |
| 1290 | names.append(AXIS_GENERIC_10, "AXIS_GENERIC_10"); |
| 1291 | names.append(AXIS_GENERIC_11, "AXIS_GENERIC_11"); |
| 1292 | names.append(AXIS_GENERIC_12, "AXIS_GENERIC_12"); |
| 1293 | names.append(AXIS_GENERIC_13, "AXIS_GENERIC_13"); |
| 1294 | names.append(AXIS_GENERIC_14, "AXIS_GENERIC_14"); |
| 1295 | names.append(AXIS_GENERIC_15, "AXIS_GENERIC_15"); |
| 1296 | names.append(AXIS_GENERIC_16, "AXIS_GENERIC_16"); |
| 1297 | } |
| 1298 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1299 | /** |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1300 | * Button constant: Primary button (left mouse button). |
| 1301 | * |
| 1302 | * This button constant is not set in response to simple touches with a finger |
| 1303 | * or stylus tip. The user must actually push a button. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1304 | * |
| 1305 | * @see #getButtonState |
| 1306 | */ |
| 1307 | public static final int BUTTON_PRIMARY = 1 << 0; |
| 1308 | |
| 1309 | /** |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 1310 | * Button constant: Secondary button (right mouse button). |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1311 | * |
| 1312 | * @see #getButtonState |
| 1313 | */ |
| 1314 | public static final int BUTTON_SECONDARY = 1 << 1; |
| 1315 | |
| 1316 | /** |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 1317 | * Button constant: Tertiary button (middle mouse button). |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1318 | * |
| 1319 | * @see #getButtonState |
| 1320 | */ |
| 1321 | public static final int BUTTON_TERTIARY = 1 << 2; |
| 1322 | |
| 1323 | /** |
| 1324 | * Button constant: Back button pressed (mouse back button). |
| 1325 | * <p> |
| 1326 | * The system may send a {@link KeyEvent#KEYCODE_BACK} key press to the application |
| 1327 | * when this button is pressed. |
| 1328 | * </p> |
| 1329 | * |
| 1330 | * @see #getButtonState |
| 1331 | */ |
| 1332 | public static final int BUTTON_BACK = 1 << 3; |
| 1333 | |
| 1334 | /** |
| 1335 | * Button constant: Forward button pressed (mouse forward button). |
| 1336 | * <p> |
| 1337 | * The system may send a {@link KeyEvent#KEYCODE_FORWARD} key press to the application |
| 1338 | * when this button is pressed. |
| 1339 | * </p> |
| 1340 | * |
| 1341 | * @see #getButtonState |
| 1342 | */ |
| 1343 | public static final int BUTTON_FORWARD = 1 << 4; |
| 1344 | |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 1345 | /** |
| 1346 | * Button constant: Primary stylus button pressed. |
| 1347 | * |
| 1348 | * @see #getButtonState |
| 1349 | */ |
| 1350 | public static final int BUTTON_STYLUS_PRIMARY = 1 << 5; |
| 1351 | |
| 1352 | /** |
| 1353 | * Button constant: Secondary stylus button pressed. |
| 1354 | * |
| 1355 | * @see #getButtonState |
| 1356 | */ |
| 1357 | public static final int BUTTON_STYLUS_SECONDARY = 1 << 6; |
| 1358 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1359 | // NOTE: If you add a new axis here you must also add it to: |
| 1360 | // native/include/android/input.h |
| 1361 | |
| 1362 | // Symbolic names of all button states in bit order from least significant |
| 1363 | // to most significant. |
| 1364 | private static final String[] BUTTON_SYMBOLIC_NAMES = new String[] { |
| 1365 | "BUTTON_PRIMARY", |
| 1366 | "BUTTON_SECONDARY", |
| 1367 | "BUTTON_TERTIARY", |
| 1368 | "BUTTON_BACK", |
| 1369 | "BUTTON_FORWARD", |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 1370 | "BUTTON_STYLUS_PRIMARY", |
| 1371 | "BUTTON_STYLUS_SECONDARY", |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1372 | "0x00000080", |
| 1373 | "0x00000100", |
| 1374 | "0x00000200", |
| 1375 | "0x00000400", |
| 1376 | "0x00000800", |
| 1377 | "0x00001000", |
| 1378 | "0x00002000", |
| 1379 | "0x00004000", |
| 1380 | "0x00008000", |
| 1381 | "0x00010000", |
| 1382 | "0x00020000", |
| 1383 | "0x00040000", |
| 1384 | "0x00080000", |
| 1385 | "0x00100000", |
| 1386 | "0x00200000", |
| 1387 | "0x00400000", |
| 1388 | "0x00800000", |
| 1389 | "0x01000000", |
| 1390 | "0x02000000", |
| 1391 | "0x04000000", |
| 1392 | "0x08000000", |
| 1393 | "0x10000000", |
| 1394 | "0x20000000", |
| 1395 | "0x40000000", |
| 1396 | "0x80000000", |
| 1397 | }; |
| 1398 | |
| 1399 | /** |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 1400 | * Classification constant: None. |
| 1401 | * |
| 1402 | * No additional information is available about the current motion event stream. |
| 1403 | * |
| 1404 | * @see #getClassification |
| 1405 | */ |
| 1406 | public static final int CLASSIFICATION_NONE = 0; |
| 1407 | |
| 1408 | /** |
| 1409 | * Classification constant: Ambiguous gesture. |
| 1410 | * |
| 1411 | * The user's intent with respect to the current event stream is not yet determined. |
| 1412 | * Gestural actions, such as scrolling, should be inhibited until the classification resolves |
| 1413 | * to another value or the event stream ends. |
| 1414 | * |
| 1415 | * @see #getClassification |
| 1416 | */ |
| 1417 | public static final int CLASSIFICATION_AMBIGUOUS_GESTURE = 1; |
| 1418 | |
| 1419 | /** |
| 1420 | * Classification constant: Deep press. |
| 1421 | * |
| 1422 | * The current event stream represents the user intentionally pressing harder on the screen. |
| 1423 | * This classification type should be used to accelerate the long press behaviour. |
| 1424 | * |
| 1425 | * @see #getClassification |
| 1426 | */ |
| 1427 | public static final int CLASSIFICATION_DEEP_PRESS = 2; |
| 1428 | |
| 1429 | /** @hide */ |
| 1430 | @Retention(SOURCE) |
| 1431 | @IntDef(prefix = { "CLASSIFICATION" }, value = { |
| 1432 | CLASSIFICATION_NONE, CLASSIFICATION_AMBIGUOUS_GESTURE, CLASSIFICATION_DEEP_PRESS}) |
| 1433 | public @interface Classification {}; |
| 1434 | |
| 1435 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1436 | * Tool type constant: Unknown tool type. |
| 1437 | * This constant is used when the tool type is not known or is not relevant, |
| 1438 | * such as for a trackball or other non-pointing device. |
| 1439 | * |
| 1440 | * @see #getToolType |
| 1441 | */ |
| 1442 | public static final int TOOL_TYPE_UNKNOWN = 0; |
| 1443 | |
| 1444 | /** |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1445 | * Tool type constant: The tool is a finger. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1446 | * |
| 1447 | * @see #getToolType |
| 1448 | */ |
| 1449 | public static final int TOOL_TYPE_FINGER = 1; |
| 1450 | |
| 1451 | /** |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1452 | * Tool type constant: The tool is a stylus. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1453 | * |
| 1454 | * @see #getToolType |
| 1455 | */ |
| 1456 | public static final int TOOL_TYPE_STYLUS = 2; |
| 1457 | |
| 1458 | /** |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1459 | * Tool type constant: The tool is a mouse or trackpad. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1460 | * |
| 1461 | * @see #getToolType |
| 1462 | */ |
| 1463 | public static final int TOOL_TYPE_MOUSE = 3; |
| 1464 | |
| 1465 | /** |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1466 | * Tool type constant: The tool is an eraser or a stylus being used in an inverted posture. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1467 | * |
| 1468 | * @see #getToolType |
| 1469 | */ |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1470 | public static final int TOOL_TYPE_ERASER = 4; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1471 | |
| 1472 | // NOTE: If you add a new tool type here you must also add it to: |
| 1473 | // native/include/android/input.h |
| 1474 | |
| 1475 | // Symbolic names of all tool types. |
| 1476 | private static final SparseArray<String> TOOL_TYPE_SYMBOLIC_NAMES = new SparseArray<String>(); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1477 | static { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1478 | SparseArray<String> names = TOOL_TYPE_SYMBOLIC_NAMES; |
| 1479 | names.append(TOOL_TYPE_UNKNOWN, "TOOL_TYPE_UNKNOWN"); |
| 1480 | names.append(TOOL_TYPE_FINGER, "TOOL_TYPE_FINGER"); |
| 1481 | names.append(TOOL_TYPE_STYLUS, "TOOL_TYPE_STYLUS"); |
| 1482 | names.append(TOOL_TYPE_MOUSE, "TOOL_TYPE_MOUSE"); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1483 | names.append(TOOL_TYPE_ERASER, "TOOL_TYPE_ERASER"); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1484 | } |
| 1485 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1486 | // Private value for history pos that obtains the current sample. |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 1487 | @UnsupportedAppUsage |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1488 | private static final int HISTORY_CURRENT = -0x80000000; |
| 1489 | |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1490 | private static final int MAX_RECYCLED = 10; |
| 1491 | private static final Object gRecyclerLock = new Object(); |
| 1492 | private static int gRecyclerUsed; |
| 1493 | private static MotionEvent gRecyclerTop; |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1494 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1495 | // Shared temporary objects used when translating coordinates supplied by |
| 1496 | // the caller into single element PointerCoords and pointer id arrays. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1497 | private static final Object gSharedTempLock = new Object(); |
| 1498 | private static PointerCoords[] gSharedTempPointerCoords; |
| 1499 | private static PointerProperties[] gSharedTempPointerProperties; |
| 1500 | private static int[] gSharedTempPointerIndexMap; |
| 1501 | |
| 1502 | private static final void ensureSharedTempPointerCapacity(int desiredCapacity) { |
| 1503 | if (gSharedTempPointerCoords == null |
| 1504 | || gSharedTempPointerCoords.length < desiredCapacity) { |
| 1505 | int capacity = gSharedTempPointerCoords != null ? gSharedTempPointerCoords.length : 8; |
| 1506 | while (capacity < desiredCapacity) { |
| 1507 | capacity *= 2; |
| 1508 | } |
| 1509 | gSharedTempPointerCoords = PointerCoords.createArray(capacity); |
| 1510 | gSharedTempPointerProperties = PointerProperties.createArray(capacity); |
| 1511 | gSharedTempPointerIndexMap = new int[capacity]; |
| 1512 | } |
| 1513 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1514 | |
| 1515 | // Pointer to the native MotionEvent object that contains the actual data. |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 1516 | @UnsupportedAppUsage |
Ashok Bhat | 99a1ef2 | 2014-01-08 14:45:08 +0000 | [diff] [blame] | 1517 | private long mNativePtr; |
Mitsuru Oshima | 8169dae | 2009-04-28 18:12:09 -0700 | [diff] [blame] | 1518 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1519 | private MotionEvent mNext; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1520 | |
Ashok Bhat | 99a1ef2 | 2014-01-08 14:45:08 +0000 | [diff] [blame] | 1521 | private static native long nativeInitialize(long nativePtr, |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1522 | int deviceId, int source, int displayId, int action, int flags, int edgeFlags, |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 1523 | int metaState, int buttonState, @Classification int classification, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1524 | float xOffset, float yOffset, float xPrecision, float yPrecision, |
| 1525 | long downTimeNanos, long eventTimeNanos, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1526 | int pointerCount, PointerProperties[] pointerIds, PointerCoords[] pointerCoords); |
Ashok Bhat | 99a1ef2 | 2014-01-08 14:45:08 +0000 | [diff] [blame] | 1527 | private static native void nativeDispose(long nativePtr); |
| 1528 | private static native void nativeAddBatch(long nativePtr, long eventTimeNanos, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1529 | PointerCoords[] pointerCoords, int metaState); |
Ashok Bhat | 99a1ef2 | 2014-01-08 14:45:08 +0000 | [diff] [blame] | 1530 | private static native void nativeGetPointerCoords(long nativePtr, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1531 | int pointerIndex, int historyPos, PointerCoords outPointerCoords); |
Ashok Bhat | 99a1ef2 | 2014-01-08 14:45:08 +0000 | [diff] [blame] | 1532 | private static native void nativeGetPointerProperties(long nativePtr, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1533 | int pointerIndex, PointerProperties outPointerProperties); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1534 | |
Ashok Bhat | 99a1ef2 | 2014-01-08 14:45:08 +0000 | [diff] [blame] | 1535 | private static native long nativeReadFromParcel(long nativePtr, Parcel parcel); |
| 1536 | private static native void nativeWriteToParcel(long nativePtr, Parcel parcel); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1537 | |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 1538 | private static native String nativeAxisToString(int axis); |
| 1539 | private static native int nativeAxisFromString(String label); |
| 1540 | |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 1541 | // -------------- @FastNative ------------------------- |
| 1542 | |
| 1543 | @FastNative |
| 1544 | private static native int nativeGetPointerId(long nativePtr, int pointerIndex); |
| 1545 | @FastNative |
| 1546 | private static native int nativeGetToolType(long nativePtr, int pointerIndex); |
| 1547 | @FastNative |
| 1548 | private static native long nativeGetEventTimeNanos(long nativePtr, int historyPos); |
| 1549 | @FastNative |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 1550 | @UnsupportedAppUsage |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 1551 | private static native float nativeGetRawAxisValue(long nativePtr, |
| 1552 | int axis, int pointerIndex, int historyPos); |
| 1553 | @FastNative |
| 1554 | private static native float nativeGetAxisValue(long nativePtr, |
| 1555 | int axis, int pointerIndex, int historyPos); |
| 1556 | |
| 1557 | // -------------- @CriticalNative ---------------------- |
| 1558 | |
| 1559 | @CriticalNative |
| 1560 | private static native long nativeCopy(long destNativePtr, long sourceNativePtr, |
| 1561 | boolean keepHistory); |
| 1562 | @CriticalNative |
| 1563 | private static native int nativeGetDeviceId(long nativePtr); |
| 1564 | @CriticalNative |
| 1565 | private static native int nativeGetSource(long nativePtr); |
| 1566 | @CriticalNative |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1567 | private static native void nativeSetSource(long nativePtr, int source); |
| 1568 | @CriticalNative |
| 1569 | private static native int nativeGetDisplayId(long nativePtr); |
| 1570 | @CriticalNative |
| 1571 | private static native void nativeSetDisplayId(long nativePtr, int displayId); |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 1572 | @CriticalNative |
| 1573 | private static native int nativeGetAction(long nativePtr); |
| 1574 | @CriticalNative |
| 1575 | private static native void nativeSetAction(long nativePtr, int action); |
| 1576 | @CriticalNative |
| 1577 | private static native boolean nativeIsTouchEvent(long nativePtr); |
| 1578 | @CriticalNative |
| 1579 | private static native int nativeGetFlags(long nativePtr); |
| 1580 | @CriticalNative |
| 1581 | private static native void nativeSetFlags(long nativePtr, int flags); |
| 1582 | @CriticalNative |
| 1583 | private static native int nativeGetEdgeFlags(long nativePtr); |
| 1584 | @CriticalNative |
| 1585 | private static native void nativeSetEdgeFlags(long nativePtr, int action); |
| 1586 | @CriticalNative |
| 1587 | private static native int nativeGetMetaState(long nativePtr); |
| 1588 | @CriticalNative |
| 1589 | private static native int nativeGetButtonState(long nativePtr); |
| 1590 | @CriticalNative |
| 1591 | private static native void nativeSetButtonState(long nativePtr, int buttonState); |
| 1592 | @CriticalNative |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 1593 | private static native int nativeGetClassification(long nativePtr); |
| 1594 | @CriticalNative |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 1595 | private static native int nativeGetActionButton(long nativePtr); |
| 1596 | @CriticalNative |
| 1597 | private static native void nativeSetActionButton(long nativePtr, int actionButton); |
| 1598 | @CriticalNative |
| 1599 | private static native void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY); |
| 1600 | @CriticalNative |
| 1601 | private static native float nativeGetXOffset(long nativePtr); |
| 1602 | @CriticalNative |
| 1603 | private static native float nativeGetYOffset(long nativePtr); |
| 1604 | @CriticalNative |
| 1605 | private static native float nativeGetXPrecision(long nativePtr); |
| 1606 | @CriticalNative |
| 1607 | private static native float nativeGetYPrecision(long nativePtr); |
| 1608 | @CriticalNative |
| 1609 | private static native long nativeGetDownTimeNanos(long nativePtr); |
| 1610 | @CriticalNative |
| 1611 | private static native void nativeSetDownTimeNanos(long nativePtr, long downTime); |
| 1612 | |
| 1613 | @CriticalNative |
| 1614 | private static native int nativeGetPointerCount(long nativePtr); |
| 1615 | @CriticalNative |
| 1616 | private static native int nativeFindPointerIndex(long nativePtr, int pointerId); |
| 1617 | |
| 1618 | @CriticalNative |
| 1619 | private static native int nativeGetHistorySize(long nativePtr); |
| 1620 | |
| 1621 | @CriticalNative |
| 1622 | private static native void nativeScale(long nativePtr, float scale); |
| 1623 | @CriticalNative |
| 1624 | private static native void nativeTransform(long nativePtr, long matrix); |
| 1625 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1626 | private MotionEvent() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1627 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1628 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1629 | @Override |
| 1630 | protected void finalize() throws Throwable { |
| 1631 | try { |
| 1632 | if (mNativePtr != 0) { |
| 1633 | nativeDispose(mNativePtr); |
| 1634 | mNativePtr = 0; |
| 1635 | } |
| 1636 | } finally { |
| 1637 | super.finalize(); |
| 1638 | } |
| 1639 | } |
| 1640 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 1641 | @UnsupportedAppUsage |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1642 | static private MotionEvent obtain() { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1643 | final MotionEvent ev; |
| 1644 | synchronized (gRecyclerLock) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1645 | ev = gRecyclerTop; |
| 1646 | if (ev == null) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1647 | return new MotionEvent(); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1648 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1649 | gRecyclerTop = ev.mNext; |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 1650 | gRecyclerUsed -= 1; |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1651 | } |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1652 | ev.mNext = null; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 1653 | ev.prepareForReuse(); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1654 | return ev; |
| 1655 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1656 | |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1657 | /** |
| 1658 | * Create a new MotionEvent, filling in all of the basic values that |
| 1659 | * define the motion. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1660 | * |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 1661 | * @param downTime The time (in ms) when the user originally pressed down to start |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1662 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 1663 | * @param eventTime The the time (in ms) when this specific event was generated. This |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1664 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 1665 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1666 | * @param pointerCount The number of pointers that will be in this event. |
| 1667 | * @param pointerProperties An array of <em>pointerCount</em> values providing |
| 1668 | * a {@link PointerProperties} property object for each pointer, which must |
| 1669 | * include the pointer identifier. |
| 1670 | * @param pointerCoords An array of <em>pointerCount</em> values providing |
| 1671 | * a {@link PointerCoords} coordinate object for each pointer. |
| 1672 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1673 | * the event was generated. |
| 1674 | * @param buttonState The state of buttons that are pressed. |
| 1675 | * @param xPrecision The precision of the X coordinate being reported. |
| 1676 | * @param yPrecision The precision of the Y coordinate being reported. |
| 1677 | * @param deviceId The id for the device that this event came from. An id of |
| 1678 | * zero indicates that the event didn't come from a physical device; other |
| 1679 | * numbers are arbitrary and you shouldn't depend on the values. |
| 1680 | * @param edgeFlags A bitfield indicating which edges, if any, were touched by this |
| 1681 | * MotionEvent. |
| 1682 | * @param source The source of this event. |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1683 | * @param displayId The display ID associated with this event. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1684 | * @param flags The motion event flags. |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1685 | * @hide |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1686 | */ |
| 1687 | static public MotionEvent obtain(long downTime, long eventTime, |
| 1688 | int action, int pointerCount, PointerProperties[] pointerProperties, |
| 1689 | PointerCoords[] pointerCoords, int metaState, int buttonState, |
| 1690 | float xPrecision, float yPrecision, int deviceId, |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1691 | int edgeFlags, int source, int displayId, int flags) { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1692 | MotionEvent ev = obtain(); |
| 1693 | ev.mNativePtr = nativeInitialize(ev.mNativePtr, |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1694 | deviceId, source, displayId, action, flags, edgeFlags, metaState, buttonState, |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 1695 | CLASSIFICATION_NONE, 0, 0, xPrecision, yPrecision, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1696 | downTime * NS_PER_MS, eventTime * NS_PER_MS, |
| 1697 | pointerCount, pointerProperties, pointerCoords); |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1698 | if (ev.mNativePtr == 0) { |
| 1699 | Log.e(TAG, "Could not initialize MotionEvent"); |
| 1700 | ev.recycle(); |
| 1701 | return null; |
| 1702 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1703 | return ev; |
| 1704 | } |
| 1705 | |
| 1706 | /** |
| 1707 | * Create a new MotionEvent, filling in all of the basic values that |
| 1708 | * define the motion. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 1709 | * |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1710 | * @param downTime The time (in ms) when the user originally pressed down to start |
| 1711 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1712 | * @param eventTime The the time (in ms) when this specific event was generated. This |
| 1713 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1714 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
| 1715 | * @param pointerCount The number of pointers that will be in this event. |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 1716 | * @param pointerProperties An array of <em>pointerCount</em> values providing |
| 1717 | * a {@link PointerProperties} property object for each pointer, which must |
| 1718 | * include the pointer identifier. |
| 1719 | * @param pointerCoords An array of <em>pointerCount</em> values providing |
| 1720 | * a {@link PointerCoords} coordinate object for each pointer. |
| 1721 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1722 | * the event was generated. |
| 1723 | * @param buttonState The state of buttons that are pressed. |
| 1724 | * @param xPrecision The precision of the X coordinate being reported. |
| 1725 | * @param yPrecision The precision of the Y coordinate being reported. |
| 1726 | * @param deviceId The id for the device that this event came from. An id of |
| 1727 | * zero indicates that the event didn't come from a physical device; other |
| 1728 | * numbers are arbitrary and you shouldn't depend on the values. |
| 1729 | * @param edgeFlags A bitfield indicating which edges, if any, were touched by this |
| 1730 | * MotionEvent. |
| 1731 | * @param source The source of this event. |
| 1732 | * @param flags The motion event flags. |
| 1733 | */ |
| 1734 | public static MotionEvent obtain(long downTime, long eventTime, |
| 1735 | int action, int pointerCount, PointerProperties[] pointerProperties, |
| 1736 | PointerCoords[] pointerCoords, int metaState, int buttonState, |
| 1737 | float xPrecision, float yPrecision, int deviceId, |
| 1738 | int edgeFlags, int source, int flags) { |
| 1739 | return obtain(downTime, eventTime, action, pointerCount, pointerProperties, pointerCoords, |
| 1740 | metaState, buttonState, xPrecision, yPrecision, deviceId, edgeFlags, source, |
| 1741 | DEFAULT_DISPLAY, flags); |
| 1742 | } |
| 1743 | |
| 1744 | /** |
| 1745 | * Create a new MotionEvent, filling in all of the basic values that |
| 1746 | * define the motion. |
| 1747 | * |
| 1748 | * @param downTime The time (in ms) when the user originally pressed down to start |
| 1749 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1750 | * @param eventTime The the time (in ms) when this specific event was generated. This |
| 1751 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1752 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
| 1753 | * @param pointerCount The number of pointers that will be in this event. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1754 | * @param pointerIds An array of <em>pointerCount</em> values providing |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 1755 | * an identifier for each pointer. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1756 | * @param pointerCoords An array of <em>pointerCount</em> values providing |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 1757 | * a {@link PointerCoords} coordinate object for each pointer. |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1758 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1759 | * the event was generated. |
| 1760 | * @param xPrecision The precision of the X coordinate being reported. |
| 1761 | * @param yPrecision The precision of the Y coordinate being reported. |
| 1762 | * @param deviceId The id for the device that this event came from. An id of |
| 1763 | * zero indicates that the event didn't come from a physical device; other |
| 1764 | * numbers are arbitrary and you shouldn't depend on the values. |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 1765 | * @param edgeFlags A bitfield indicating which edges, if any, were touched by this |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1766 | * MotionEvent. |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 1767 | * @param source The source of this event. |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 1768 | * @param flags The motion event flags. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1769 | * |
| 1770 | * @deprecated Use {@link #obtain(long, long, int, int, PointerProperties[], PointerCoords[], int, int, float, float, int, int, int, int)} |
| 1771 | * instead. |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1772 | */ |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1773 | @Deprecated |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 1774 | static public MotionEvent obtain(long downTime, long eventTime, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1775 | int action, int pointerCount, int[] pointerIds, PointerCoords[] pointerCoords, |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 1776 | int metaState, float xPrecision, float yPrecision, int deviceId, |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 1777 | int edgeFlags, int source, int flags) { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1778 | synchronized (gSharedTempLock) { |
| 1779 | ensureSharedTempPointerCapacity(pointerCount); |
| 1780 | final PointerProperties[] pp = gSharedTempPointerProperties; |
| 1781 | for (int i = 0; i < pointerCount; i++) { |
| 1782 | pp[i].clear(); |
| 1783 | pp[i].id = pointerIds[i]; |
| 1784 | } |
| 1785 | return obtain(downTime, eventTime, action, pointerCount, pp, |
| 1786 | pointerCoords, metaState, 0, xPrecision, yPrecision, deviceId, |
| 1787 | edgeFlags, source, flags); |
| 1788 | } |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 1789 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1790 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1791 | /** |
| 1792 | * Create a new MotionEvent, filling in all of the basic values that |
| 1793 | * define the motion. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1794 | * |
| 1795 | * @param downTime The time (in ms) when the user originally pressed down to start |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1796 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1797 | * @param eventTime The the time (in ms) when this specific event was generated. This |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1798 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 1799 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1800 | * @param x The X coordinate of this event. |
| 1801 | * @param y The Y coordinate of this event. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1802 | * @param pressure The current pressure of this event. The pressure generally |
| 1803 | * ranges from 0 (no pressure at all) to 1 (normal pressure), however |
| 1804 | * values higher than 1 may be generated depending on the calibration of |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1805 | * the input device. |
| 1806 | * @param size A scaled value of the approximate size of the area being pressed when |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1807 | * touched with the finger. The actual value in pixels corresponding to the finger |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1808 | * touch is normalized with a device specific range of values |
| 1809 | * and scaled to a value between 0 and 1. |
| 1810 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1811 | * the event was generated. |
| 1812 | * @param xPrecision The precision of the X coordinate being reported. |
| 1813 | * @param yPrecision The precision of the Y coordinate being reported. |
| 1814 | * @param deviceId The id for the device that this event came from. An id of |
| 1815 | * zero indicates that the event didn't come from a physical device; other |
| 1816 | * numbers are arbitrary and you shouldn't depend on the values. |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 1817 | * @param edgeFlags A bitfield indicating which edges, if any, were touched by this |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1818 | * MotionEvent. |
| 1819 | */ |
| 1820 | static public MotionEvent obtain(long downTime, long eventTime, int action, |
| 1821 | float x, float y, float pressure, float size, int metaState, |
| 1822 | float xPrecision, float yPrecision, int deviceId, int edgeFlags) { |
Arthur Hung | 19b517a | 2018-09-14 18:24:31 +0800 | [diff] [blame] | 1823 | return obtain(downTime, eventTime, action, x, y, pressure, size, metaState, |
| 1824 | xPrecision, yPrecision, deviceId, edgeFlags, InputDevice.SOURCE_UNKNOWN, |
| 1825 | DEFAULT_DISPLAY); |
| 1826 | } |
| 1827 | |
| 1828 | /** |
| 1829 | * Create a new MotionEvent, filling in all of the basic values that |
| 1830 | * define the motion. |
| 1831 | * |
| 1832 | * @param downTime The time (in ms) when the user originally pressed down to start |
| 1833 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1834 | * @param eventTime The the time (in ms) when this specific event was generated. This |
| 1835 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1836 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
| 1837 | * @param x The X coordinate of this event. |
| 1838 | * @param y The Y coordinate of this event. |
| 1839 | * @param pressure The current pressure of this event. The pressure generally |
| 1840 | * ranges from 0 (no pressure at all) to 1 (normal pressure), however |
| 1841 | * values higher than 1 may be generated depending on the calibration of |
| 1842 | * the input device. |
| 1843 | * @param size A scaled value of the approximate size of the area being pressed when |
| 1844 | * touched with the finger. The actual value in pixels corresponding to the finger |
| 1845 | * touch is normalized with a device specific range of values |
| 1846 | * and scaled to a value between 0 and 1. |
| 1847 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1848 | * the event was generated. |
| 1849 | * @param xPrecision The precision of the X coordinate being reported. |
| 1850 | * @param yPrecision The precision of the Y coordinate being reported. |
| 1851 | * @param deviceId The id for the device that this event came from. An id of |
| 1852 | * zero indicates that the event didn't come from a physical device; other |
| 1853 | * numbers are arbitrary and you shouldn't depend on the values. |
| 1854 | * @param source The source of this event. |
| 1855 | * @param edgeFlags A bitfield indicating which edges, if any, were touched by this |
| 1856 | * MotionEvent. |
| 1857 | * @param displayId The display ID associated with this event. |
| 1858 | * @hide |
| 1859 | */ |
| 1860 | public static MotionEvent obtain(long downTime, long eventTime, int action, |
| 1861 | float x, float y, float pressure, float size, int metaState, |
| 1862 | float xPrecision, float yPrecision, int deviceId, int edgeFlags, int source, |
| 1863 | int displayId) { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1864 | MotionEvent ev = obtain(); |
| 1865 | synchronized (gSharedTempLock) { |
| 1866 | ensureSharedTempPointerCapacity(1); |
| 1867 | final PointerProperties[] pp = gSharedTempPointerProperties; |
| 1868 | pp[0].clear(); |
| 1869 | pp[0].id = 0; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1870 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1871 | final PointerCoords pc[] = gSharedTempPointerCoords; |
| 1872 | pc[0].clear(); |
| 1873 | pc[0].x = x; |
| 1874 | pc[0].y = y; |
| 1875 | pc[0].pressure = pressure; |
| 1876 | pc[0].size = size; |
| 1877 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1878 | ev.mNativePtr = nativeInitialize(ev.mNativePtr, |
Arthur Hung | 19b517a | 2018-09-14 18:24:31 +0800 | [diff] [blame] | 1879 | deviceId, source, displayId, |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 1880 | action, 0, edgeFlags, metaState, 0 /*buttonState*/, CLASSIFICATION_NONE, |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1881 | 0, 0, xPrecision, yPrecision, |
| 1882 | downTime * NS_PER_MS, eventTime * NS_PER_MS, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1883 | 1, pp, pc); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1884 | return ev; |
| 1885 | } |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 1886 | } |
| 1887 | |
| 1888 | /** |
| 1889 | * Create a new MotionEvent, filling in all of the basic values that |
| 1890 | * define the motion. |
| 1891 | * |
| 1892 | * @param downTime The time (in ms) when the user originally pressed down to start |
| 1893 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
| 1894 | * @param eventTime The the time (in ms) when this specific event was generated. This |
| 1895 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 1896 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1897 | * @param pointerCount The number of pointers that are active in this event. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 1898 | * @param x The X coordinate of this event. |
| 1899 | * @param y The Y coordinate of this event. |
| 1900 | * @param pressure The current pressure of this event. The pressure generally |
| 1901 | * ranges from 0 (no pressure at all) to 1 (normal pressure), however |
| 1902 | * values higher than 1 may be generated depending on the calibration of |
| 1903 | * the input device. |
| 1904 | * @param size A scaled value of the approximate size of the area being pressed when |
| 1905 | * touched with the finger. The actual value in pixels corresponding to the finger |
| 1906 | * touch is normalized with a device specific range of values |
| 1907 | * and scaled to a value between 0 and 1. |
| 1908 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1909 | * the event was generated. |
| 1910 | * @param xPrecision The precision of the X coordinate being reported. |
| 1911 | * @param yPrecision The precision of the Y coordinate being reported. |
| 1912 | * @param deviceId The id for the device that this event came from. An id of |
| 1913 | * zero indicates that the event didn't come from a physical device; other |
| 1914 | * numbers are arbitrary and you shouldn't depend on the values. |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 1915 | * @param edgeFlags A bitfield indicating which edges, if any, were touched by this |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 1916 | * MotionEvent. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 1917 | * |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 1918 | * @deprecated Use {@link #obtain(long, long, int, float, float, float, float, int, float, float, int, int)} |
| 1919 | * instead. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 1920 | */ |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 1921 | @Deprecated |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 1922 | static public MotionEvent obtain(long downTime, long eventTime, int action, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1923 | int pointerCount, float x, float y, float pressure, float size, int metaState, |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 1924 | float xPrecision, float yPrecision, int deviceId, int edgeFlags) { |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 1925 | return obtain(downTime, eventTime, action, x, y, pressure, size, |
| 1926 | metaState, xPrecision, yPrecision, deviceId, edgeFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1927 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1928 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1929 | /** |
| 1930 | * Create a new MotionEvent, filling in a subset of the basic motion |
| 1931 | * values. Those not specified here are: device id (always 0), pressure |
| 1932 | * and size (always 1), x and y precision (always 1), and edgeFlags (always 0). |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1933 | * |
| 1934 | * @param downTime The time (in ms) when the user originally pressed down to start |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1935 | * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1936 | * @param eventTime The the time (in ms) when this specific event was generated. This |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1937 | * must be obtained from {@link SystemClock#uptimeMillis()}. |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 1938 | * @param action The kind of action being performed, such as {@link #ACTION_DOWN}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1939 | * @param x The X coordinate of this event. |
| 1940 | * @param y The Y coordinate of this event. |
| 1941 | * @param metaState The state of any meta / modifier keys that were in effect when |
| 1942 | * the event was generated. |
| 1943 | */ |
| 1944 | static public MotionEvent obtain(long downTime, long eventTime, int action, |
| 1945 | float x, float y, int metaState) { |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 1946 | return obtain(downTime, eventTime, action, x, y, 1.0f, 1.0f, |
| 1947 | metaState, 1.0f, 1.0f, 0, 0); |
Mitsuru Oshima | 8169dae | 2009-04-28 18:12:09 -0700 | [diff] [blame] | 1948 | } |
| 1949 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1950 | /** |
| 1951 | * Create a new MotionEvent, copying from an existing one. |
| 1952 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1953 | static public MotionEvent obtain(MotionEvent other) { |
| 1954 | if (other == null) { |
| 1955 | throw new IllegalArgumentException("other motion event must not be null"); |
| 1956 | } |
| 1957 | |
| 1958 | MotionEvent ev = obtain(); |
| 1959 | ev.mNativePtr = nativeCopy(ev.mNativePtr, other.mNativePtr, true /*keepHistory*/); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1960 | return ev; |
| 1961 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 1962 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1963 | /** |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1964 | * Create a new MotionEvent, copying from an existing one, but not including |
| 1965 | * any historical point information. |
| 1966 | */ |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 1967 | static public MotionEvent obtainNoHistory(MotionEvent other) { |
| 1968 | if (other == null) { |
| 1969 | throw new IllegalArgumentException("other motion event must not be null"); |
| 1970 | } |
| 1971 | |
| 1972 | MotionEvent ev = obtain(); |
| 1973 | ev.mNativePtr = nativeCopy(ev.mNativePtr, other.mNativePtr, false /*keepHistory*/); |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1974 | return ev; |
| 1975 | } |
| 1976 | |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 1977 | /** @hide */ |
| 1978 | @Override |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 1979 | @UnsupportedAppUsage |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 1980 | public MotionEvent copy() { |
| 1981 | return obtain(this); |
| 1982 | } |
| 1983 | |
Dianne Hackborn | 8df8b2b | 2009-08-17 15:15:18 -0700 | [diff] [blame] | 1984 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1985 | * Recycle the MotionEvent, to be re-used by a later caller. After calling |
| 1986 | * this function you must not ever touch the event again. |
| 1987 | */ |
Jeff Brown | 92cc2d8 | 2011-12-02 01:19:47 -0800 | [diff] [blame] | 1988 | @Override |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 1989 | public final void recycle() { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 1990 | super.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1991 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1992 | synchronized (gRecyclerLock) { |
| 1993 | if (gRecyclerUsed < MAX_RECYCLED) { |
| 1994 | gRecyclerUsed++; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1995 | mNext = gRecyclerTop; |
| 1996 | gRecyclerTop = this; |
| 1997 | } |
| 1998 | } |
| 1999 | } |
Jeff Brown | 9ea77fc | 2012-03-21 19:49:27 -0700 | [diff] [blame] | 2000 | |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 2001 | /** |
Jeff Brown | 9ea77fc | 2012-03-21 19:49:27 -0700 | [diff] [blame] | 2002 | * Applies a scale factor to all points within this event. |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 2003 | * |
Jeff Brown | 9ea77fc | 2012-03-21 19:49:27 -0700 | [diff] [blame] | 2004 | * This method is used to adjust touch events to simulate different density |
| 2005 | * displays for compatibility mode. The values returned by {@link #getRawX()}, |
| 2006 | * {@link #getRawY()}, {@link #getXPrecision()} and {@link #getYPrecision()} |
| 2007 | * are also affected by the scale factor. |
| 2008 | * |
| 2009 | * @param scale The scale factor to apply. |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 2010 | * @hide |
| 2011 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 2012 | @UnsupportedAppUsage |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 2013 | public final void scale(float scale) { |
Jeff Brown | 9ea77fc | 2012-03-21 19:49:27 -0700 | [diff] [blame] | 2014 | if (scale != 1.0f) { |
| 2015 | nativeScale(mNativePtr, scale); |
| 2016 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | /** {@inheritDoc} */ |
| 2020 | @Override |
| 2021 | public final int getDeviceId() { |
| 2022 | return nativeGetDeviceId(mNativePtr); |
| 2023 | } |
| 2024 | |
| 2025 | /** {@inheritDoc} */ |
| 2026 | @Override |
| 2027 | public final int getSource() { |
| 2028 | return nativeGetSource(mNativePtr); |
| 2029 | } |
| 2030 | |
| 2031 | /** {@inheritDoc} */ |
| 2032 | @Override |
| 2033 | public final void setSource(int source) { |
| 2034 | nativeSetSource(mNativePtr, source); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 2035 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2036 | |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 2037 | /** @hide */ |
Siarhei Vishniakou | 91fa08f | 2018-06-08 22:49:30 +0100 | [diff] [blame] | 2038 | @Override |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 2039 | public int getDisplayId() { |
| 2040 | return nativeGetDisplayId(mNativePtr); |
| 2041 | } |
| 2042 | |
| 2043 | /** @hide */ |
lumark | 793e056 | 2018-07-09 22:14:33 +0800 | [diff] [blame] | 2044 | @TestApi |
Siarhei Vishniakou | 91fa08f | 2018-06-08 22:49:30 +0100 | [diff] [blame] | 2045 | @Override |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 2046 | public void setDisplayId(int displayId) { |
| 2047 | nativeSetDisplayId(mNativePtr, displayId); |
| 2048 | } |
| 2049 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2050 | /** |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 2051 | * Return the kind of action being performed. |
| 2052 | * Consider using {@link #getActionMasked} and {@link #getActionIndex} to retrieve |
| 2053 | * the separate masked action and pointer index. |
| 2054 | * @return The action, such as {@link #ACTION_DOWN} or |
| 2055 | * the combination of {@link #ACTION_POINTER_DOWN} with a shifted pointer index. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2056 | */ |
| 2057 | public final int getAction() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2058 | return nativeGetAction(mNativePtr); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2059 | } |
| 2060 | |
| 2061 | /** |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 2062 | * Return the masked action being performed, without pointer index information. |
| 2063 | * Use {@link #getActionIndex} to return the index associated with pointer actions. |
| 2064 | * @return The action, such as {@link #ACTION_DOWN} or {@link #ACTION_POINTER_DOWN}. |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 2065 | */ |
| 2066 | public final int getActionMasked() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2067 | return nativeGetAction(mNativePtr) & ACTION_MASK; |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 2068 | } |
| 2069 | |
| 2070 | /** |
| 2071 | * For {@link #ACTION_POINTER_DOWN} or {@link #ACTION_POINTER_UP} |
| 2072 | * as returned by {@link #getActionMasked}, this returns the associated |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 2073 | * pointer index. |
| 2074 | * The index may be used with {@link #getPointerId(int)}, |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 2075 | * {@link #getX(int)}, {@link #getY(int)}, {@link #getPressure(int)}, |
| 2076 | * and {@link #getSize(int)} to get information about the pointer that has |
| 2077 | * gone down or up. |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 2078 | * @return The index associated with the action. |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 2079 | */ |
| 2080 | public final int getActionIndex() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2081 | return (nativeGetAction(mNativePtr) & ACTION_POINTER_INDEX_MASK) |
| 2082 | >> ACTION_POINTER_INDEX_SHIFT; |
Dianne Hackborn | b125dc5 | 2010-02-12 15:52:09 -0800 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | /** |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 2086 | * Returns true if this motion event is a touch event. |
| 2087 | * <p> |
Jeff Brown | a032cc0 | 2011-03-07 16:56:21 -0800 | [diff] [blame] | 2088 | * Specifically excludes pointer events with action {@link #ACTION_HOVER_MOVE}, |
| 2089 | * {@link #ACTION_HOVER_ENTER}, {@link #ACTION_HOVER_EXIT}, or {@link #ACTION_SCROLL} |
| 2090 | * because they are not actually touch events (the pointer is not down). |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 2091 | * </p> |
| 2092 | * @return True if this motion event is a touch event. |
| 2093 | * @hide |
| 2094 | */ |
| 2095 | public final boolean isTouchEvent() { |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 2096 | return nativeIsTouchEvent(mNativePtr); |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 2097 | } |
| 2098 | |
| 2099 | /** |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 2100 | * Gets the motion event flags. |
| 2101 | * |
| 2102 | * @see #FLAG_WINDOW_IS_OBSCURED |
| 2103 | */ |
| 2104 | public final int getFlags() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2105 | return nativeGetFlags(mNativePtr); |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 2106 | } |
| 2107 | |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 2108 | /** @hide */ |
| 2109 | @Override |
| 2110 | public final boolean isTainted() { |
| 2111 | final int flags = getFlags(); |
| 2112 | return (flags & FLAG_TAINTED) != 0; |
| 2113 | } |
| 2114 | |
| 2115 | /** @hide */ |
| 2116 | @Override |
| 2117 | public final void setTainted(boolean tainted) { |
| 2118 | final int flags = getFlags(); |
| 2119 | nativeSetFlags(mNativePtr, tainted ? flags | FLAG_TAINTED : flags & ~FLAG_TAINTED); |
| 2120 | } |
| 2121 | |
Svetoslav | ded133c | 2015-01-30 20:28:41 -0800 | [diff] [blame] | 2122 | /** @hide */ |
| 2123 | public final boolean isTargetAccessibilityFocus() { |
| 2124 | final int flags = getFlags(); |
| 2125 | return (flags & FLAG_TARGET_ACCESSIBILITY_FOCUS) != 0; |
| 2126 | } |
| 2127 | |
| 2128 | /** @hide */ |
| 2129 | public final void setTargetAccessibilityFocus(boolean targetsFocus) { |
| 2130 | final int flags = getFlags(); |
| 2131 | nativeSetFlags(mNativePtr, targetsFocus |
| 2132 | ? flags | FLAG_TARGET_ACCESSIBILITY_FOCUS |
| 2133 | : flags & ~FLAG_TARGET_ACCESSIBILITY_FOCUS); |
| 2134 | } |
| 2135 | |
Vladislav Kaznacheev | 5a77c37 | 2016-10-10 16:11:15 -0700 | [diff] [blame] | 2136 | /** @hide */ |
| 2137 | public final boolean isHoverExitPending() { |
| 2138 | final int flags = getFlags(); |
| 2139 | return (flags & FLAG_HOVER_EXIT_PENDING) != 0; |
| 2140 | } |
| 2141 | |
| 2142 | /** @hide */ |
| 2143 | public void setHoverExitPending(boolean hoverExitPending) { |
| 2144 | final int flags = getFlags(); |
| 2145 | nativeSetFlags(mNativePtr, hoverExitPending |
| 2146 | ? flags | FLAG_HOVER_EXIT_PENDING |
| 2147 | : flags & ~FLAG_HOVER_EXIT_PENDING); |
| 2148 | } |
| 2149 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 2150 | /** |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2151 | * Returns the time (in ms) when the user originally pressed down to start |
| 2152 | * a stream of position events. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2153 | */ |
| 2154 | public final long getDownTime() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2155 | return nativeGetDownTimeNanos(mNativePtr) / NS_PER_MS; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2156 | } |
| 2157 | |
| 2158 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2159 | * Sets the time (in ms) when the user originally pressed down to start |
| 2160 | * a stream of position events. |
| 2161 | * |
| 2162 | * @hide |
| 2163 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 2164 | @UnsupportedAppUsage |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2165 | public final void setDownTime(long downTime) { |
| 2166 | nativeSetDownTimeNanos(mNativePtr, downTime * NS_PER_MS); |
| 2167 | } |
| 2168 | |
| 2169 | /** |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2170 | * Retrieve the time this event occurred, |
| 2171 | * in the {@link android.os.SystemClock#uptimeMillis} time base. |
| 2172 | * |
| 2173 | * @return Returns the time this event occurred, |
| 2174 | * in the {@link android.os.SystemClock#uptimeMillis} time base. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2175 | */ |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2176 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2177 | public final long getEventTime() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2178 | return nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT) / NS_PER_MS; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2179 | } |
| 2180 | |
| 2181 | /** |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2182 | * Retrieve the time this event occurred, |
| 2183 | * in the {@link android.os.SystemClock#uptimeMillis} time base but with |
| 2184 | * nanosecond precision. |
| 2185 | * <p> |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 2186 | * The value is in nanosecond precision but it may not have nanosecond accuracy. |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2187 | * </p> |
| 2188 | * |
| 2189 | * @return Returns the time this event occurred, |
| 2190 | * in the {@link android.os.SystemClock#uptimeMillis} time base but with |
| 2191 | * nanosecond precision. |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 2192 | * |
| 2193 | * @hide |
| 2194 | */ |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2195 | @Override |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 2196 | @UnsupportedAppUsage |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 2197 | public final long getEventTimeNano() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2198 | return nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT); |
Michael Chan | 53071d6 | 2009-05-13 17:29:48 -0700 | [diff] [blame] | 2199 | } |
| 2200 | |
| 2201 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2202 | * {@link #getX(int)} for the first pointer index (may be an |
| 2203 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2204 | * |
| 2205 | * @see #AXIS_X |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2206 | */ |
| 2207 | public final float getX() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2208 | return nativeGetAxisValue(mNativePtr, AXIS_X, 0, HISTORY_CURRENT); |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2209 | } |
| 2210 | |
| 2211 | /** |
| 2212 | * {@link #getY(int)} for the first pointer index (may be an |
| 2213 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2214 | * |
| 2215 | * @see #AXIS_Y |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2216 | */ |
| 2217 | public final float getY() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2218 | return nativeGetAxisValue(mNativePtr, AXIS_Y, 0, HISTORY_CURRENT); |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2219 | } |
| 2220 | |
| 2221 | /** |
| 2222 | * {@link #getPressure(int)} for the first pointer index (may be an |
| 2223 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2224 | * |
| 2225 | * @see #AXIS_PRESSURE |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2226 | */ |
| 2227 | public final float getPressure() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2228 | return nativeGetAxisValue(mNativePtr, AXIS_PRESSURE, 0, HISTORY_CURRENT); |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | /** |
| 2232 | * {@link #getSize(int)} for the first pointer index (may be an |
| 2233 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2234 | * |
| 2235 | * @see #AXIS_SIZE |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2236 | */ |
| 2237 | public final float getSize() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2238 | return nativeGetAxisValue(mNativePtr, AXIS_SIZE, 0, HISTORY_CURRENT); |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2239 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2240 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2241 | /** |
| 2242 | * {@link #getTouchMajor(int)} for the first pointer index (may be an |
| 2243 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2244 | * |
| 2245 | * @see #AXIS_TOUCH_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2246 | */ |
| 2247 | public final float getTouchMajor() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2248 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MAJOR, 0, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2249 | } |
| 2250 | |
| 2251 | /** |
| 2252 | * {@link #getTouchMinor(int)} for the first pointer index (may be an |
| 2253 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2254 | * |
| 2255 | * @see #AXIS_TOUCH_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2256 | */ |
| 2257 | public final float getTouchMinor() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2258 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MINOR, 0, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2259 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2260 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2261 | /** |
| 2262 | * {@link #getToolMajor(int)} for the first pointer index (may be an |
| 2263 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2264 | * |
| 2265 | * @see #AXIS_TOOL_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2266 | */ |
| 2267 | public final float getToolMajor() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2268 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MAJOR, 0, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2269 | } |
| 2270 | |
| 2271 | /** |
| 2272 | * {@link #getToolMinor(int)} for the first pointer index (may be an |
| 2273 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2274 | * |
| 2275 | * @see #AXIS_TOOL_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2276 | */ |
| 2277 | public final float getToolMinor() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2278 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MINOR, 0, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2279 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2280 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2281 | /** |
| 2282 | * {@link #getOrientation(int)} for the first pointer index (may be an |
| 2283 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2284 | * |
| 2285 | * @see #AXIS_ORIENTATION |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2286 | */ |
| 2287 | public final float getOrientation() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2288 | return nativeGetAxisValue(mNativePtr, AXIS_ORIENTATION, 0, HISTORY_CURRENT); |
| 2289 | } |
| 2290 | |
| 2291 | /** |
| 2292 | * {@link #getAxisValue(int)} for the first pointer index (may be an |
| 2293 | * arbitrary pointer identifier). |
| 2294 | * |
| 2295 | * @param axis The axis identifier for the axis value to retrieve. |
| 2296 | * |
| 2297 | * @see #AXIS_X |
| 2298 | * @see #AXIS_Y |
| 2299 | */ |
| 2300 | public final float getAxisValue(int axis) { |
| 2301 | return nativeGetAxisValue(mNativePtr, axis, 0, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2302 | } |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2303 | |
| 2304 | /** |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2305 | * The number of pointers of data contained in this event. Always |
| 2306 | * >= 1. |
| 2307 | */ |
| 2308 | public final int getPointerCount() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2309 | return nativeGetPointerCount(mNativePtr); |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2310 | } |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 2311 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2312 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2313 | * Return the pointer identifier associated with a particular pointer |
Trevor Johns | 682c24e | 2016-04-12 10:13:47 -0700 | [diff] [blame] | 2314 | * data index in this event. The identifier tells you the actual pointer |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2315 | * number associated with the data, accounting for individual pointers |
| 2316 | * going up and down since the start of the current gesture. |
| 2317 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2318 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2319 | */ |
Dianne Hackborn | d41ba66 | 2009-08-05 15:30:56 -0700 | [diff] [blame] | 2320 | public final int getPointerId(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2321 | return nativeGetPointerId(mNativePtr, pointerIndex); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2322 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2323 | |
| 2324 | /** |
| 2325 | * Gets the tool type of a pointer for the given pointer index. |
| 2326 | * The tool type indicates the type of tool used to make contact such |
| 2327 | * as a finger or stylus, if known. |
| 2328 | * |
| 2329 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2330 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2331 | * @return The tool type of the pointer. |
| 2332 | * |
| 2333 | * @see #TOOL_TYPE_UNKNOWN |
| 2334 | * @see #TOOL_TYPE_FINGER |
| 2335 | * @see #TOOL_TYPE_STYLUS |
| 2336 | * @see #TOOL_TYPE_MOUSE |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2337 | */ |
| 2338 | public final int getToolType(int pointerIndex) { |
| 2339 | return nativeGetToolType(mNativePtr, pointerIndex); |
| 2340 | } |
| 2341 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2342 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2343 | * Given a pointer identifier, find the index of its data in the event. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2344 | * |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2345 | * @param pointerId The identifier of the pointer to be found. |
| 2346 | * @return Returns either the index of the pointer (for use with |
Gilles Debunne | b0d6ba1 | 2010-08-17 20:01:42 -0700 | [diff] [blame] | 2347 | * {@link #getX(int)} et al.), or -1 if there is no data available for |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2348 | * that pointer identifier. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2349 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2350 | public final int findPointerIndex(int pointerId) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2351 | return nativeFindPointerIndex(mNativePtr, pointerId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2352 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2353 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2354 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2355 | * Returns the X coordinate of this event for the given pointer |
| 2356 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2357 | * identifier for this index). |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2358 | * Whole numbers are pixels; the |
| 2359 | * value may have a fraction for input devices that are sub-pixel precise. |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2360 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2361 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2362 | * |
| 2363 | * @see #AXIS_X |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2364 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2365 | public final float getX(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2366 | return nativeGetAxisValue(mNativePtr, AXIS_X, pointerIndex, HISTORY_CURRENT); |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2367 | } |
| 2368 | |
| 2369 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2370 | * Returns the Y coordinate of this event for the given pointer |
| 2371 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2372 | * identifier for this index). |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2373 | * Whole numbers are pixels; the |
| 2374 | * value may have a fraction for input devices that are sub-pixel precise. |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2375 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2376 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2377 | * |
| 2378 | * @see #AXIS_Y |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2379 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2380 | public final float getY(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2381 | return nativeGetAxisValue(mNativePtr, AXIS_Y, pointerIndex, HISTORY_CURRENT); |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2382 | } |
| 2383 | |
| 2384 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2385 | * Returns the current pressure of this event for the given pointer |
| 2386 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2387 | * identifier for this index). |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2388 | * The pressure generally |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2389 | * ranges from 0 (no pressure at all) to 1 (normal pressure), however |
| 2390 | * values higher than 1 may be generated depending on the calibration of |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2391 | * the input device. |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2392 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2393 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2394 | * |
| 2395 | * @see #AXIS_PRESSURE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2396 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2397 | public final float getPressure(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2398 | return nativeGetAxisValue(mNativePtr, AXIS_PRESSURE, pointerIndex, HISTORY_CURRENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2399 | } |
| 2400 | |
| 2401 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2402 | * Returns a scaled value of the approximate size for the given pointer |
| 2403 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2404 | * identifier for this index). |
| 2405 | * This represents some approximation of the area of the screen being |
| 2406 | * pressed; the actual value in pixels corresponding to the |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2407 | * touch is normalized with the device specific range of values |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2408 | * and scaled to a value between 0 and 1. The value of size can be used to |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2409 | * determine fat touch events. |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2410 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2411 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2412 | * |
| 2413 | * @see #AXIS_SIZE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2414 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2415 | public final float getSize(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2416 | return nativeGetAxisValue(mNativePtr, AXIS_SIZE, pointerIndex, HISTORY_CURRENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2417 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2418 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2419 | /** |
| 2420 | * Returns the length of the major axis of an ellipse that describes the touch |
| 2421 | * area at the point of contact for the given pointer |
| 2422 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2423 | * identifier for this index). |
| 2424 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2425 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2426 | * |
| 2427 | * @see #AXIS_TOUCH_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2428 | */ |
| 2429 | public final float getTouchMajor(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2430 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MAJOR, pointerIndex, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2431 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2432 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2433 | /** |
| 2434 | * Returns the length of the minor axis of an ellipse that describes the touch |
| 2435 | * area at the point of contact for the given pointer |
| 2436 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2437 | * identifier for this index). |
| 2438 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2439 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2440 | * |
| 2441 | * @see #AXIS_TOUCH_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2442 | */ |
| 2443 | public final float getTouchMinor(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2444 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MINOR, pointerIndex, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2445 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2446 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2447 | /** |
| 2448 | * Returns the length of the major axis of an ellipse that describes the size of |
| 2449 | * the approaching tool for the given pointer |
| 2450 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2451 | * identifier for this index). |
| 2452 | * The tool area represents the estimated size of the finger or pen that is |
| 2453 | * touching the device independent of its actual touch area at the point of contact. |
| 2454 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2455 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2456 | * |
| 2457 | * @see #AXIS_TOOL_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2458 | */ |
| 2459 | public final float getToolMajor(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2460 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MAJOR, pointerIndex, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2461 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2462 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2463 | /** |
| 2464 | * Returns the length of the minor axis of an ellipse that describes the size of |
| 2465 | * the approaching tool for the given pointer |
| 2466 | * <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2467 | * identifier for this index). |
| 2468 | * The tool area represents the estimated size of the finger or pen that is |
| 2469 | * touching the device independent of its actual touch area at the point of contact. |
| 2470 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2471 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2472 | * |
| 2473 | * @see #AXIS_TOOL_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2474 | */ |
| 2475 | public final float getToolMinor(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2476 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MINOR, pointerIndex, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2477 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2478 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2479 | /** |
| 2480 | * Returns the orientation of the touch area and tool area in radians clockwise from vertical |
| 2481 | * for the given pointer <em>index</em> (use {@link #getPointerId(int)} to find the pointer |
| 2482 | * identifier for this index). |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2483 | * An angle of 0 radians indicates that the major axis of contact is oriented |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2484 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 2485 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 2486 | * indicates that the major axis of contact is oriented to the left. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 2487 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2488 | * (finger pointing fully right). |
| 2489 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2490 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2491 | * |
| 2492 | * @see #AXIS_ORIENTATION |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2493 | */ |
| 2494 | public final float getOrientation(int pointerIndex) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2495 | return nativeGetAxisValue(mNativePtr, AXIS_ORIENTATION, pointerIndex, HISTORY_CURRENT); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2496 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2497 | |
| 2498 | /** |
| 2499 | * Returns the value of the requested axis for the given pointer <em>index</em> |
| 2500 | * (use {@link #getPointerId(int)} to find the pointer identifier for this index). |
| 2501 | * |
| 2502 | * @param axis The axis identifier for the axis value to retrieve. |
| 2503 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2504 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2505 | * @return The value of the axis, or 0 if the axis is not available. |
| 2506 | * |
| 2507 | * @see #AXIS_X |
| 2508 | * @see #AXIS_Y |
| 2509 | */ |
| 2510 | public final float getAxisValue(int axis, int pointerIndex) { |
| 2511 | return nativeGetAxisValue(mNativePtr, axis, pointerIndex, HISTORY_CURRENT); |
| 2512 | } |
| 2513 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2514 | /** |
| 2515 | * Populates a {@link PointerCoords} object with pointer coordinate data for |
| 2516 | * the specified pointer index. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2517 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2518 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2519 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2520 | * @param outPointerCoords The pointer coordinate object to populate. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2521 | * |
| 2522 | * @see PointerCoords |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2523 | */ |
| 2524 | public final void getPointerCoords(int pointerIndex, PointerCoords outPointerCoords) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2525 | nativeGetPointerCoords(mNativePtr, pointerIndex, HISTORY_CURRENT, outPointerCoords); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2526 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2527 | |
| 2528 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2529 | * Populates a {@link PointerProperties} object with pointer properties for |
| 2530 | * the specified pointer index. |
| 2531 | * |
| 2532 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2533 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2534 | * @param outPointerProperties The pointer properties object to populate. |
| 2535 | * |
| 2536 | * @see PointerProperties |
| 2537 | */ |
| 2538 | public final void getPointerProperties(int pointerIndex, |
| 2539 | PointerProperties outPointerProperties) { |
| 2540 | nativeGetPointerProperties(mNativePtr, pointerIndex, outPointerProperties); |
| 2541 | } |
| 2542 | |
| 2543 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2544 | * Returns the state of any meta / modifier keys that were in effect when |
| 2545 | * the event was generated. This is the same values as those |
| 2546 | * returned by {@link KeyEvent#getMetaState() KeyEvent.getMetaState}. |
| 2547 | * |
| 2548 | * @return an integer in which each bit set to 1 represents a pressed |
| 2549 | * meta key |
| 2550 | * |
| 2551 | * @see KeyEvent#getMetaState() |
| 2552 | */ |
| 2553 | public final int getMetaState() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2554 | return nativeGetMetaState(mNativePtr); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2555 | } |
| 2556 | |
| 2557 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2558 | * Gets the state of all buttons that are pressed such as a mouse or stylus button. |
| 2559 | * |
| 2560 | * @return The button state. |
| 2561 | * |
| 2562 | * @see #BUTTON_PRIMARY |
| 2563 | * @see #BUTTON_SECONDARY |
| 2564 | * @see #BUTTON_TERTIARY |
| 2565 | * @see #BUTTON_FORWARD |
| 2566 | * @see #BUTTON_BACK |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 2567 | * @see #BUTTON_STYLUS_PRIMARY |
| 2568 | * @see #BUTTON_STYLUS_SECONDARY |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 2569 | */ |
| 2570 | public final int getButtonState() { |
| 2571 | return nativeGetButtonState(mNativePtr); |
| 2572 | } |
| 2573 | |
| 2574 | /** |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 2575 | * Sets the bitfield indicating which buttons are pressed. |
| 2576 | * |
| 2577 | * @see #getButtonState() |
| 2578 | * @hide |
| 2579 | */ |
Kirill Grouchnikov | b2a44f0 | 2016-09-14 16:24:44 -0700 | [diff] [blame] | 2580 | @TestApi |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 2581 | public final void setButtonState(int buttonState) { |
| 2582 | nativeSetButtonState(mNativePtr, buttonState); |
| 2583 | } |
| 2584 | |
| 2585 | /** |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 2586 | * Returns the classification for the current gesture. |
| 2587 | * The classification may change as more events become available for the same gesture. |
| 2588 | * |
| 2589 | * @see #CLASSIFICATION_NONE |
| 2590 | * @see #CLASSIFICATION_AMBIGUOUS_GESTURE |
| 2591 | * @see #CLASSIFICATION_DEEP_PRESS |
| 2592 | */ |
| 2593 | public @Classification int getClassification() { |
| 2594 | return nativeGetClassification(mNativePtr); |
| 2595 | } |
| 2596 | |
| 2597 | /** |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 2598 | * Gets which button has been modified during a press or release action. |
| 2599 | * |
| 2600 | * For actions other than {@link #ACTION_BUTTON_PRESS} and {@link #ACTION_BUTTON_RELEASE} |
| 2601 | * the returned value is undefined. |
| 2602 | * |
| 2603 | * @see #getButtonState() |
| 2604 | */ |
| 2605 | public final int getActionButton() { |
| 2606 | return nativeGetActionButton(mNativePtr); |
| 2607 | } |
| 2608 | |
| 2609 | /** |
Michael Wright | 6b819b4 | 2015-06-17 21:06:03 +0100 | [diff] [blame] | 2610 | * Sets the action button for the event. |
| 2611 | * |
| 2612 | * @see #getActionButton() |
| 2613 | * @hide |
| 2614 | */ |
Kirill Grouchnikov | c0b0ba5 | 2016-09-13 16:09:37 -0700 | [diff] [blame] | 2615 | @TestApi |
Michael Wright | 6b819b4 | 2015-06-17 21:06:03 +0100 | [diff] [blame] | 2616 | public final void setActionButton(int button) { |
| 2617 | nativeSetActionButton(mNativePtr, button); |
| 2618 | } |
| 2619 | |
| 2620 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2621 | * Returns the original raw X coordinate of this event. For touch |
| 2622 | * events on the screen, this is the original location of the event |
| 2623 | * on the screen, before it had been adjusted for the containing window |
| 2624 | * and views. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2625 | * |
Michael Wright | 072137c | 2013-04-24 20:41:20 -0700 | [diff] [blame] | 2626 | * @see #getX(int) |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2627 | * @see #AXIS_X |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2628 | */ |
| 2629 | public final float getRawX() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2630 | return nativeGetRawAxisValue(mNativePtr, AXIS_X, 0, HISTORY_CURRENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2631 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2632 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2633 | /** |
| 2634 | * Returns the original raw Y coordinate of this event. For touch |
| 2635 | * events on the screen, this is the original location of the event |
| 2636 | * on the screen, before it had been adjusted for the containing window |
| 2637 | * and views. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2638 | * |
Michael Wright | 072137c | 2013-04-24 20:41:20 -0700 | [diff] [blame] | 2639 | * @see #getY(int) |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2640 | * @see #AXIS_Y |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2641 | */ |
| 2642 | public final float getRawY() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2643 | return nativeGetRawAxisValue(mNativePtr, AXIS_Y, 0, HISTORY_CURRENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2644 | } |
| 2645 | |
| 2646 | /** |
Vishnu Nair | 1899955 | 2018-12-13 09:28:11 -0800 | [diff] [blame] | 2647 | * Returns the original raw X coordinate of this event. For touch |
| 2648 | * events on the screen, this is the original location of the event |
| 2649 | * on the screen, before it had been adjusted for the containing window |
| 2650 | * and views. |
| 2651 | * |
| 2652 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2653 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2654 | * |
| 2655 | * @see #getX(int) |
| 2656 | * @see #AXIS_X |
| 2657 | */ |
| 2658 | public float getRawX(int pointerIndex) { |
| 2659 | return nativeGetRawAxisValue(mNativePtr, AXIS_X, pointerIndex, HISTORY_CURRENT); |
| 2660 | } |
| 2661 | |
| 2662 | /** |
| 2663 | * Returns the original raw Y coordinate of this event. For touch |
| 2664 | * events on the screen, this is the original location of the event |
| 2665 | * on the screen, before it had been adjusted for the containing window |
| 2666 | * and views. |
| 2667 | * |
| 2668 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2669 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2670 | * |
| 2671 | * @see #getY(int) |
| 2672 | * @see #AXIS_Y |
| 2673 | */ |
| 2674 | public float getRawY(int pointerIndex) { |
| 2675 | return nativeGetRawAxisValue(mNativePtr, AXIS_Y, pointerIndex, HISTORY_CURRENT); |
| 2676 | } |
| 2677 | |
| 2678 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2679 | * Return the precision of the X coordinates being reported. You can |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2680 | * multiply this number with {@link #getX} to find the actual hardware |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2681 | * value of the X coordinate. |
| 2682 | * @return Returns the precision of X coordinates being reported. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2683 | * |
| 2684 | * @see #AXIS_X |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2685 | */ |
| 2686 | public final float getXPrecision() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2687 | return nativeGetXPrecision(mNativePtr); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2688 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2689 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2690 | /** |
| 2691 | * Return the precision of the Y coordinates being reported. You can |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2692 | * multiply this number with {@link #getY} to find the actual hardware |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2693 | * value of the Y coordinate. |
| 2694 | * @return Returns the precision of Y coordinates being reported. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2695 | * |
| 2696 | * @see #AXIS_Y |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2697 | */ |
| 2698 | public final float getYPrecision() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2699 | return nativeGetYPrecision(mNativePtr); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2700 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2701 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2702 | /** |
| 2703 | * Returns the number of historical points in this event. These are |
| 2704 | * movements that have occurred between this event and the previous event. |
| 2705 | * This only applies to ACTION_MOVE events -- all other actions will have |
| 2706 | * a size of 0. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2707 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2708 | * @return Returns the number of historical points in the event. |
| 2709 | */ |
| 2710 | public final int getHistorySize() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2711 | return nativeGetHistorySize(mNativePtr); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2712 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2713 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2714 | /** |
| 2715 | * Returns the time that a historical movement occurred between this event |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2716 | * and the previous event, in the {@link android.os.SystemClock#uptimeMillis} time base. |
| 2717 | * <p> |
| 2718 | * This only applies to ACTION_MOVE events. |
| 2719 | * </p> |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2720 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2721 | * @param pos Which historical value to return; must be less than |
| 2722 | * {@link #getHistorySize} |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2723 | * @return Returns the time that a historical movement occurred between this |
| 2724 | * event and the previous event, |
| 2725 | * in the {@link android.os.SystemClock#uptimeMillis} time base. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2726 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2727 | * @see #getHistorySize |
| 2728 | * @see #getEventTime |
| 2729 | */ |
| 2730 | public final long getHistoricalEventTime(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2731 | return nativeGetEventTimeNanos(mNativePtr, pos) / NS_PER_MS; |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | /** |
Jeff Brown | b11499d | 2012-04-20 19:54:22 -0700 | [diff] [blame] | 2735 | * Returns the time that a historical movement occurred between this event |
| 2736 | * and the previous event, in the {@link android.os.SystemClock#uptimeMillis} time base |
| 2737 | * but with nanosecond (instead of millisecond) precision. |
| 2738 | * <p> |
| 2739 | * This only applies to ACTION_MOVE events. |
| 2740 | * </p><p> |
| 2741 | * The value is in nanosecond precision but it may not have nanosecond accuracy. |
| 2742 | * </p> |
| 2743 | * |
| 2744 | * @param pos Which historical value to return; must be less than |
| 2745 | * {@link #getHistorySize} |
| 2746 | * @return Returns the time that a historical movement occurred between this |
| 2747 | * event and the previous event, |
| 2748 | * in the {@link android.os.SystemClock#uptimeMillis} time base but with |
| 2749 | * nanosecond (instead of millisecond) precision. |
| 2750 | * |
| 2751 | * @see #getHistorySize |
| 2752 | * @see #getEventTime |
| 2753 | * |
| 2754 | * @hide |
| 2755 | */ |
| 2756 | public final long getHistoricalEventTimeNano(int pos) { |
| 2757 | return nativeGetEventTimeNanos(mNativePtr, pos); |
| 2758 | } |
| 2759 | |
| 2760 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2761 | * {@link #getHistoricalX(int, int)} for the first pointer index (may be an |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2762 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2763 | * |
| 2764 | * @param pos Which historical value to return; must be less than |
| 2765 | * {@link #getHistorySize} |
| 2766 | * |
| 2767 | * @see #getHistorySize |
| 2768 | * @see #getX() |
| 2769 | * @see #AXIS_X |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2770 | */ |
| 2771 | public final float getHistoricalX(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2772 | return nativeGetAxisValue(mNativePtr, AXIS_X, 0, pos); |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2773 | } |
| 2774 | |
| 2775 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2776 | * {@link #getHistoricalY(int, int)} for the first pointer index (may be an |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2777 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2778 | * |
| 2779 | * @param pos Which historical value to return; must be less than |
| 2780 | * {@link #getHistorySize} |
| 2781 | * |
| 2782 | * @see #getHistorySize |
| 2783 | * @see #getY() |
| 2784 | * @see #AXIS_Y |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2785 | */ |
| 2786 | public final float getHistoricalY(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2787 | return nativeGetAxisValue(mNativePtr, AXIS_Y, 0, pos); |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2788 | } |
| 2789 | |
| 2790 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2791 | * {@link #getHistoricalPressure(int, int)} for the first pointer index (may be an |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2792 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2793 | * |
| 2794 | * @param pos Which historical value to return; must be less than |
| 2795 | * {@link #getHistorySize} |
| 2796 | * |
| 2797 | * @see #getHistorySize |
| 2798 | * @see #getPressure() |
| 2799 | * @see #AXIS_PRESSURE |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2800 | */ |
| 2801 | public final float getHistoricalPressure(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2802 | return nativeGetAxisValue(mNativePtr, AXIS_PRESSURE, 0, pos); |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2803 | } |
| 2804 | |
| 2805 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2806 | * {@link #getHistoricalSize(int, int)} for the first pointer index (may be an |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2807 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2808 | * |
| 2809 | * @param pos Which historical value to return; must be less than |
| 2810 | * {@link #getHistorySize} |
| 2811 | * |
| 2812 | * @see #getHistorySize |
| 2813 | * @see #getSize() |
| 2814 | * @see #AXIS_SIZE |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 2815 | */ |
| 2816 | public final float getHistoricalSize(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2817 | return nativeGetAxisValue(mNativePtr, AXIS_SIZE, 0, pos); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2818 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2819 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2820 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2821 | * {@link #getHistoricalTouchMajor(int, int)} for the first pointer index (may be an |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2822 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2823 | * |
| 2824 | * @param pos Which historical value to return; must be less than |
| 2825 | * {@link #getHistorySize} |
| 2826 | * |
| 2827 | * @see #getHistorySize |
| 2828 | * @see #getTouchMajor() |
| 2829 | * @see #AXIS_TOUCH_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2830 | */ |
| 2831 | public final float getHistoricalTouchMajor(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2832 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MAJOR, 0, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2833 | } |
| 2834 | |
| 2835 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2836 | * {@link #getHistoricalTouchMinor(int, int)} for the first pointer index (may be an |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2837 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2838 | * |
| 2839 | * @param pos Which historical value to return; must be less than |
| 2840 | * {@link #getHistorySize} |
| 2841 | * |
| 2842 | * @see #getHistorySize |
| 2843 | * @see #getTouchMinor() |
| 2844 | * @see #AXIS_TOUCH_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2845 | */ |
| 2846 | public final float getHistoricalTouchMinor(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2847 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MINOR, 0, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2848 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2849 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2850 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2851 | * {@link #getHistoricalToolMajor(int, int)} for the first pointer index (may be an |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2852 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2853 | * |
| 2854 | * @param pos Which historical value to return; must be less than |
| 2855 | * {@link #getHistorySize} |
| 2856 | * |
| 2857 | * @see #getHistorySize |
| 2858 | * @see #getToolMajor() |
| 2859 | * @see #AXIS_TOOL_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2860 | */ |
| 2861 | public final float getHistoricalToolMajor(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2862 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MAJOR, 0, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2863 | } |
| 2864 | |
| 2865 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2866 | * {@link #getHistoricalToolMinor(int, int)} for the first pointer index (may be an |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2867 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2868 | * |
| 2869 | * @param pos Which historical value to return; must be less than |
| 2870 | * {@link #getHistorySize} |
| 2871 | * |
| 2872 | * @see #getHistorySize |
| 2873 | * @see #getToolMinor() |
| 2874 | * @see #AXIS_TOOL_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2875 | */ |
| 2876 | public final float getHistoricalToolMinor(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2877 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MINOR, 0, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2878 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2879 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2880 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2881 | * {@link #getHistoricalOrientation(int, int)} for the first pointer index (may be an |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2882 | * arbitrary pointer identifier). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2883 | * |
| 2884 | * @param pos Which historical value to return; must be less than |
| 2885 | * {@link #getHistorySize} |
| 2886 | * |
| 2887 | * @see #getHistorySize |
| 2888 | * @see #getOrientation() |
| 2889 | * @see #AXIS_ORIENTATION |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2890 | */ |
| 2891 | public final float getHistoricalOrientation(int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2892 | return nativeGetAxisValue(mNativePtr, AXIS_ORIENTATION, 0, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2893 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2894 | |
| 2895 | /** |
| 2896 | * {@link #getHistoricalAxisValue(int, int, int)} for the first pointer index (may be an |
| 2897 | * arbitrary pointer identifier). |
| 2898 | * |
| 2899 | * @param axis The axis identifier for the axis value to retrieve. |
| 2900 | * @param pos Which historical value to return; must be less than |
| 2901 | * {@link #getHistorySize} |
| 2902 | * |
| 2903 | * @see #getHistorySize |
| 2904 | * @see #getAxisValue(int) |
| 2905 | * @see #AXIS_X |
| 2906 | * @see #AXIS_Y |
| 2907 | */ |
| 2908 | public final float getHistoricalAxisValue(int axis, int pos) { |
| 2909 | return nativeGetAxisValue(mNativePtr, axis, 0, pos); |
| 2910 | } |
| 2911 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2912 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2913 | * Returns a historical X coordinate, as per {@link #getX(int)}, that |
| 2914 | * occurred between this event and the previous event for the given pointer. |
| 2915 | * Only applies to ACTION_MOVE events. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2916 | * |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2917 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2918 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2919 | * @param pos Which historical value to return; must be less than |
| 2920 | * {@link #getHistorySize} |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2921 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2922 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2923 | * @see #getX(int) |
| 2924 | * @see #AXIS_X |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2925 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2926 | public final float getHistoricalX(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2927 | return nativeGetAxisValue(mNativePtr, AXIS_X, pointerIndex, pos); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2928 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2929 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2930 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2931 | * Returns a historical Y coordinate, as per {@link #getY(int)}, that |
| 2932 | * occurred between this event and the previous event for the given pointer. |
| 2933 | * Only applies to ACTION_MOVE events. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2934 | * |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2935 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2936 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2937 | * @param pos Which historical value to return; must be less than |
| 2938 | * {@link #getHistorySize} |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2939 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2940 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2941 | * @see #getY(int) |
| 2942 | * @see #AXIS_Y |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2943 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2944 | public final float getHistoricalY(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2945 | return nativeGetAxisValue(mNativePtr, AXIS_Y, pointerIndex, pos); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2946 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2947 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2948 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2949 | * Returns a historical pressure coordinate, as per {@link #getPressure(int)}, |
| 2950 | * that occurred between this event and the previous event for the given |
| 2951 | * pointer. Only applies to ACTION_MOVE events. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2952 | * |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2953 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2954 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2955 | * @param pos Which historical value to return; must be less than |
| 2956 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2957 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2958 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2959 | * @see #getPressure(int) |
| 2960 | * @see #AXIS_PRESSURE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2961 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2962 | public final float getHistoricalPressure(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2963 | return nativeGetAxisValue(mNativePtr, AXIS_PRESSURE, pointerIndex, pos); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2964 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2965 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2966 | /** |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2967 | * Returns a historical size coordinate, as per {@link #getSize(int)}, that |
| 2968 | * occurred between this event and the previous event for the given pointer. |
| 2969 | * Only applies to ACTION_MOVE events. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 2970 | * |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2971 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2972 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2973 | * @param pos Which historical value to return; must be less than |
| 2974 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2975 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2976 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2977 | * @see #getSize(int) |
| 2978 | * @see #AXIS_SIZE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2979 | */ |
Dianne Hackborn | 0dd7cb4 | 2009-08-04 05:49:43 -0700 | [diff] [blame] | 2980 | public final float getHistoricalSize(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2981 | return nativeGetAxisValue(mNativePtr, AXIS_SIZE, pointerIndex, pos); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2982 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2983 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2984 | /** |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2985 | * Returns a historical touch major axis coordinate, as per {@link #getTouchMajor(int)}, that |
| 2986 | * occurred between this event and the previous event for the given pointer. |
| 2987 | * Only applies to ACTION_MOVE events. |
| 2988 | * |
| 2989 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 2990 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 2991 | * @param pos Which historical value to return; must be less than |
| 2992 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 2993 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2994 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2995 | * @see #getTouchMajor(int) |
| 2996 | * @see #AXIS_TOUCH_MAJOR |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2997 | */ |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 2998 | public final float getHistoricalTouchMajor(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 2999 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MAJOR, pointerIndex, pos); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3000 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3001 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3002 | /** |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3003 | * Returns a historical touch minor axis coordinate, as per {@link #getTouchMinor(int)}, that |
| 3004 | * occurred between this event and the previous event for the given pointer. |
| 3005 | * Only applies to ACTION_MOVE events. |
| 3006 | * |
| 3007 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 3008 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 3009 | * @param pos Which historical value to return; must be less than |
| 3010 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3011 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3012 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3013 | * @see #getTouchMinor(int) |
| 3014 | * @see #AXIS_TOUCH_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3015 | */ |
| 3016 | public final float getHistoricalTouchMinor(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3017 | return nativeGetAxisValue(mNativePtr, AXIS_TOUCH_MINOR, pointerIndex, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3018 | } |
| 3019 | |
| 3020 | /** |
| 3021 | * Returns a historical tool major axis coordinate, as per {@link #getToolMajor(int)}, that |
| 3022 | * occurred between this event and the previous event for the given pointer. |
| 3023 | * Only applies to ACTION_MOVE events. |
| 3024 | * |
| 3025 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 3026 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 3027 | * @param pos Which historical value to return; must be less than |
| 3028 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3029 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3030 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3031 | * @see #getToolMajor(int) |
| 3032 | * @see #AXIS_TOOL_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3033 | */ |
| 3034 | public final float getHistoricalToolMajor(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3035 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MAJOR, pointerIndex, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3036 | } |
| 3037 | |
| 3038 | /** |
| 3039 | * Returns a historical tool minor axis coordinate, as per {@link #getToolMinor(int)}, that |
| 3040 | * occurred between this event and the previous event for the given pointer. |
| 3041 | * Only applies to ACTION_MOVE events. |
| 3042 | * |
| 3043 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 3044 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 3045 | * @param pos Which historical value to return; must be less than |
| 3046 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3047 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3048 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3049 | * @see #getToolMinor(int) |
| 3050 | * @see #AXIS_TOOL_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3051 | */ |
| 3052 | public final float getHistoricalToolMinor(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3053 | return nativeGetAxisValue(mNativePtr, AXIS_TOOL_MINOR, pointerIndex, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3054 | } |
| 3055 | |
| 3056 | /** |
| 3057 | * Returns a historical orientation coordinate, as per {@link #getOrientation(int)}, that |
| 3058 | * occurred between this event and the previous event for the given pointer. |
| 3059 | * Only applies to ACTION_MOVE events. |
| 3060 | * |
| 3061 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 3062 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 3063 | * @param pos Which historical value to return; must be less than |
| 3064 | * {@link #getHistorySize} |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3065 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3066 | * @see #getHistorySize |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3067 | * @see #getOrientation(int) |
| 3068 | * @see #AXIS_ORIENTATION |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3069 | */ |
| 3070 | public final float getHistoricalOrientation(int pointerIndex, int pos) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3071 | return nativeGetAxisValue(mNativePtr, AXIS_ORIENTATION, pointerIndex, pos); |
| 3072 | } |
| 3073 | |
| 3074 | /** |
| 3075 | * Returns the historical value of the requested axis, as per {@link #getAxisValue(int, int)}, |
| 3076 | * occurred between this event and the previous event for the given pointer. |
| 3077 | * Only applies to ACTION_MOVE events. |
| 3078 | * |
| 3079 | * @param axis The axis identifier for the axis value to retrieve. |
| 3080 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 3081 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 3082 | * @param pos Which historical value to return; must be less than |
| 3083 | * {@link #getHistorySize} |
| 3084 | * @return The value of the axis, or 0 if the axis is not available. |
| 3085 | * |
| 3086 | * @see #AXIS_X |
| 3087 | * @see #AXIS_Y |
| 3088 | */ |
| 3089 | public final float getHistoricalAxisValue(int axis, int pointerIndex, int pos) { |
| 3090 | return nativeGetAxisValue(mNativePtr, axis, pointerIndex, pos); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3091 | } |
| 3092 | |
| 3093 | /** |
| 3094 | * Populates a {@link PointerCoords} object with historical pointer coordinate data, |
| 3095 | * as per {@link #getPointerCoords}, that occurred between this event and the previous |
| 3096 | * event for the given pointer. |
| 3097 | * Only applies to ACTION_MOVE events. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3098 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3099 | * @param pointerIndex Raw index of pointer to retrieve. Value may be from 0 |
| 3100 | * (the first pointer that is down) to {@link #getPointerCount()}-1. |
| 3101 | * @param pos Which historical value to return; must be less than |
| 3102 | * {@link #getHistorySize} |
| 3103 | * @param outPointerCoords The pointer coordinate object to populate. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3104 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3105 | * @see #getHistorySize |
| 3106 | * @see #getPointerCoords |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3107 | * @see PointerCoords |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3108 | */ |
| 3109 | public final void getHistoricalPointerCoords(int pointerIndex, int pos, |
| 3110 | PointerCoords outPointerCoords) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3111 | nativeGetPointerCoords(mNativePtr, pointerIndex, pos, outPointerCoords); |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3112 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3113 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3114 | /** |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3115 | * Returns a bitfield indicating which edges, if any, were touched by this |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3116 | * MotionEvent. For touch events, clients can use this to determine if the |
| 3117 | * user's finger was touching the edge of the display. |
| 3118 | * |
Jeff Brown | d41cff2 | 2011-03-03 02:09:54 -0800 | [diff] [blame] | 3119 | * This property is only set for {@link #ACTION_DOWN} events. |
| 3120 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3121 | * @see #EDGE_LEFT |
| 3122 | * @see #EDGE_TOP |
| 3123 | * @see #EDGE_RIGHT |
| 3124 | * @see #EDGE_BOTTOM |
| 3125 | */ |
| 3126 | public final int getEdgeFlags() { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3127 | return nativeGetEdgeFlags(mNativePtr); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3128 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3129 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3130 | /** |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 3131 | * Sets the bitfield indicating which edges, if any, were touched by this |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3132 | * MotionEvent. |
| 3133 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3134 | * @see #getEdgeFlags() |
| 3135 | */ |
| 3136 | public final void setEdgeFlags(int flags) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3137 | nativeSetEdgeFlags(mNativePtr, flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3138 | } |
| 3139 | |
| 3140 | /** |
| 3141 | * Sets this event's action. |
| 3142 | */ |
| 3143 | public final void setAction(int action) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3144 | nativeSetAction(mNativePtr, action); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3145 | } |
| 3146 | |
| 3147 | /** |
| 3148 | * Adjust this event's location. |
| 3149 | * @param deltaX Amount to add to the current X coordinate of the event. |
| 3150 | * @param deltaY Amount to add to the current Y coordinate of the event. |
| 3151 | */ |
| 3152 | public final void offsetLocation(float deltaX, float deltaY) { |
Jeff Brown | 9ea77fc | 2012-03-21 19:49:27 -0700 | [diff] [blame] | 3153 | if (deltaX != 0.0f || deltaY != 0.0f) { |
| 3154 | nativeOffsetLocation(mNativePtr, deltaX, deltaY); |
| 3155 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3156 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3157 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3158 | /** |
| 3159 | * Set this event's location. Applies {@link #offsetLocation} with a |
| 3160 | * delta from the current location to the given new location. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3161 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3162 | * @param x New absolute X location. |
| 3163 | * @param y New absolute Y location. |
| 3164 | */ |
| 3165 | public final void setLocation(float x, float y) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3166 | float oldX = getX(); |
| 3167 | float oldY = getY(); |
Jeff Brown | 9ea77fc | 2012-03-21 19:49:27 -0700 | [diff] [blame] | 3168 | offsetLocation(x - oldX, y - oldY); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 3169 | } |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3170 | |
Jeff Brown | 20e987b | 2010-08-23 12:01:02 -0700 | [diff] [blame] | 3171 | /** |
| 3172 | * Applies a transformation matrix to all of the points in the event. |
| 3173 | * |
| 3174 | * @param matrix The transformation matrix to apply. |
| 3175 | */ |
| 3176 | public final void transform(Matrix matrix) { |
| 3177 | if (matrix == null) { |
| 3178 | throw new IllegalArgumentException("matrix must not be null"); |
| 3179 | } |
| 3180 | |
John Reck | 0970997 | 2016-10-03 15:47:18 -0700 | [diff] [blame] | 3181 | nativeTransform(mNativePtr, matrix.native_instance); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3182 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3183 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3184 | /** |
| 3185 | * Add a new movement to the batch of movements in this event. The event's |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3186 | * current location, position and size is updated to the new values. |
| 3187 | * The current values in the event are added to a list of historical values. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3188 | * |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 3189 | * Only applies to {@link #ACTION_MOVE} or {@link #ACTION_HOVER_MOVE} events. |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3190 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3191 | * @param eventTime The time stamp (in ms) for this data. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3192 | * @param x The new X position. |
| 3193 | * @param y The new Y position. |
| 3194 | * @param pressure The new pressure. |
| 3195 | * @param size The new size. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 3196 | * @param metaState Meta key state. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3197 | */ |
| 3198 | public final void addBatch(long eventTime, float x, float y, |
| 3199 | float pressure, float size, int metaState) { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3200 | synchronized (gSharedTempLock) { |
| 3201 | ensureSharedTempPointerCapacity(1); |
| 3202 | final PointerCoords[] pc = gSharedTempPointerCoords; |
| 3203 | pc[0].clear(); |
| 3204 | pc[0].x = x; |
| 3205 | pc[0].y = y; |
| 3206 | pc[0].pressure = pressure; |
| 3207 | pc[0].size = size; |
| 3208 | |
| 3209 | nativeAddBatch(mNativePtr, eventTime * NS_PER_MS, pc, metaState); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3210 | } |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 3211 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3212 | |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 3213 | /** |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3214 | * Add a new movement to the batch of movements in this event. The event's |
| 3215 | * current location, position and size is updated to the new values. |
| 3216 | * The current values in the event are added to a list of historical values. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3217 | * |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 3218 | * Only applies to {@link #ACTION_MOVE} or {@link #ACTION_HOVER_MOVE} events. |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3219 | * |
| 3220 | * @param eventTime The time stamp (in ms) for this data. |
| 3221 | * @param pointerCoords The new pointer coordinates. |
| 3222 | * @param metaState Meta key state. |
Dianne Hackborn | 9822d2b | 2009-07-20 17:33:15 -0700 | [diff] [blame] | 3223 | */ |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3224 | public final void addBatch(long eventTime, PointerCoords[] pointerCoords, int metaState) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3225 | nativeAddBatch(mNativePtr, eventTime * NS_PER_MS, pointerCoords, metaState); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3226 | } |
Romain Guy | cafdea6 | 2009-06-12 10:51:36 -0700 | [diff] [blame] | 3227 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3228 | /** |
Jeff Brown | 9d3bdbd | 2012-03-21 11:50:06 -0700 | [diff] [blame] | 3229 | * Adds all of the movement samples of the specified event to this one if |
| 3230 | * it is compatible. To be compatible, the event must have the same device id, |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 3231 | * source, display id, action, flags, classification, pointer count, pointer properties. |
Jeff Brown | 9d3bdbd | 2012-03-21 11:50:06 -0700 | [diff] [blame] | 3232 | * |
| 3233 | * Only applies to {@link #ACTION_MOVE} or {@link #ACTION_HOVER_MOVE} events. |
| 3234 | * |
| 3235 | * @param event The event whose movements samples should be added to this one |
| 3236 | * if possible. |
| 3237 | * @return True if batching was performed or false if batching was not possible. |
| 3238 | * @hide |
| 3239 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 3240 | @UnsupportedAppUsage |
Jeff Brown | 9d3bdbd | 2012-03-21 11:50:06 -0700 | [diff] [blame] | 3241 | public final boolean addBatch(MotionEvent event) { |
| 3242 | final int action = nativeGetAction(mNativePtr); |
| 3243 | if (action != ACTION_MOVE && action != ACTION_HOVER_MOVE) { |
| 3244 | return false; |
| 3245 | } |
| 3246 | if (action != nativeGetAction(event.mNativePtr)) { |
| 3247 | return false; |
| 3248 | } |
| 3249 | |
| 3250 | if (nativeGetDeviceId(mNativePtr) != nativeGetDeviceId(event.mNativePtr) |
| 3251 | || nativeGetSource(mNativePtr) != nativeGetSource(event.mNativePtr) |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 3252 | || nativeGetDisplayId(mNativePtr) != nativeGetDisplayId(event.mNativePtr) |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 3253 | || nativeGetFlags(mNativePtr) != nativeGetFlags(event.mNativePtr) |
| 3254 | || nativeGetClassification(mNativePtr) |
| 3255 | != nativeGetClassification(event.mNativePtr)) { |
Jeff Brown | 9d3bdbd | 2012-03-21 11:50:06 -0700 | [diff] [blame] | 3256 | return false; |
| 3257 | } |
| 3258 | |
| 3259 | final int pointerCount = nativeGetPointerCount(mNativePtr); |
| 3260 | if (pointerCount != nativeGetPointerCount(event.mNativePtr)) { |
| 3261 | return false; |
| 3262 | } |
| 3263 | |
| 3264 | synchronized (gSharedTempLock) { |
| 3265 | ensureSharedTempPointerCapacity(Math.max(pointerCount, 2)); |
| 3266 | final PointerProperties[] pp = gSharedTempPointerProperties; |
| 3267 | final PointerCoords[] pc = gSharedTempPointerCoords; |
| 3268 | |
| 3269 | for (int i = 0; i < pointerCount; i++) { |
| 3270 | nativeGetPointerProperties(mNativePtr, i, pp[0]); |
| 3271 | nativeGetPointerProperties(event.mNativePtr, i, pp[1]); |
| 3272 | if (!pp[0].equals(pp[1])) { |
| 3273 | return false; |
| 3274 | } |
| 3275 | } |
| 3276 | |
| 3277 | final int metaState = nativeGetMetaState(event.mNativePtr); |
| 3278 | final int historySize = nativeGetHistorySize(event.mNativePtr); |
| 3279 | for (int h = 0; h <= historySize; h++) { |
| 3280 | final int historyPos = (h == historySize ? HISTORY_CURRENT : h); |
| 3281 | |
| 3282 | for (int i = 0; i < pointerCount; i++) { |
| 3283 | nativeGetPointerCoords(event.mNativePtr, i, historyPos, pc[i]); |
| 3284 | } |
| 3285 | |
| 3286 | final long eventTimeNanos = nativeGetEventTimeNanos(event.mNativePtr, historyPos); |
| 3287 | nativeAddBatch(mNativePtr, eventTimeNanos, pc, metaState); |
| 3288 | } |
| 3289 | } |
| 3290 | return true; |
| 3291 | } |
| 3292 | |
| 3293 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3294 | * Returns true if all points in the motion event are completely within the specified bounds. |
| 3295 | * @hide |
| 3296 | */ |
| 3297 | public final boolean isWithinBoundsNoHistory(float left, float top, |
| 3298 | float right, float bottom) { |
| 3299 | final int pointerCount = nativeGetPointerCount(mNativePtr); |
| 3300 | for (int i = 0; i < pointerCount; i++) { |
| 3301 | final float x = nativeGetAxisValue(mNativePtr, AXIS_X, i, HISTORY_CURRENT); |
| 3302 | final float y = nativeGetAxisValue(mNativePtr, AXIS_Y, i, HISTORY_CURRENT); |
| 3303 | if (x < left || x > right || y < top || y > bottom) { |
| 3304 | return false; |
| 3305 | } |
| 3306 | } |
| 3307 | return true; |
| 3308 | } |
| 3309 | |
| 3310 | private static final float clamp(float value, float low, float high) { |
| 3311 | if (value < low) { |
| 3312 | return low; |
| 3313 | } else if (value > high) { |
| 3314 | return high; |
| 3315 | } |
| 3316 | return value; |
| 3317 | } |
| 3318 | |
| 3319 | /** |
| 3320 | * Returns a new motion events whose points have been clamped to the specified bounds. |
| 3321 | * @hide |
| 3322 | */ |
| 3323 | public final MotionEvent clampNoHistory(float left, float top, float right, float bottom) { |
| 3324 | MotionEvent ev = obtain(); |
| 3325 | synchronized (gSharedTempLock) { |
| 3326 | final int pointerCount = nativeGetPointerCount(mNativePtr); |
| 3327 | |
| 3328 | ensureSharedTempPointerCapacity(pointerCount); |
| 3329 | final PointerProperties[] pp = gSharedTempPointerProperties; |
| 3330 | final PointerCoords[] pc = gSharedTempPointerCoords; |
| 3331 | |
| 3332 | for (int i = 0; i < pointerCount; i++) { |
| 3333 | nativeGetPointerProperties(mNativePtr, i, pp[i]); |
| 3334 | nativeGetPointerCoords(mNativePtr, i, HISTORY_CURRENT, pc[i]); |
| 3335 | pc[i].x = clamp(pc[i].x, left, right); |
| 3336 | pc[i].y = clamp(pc[i].y, top, bottom); |
| 3337 | } |
| 3338 | ev.mNativePtr = nativeInitialize(ev.mNativePtr, |
| 3339 | nativeGetDeviceId(mNativePtr), nativeGetSource(mNativePtr), |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 3340 | nativeGetDisplayId(mNativePtr), |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3341 | nativeGetAction(mNativePtr), nativeGetFlags(mNativePtr), |
| 3342 | nativeGetEdgeFlags(mNativePtr), nativeGetMetaState(mNativePtr), |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 3343 | nativeGetButtonState(mNativePtr), nativeGetClassification(mNativePtr), |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3344 | nativeGetXOffset(mNativePtr), nativeGetYOffset(mNativePtr), |
| 3345 | nativeGetXPrecision(mNativePtr), nativeGetYPrecision(mNativePtr), |
| 3346 | nativeGetDownTimeNanos(mNativePtr), |
| 3347 | nativeGetEventTimeNanos(mNativePtr, HISTORY_CURRENT), |
| 3348 | pointerCount, pp, pc); |
| 3349 | return ev; |
| 3350 | } |
| 3351 | } |
| 3352 | |
| 3353 | /** |
| 3354 | * Gets an integer where each pointer id present in the event is marked as a bit. |
| 3355 | * @hide |
| 3356 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 3357 | @UnsupportedAppUsage |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3358 | public final int getPointerIdBits() { |
| 3359 | int idBits = 0; |
| 3360 | final int pointerCount = nativeGetPointerCount(mNativePtr); |
| 3361 | for (int i = 0; i < pointerCount; i++) { |
| 3362 | idBits |= 1 << nativeGetPointerId(mNativePtr, i); |
| 3363 | } |
| 3364 | return idBits; |
| 3365 | } |
| 3366 | |
| 3367 | /** |
| 3368 | * Splits a motion event such that it includes only a subset of pointer ids. |
| 3369 | * @hide |
| 3370 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 3371 | @UnsupportedAppUsage |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3372 | public final MotionEvent split(int idBits) { |
| 3373 | MotionEvent ev = obtain(); |
| 3374 | synchronized (gSharedTempLock) { |
| 3375 | final int oldPointerCount = nativeGetPointerCount(mNativePtr); |
| 3376 | ensureSharedTempPointerCapacity(oldPointerCount); |
| 3377 | final PointerProperties[] pp = gSharedTempPointerProperties; |
| 3378 | final PointerCoords[] pc = gSharedTempPointerCoords; |
| 3379 | final int[] map = gSharedTempPointerIndexMap; |
| 3380 | |
| 3381 | final int oldAction = nativeGetAction(mNativePtr); |
| 3382 | final int oldActionMasked = oldAction & ACTION_MASK; |
| 3383 | final int oldActionPointerIndex = (oldAction & ACTION_POINTER_INDEX_MASK) |
| 3384 | >> ACTION_POINTER_INDEX_SHIFT; |
| 3385 | int newActionPointerIndex = -1; |
| 3386 | int newPointerCount = 0; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3387 | for (int i = 0; i < oldPointerCount; i++) { |
| 3388 | nativeGetPointerProperties(mNativePtr, i, pp[newPointerCount]); |
| 3389 | final int idBit = 1 << pp[newPointerCount].id; |
| 3390 | if ((idBit & idBits) != 0) { |
| 3391 | if (i == oldActionPointerIndex) { |
| 3392 | newActionPointerIndex = newPointerCount; |
| 3393 | } |
| 3394 | map[newPointerCount] = i; |
| 3395 | newPointerCount += 1; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3396 | } |
| 3397 | } |
| 3398 | |
| 3399 | if (newPointerCount == 0) { |
| 3400 | throw new IllegalArgumentException("idBits did not match any ids in the event"); |
| 3401 | } |
| 3402 | |
| 3403 | final int newAction; |
| 3404 | if (oldActionMasked == ACTION_POINTER_DOWN || oldActionMasked == ACTION_POINTER_UP) { |
| 3405 | if (newActionPointerIndex < 0) { |
| 3406 | // An unrelated pointer changed. |
| 3407 | newAction = ACTION_MOVE; |
| 3408 | } else if (newPointerCount == 1) { |
| 3409 | // The first/last pointer went down/up. |
| 3410 | newAction = oldActionMasked == ACTION_POINTER_DOWN |
| 3411 | ? ACTION_DOWN : ACTION_UP; |
| 3412 | } else { |
| 3413 | // A secondary pointer went down/up. |
| 3414 | newAction = oldActionMasked |
| 3415 | | (newActionPointerIndex << ACTION_POINTER_INDEX_SHIFT); |
| 3416 | } |
| 3417 | } else { |
| 3418 | // Simple up/down/cancel/move or other motion action. |
| 3419 | newAction = oldAction; |
| 3420 | } |
| 3421 | |
| 3422 | final int historySize = nativeGetHistorySize(mNativePtr); |
| 3423 | for (int h = 0; h <= historySize; h++) { |
| 3424 | final int historyPos = h == historySize ? HISTORY_CURRENT : h; |
| 3425 | |
| 3426 | for (int i = 0; i < newPointerCount; i++) { |
| 3427 | nativeGetPointerCoords(mNativePtr, map[i], historyPos, pc[i]); |
| 3428 | } |
| 3429 | |
| 3430 | final long eventTimeNanos = nativeGetEventTimeNanos(mNativePtr, historyPos); |
| 3431 | if (h == 0) { |
| 3432 | ev.mNativePtr = nativeInitialize(ev.mNativePtr, |
| 3433 | nativeGetDeviceId(mNativePtr), nativeGetSource(mNativePtr), |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 3434 | nativeGetDisplayId(mNativePtr), |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3435 | newAction, nativeGetFlags(mNativePtr), |
| 3436 | nativeGetEdgeFlags(mNativePtr), nativeGetMetaState(mNativePtr), |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 3437 | nativeGetButtonState(mNativePtr), nativeGetClassification(mNativePtr), |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3438 | nativeGetXOffset(mNativePtr), nativeGetYOffset(mNativePtr), |
| 3439 | nativeGetXPrecision(mNativePtr), nativeGetYPrecision(mNativePtr), |
| 3440 | nativeGetDownTimeNanos(mNativePtr), eventTimeNanos, |
| 3441 | newPointerCount, pp, pc); |
| 3442 | } else { |
| 3443 | nativeAddBatch(ev.mNativePtr, eventTimeNanos, pc, 0); |
| 3444 | } |
| 3445 | } |
| 3446 | return ev; |
| 3447 | } |
| 3448 | } |
| 3449 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3450 | @Override |
| 3451 | public String toString() { |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3452 | StringBuilder msg = new StringBuilder(); |
| 3453 | msg.append("MotionEvent { action=").append(actionToString(getAction())); |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3454 | appendUnless("0", msg, ", actionButton=", buttonStateToString(getActionButton())); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3455 | |
| 3456 | final int pointerCount = getPointerCount(); |
| 3457 | for (int i = 0; i < pointerCount; i++) { |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3458 | appendUnless(i, msg, ", id[" + i + "]=", getPointerId(i)); |
| 3459 | float x = getX(i); |
| 3460 | float y = getY(i); |
| 3461 | if (!DEBUG_CONCISE_TOSTRING || x != 0f || y != 0f) { |
| 3462 | msg.append(", x[").append(i).append("]=").append(x); |
| 3463 | msg.append(", y[").append(i).append("]=").append(y); |
| 3464 | } |
| 3465 | appendUnless(TOOL_TYPE_SYMBOLIC_NAMES.get(TOOL_TYPE_FINGER), |
| 3466 | msg, ", toolType[" + i + "]=", toolTypeToString(getToolType(i))); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3467 | } |
| 3468 | |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3469 | appendUnless("0", msg, ", buttonState=", MotionEvent.buttonStateToString(getButtonState())); |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 3470 | appendUnless(classificationToString(CLASSIFICATION_NONE), msg, ", classification=", |
| 3471 | classificationToString(getClassification())); |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3472 | appendUnless("0", msg, ", metaState=", KeyEvent.metaStateToString(getMetaState())); |
| 3473 | appendUnless("0", msg, ", flags=0x", Integer.toHexString(getFlags())); |
| 3474 | appendUnless("0", msg, ", edgeFlags=0x", Integer.toHexString(getEdgeFlags())); |
| 3475 | appendUnless(1, msg, ", pointerCount=", pointerCount); |
| 3476 | appendUnless(0, msg, ", historySize=", getHistorySize()); |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3477 | msg.append(", eventTime=").append(getEventTime()); |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3478 | if (!DEBUG_CONCISE_TOSTRING) { |
| 3479 | msg.append(", downTime=").append(getDownTime()); |
| 3480 | msg.append(", deviceId=").append(getDeviceId()); |
| 3481 | msg.append(", source=0x").append(Integer.toHexString(getSource())); |
Siarhei Vishniakou | 85ddfff | 2018-01-31 16:49:36 -0800 | [diff] [blame] | 3482 | msg.append(", displayId=").append(getDisplayId()); |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3483 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3484 | msg.append(" }"); |
| 3485 | return msg.toString(); |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3486 | } |
| 3487 | |
Eugene Susla | e6e55b5 | 2018-01-11 15:12:56 -0800 | [diff] [blame] | 3488 | private static <T> void appendUnless(T defValue, StringBuilder sb, String key, T value) { |
| 3489 | if (DEBUG_CONCISE_TOSTRING && Objects.equals(defValue, value)) return; |
| 3490 | sb.append(key).append(value); |
| 3491 | } |
| 3492 | |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3493 | /** |
John Spurlock | 4dad6ca | 2013-06-05 13:17:05 -0400 | [diff] [blame] | 3494 | * Returns a string that represents the symbolic name of the specified unmasked action |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3495 | * such as "ACTION_DOWN", "ACTION_POINTER_DOWN(3)" or an equivalent numeric constant |
| 3496 | * such as "35" if unknown. |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3497 | * |
John Spurlock | 4dad6ca | 2013-06-05 13:17:05 -0400 | [diff] [blame] | 3498 | * @param action The unmasked action. |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3499 | * @return The symbolic name of the specified action. |
John Spurlock | 4dad6ca | 2013-06-05 13:17:05 -0400 | [diff] [blame] | 3500 | * @see #getAction() |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3501 | */ |
| 3502 | public static String actionToString(int action) { |
| 3503 | switch (action) { |
| 3504 | case ACTION_DOWN: |
| 3505 | return "ACTION_DOWN"; |
| 3506 | case ACTION_UP: |
| 3507 | return "ACTION_UP"; |
| 3508 | case ACTION_CANCEL: |
| 3509 | return "ACTION_CANCEL"; |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 3510 | case ACTION_OUTSIDE: |
| 3511 | return "ACTION_OUTSIDE"; |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3512 | case ACTION_MOVE: |
| 3513 | return "ACTION_MOVE"; |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 3514 | case ACTION_HOVER_MOVE: |
| 3515 | return "ACTION_HOVER_MOVE"; |
Jeff Brown | 33bbfd2 | 2011-02-24 20:55:35 -0800 | [diff] [blame] | 3516 | case ACTION_SCROLL: |
| 3517 | return "ACTION_SCROLL"; |
Jeff Brown | a032cc0 | 2011-03-07 16:56:21 -0800 | [diff] [blame] | 3518 | case ACTION_HOVER_ENTER: |
| 3519 | return "ACTION_HOVER_ENTER"; |
| 3520 | case ACTION_HOVER_EXIT: |
| 3521 | return "ACTION_HOVER_EXIT"; |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 3522 | case ACTION_BUTTON_PRESS: |
| 3523 | return "ACTION_BUTTON_PRESS"; |
| 3524 | case ACTION_BUTTON_RELEASE: |
| 3525 | return "ACTION_BUTTON_RELEASE"; |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 3526 | } |
| 3527 | int index = (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT; |
| 3528 | switch (action & ACTION_MASK) { |
| 3529 | case ACTION_POINTER_DOWN: |
| 3530 | return "ACTION_POINTER_DOWN(" + index + ")"; |
| 3531 | case ACTION_POINTER_UP: |
| 3532 | return "ACTION_POINTER_UP(" + index + ")"; |
| 3533 | default: |
| 3534 | return Integer.toString(action); |
| 3535 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3536 | } |
| 3537 | |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3538 | /** |
| 3539 | * Returns a string that represents the symbolic name of the specified axis |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3540 | * such as "AXIS_X" or an equivalent numeric constant such as "42" if unknown. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3541 | * |
John Spurlock | 4dad6ca | 2013-06-05 13:17:05 -0400 | [diff] [blame] | 3542 | * @param axis The axis. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3543 | * @return The symbolic name of the specified axis. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3544 | */ |
| 3545 | public static String axisToString(int axis) { |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 3546 | String symbolicName = nativeAxisToString(axis); |
| 3547 | return symbolicName != null ? LABEL_PREFIX + symbolicName : Integer.toString(axis); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3548 | } |
| 3549 | |
| 3550 | /** |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 3551 | * Gets an axis by its symbolic name such as "AXIS_X" or an |
| 3552 | * equivalent numeric constant such as "42". |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3553 | * |
| 3554 | * @param symbolicName The symbolic name of the axis. |
| 3555 | * @return The axis or -1 if not found. |
John Spurlock | 4dad6ca | 2013-06-05 13:17:05 -0400 | [diff] [blame] | 3556 | * @see KeyEvent#keyCodeToString(int) |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3557 | */ |
| 3558 | public static int axisFromString(String symbolicName) { |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 3559 | if (symbolicName.startsWith(LABEL_PREFIX)) { |
| 3560 | symbolicName = symbolicName.substring(LABEL_PREFIX.length()); |
Michael Wright | 973efa0 | 2014-05-13 15:38:56 -0700 | [diff] [blame] | 3561 | int axis = nativeAxisFromString(symbolicName); |
| 3562 | if (axis >= 0) { |
| 3563 | return axis; |
| 3564 | } |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3565 | } |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3566 | try { |
| 3567 | return Integer.parseInt(symbolicName, 10); |
| 3568 | } catch (NumberFormatException ex) { |
| 3569 | return -1; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3570 | } |
| 3571 | } |
| 3572 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3573 | /** |
| 3574 | * Returns a string that represents the symbolic name of the specified combined |
| 3575 | * button state flags such as "0", "BUTTON_PRIMARY", |
| 3576 | * "BUTTON_PRIMARY|BUTTON_SECONDARY" or an equivalent numeric constant such as "0x10000000" |
| 3577 | * if unknown. |
| 3578 | * |
| 3579 | * @param buttonState The button state. |
| 3580 | * @return The symbolic name of the specified combined button state flags. |
| 3581 | * @hide |
| 3582 | */ |
| 3583 | public static String buttonStateToString(int buttonState) { |
| 3584 | if (buttonState == 0) { |
| 3585 | return "0"; |
| 3586 | } |
| 3587 | StringBuilder result = null; |
| 3588 | int i = 0; |
| 3589 | while (buttonState != 0) { |
| 3590 | final boolean isSet = (buttonState & 1) != 0; |
| 3591 | buttonState >>>= 1; // unsigned shift! |
| 3592 | if (isSet) { |
| 3593 | final String name = BUTTON_SYMBOLIC_NAMES[i]; |
| 3594 | if (result == null) { |
| 3595 | if (buttonState == 0) { |
| 3596 | return name; |
| 3597 | } |
| 3598 | result = new StringBuilder(name); |
| 3599 | } else { |
| 3600 | result.append('|'); |
| 3601 | result.append(name); |
| 3602 | } |
| 3603 | } |
| 3604 | i += 1; |
| 3605 | } |
| 3606 | return result.toString(); |
| 3607 | } |
| 3608 | |
| 3609 | /** |
Siarhei Vishniakou | b05b0b5 | 2018-12-28 17:50:24 -0800 | [diff] [blame] | 3610 | * Returns a string that represents the symbolic name of the specified classification. |
| 3611 | * |
| 3612 | * @param classification The classification type. |
| 3613 | * @return The symbolic name of this classification. |
| 3614 | * @hide |
| 3615 | */ |
| 3616 | public static String classificationToString(@Classification int classification) { |
| 3617 | switch (classification) { |
| 3618 | case CLASSIFICATION_NONE: |
| 3619 | return "NONE"; |
| 3620 | case CLASSIFICATION_AMBIGUOUS_GESTURE: |
| 3621 | return "AMBIGUOUS_GESTURE"; |
| 3622 | case CLASSIFICATION_DEEP_PRESS: |
| 3623 | return "DEEP_PRESS"; |
| 3624 | |
| 3625 | } |
| 3626 | return "NONE"; |
| 3627 | } |
| 3628 | |
| 3629 | /** |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3630 | * Returns a string that represents the symbolic name of the specified tool type |
| 3631 | * such as "TOOL_TYPE_FINGER" or an equivalent numeric constant such as "42" if unknown. |
| 3632 | * |
| 3633 | * @param toolType The tool type. |
| 3634 | * @return The symbolic name of the specified tool type. |
| 3635 | * @hide |
| 3636 | */ |
| 3637 | public static String toolTypeToString(int toolType) { |
| 3638 | String symbolicName = TOOL_TYPE_SYMBOLIC_NAMES.get(toolType); |
| 3639 | return symbolicName != null ? symbolicName : Integer.toString(toolType); |
| 3640 | } |
| 3641 | |
Sujith Ramakrishnan | cc32bd8 | 2014-05-19 15:32:13 -0700 | [diff] [blame] | 3642 | /** |
| 3643 | * Checks if a mouse or stylus button (or combination of buttons) is pressed. |
| 3644 | * @param button Button (or combination of buttons). |
| 3645 | * @return True if specified buttons are pressed. |
| 3646 | * |
| 3647 | * @see #BUTTON_PRIMARY |
| 3648 | * @see #BUTTON_SECONDARY |
| 3649 | * @see #BUTTON_TERTIARY |
| 3650 | * @see #BUTTON_FORWARD |
| 3651 | * @see #BUTTON_BACK |
Michael Wright | 5bd69e6 | 2015-05-14 14:48:08 +0100 | [diff] [blame] | 3652 | * @see #BUTTON_STYLUS_PRIMARY |
| 3653 | * @see #BUTTON_STYLUS_SECONDARY |
Sujith Ramakrishnan | cc32bd8 | 2014-05-19 15:32:13 -0700 | [diff] [blame] | 3654 | */ |
| 3655 | public final boolean isButtonPressed(int button) { |
| 3656 | if (button == 0) { |
| 3657 | return false; |
| 3658 | } |
| 3659 | return (getButtonState() & button) == button; |
| 3660 | } |
| 3661 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3662 | public static final Parcelable.Creator<MotionEvent> CREATOR |
| 3663 | = new Parcelable.Creator<MotionEvent>() { |
| 3664 | public MotionEvent createFromParcel(Parcel in) { |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 3665 | in.readInt(); // skip token, we already know this is a MotionEvent |
| 3666 | return MotionEvent.createFromParcelBody(in); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3667 | } |
| 3668 | |
| 3669 | public MotionEvent[] newArray(int size) { |
| 3670 | return new MotionEvent[size]; |
| 3671 | } |
| 3672 | }; |
| 3673 | |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 3674 | /** @hide */ |
| 3675 | public static MotionEvent createFromParcelBody(Parcel in) { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3676 | MotionEvent ev = obtain(); |
| 3677 | ev.mNativePtr = nativeReadFromParcel(ev.mNativePtr, in); |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 3678 | return ev; |
| 3679 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3680 | |
Wale Ogunwale | c3672cd | 2014-11-05 15:17:35 -0800 | [diff] [blame] | 3681 | /** @hide */ |
| 3682 | @Override |
| 3683 | public final void cancel() { |
| 3684 | setAction(ACTION_CANCEL); |
| 3685 | } |
| 3686 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3687 | public void writeToParcel(Parcel out, int flags) { |
Jeff Brown | 6ec402b | 2010-07-28 15:48:59 -0700 | [diff] [blame] | 3688 | out.writeInt(PARCEL_TOKEN_MOTION_EVENT); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3689 | nativeWriteToParcel(mNativePtr, out); |
Jeff Brown | 5c225b1 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 3690 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3691 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3692 | /** |
| 3693 | * Transfer object for pointer coordinates. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3694 | * |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3695 | * Objects of this type can be used to specify the pointer coordinates when |
| 3696 | * creating new {@link MotionEvent} objects and to query pointer coordinates |
| 3697 | * in bulk. |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3698 | * |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3699 | * Refer to {@link InputDevice} for information about how different kinds of |
| 3700 | * input devices and sources represent pointer coordinates. |
| 3701 | */ |
| 3702 | public static final class PointerCoords { |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3703 | private static final int INITIAL_PACKED_AXIS_VALUES = 8; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 3704 | @UnsupportedAppUsage |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3705 | private long mPackedAxisBits; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 3706 | @UnsupportedAppUsage |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3707 | private float[] mPackedAxisValues; |
| 3708 | |
| 3709 | /** |
| 3710 | * Creates a pointer coords object with all axes initialized to zero. |
| 3711 | */ |
| 3712 | public PointerCoords() { |
| 3713 | } |
| 3714 | |
| 3715 | /** |
| 3716 | * Creates a pointer coords object as a copy of the |
| 3717 | * contents of another pointer coords object. |
| 3718 | * |
| 3719 | * @param other The pointer coords object to copy. |
| 3720 | */ |
| 3721 | public PointerCoords(PointerCoords other) { |
| 3722 | copyFrom(other); |
| 3723 | } |
| 3724 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3725 | /** @hide */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 3726 | @UnsupportedAppUsage |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3727 | public static PointerCoords[] createArray(int size) { |
| 3728 | PointerCoords[] array = new PointerCoords[size]; |
| 3729 | for (int i = 0; i < size; i++) { |
| 3730 | array[i] = new PointerCoords(); |
| 3731 | } |
| 3732 | return array; |
| 3733 | } |
| 3734 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3735 | /** |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3736 | * The X component of the pointer movement. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3737 | * |
| 3738 | * @see MotionEvent#AXIS_X |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3739 | */ |
| 3740 | public float x; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3741 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3742 | /** |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3743 | * The Y component of the pointer movement. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3744 | * |
| 3745 | * @see MotionEvent#AXIS_Y |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3746 | */ |
| 3747 | public float y; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3748 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3749 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3750 | * A normalized value that describes the pressure applied to the device |
| 3751 | * by a finger or other tool. |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3752 | * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3753 | * although values higher than 1 may be generated depending on the calibration of |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3754 | * the input device. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3755 | * |
| 3756 | * @see MotionEvent#AXIS_PRESSURE |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3757 | */ |
| 3758 | public float pressure; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3759 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3760 | /** |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3761 | * A normalized value that describes the approximate size of the pointer touch area |
| 3762 | * in relation to the maximum detectable size of the device. |
| 3763 | * It represents some approximation of the area of the screen being |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3764 | * pressed; the actual value in pixels corresponding to the |
| 3765 | * touch is normalized with the device specific range of values |
| 3766 | * and scaled to a value between 0 and 1. The value of size can be used to |
| 3767 | * determine fat touch events. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3768 | * |
| 3769 | * @see MotionEvent#AXIS_SIZE |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3770 | */ |
| 3771 | public float size; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3772 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3773 | /** |
| 3774 | * The length of the major axis of an ellipse that describes the touch area at |
| 3775 | * the point of contact. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3776 | * If the device is a touch screen, the length is reported in pixels, otherwise it is |
| 3777 | * reported in device-specific units. |
| 3778 | * |
| 3779 | * @see MotionEvent#AXIS_TOUCH_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3780 | */ |
| 3781 | public float touchMajor; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3782 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3783 | /** |
| 3784 | * The length of the minor axis of an ellipse that describes the touch area at |
| 3785 | * the point of contact. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3786 | * If the device is a touch screen, the length is reported in pixels, otherwise it is |
| 3787 | * reported in device-specific units. |
| 3788 | * |
| 3789 | * @see MotionEvent#AXIS_TOUCH_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3790 | */ |
| 3791 | public float touchMinor; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3792 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3793 | /** |
| 3794 | * The length of the major axis of an ellipse that describes the size of |
| 3795 | * the approaching tool. |
| 3796 | * The tool area represents the estimated size of the finger or pen that is |
| 3797 | * touching the device independent of its actual touch area at the point of contact. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3798 | * If the device is a touch screen, the length is reported in pixels, otherwise it is |
| 3799 | * reported in device-specific units. |
| 3800 | * |
| 3801 | * @see MotionEvent#AXIS_TOOL_MAJOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3802 | */ |
| 3803 | public float toolMajor; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3804 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3805 | /** |
| 3806 | * The length of the minor axis of an ellipse that describes the size of |
| 3807 | * the approaching tool. |
| 3808 | * The tool area represents the estimated size of the finger or pen that is |
| 3809 | * touching the device independent of its actual touch area at the point of contact. |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3810 | * If the device is a touch screen, the length is reported in pixels, otherwise it is |
| 3811 | * reported in device-specific units. |
| 3812 | * |
| 3813 | * @see MotionEvent#AXIS_TOOL_MINOR |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3814 | */ |
| 3815 | public float toolMinor; |
Dennis Kempin | ac1b31d | 2016-11-02 17:02:25 -0700 | [diff] [blame] | 3816 | |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3817 | /** |
| 3818 | * The orientation of the touch area and tool area in radians clockwise from vertical. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3819 | * An angle of 0 radians indicates that the major axis of contact is oriented |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3820 | * upwards, is perfectly circular or is of unknown orientation. A positive angle |
| 3821 | * indicates that the major axis of contact is oriented to the right. A negative angle |
| 3822 | * indicates that the major axis of contact is oriented to the left. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 3823 | * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3824 | * (finger pointing fully right). |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3825 | * |
| 3826 | * @see MotionEvent#AXIS_ORIENTATION |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3827 | */ |
| 3828 | public float orientation; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3829 | |
| 3830 | /** |
| 3831 | * Clears the contents of this object. |
| 3832 | * Resets all axes to zero. |
| 3833 | */ |
| 3834 | public void clear() { |
| 3835 | mPackedAxisBits = 0; |
| 3836 | |
| 3837 | x = 0; |
| 3838 | y = 0; |
| 3839 | pressure = 0; |
| 3840 | size = 0; |
| 3841 | touchMajor = 0; |
| 3842 | touchMinor = 0; |
| 3843 | toolMajor = 0; |
| 3844 | toolMinor = 0; |
| 3845 | orientation = 0; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3846 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3847 | |
| 3848 | /** |
| 3849 | * Copies the contents of another pointer coords object. |
| 3850 | * |
| 3851 | * @param other The pointer coords object to copy. |
| 3852 | */ |
| 3853 | public void copyFrom(PointerCoords other) { |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3854 | final long bits = other.mPackedAxisBits; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3855 | mPackedAxisBits = bits; |
| 3856 | if (bits != 0) { |
| 3857 | final float[] otherValues = other.mPackedAxisValues; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3858 | final int count = Long.bitCount(bits); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3859 | float[] values = mPackedAxisValues; |
| 3860 | if (values == null || count > values.length) { |
| 3861 | values = new float[otherValues.length]; |
| 3862 | mPackedAxisValues = values; |
| 3863 | } |
| 3864 | System.arraycopy(otherValues, 0, values, 0, count); |
| 3865 | } |
| 3866 | |
| 3867 | x = other.x; |
| 3868 | y = other.y; |
| 3869 | pressure = other.pressure; |
| 3870 | size = other.size; |
| 3871 | touchMajor = other.touchMajor; |
| 3872 | touchMinor = other.touchMinor; |
| 3873 | toolMajor = other.toolMajor; |
| 3874 | toolMinor = other.toolMinor; |
| 3875 | orientation = other.orientation; |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3876 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3877 | |
| 3878 | /** |
| 3879 | * Gets the value associated with the specified axis. |
| 3880 | * |
| 3881 | * @param axis The axis identifier for the axis value to retrieve. |
| 3882 | * @return The value associated with the axis, or 0 if none. |
| 3883 | * |
| 3884 | * @see MotionEvent#AXIS_X |
| 3885 | * @see MotionEvent#AXIS_Y |
| 3886 | */ |
| 3887 | public float getAxisValue(int axis) { |
| 3888 | switch (axis) { |
| 3889 | case AXIS_X: |
| 3890 | return x; |
| 3891 | case AXIS_Y: |
| 3892 | return y; |
| 3893 | case AXIS_PRESSURE: |
| 3894 | return pressure; |
| 3895 | case AXIS_SIZE: |
| 3896 | return size; |
| 3897 | case AXIS_TOUCH_MAJOR: |
| 3898 | return touchMajor; |
| 3899 | case AXIS_TOUCH_MINOR: |
| 3900 | return touchMinor; |
| 3901 | case AXIS_TOOL_MAJOR: |
| 3902 | return toolMajor; |
| 3903 | case AXIS_TOOL_MINOR: |
| 3904 | return toolMinor; |
| 3905 | case AXIS_ORIENTATION: |
| 3906 | return orientation; |
| 3907 | default: { |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3908 | if (axis < 0 || axis > 63) { |
| 3909 | throw new IllegalArgumentException("Axis out of range."); |
| 3910 | } |
| 3911 | final long bits = mPackedAxisBits; |
Michael Wright | 9adca06 | 2014-03-19 11:51:26 -0700 | [diff] [blame] | 3912 | final long axisBit = 0x8000000000000000L >>> axis; |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3913 | if ((bits & axisBit) == 0) { |
| 3914 | return 0; |
| 3915 | } |
Michael Wright | 9adca06 | 2014-03-19 11:51:26 -0700 | [diff] [blame] | 3916 | final int index = Long.bitCount(bits & ~(0xFFFFFFFFFFFFFFFFL >>> axis)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3917 | return mPackedAxisValues[index]; |
| 3918 | } |
| 3919 | } |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3920 | } |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3921 | |
| 3922 | /** |
| 3923 | * Sets the value associated with the specified axis. |
| 3924 | * |
| 3925 | * @param axis The axis identifier for the axis value to assign. |
| 3926 | * @param value The value to set. |
| 3927 | * |
| 3928 | * @see MotionEvent#AXIS_X |
| 3929 | * @see MotionEvent#AXIS_Y |
| 3930 | */ |
| 3931 | public void setAxisValue(int axis, float value) { |
| 3932 | switch (axis) { |
| 3933 | case AXIS_X: |
| 3934 | x = value; |
| 3935 | break; |
| 3936 | case AXIS_Y: |
| 3937 | y = value; |
| 3938 | break; |
| 3939 | case AXIS_PRESSURE: |
| 3940 | pressure = value; |
| 3941 | break; |
| 3942 | case AXIS_SIZE: |
| 3943 | size = value; |
| 3944 | break; |
| 3945 | case AXIS_TOUCH_MAJOR: |
| 3946 | touchMajor = value; |
| 3947 | break; |
| 3948 | case AXIS_TOUCH_MINOR: |
| 3949 | touchMinor = value; |
| 3950 | break; |
| 3951 | case AXIS_TOOL_MAJOR: |
| 3952 | toolMajor = value; |
| 3953 | break; |
| 3954 | case AXIS_TOOL_MINOR: |
| 3955 | toolMinor = value; |
| 3956 | break; |
| 3957 | case AXIS_ORIENTATION: |
| 3958 | orientation = value; |
| 3959 | break; |
| 3960 | default: { |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3961 | if (axis < 0 || axis > 63) { |
| 3962 | throw new IllegalArgumentException("Axis out of range."); |
| 3963 | } |
| 3964 | final long bits = mPackedAxisBits; |
Michael Wright | 9adca06 | 2014-03-19 11:51:26 -0700 | [diff] [blame] | 3965 | final long axisBit = 0x8000000000000000L >>> axis; |
| 3966 | final int index = Long.bitCount(bits & ~(0xFFFFFFFFFFFFFFFFL >>> axis)); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3967 | float[] values = mPackedAxisValues; |
| 3968 | if ((bits & axisBit) == 0) { |
| 3969 | if (values == null) { |
| 3970 | values = new float[INITIAL_PACKED_AXIS_VALUES]; |
| 3971 | mPackedAxisValues = values; |
| 3972 | } else { |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3973 | final int count = Long.bitCount(bits); |
Jeff Brown | 91c69ab | 2011-02-14 17:03:18 -0800 | [diff] [blame] | 3974 | if (count < values.length) { |
| 3975 | if (index != count) { |
| 3976 | System.arraycopy(values, index, values, index + 1, |
| 3977 | count - index); |
| 3978 | } |
| 3979 | } else { |
| 3980 | float[] newValues = new float[count * 2]; |
| 3981 | System.arraycopy(values, 0, newValues, 0, index); |
| 3982 | System.arraycopy(values, index, newValues, index + 1, |
| 3983 | count - index); |
| 3984 | values = newValues; |
| 3985 | mPackedAxisValues = values; |
| 3986 | } |
| 3987 | } |
| 3988 | mPackedAxisBits = bits | axisBit; |
| 3989 | } |
| 3990 | values[index] = value; |
| 3991 | } |
| 3992 | } |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3993 | } |
Jeff Brown | c5ed591 | 2010-07-14 18:48:53 -0700 | [diff] [blame] | 3994 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 3995 | |
| 3996 | /** |
| 3997 | * Transfer object for pointer properties. |
| 3998 | * |
| 3999 | * Objects of this type can be used to specify the pointer id and tool type |
| 4000 | * when creating new {@link MotionEvent} objects and to query pointer properties in bulk. |
| 4001 | */ |
| 4002 | public static final class PointerProperties { |
| 4003 | /** |
| 4004 | * Creates a pointer properties object with an invalid pointer id. |
| 4005 | */ |
| 4006 | public PointerProperties() { |
| 4007 | clear(); |
| 4008 | } |
| 4009 | |
| 4010 | /** |
| 4011 | * Creates a pointer properties object as a copy of the contents of |
| 4012 | * another pointer properties object. |
| 4013 | * @param other |
| 4014 | */ |
| 4015 | public PointerProperties(PointerProperties other) { |
| 4016 | copyFrom(other); |
| 4017 | } |
| 4018 | |
| 4019 | /** @hide */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 4020 | @UnsupportedAppUsage |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 4021 | public static PointerProperties[] createArray(int size) { |
| 4022 | PointerProperties[] array = new PointerProperties[size]; |
| 4023 | for (int i = 0; i < size; i++) { |
| 4024 | array[i] = new PointerProperties(); |
| 4025 | } |
| 4026 | return array; |
| 4027 | } |
| 4028 | |
| 4029 | /** |
| 4030 | * The pointer id. |
| 4031 | * Initially set to {@link #INVALID_POINTER_ID} (-1). |
| 4032 | * |
| 4033 | * @see MotionEvent#getPointerId(int) |
| 4034 | */ |
| 4035 | public int id; |
| 4036 | |
| 4037 | /** |
| 4038 | * The pointer tool type. |
| 4039 | * Initially set to 0. |
| 4040 | * |
| 4041 | * @see MotionEvent#getToolType(int) |
| 4042 | */ |
| 4043 | public int toolType; |
| 4044 | |
| 4045 | /** |
| 4046 | * Resets the pointer properties to their initial values. |
| 4047 | */ |
| 4048 | public void clear() { |
| 4049 | id = INVALID_POINTER_ID; |
| 4050 | toolType = TOOL_TYPE_UNKNOWN; |
| 4051 | } |
| 4052 | |
| 4053 | /** |
| 4054 | * Copies the contents of another pointer properties object. |
| 4055 | * |
| 4056 | * @param other The pointer properties object to copy. |
| 4057 | */ |
| 4058 | public void copyFrom(PointerProperties other) { |
| 4059 | id = other.id; |
| 4060 | toolType = other.toolType; |
| 4061 | } |
Jeff Brown | 9d3bdbd | 2012-03-21 11:50:06 -0700 | [diff] [blame] | 4062 | |
| 4063 | @Override |
| 4064 | public boolean equals(Object other) { |
| 4065 | if (other instanceof PointerProperties) { |
| 4066 | return equals((PointerProperties)other); |
| 4067 | } |
| 4068 | return false; |
| 4069 | } |
| 4070 | |
| 4071 | private boolean equals(PointerProperties other) { |
| 4072 | return other != null && id == other.id && toolType == other.toolType; |
| 4073 | } |
| 4074 | |
| 4075 | @Override |
| 4076 | public int hashCode() { |
| 4077 | return id | (toolType << 8); |
| 4078 | } |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 4079 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4080 | } |