Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | #ifndef _UI_INPUT_READER_H |
| 18 | #define _UI_INPUT_READER_H |
| 19 | |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 20 | #include "EventHub.h" |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 21 | #include "PointerController.h" |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 22 | #include "InputListener.h" |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 23 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 24 | #include <ui/Input.h> |
Jeff Brown | b4ff35d | 2011-01-02 16:37:43 -0800 | [diff] [blame] | 25 | #include <ui/DisplayInfo.h> |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 26 | #include <utils/KeyedVector.h> |
| 27 | #include <utils/threads.h> |
| 28 | #include <utils/Timers.h> |
| 29 | #include <utils/RefBase.h> |
| 30 | #include <utils/String8.h> |
| 31 | #include <utils/BitSet.h> |
| 32 | |
| 33 | #include <stddef.h> |
| 34 | #include <unistd.h> |
| 35 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 36 | namespace android { |
| 37 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 38 | class InputDevice; |
| 39 | class InputMapper; |
| 40 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 41 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 42 | /* |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 43 | * Input reader configuration. |
| 44 | * |
| 45 | * Specifies various options that modify the behavior of the input reader. |
| 46 | */ |
| 47 | struct InputReaderConfiguration { |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 48 | // Describes changes that have occurred. |
| 49 | enum { |
| 50 | // The pointer speed changed. |
| 51 | CHANGE_POINTER_SPEED = 1 << 0, |
| 52 | |
| 53 | // The pointer gesture control changed. |
| 54 | CHANGE_POINTER_GESTURE_ENABLEMENT = 1 << 1, |
| 55 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 56 | // The display size or orientation changed. |
| 57 | CHANGE_DISPLAY_INFO = 1 << 2, |
| 58 | |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 59 | // All devices must be reopened. |
| 60 | CHANGE_MUST_REOPEN = 1 << 31, |
| 61 | }; |
| 62 | |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 63 | // Gets the amount of time to disable virtual keys after the screen is touched |
| 64 | // in order to filter out accidental virtual key presses due to swiping gestures |
| 65 | // or taps near the edge of the display. May be 0 to disable the feature. |
| 66 | nsecs_t virtualKeyQuietTime; |
| 67 | |
| 68 | // The excluded device names for the platform. |
| 69 | // Devices with these names will be ignored. |
| 70 | Vector<String8> excludedDeviceNames; |
| 71 | |
Jeff Brown | 19c97d46 | 2011-06-01 12:33:19 -0700 | [diff] [blame] | 72 | // Velocity control parameters for mouse pointer movements. |
| 73 | VelocityControlParameters pointerVelocityControlParameters; |
| 74 | |
| 75 | // Velocity control parameters for mouse wheel movements. |
| 76 | VelocityControlParameters wheelVelocityControlParameters; |
| 77 | |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 78 | // True if pointer gestures are enabled. |
| 79 | bool pointerGesturesEnabled; |
| 80 | |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 81 | // Quiet time between certain pointer gesture transitions. |
| 82 | // Time to allow for all fingers or buttons to settle into a stable state before |
| 83 | // starting a new gesture. |
| 84 | nsecs_t pointerGestureQuietInterval; |
| 85 | |
| 86 | // The minimum speed that a pointer must travel for us to consider switching the active |
| 87 | // touch pointer to it during a drag. This threshold is set to avoid switching due |
| 88 | // to noise from a finger resting on the touch pad (perhaps just pressing it down). |
| 89 | float pointerGestureDragMinSwitchSpeed; // in pixels per second |
| 90 | |
| 91 | // Tap gesture delay time. |
| 92 | // The time between down and up must be less than this to be considered a tap. |
| 93 | nsecs_t pointerGestureTapInterval; |
| 94 | |
| 95 | // Tap drag gesture delay time. |
| 96 | // The time between the previous tap's up and the next down must be less than |
| 97 | // this to be considered a drag. Otherwise, the previous tap is finished and a |
| 98 | // new tap begins. |
| 99 | // |
| 100 | // Note that the previous tap will be held down for this entire duration so this |
| 101 | // interval must be shorter than the long press timeout. |
| 102 | nsecs_t pointerGestureTapDragInterval; |
| 103 | |
| 104 | // The distance in pixels that the pointer is allowed to move from initial down |
| 105 | // to up and still be called a tap. |
| 106 | float pointerGestureTapSlop; // in pixels |
| 107 | |
| 108 | // Time after the first touch points go down to settle on an initial centroid. |
| 109 | // This is intended to be enough time to handle cases where the user puts down two |
| 110 | // fingers at almost but not quite exactly the same time. |
| 111 | nsecs_t pointerGestureMultitouchSettleInterval; |
| 112 | |
| 113 | // The transition from PRESS to SWIPE or FREEFORM gesture mode is made when |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 114 | // at least two pointers have moved at least this far from their starting place. |
| 115 | float pointerGestureMultitouchMinDistance; // in pixels |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 116 | |
| 117 | // The transition from PRESS to SWIPE gesture mode can only occur when the |
| 118 | // cosine of the angle between the two vectors is greater than or equal to than this value |
| 119 | // which indicates that the vectors are oriented in the same direction. |
| 120 | // When the vectors are oriented in the exactly same direction, the cosine is 1.0. |
| 121 | // (In exactly opposite directions, the cosine is -1.0.) |
| 122 | float pointerGestureSwipeTransitionAngleCosine; |
| 123 | |
| 124 | // The transition from PRESS to SWIPE gesture mode can only occur when the |
| 125 | // fingers are no more than this far apart relative to the diagonal size of |
| 126 | // the touch pad. For example, a ratio of 0.5 means that the fingers must be |
| 127 | // no more than half the diagonal size of the touch pad apart. |
| 128 | float pointerGestureSwipeMaxWidthRatio; |
| 129 | |
| 130 | // The gesture movement speed factor relative to the size of the display. |
| 131 | // Movement speed applies when the fingers are moving in the same direction. |
| 132 | // Without acceleration, a full swipe of the touch pad diagonal in movement mode |
| 133 | // will cover this portion of the display diagonal. |
| 134 | float pointerGestureMovementSpeedRatio; |
| 135 | |
| 136 | // The gesture zoom speed factor relative to the size of the display. |
| 137 | // Zoom speed applies when the fingers are mostly moving relative to each other |
| 138 | // to execute a scale gesture or similar. |
| 139 | // Without acceleration, a full swipe of the touch pad diagonal in zoom mode |
| 140 | // will cover this portion of the display diagonal. |
| 141 | float pointerGestureZoomSpeedRatio; |
| 142 | |
| 143 | InputReaderConfiguration() : |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 144 | virtualKeyQuietTime(0), |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 145 | pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f, 3.0f), |
Jeff Brown | 19c97d46 | 2011-06-01 12:33:19 -0700 | [diff] [blame] | 146 | wheelVelocityControlParameters(1.0f, 15.0f, 50.0f, 4.0f), |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 147 | pointerGesturesEnabled(true), |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 148 | pointerGestureQuietInterval(100 * 1000000LL), // 100 ms |
| 149 | pointerGestureDragMinSwitchSpeed(50), // 50 pixels per second |
| 150 | pointerGestureTapInterval(150 * 1000000LL), // 150 ms |
| 151 | pointerGestureTapDragInterval(150 * 1000000LL), // 150 ms |
| 152 | pointerGestureTapSlop(10.0f), // 10 pixels |
| 153 | pointerGestureMultitouchSettleInterval(100 * 1000000LL), // 100 ms |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 154 | pointerGestureMultitouchMinDistance(15), // 15 pixels |
Jeff Brown | 6674d9b | 2011-06-07 16:50:14 -0700 | [diff] [blame] | 155 | pointerGestureSwipeTransitionAngleCosine(0.2588f), // cosine of 75 degrees |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 156 | pointerGestureSwipeMaxWidthRatio(0.25f), |
| 157 | pointerGestureMovementSpeedRatio(0.8f), |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 158 | pointerGestureZoomSpeedRatio(0.3f) { } |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 159 | |
| 160 | bool getDisplayInfo(int32_t displayId, bool external, |
| 161 | int32_t* width, int32_t* height, int32_t* orientation) const; |
| 162 | |
| 163 | void setDisplayInfo(int32_t displayId, bool external, |
| 164 | int32_t width, int32_t height, int32_t orientation); |
| 165 | |
| 166 | private: |
| 167 | struct DisplayInfo { |
| 168 | int32_t width; |
| 169 | int32_t height; |
| 170 | int32_t orientation; |
| 171 | |
| 172 | DisplayInfo() : |
| 173 | width(-1), height(-1), orientation(DISPLAY_ORIENTATION_0) { |
| 174 | } |
| 175 | }; |
| 176 | |
| 177 | DisplayInfo mInternalDisplay; |
| 178 | DisplayInfo mExternalDisplay; |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 179 | }; |
| 180 | |
| 181 | |
| 182 | /* |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 183 | * Input reader policy interface. |
| 184 | * |
| 185 | * The input reader policy is used by the input reader to interact with the Window Manager |
| 186 | * and other system components. |
| 187 | * |
| 188 | * The actual implementation is partially supported by callbacks into the DVM |
| 189 | * via JNI. This interface is also mocked in the unit tests. |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 190 | * |
| 191 | * These methods must NOT re-enter the input reader since they may be called while |
| 192 | * holding the input reader lock. |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 193 | */ |
| 194 | class InputReaderPolicyInterface : public virtual RefBase { |
| 195 | protected: |
| 196 | InputReaderPolicyInterface() { } |
| 197 | virtual ~InputReaderPolicyInterface() { } |
| 198 | |
| 199 | public: |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 200 | /* Gets the input reader configuration. */ |
| 201 | virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 202 | |
| 203 | /* Gets a pointer controller associated with the specified cursor device (ie. a mouse). */ |
| 204 | virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId) = 0; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 205 | }; |
| 206 | |
| 207 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 208 | /* Processes raw input events and sends cooked event data to an input listener. */ |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 209 | class InputReaderInterface : public virtual RefBase { |
| 210 | protected: |
| 211 | InputReaderInterface() { } |
| 212 | virtual ~InputReaderInterface() { } |
| 213 | |
| 214 | public: |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 215 | /* Dumps the state of the input reader. |
| 216 | * |
| 217 | * This method may be called on any thread (usually by the input manager). */ |
| 218 | virtual void dump(String8& dump) = 0; |
| 219 | |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 220 | /* Called by the heatbeat to ensures that the reader has not deadlocked. */ |
| 221 | virtual void monitor() = 0; |
| 222 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 223 | /* Runs a single iteration of the processing loop. |
| 224 | * Nominally reads and processes one incoming message from the EventHub. |
| 225 | * |
| 226 | * This method should be called on the input reader thread. |
| 227 | */ |
| 228 | virtual void loopOnce() = 0; |
| 229 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 230 | /* Gets the current input device configuration. |
| 231 | * |
| 232 | * This method may be called on any thread (usually by the input manager). |
| 233 | */ |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 234 | virtual void getInputConfiguration(InputConfiguration* outConfiguration) = 0; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 235 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 236 | /* Gets information about the specified input device. |
| 237 | * Returns OK if the device information was obtained or NAME_NOT_FOUND if there |
| 238 | * was no such device. |
| 239 | * |
| 240 | * This method may be called on any thread (usually by the input manager). |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 241 | */ |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 242 | virtual status_t getInputDeviceInfo(int32_t deviceId, InputDeviceInfo* outDeviceInfo) = 0; |
| 243 | |
| 244 | /* Gets the list of all registered device ids. */ |
| 245 | virtual void getInputDeviceIds(Vector<int32_t>& outDeviceIds) = 0; |
| 246 | |
| 247 | /* Query current input state. */ |
| 248 | virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, |
| 249 | int32_t scanCode) = 0; |
| 250 | virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, |
| 251 | int32_t keyCode) = 0; |
| 252 | virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, |
| 253 | int32_t sw) = 0; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 254 | |
| 255 | /* Determine whether physical keys exist for the given framework-domain key codes. */ |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 256 | virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, |
| 257 | size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0; |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 258 | |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 259 | /* Requests that a reconfiguration of all input devices. |
| 260 | * The changes flag is a bitfield that indicates what has changed and whether |
| 261 | * the input devices must all be reopened. */ |
| 262 | virtual void requestRefreshConfiguration(uint32_t changes) = 0; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 263 | }; |
| 264 | |
| 265 | |
| 266 | /* Internal interface used by individual input devices to access global input device state |
| 267 | * and parameters maintained by the input reader. |
| 268 | */ |
| 269 | class InputReaderContext { |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 270 | public: |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 271 | InputReaderContext() { } |
| 272 | virtual ~InputReaderContext() { } |
| 273 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 274 | virtual void updateGlobalMetaState() = 0; |
| 275 | virtual int32_t getGlobalMetaState() = 0; |
| 276 | |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 277 | virtual void disableVirtualKeysUntil(nsecs_t time) = 0; |
| 278 | virtual bool shouldDropVirtualKey(nsecs_t now, |
| 279 | InputDevice* device, int32_t keyCode, int32_t scanCode) = 0; |
| 280 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 281 | virtual void fadePointer() = 0; |
| 282 | |
Jeff Brown | aa3855d | 2011-03-17 01:34:19 -0700 | [diff] [blame] | 283 | virtual void requestTimeoutAtTime(nsecs_t when) = 0; |
| 284 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 285 | virtual InputReaderPolicyInterface* getPolicy() = 0; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 286 | virtual InputListenerInterface* getListener() = 0; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 287 | virtual EventHubInterface* getEventHub() = 0; |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 288 | }; |
| 289 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 290 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 291 | /* The input reader reads raw event data from the event hub and processes it into input events |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 292 | * that it sends to the input listener. Some functions of the input reader, such as early |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 293 | * event filtering in low power states, are controlled by a separate policy object. |
| 294 | * |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 295 | * The InputReader owns a collection of InputMappers. Most of the work it does happens |
| 296 | * on the input reader thread but the InputReader can receive queries from other system |
| 297 | * components running on arbitrary threads. To keep things manageable, the InputReader |
| 298 | * uses a single Mutex to guard its state. The Mutex may be held while calling into the |
| 299 | * EventHub or the InputReaderPolicy but it is never held while calling into the |
| 300 | * InputListener. |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 301 | */ |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 302 | class InputReader : public InputReaderInterface { |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 303 | public: |
| 304 | InputReader(const sp<EventHubInterface>& eventHub, |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 305 | const sp<InputReaderPolicyInterface>& policy, |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 306 | const sp<InputListenerInterface>& listener); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 307 | virtual ~InputReader(); |
| 308 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 309 | virtual void dump(String8& dump); |
Jeff Brown | 89ef072 | 2011-08-10 16:25:21 -0700 | [diff] [blame] | 310 | virtual void monitor(); |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 311 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 312 | virtual void loopOnce(); |
| 313 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 314 | virtual void getInputConfiguration(InputConfiguration* outConfiguration); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 315 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 316 | virtual status_t getInputDeviceInfo(int32_t deviceId, InputDeviceInfo* outDeviceInfo); |
| 317 | virtual void getInputDeviceIds(Vector<int32_t>& outDeviceIds); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 318 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 319 | virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, |
| 320 | int32_t scanCode); |
| 321 | virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, |
| 322 | int32_t keyCode); |
| 323 | virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, |
| 324 | int32_t sw); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 325 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 326 | virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, |
| 327 | size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 328 | |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 329 | virtual void requestRefreshConfiguration(uint32_t changes); |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 330 | |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 331 | protected: |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 332 | // These members are protected so they can be instrumented by test cases. |
| 333 | virtual InputDevice* createDeviceLocked(int32_t deviceId, |
| 334 | const String8& name, uint32_t classes); |
| 335 | |
| 336 | class ContextImpl : public InputReaderContext { |
| 337 | InputReader* mReader; |
| 338 | |
| 339 | public: |
| 340 | ContextImpl(InputReader* reader); |
| 341 | |
| 342 | virtual void updateGlobalMetaState(); |
| 343 | virtual int32_t getGlobalMetaState(); |
| 344 | virtual void disableVirtualKeysUntil(nsecs_t time); |
| 345 | virtual bool shouldDropVirtualKey(nsecs_t now, |
| 346 | InputDevice* device, int32_t keyCode, int32_t scanCode); |
| 347 | virtual void fadePointer(); |
| 348 | virtual void requestTimeoutAtTime(nsecs_t when); |
| 349 | virtual InputReaderPolicyInterface* getPolicy(); |
| 350 | virtual InputListenerInterface* getListener(); |
| 351 | virtual EventHubInterface* getEventHub(); |
| 352 | } mContext; |
| 353 | |
| 354 | friend class ContextImpl; |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 355 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 356 | private: |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 357 | Mutex mLock; |
| 358 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 359 | sp<EventHubInterface> mEventHub; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 360 | sp<InputReaderPolicyInterface> mPolicy; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 361 | sp<QueuedInputListener> mQueuedListener; |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 362 | |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 363 | InputReaderConfiguration mConfig; |
| 364 | |
Jeff Brown | b719874 | 2011-03-18 18:14:26 -0700 | [diff] [blame] | 365 | // The event queue. |
| 366 | static const int EVENT_BUFFER_SIZE = 256; |
| 367 | RawEvent mEventBuffer[EVENT_BUFFER_SIZE]; |
| 368 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 369 | KeyedVector<int32_t, InputDevice*> mDevices; |
| 370 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 371 | // low-level input event decoding and device management |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 372 | void processEventsLocked(const RawEvent* rawEvents, size_t count); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 373 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 374 | void addDeviceLocked(nsecs_t when, int32_t deviceId); |
| 375 | void removeDeviceLocked(nsecs_t when, int32_t deviceId); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 376 | void processEventsForDeviceLocked(int32_t deviceId, const RawEvent* rawEvents, size_t count); |
| 377 | void timeoutExpiredLocked(nsecs_t when); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 378 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 379 | void handleConfigurationChangedLocked(nsecs_t when); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 380 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 381 | int32_t mGlobalMetaState; |
| 382 | void updateGlobalMetaStateLocked(); |
| 383 | int32_t getGlobalMetaStateLocked(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 384 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 385 | void fadePointerLocked(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 386 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 387 | InputConfiguration mInputConfiguration; |
| 388 | void updateInputConfigurationLocked(); |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 389 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 390 | nsecs_t mDisableVirtualKeysTimeout; |
| 391 | void disableVirtualKeysUntilLocked(nsecs_t time); |
| 392 | bool shouldDropVirtualKeyLocked(nsecs_t now, |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 393 | InputDevice* device, int32_t keyCode, int32_t scanCode); |
| 394 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 395 | nsecs_t mNextTimeout; |
| 396 | void requestTimeoutAtTimeLocked(nsecs_t when); |
Jeff Brown | aa3855d | 2011-03-17 01:34:19 -0700 | [diff] [blame] | 397 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 398 | uint32_t mConfigurationChangesToRefresh; |
| 399 | void refreshConfigurationLocked(uint32_t changes); |
Jeff Brown | 1a84fd1 | 2011-06-02 01:26:32 -0700 | [diff] [blame] | 400 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 401 | // state queries |
| 402 | typedef int32_t (InputDevice::*GetStateFunc)(uint32_t sourceMask, int32_t code); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 403 | int32_t getStateLocked(int32_t deviceId, uint32_t sourceMask, int32_t code, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 404 | GetStateFunc getStateFunc); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 405 | bool markSupportedKeyCodesLocked(int32_t deviceId, uint32_t sourceMask, size_t numCodes, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 406 | const int32_t* keyCodes, uint8_t* outFlags); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 407 | }; |
| 408 | |
| 409 | |
| 410 | /* Reads raw events from the event hub and processes them, endlessly. */ |
| 411 | class InputReaderThread : public Thread { |
| 412 | public: |
| 413 | InputReaderThread(const sp<InputReaderInterface>& reader); |
| 414 | virtual ~InputReaderThread(); |
| 415 | |
| 416 | private: |
| 417 | sp<InputReaderInterface> mReader; |
| 418 | |
| 419 | virtual bool threadLoop(); |
| 420 | }; |
| 421 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 422 | |
| 423 | /* Represents the state of a single input device. */ |
| 424 | class InputDevice { |
| 425 | public: |
| 426 | InputDevice(InputReaderContext* context, int32_t id, const String8& name); |
| 427 | ~InputDevice(); |
| 428 | |
| 429 | inline InputReaderContext* getContext() { return mContext; } |
| 430 | inline int32_t getId() { return mId; } |
| 431 | inline const String8& getName() { return mName; } |
| 432 | inline uint32_t getSources() { return mSources; } |
| 433 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 434 | inline bool isExternal() { return mIsExternal; } |
| 435 | inline void setExternal(bool external) { mIsExternal = external; } |
| 436 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 437 | inline bool isIgnored() { return mMappers.isEmpty(); } |
| 438 | |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 439 | void dump(String8& dump); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 440 | void addMapper(InputMapper* mapper); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 441 | void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); |
| 442 | void reset(nsecs_t when); |
Jeff Brown | b719874 | 2011-03-18 18:14:26 -0700 | [diff] [blame] | 443 | void process(const RawEvent* rawEvents, size_t count); |
Jeff Brown | aa3855d | 2011-03-17 01:34:19 -0700 | [diff] [blame] | 444 | void timeoutExpired(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 445 | |
| 446 | void getDeviceInfo(InputDeviceInfo* outDeviceInfo); |
| 447 | int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 448 | int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 449 | int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode); |
| 450 | bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 451 | const int32_t* keyCodes, uint8_t* outFlags); |
| 452 | |
| 453 | int32_t getMetaState(); |
| 454 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 455 | void fadePointer(); |
| 456 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 457 | void notifyReset(nsecs_t when); |
| 458 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 459 | inline const PropertyMap& getConfiguration() { return mConfiguration; } |
| 460 | inline EventHubInterface* getEventHub() { return mContext->getEventHub(); } |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 461 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 462 | bool hasKey(int32_t code) { |
| 463 | return getEventHub()->hasScanCode(mId, code); |
| 464 | } |
| 465 | |
| 466 | bool isKeyPressed(int32_t code) { |
| 467 | return getEventHub()->getScanCodeState(mId, code) == AKEY_STATE_DOWN; |
| 468 | } |
| 469 | |
| 470 | int32_t getAbsoluteAxisValue(int32_t code) { |
| 471 | int32_t value; |
| 472 | getEventHub()->getAbsoluteAxisValue(mId, code, &value); |
| 473 | return value; |
| 474 | } |
| 475 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 476 | private: |
| 477 | InputReaderContext* mContext; |
| 478 | int32_t mId; |
| 479 | |
| 480 | Vector<InputMapper*> mMappers; |
| 481 | |
| 482 | String8 mName; |
| 483 | uint32_t mSources; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 484 | bool mIsExternal; |
Jeff Brown | 80fd47c | 2011-05-24 01:07:44 -0700 | [diff] [blame] | 485 | bool mDropUntilNextSync; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 486 | |
| 487 | typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code); |
| 488 | int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 489 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 490 | PropertyMap mConfiguration; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 491 | }; |
| 492 | |
| 493 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 494 | /* Keeps track of the state of mouse or touch pad buttons. */ |
| 495 | class CursorButtonAccumulator { |
| 496 | public: |
| 497 | CursorButtonAccumulator(); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 498 | void reset(InputDevice* device); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 499 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 500 | void process(const RawEvent* rawEvent); |
| 501 | |
| 502 | uint32_t getButtonState() const; |
| 503 | |
| 504 | private: |
| 505 | bool mBtnLeft; |
| 506 | bool mBtnRight; |
| 507 | bool mBtnMiddle; |
| 508 | bool mBtnBack; |
| 509 | bool mBtnSide; |
| 510 | bool mBtnForward; |
| 511 | bool mBtnExtra; |
| 512 | bool mBtnTask; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 513 | |
| 514 | void clearButtons(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 515 | }; |
| 516 | |
| 517 | |
| 518 | /* Keeps track of cursor movements. */ |
| 519 | |
| 520 | class CursorMotionAccumulator { |
| 521 | public: |
| 522 | CursorMotionAccumulator(); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 523 | void reset(InputDevice* device); |
| 524 | |
| 525 | void process(const RawEvent* rawEvent); |
| 526 | void finishSync(); |
| 527 | |
| 528 | inline int32_t getRelativeX() const { return mRelX; } |
| 529 | inline int32_t getRelativeY() const { return mRelY; } |
| 530 | |
| 531 | private: |
| 532 | int32_t mRelX; |
| 533 | int32_t mRelY; |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 534 | |
| 535 | void clearRelativeAxes(); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 536 | }; |
| 537 | |
| 538 | |
| 539 | /* Keeps track of cursor scrolling motions. */ |
| 540 | |
| 541 | class CursorScrollAccumulator { |
| 542 | public: |
| 543 | CursorScrollAccumulator(); |
| 544 | void configure(InputDevice* device); |
| 545 | void reset(InputDevice* device); |
| 546 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 547 | void process(const RawEvent* rawEvent); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 548 | void finishSync(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 549 | |
| 550 | inline bool haveRelativeVWheel() const { return mHaveRelWheel; } |
| 551 | inline bool haveRelativeHWheel() const { return mHaveRelHWheel; } |
| 552 | |
| 553 | inline int32_t getRelativeX() const { return mRelX; } |
| 554 | inline int32_t getRelativeY() const { return mRelY; } |
| 555 | inline int32_t getRelativeVWheel() const { return mRelWheel; } |
| 556 | inline int32_t getRelativeHWheel() const { return mRelHWheel; } |
| 557 | |
| 558 | private: |
| 559 | bool mHaveRelWheel; |
| 560 | bool mHaveRelHWheel; |
| 561 | |
| 562 | int32_t mRelX; |
| 563 | int32_t mRelY; |
| 564 | int32_t mRelWheel; |
| 565 | int32_t mRelHWheel; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 566 | |
| 567 | void clearRelativeAxes(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 568 | }; |
| 569 | |
| 570 | |
| 571 | /* Keeps track of the state of touch, stylus and tool buttons. */ |
| 572 | class TouchButtonAccumulator { |
| 573 | public: |
| 574 | TouchButtonAccumulator(); |
| 575 | void configure(InputDevice* device); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 576 | void reset(InputDevice* device); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 577 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 578 | void process(const RawEvent* rawEvent); |
| 579 | |
| 580 | uint32_t getButtonState() const; |
| 581 | int32_t getToolType() const; |
Jeff Brown | d87c6d5 | 2011-08-10 14:55:59 -0700 | [diff] [blame] | 582 | bool isToolActive() const; |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 583 | bool isHovering() const; |
| 584 | |
| 585 | private: |
| 586 | bool mHaveBtnTouch; |
| 587 | |
| 588 | bool mBtnTouch; |
| 589 | bool mBtnStylus; |
| 590 | bool mBtnStylus2; |
| 591 | bool mBtnToolFinger; |
| 592 | bool mBtnToolPen; |
| 593 | bool mBtnToolRubber; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 594 | bool mBtnToolBrush; |
| 595 | bool mBtnToolPencil; |
| 596 | bool mBtnToolAirbrush; |
| 597 | bool mBtnToolMouse; |
| 598 | bool mBtnToolLens; |
| 599 | |
| 600 | void clearButtons(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 601 | }; |
| 602 | |
| 603 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 604 | /* Raw axis information from the driver. */ |
| 605 | struct RawPointerAxes { |
| 606 | RawAbsoluteAxisInfo x; |
| 607 | RawAbsoluteAxisInfo y; |
| 608 | RawAbsoluteAxisInfo pressure; |
| 609 | RawAbsoluteAxisInfo touchMajor; |
| 610 | RawAbsoluteAxisInfo touchMinor; |
| 611 | RawAbsoluteAxisInfo toolMajor; |
| 612 | RawAbsoluteAxisInfo toolMinor; |
| 613 | RawAbsoluteAxisInfo orientation; |
| 614 | RawAbsoluteAxisInfo distance; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 615 | RawAbsoluteAxisInfo tiltX; |
| 616 | RawAbsoluteAxisInfo tiltY; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 617 | RawAbsoluteAxisInfo trackingId; |
| 618 | RawAbsoluteAxisInfo slot; |
| 619 | |
| 620 | RawPointerAxes(); |
| 621 | void clear(); |
| 622 | }; |
| 623 | |
| 624 | |
| 625 | /* Raw data for a collection of pointers including a pointer id mapping table. */ |
| 626 | struct RawPointerData { |
| 627 | struct Pointer { |
| 628 | uint32_t id; |
| 629 | int32_t x; |
| 630 | int32_t y; |
| 631 | int32_t pressure; |
| 632 | int32_t touchMajor; |
| 633 | int32_t touchMinor; |
| 634 | int32_t toolMajor; |
| 635 | int32_t toolMinor; |
| 636 | int32_t orientation; |
| 637 | int32_t distance; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 638 | int32_t tiltX; |
| 639 | int32_t tiltY; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 640 | int32_t toolType; // a fully decoded AMOTION_EVENT_TOOL_TYPE constant |
| 641 | bool isHovering; |
| 642 | }; |
| 643 | |
| 644 | uint32_t pointerCount; |
| 645 | Pointer pointers[MAX_POINTERS]; |
| 646 | BitSet32 hoveringIdBits, touchingIdBits; |
| 647 | uint32_t idToIndex[MAX_POINTER_ID + 1]; |
| 648 | |
| 649 | RawPointerData(); |
| 650 | void clear(); |
| 651 | void copyFrom(const RawPointerData& other); |
| 652 | void getCentroidOfTouchingPointers(float* outX, float* outY) const; |
| 653 | |
| 654 | inline void markIdBit(uint32_t id, bool isHovering) { |
| 655 | if (isHovering) { |
| 656 | hoveringIdBits.markBit(id); |
| 657 | } else { |
| 658 | touchingIdBits.markBit(id); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | inline void clearIdBits() { |
| 663 | hoveringIdBits.clear(); |
| 664 | touchingIdBits.clear(); |
| 665 | } |
| 666 | |
| 667 | inline const Pointer& pointerForId(uint32_t id) const { |
| 668 | return pointers[idToIndex[id]]; |
| 669 | } |
| 670 | |
| 671 | inline bool isHovering(uint32_t pointerIndex) { |
| 672 | return pointers[pointerIndex].isHovering; |
| 673 | } |
| 674 | }; |
| 675 | |
| 676 | |
| 677 | /* Cooked data for a collection of pointers including a pointer id mapping table. */ |
| 678 | struct CookedPointerData { |
| 679 | uint32_t pointerCount; |
| 680 | PointerProperties pointerProperties[MAX_POINTERS]; |
| 681 | PointerCoords pointerCoords[MAX_POINTERS]; |
| 682 | BitSet32 hoveringIdBits, touchingIdBits; |
| 683 | uint32_t idToIndex[MAX_POINTER_ID + 1]; |
| 684 | |
| 685 | CookedPointerData(); |
| 686 | void clear(); |
| 687 | void copyFrom(const CookedPointerData& other); |
| 688 | |
| 689 | inline bool isHovering(uint32_t pointerIndex) { |
| 690 | return hoveringIdBits.hasBit(pointerProperties[pointerIndex].id); |
| 691 | } |
| 692 | }; |
| 693 | |
| 694 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 695 | /* Keeps track of the state of single-touch protocol. */ |
| 696 | class SingleTouchMotionAccumulator { |
| 697 | public: |
| 698 | SingleTouchMotionAccumulator(); |
| 699 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 700 | void process(const RawEvent* rawEvent); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 701 | void reset(InputDevice* device); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 702 | |
| 703 | inline int32_t getAbsoluteX() const { return mAbsX; } |
| 704 | inline int32_t getAbsoluteY() const { return mAbsY; } |
| 705 | inline int32_t getAbsolutePressure() const { return mAbsPressure; } |
| 706 | inline int32_t getAbsoluteToolWidth() const { return mAbsToolWidth; } |
| 707 | inline int32_t getAbsoluteDistance() const { return mAbsDistance; } |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 708 | inline int32_t getAbsoluteTiltX() const { return mAbsTiltX; } |
| 709 | inline int32_t getAbsoluteTiltY() const { return mAbsTiltY; } |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 710 | |
| 711 | private: |
| 712 | int32_t mAbsX; |
| 713 | int32_t mAbsY; |
| 714 | int32_t mAbsPressure; |
| 715 | int32_t mAbsToolWidth; |
| 716 | int32_t mAbsDistance; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 717 | int32_t mAbsTiltX; |
| 718 | int32_t mAbsTiltY; |
| 719 | |
| 720 | void clearAbsoluteAxes(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 721 | }; |
| 722 | |
| 723 | |
| 724 | /* Keeps track of the state of multi-touch protocol. */ |
| 725 | class MultiTouchMotionAccumulator { |
| 726 | public: |
| 727 | class Slot { |
| 728 | public: |
| 729 | inline bool isInUse() const { return mInUse; } |
| 730 | inline int32_t getX() const { return mAbsMTPositionX; } |
| 731 | inline int32_t getY() const { return mAbsMTPositionY; } |
| 732 | inline int32_t getTouchMajor() const { return mAbsMTTouchMajor; } |
| 733 | inline int32_t getTouchMinor() const { |
| 734 | return mHaveAbsMTTouchMinor ? mAbsMTTouchMinor : mAbsMTTouchMajor; } |
| 735 | inline int32_t getToolMajor() const { return mAbsMTWidthMajor; } |
| 736 | inline int32_t getToolMinor() const { |
| 737 | return mHaveAbsMTWidthMinor ? mAbsMTWidthMinor : mAbsMTWidthMajor; } |
| 738 | inline int32_t getOrientation() const { return mAbsMTOrientation; } |
| 739 | inline int32_t getTrackingId() const { return mAbsMTTrackingId; } |
| 740 | inline int32_t getPressure() const { return mAbsMTPressure; } |
| 741 | inline int32_t getDistance() const { return mAbsMTDistance; } |
| 742 | inline int32_t getToolType() const; |
| 743 | |
| 744 | private: |
| 745 | friend class MultiTouchMotionAccumulator; |
| 746 | |
| 747 | bool mInUse; |
| 748 | bool mHaveAbsMTTouchMinor; |
| 749 | bool mHaveAbsMTWidthMinor; |
| 750 | bool mHaveAbsMTToolType; |
| 751 | |
| 752 | int32_t mAbsMTPositionX; |
| 753 | int32_t mAbsMTPositionY; |
| 754 | int32_t mAbsMTTouchMajor; |
| 755 | int32_t mAbsMTTouchMinor; |
| 756 | int32_t mAbsMTWidthMajor; |
| 757 | int32_t mAbsMTWidthMinor; |
| 758 | int32_t mAbsMTOrientation; |
| 759 | int32_t mAbsMTTrackingId; |
| 760 | int32_t mAbsMTPressure; |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 761 | int32_t mAbsMTDistance; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 762 | int32_t mAbsMTToolType; |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 763 | |
| 764 | Slot(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 765 | void clear(); |
| 766 | }; |
| 767 | |
| 768 | MultiTouchMotionAccumulator(); |
| 769 | ~MultiTouchMotionAccumulator(); |
| 770 | |
| 771 | void configure(size_t slotCount, bool usingSlotsProtocol); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 772 | void reset(InputDevice* device); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 773 | void process(const RawEvent* rawEvent); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 774 | void finishSync(); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 775 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 776 | inline size_t getSlotCount() const { return mSlotCount; } |
| 777 | inline const Slot* getSlot(size_t index) const { return &mSlots[index]; } |
| 778 | |
| 779 | private: |
| 780 | int32_t mCurrentSlot; |
| 781 | Slot* mSlots; |
| 782 | size_t mSlotCount; |
| 783 | bool mUsingSlotsProtocol; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 784 | |
| 785 | void clearSlots(int32_t initialSlot); |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 786 | }; |
| 787 | |
| 788 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 789 | /* An input mapper transforms raw input events into cooked event data. |
| 790 | * A single input device can have multiple associated input mappers in order to interpret |
| 791 | * different classes of events. |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 792 | * |
| 793 | * InputMapper lifecycle: |
| 794 | * - create |
| 795 | * - configure with 0 changes |
| 796 | * - reset |
| 797 | * - process, process, process (may occasionally reconfigure with non-zero changes or reset) |
| 798 | * - reset |
| 799 | * - destroy |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 800 | */ |
| 801 | class InputMapper { |
| 802 | public: |
| 803 | InputMapper(InputDevice* device); |
| 804 | virtual ~InputMapper(); |
| 805 | |
| 806 | inline InputDevice* getDevice() { return mDevice; } |
| 807 | inline int32_t getDeviceId() { return mDevice->getId(); } |
| 808 | inline const String8 getDeviceName() { return mDevice->getName(); } |
| 809 | inline InputReaderContext* getContext() { return mContext; } |
| 810 | inline InputReaderPolicyInterface* getPolicy() { return mContext->getPolicy(); } |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 811 | inline InputListenerInterface* getListener() { return mContext->getListener(); } |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 812 | inline EventHubInterface* getEventHub() { return mContext->getEventHub(); } |
| 813 | |
| 814 | virtual uint32_t getSources() = 0; |
| 815 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 816 | virtual void dump(String8& dump); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 817 | virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); |
| 818 | virtual void reset(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 819 | virtual void process(const RawEvent* rawEvent) = 0; |
Jeff Brown | aa3855d | 2011-03-17 01:34:19 -0700 | [diff] [blame] | 820 | virtual void timeoutExpired(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 821 | |
| 822 | virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 823 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 824 | virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode); |
| 825 | virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 826 | const int32_t* keyCodes, uint8_t* outFlags); |
| 827 | |
| 828 | virtual int32_t getMetaState(); |
| 829 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 830 | virtual void fadePointer(); |
| 831 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 832 | protected: |
| 833 | InputDevice* mDevice; |
| 834 | InputReaderContext* mContext; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 835 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 836 | status_t getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo); |
| 837 | |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 838 | static void dumpRawAbsoluteAxisInfo(String8& dump, |
| 839 | const RawAbsoluteAxisInfo& axis, const char* name); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 840 | }; |
| 841 | |
| 842 | |
| 843 | class SwitchInputMapper : public InputMapper { |
| 844 | public: |
| 845 | SwitchInputMapper(InputDevice* device); |
| 846 | virtual ~SwitchInputMapper(); |
| 847 | |
| 848 | virtual uint32_t getSources(); |
| 849 | virtual void process(const RawEvent* rawEvent); |
| 850 | |
| 851 | virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode); |
| 852 | |
| 853 | private: |
| 854 | void processSwitch(nsecs_t when, int32_t switchCode, int32_t switchValue); |
| 855 | }; |
| 856 | |
| 857 | |
| 858 | class KeyboardInputMapper : public InputMapper { |
| 859 | public: |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 860 | KeyboardInputMapper(InputDevice* device, uint32_t source, int32_t keyboardType); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 861 | virtual ~KeyboardInputMapper(); |
| 862 | |
| 863 | virtual uint32_t getSources(); |
| 864 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 865 | virtual void dump(String8& dump); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 866 | virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); |
| 867 | virtual void reset(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 868 | virtual void process(const RawEvent* rawEvent); |
| 869 | |
| 870 | virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 871 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 872 | virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 873 | const int32_t* keyCodes, uint8_t* outFlags); |
| 874 | |
| 875 | virtual int32_t getMetaState(); |
| 876 | |
| 877 | private: |
| 878 | struct KeyDown { |
| 879 | int32_t keyCode; |
| 880 | int32_t scanCode; |
| 881 | }; |
| 882 | |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 883 | uint32_t mSource; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 884 | int32_t mKeyboardType; |
| 885 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 886 | int32_t mOrientation; // orientation for dpad keys |
| 887 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 888 | Vector<KeyDown> mKeyDowns; // keys that are down |
| 889 | int32_t mMetaState; |
| 890 | nsecs_t mDownTime; // time of most recent key down |
| 891 | |
| 892 | struct LedState { |
| 893 | bool avail; // led is available |
| 894 | bool on; // we think the led is currently on |
| 895 | }; |
| 896 | LedState mCapsLockLedState; |
| 897 | LedState mNumLockLedState; |
| 898 | LedState mScrollLockLedState; |
| 899 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 900 | // Immutable configuration parameters. |
| 901 | struct Parameters { |
| 902 | int32_t associatedDisplayId; |
| 903 | bool orientationAware; |
| 904 | } mParameters; |
| 905 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 906 | void configureParameters(); |
| 907 | void dumpParameters(String8& dump); |
| 908 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 909 | bool isKeyboardOrGamepadKey(int32_t scanCode); |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 910 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 911 | void processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode, |
| 912 | uint32_t policyFlags); |
| 913 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 914 | ssize_t findKeyDown(int32_t scanCode); |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 915 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 916 | void resetLedState(); |
| 917 | void initializeLedState(LedState& ledState, int32_t led); |
| 918 | void updateLedState(bool reset); |
| 919 | void updateLedStateForModifier(LedState& ledState, int32_t led, |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 920 | int32_t modifier, bool reset); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 921 | }; |
| 922 | |
| 923 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 924 | class CursorInputMapper : public InputMapper { |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 925 | public: |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 926 | CursorInputMapper(InputDevice* device); |
| 927 | virtual ~CursorInputMapper(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 928 | |
| 929 | virtual uint32_t getSources(); |
| 930 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 931 | virtual void dump(String8& dump); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 932 | virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); |
| 933 | virtual void reset(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 934 | virtual void process(const RawEvent* rawEvent); |
| 935 | |
Jeff Brown | c3fc2d0 | 2010-08-10 15:47:53 -0700 | [diff] [blame] | 936 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 937 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame] | 938 | virtual void fadePointer(); |
| 939 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 940 | private: |
| 941 | // Amount that trackball needs to move in order to generate a key event. |
| 942 | static const int32_t TRACKBALL_MOVEMENT_THRESHOLD = 6; |
| 943 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 944 | // Immutable configuration parameters. |
| 945 | struct Parameters { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 946 | enum Mode { |
| 947 | MODE_POINTER, |
| 948 | MODE_NAVIGATION, |
| 949 | }; |
| 950 | |
| 951 | Mode mode; |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 952 | int32_t associatedDisplayId; |
| 953 | bool orientationAware; |
| 954 | } mParameters; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 955 | |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 956 | CursorButtonAccumulator mCursorButtonAccumulator; |
| 957 | CursorMotionAccumulator mCursorMotionAccumulator; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 958 | CursorScrollAccumulator mCursorScrollAccumulator; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 959 | |
Jeff Brown | efd3266 | 2011-03-08 15:13:06 -0800 | [diff] [blame] | 960 | int32_t mSource; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 961 | float mXScale; |
| 962 | float mYScale; |
| 963 | float mXPrecision; |
| 964 | float mYPrecision; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 965 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 966 | float mVWheelScale; |
| 967 | float mHWheelScale; |
| 968 | |
Jeff Brown | 19c97d46 | 2011-06-01 12:33:19 -0700 | [diff] [blame] | 969 | // Velocity controls for mouse pointer and wheel movements. |
| 970 | // The controls for X and Y wheel movements are separate to keep them decoupled. |
| 971 | VelocityControl mPointerVelocityControl; |
| 972 | VelocityControl mWheelXVelocityControl; |
| 973 | VelocityControl mWheelYVelocityControl; |
| 974 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 975 | int32_t mOrientation; |
| 976 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 977 | sp<PointerControllerInterface> mPointerController; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 978 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 979 | int32_t mButtonState; |
| 980 | nsecs_t mDownTime; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 981 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 982 | void configureParameters(); |
| 983 | void dumpParameters(String8& dump); |
| 984 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 985 | void sync(nsecs_t when); |
| 986 | }; |
| 987 | |
| 988 | |
| 989 | class TouchInputMapper : public InputMapper { |
| 990 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 991 | TouchInputMapper(InputDevice* device); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 992 | virtual ~TouchInputMapper(); |
| 993 | |
| 994 | virtual uint32_t getSources(); |
| 995 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 996 | virtual void dump(String8& dump); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 997 | virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); |
| 998 | virtual void reset(nsecs_t when); |
| 999 | virtual void process(const RawEvent* rawEvent); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1000 | |
| 1001 | virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 1002 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 1003 | virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 1004 | const int32_t* keyCodes, uint8_t* outFlags); |
| 1005 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1006 | virtual void fadePointer(); |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1007 | virtual void timeoutExpired(nsecs_t when); |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1008 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1009 | protected: |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1010 | CursorButtonAccumulator mCursorButtonAccumulator; |
| 1011 | CursorScrollAccumulator mCursorScrollAccumulator; |
| 1012 | TouchButtonAccumulator mTouchButtonAccumulator; |
| 1013 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1014 | struct VirtualKey { |
| 1015 | int32_t keyCode; |
| 1016 | int32_t scanCode; |
| 1017 | uint32_t flags; |
| 1018 | |
| 1019 | // computed hit box, specified in touch screen coords based on known display size |
| 1020 | int32_t hitLeft; |
| 1021 | int32_t hitTop; |
| 1022 | int32_t hitRight; |
| 1023 | int32_t hitBottom; |
| 1024 | |
| 1025 | inline bool isHit(int32_t x, int32_t y) const { |
| 1026 | return x >= hitLeft && x <= hitRight && y >= hitTop && y <= hitBottom; |
| 1027 | } |
| 1028 | }; |
| 1029 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1030 | // Input sources and device mode. |
| 1031 | uint32_t mSource; |
| 1032 | |
| 1033 | enum DeviceMode { |
| 1034 | DEVICE_MODE_DISABLED, // input is disabled |
| 1035 | DEVICE_MODE_DIRECT, // direct mapping (touchscreen) |
| 1036 | DEVICE_MODE_UNSCALED, // unscaled mapping (touchpad) |
| 1037 | DEVICE_MODE_POINTER, // pointer mapping (pointer) |
| 1038 | }; |
| 1039 | DeviceMode mDeviceMode; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 1040 | |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 1041 | // The reader's configuration. |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 1042 | InputReaderConfiguration mConfig; |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 1043 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1044 | // Immutable configuration parameters. |
| 1045 | struct Parameters { |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 1046 | enum DeviceType { |
| 1047 | DEVICE_TYPE_TOUCH_SCREEN, |
| 1048 | DEVICE_TYPE_TOUCH_PAD, |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1049 | DEVICE_TYPE_POINTER, |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 1050 | }; |
| 1051 | |
| 1052 | DeviceType deviceType; |
| 1053 | int32_t associatedDisplayId; |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 1054 | bool associatedDisplayIsExternal; |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 1055 | bool orientationAware; |
| 1056 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1057 | enum GestureMode { |
| 1058 | GESTURE_MODE_POINTER, |
| 1059 | GESTURE_MODE_SPOTS, |
| 1060 | }; |
| 1061 | GestureMode gestureMode; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1062 | } mParameters; |
| 1063 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1064 | // Immutable calibration parameters in parsed form. |
| 1065 | struct Calibration { |
Jeff Brown | a1f89ce | 2011-08-11 00:05:01 -0700 | [diff] [blame] | 1066 | // Size |
| 1067 | enum SizeCalibration { |
| 1068 | SIZE_CALIBRATION_DEFAULT, |
| 1069 | SIZE_CALIBRATION_NONE, |
| 1070 | SIZE_CALIBRATION_GEOMETRIC, |
| 1071 | SIZE_CALIBRATION_DIAMETER, |
| 1072 | SIZE_CALIBRATION_AREA, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1073 | }; |
| 1074 | |
Jeff Brown | a1f89ce | 2011-08-11 00:05:01 -0700 | [diff] [blame] | 1075 | SizeCalibration sizeCalibration; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1076 | |
Jeff Brown | a1f89ce | 2011-08-11 00:05:01 -0700 | [diff] [blame] | 1077 | bool haveSizeScale; |
| 1078 | float sizeScale; |
| 1079 | bool haveSizeBias; |
| 1080 | float sizeBias; |
| 1081 | bool haveSizeIsSummed; |
| 1082 | bool sizeIsSummed; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1083 | |
| 1084 | // Pressure |
| 1085 | enum PressureCalibration { |
| 1086 | PRESSURE_CALIBRATION_DEFAULT, |
| 1087 | PRESSURE_CALIBRATION_NONE, |
| 1088 | PRESSURE_CALIBRATION_PHYSICAL, |
| 1089 | PRESSURE_CALIBRATION_AMPLITUDE, |
| 1090 | }; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1091 | |
| 1092 | PressureCalibration pressureCalibration; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1093 | bool havePressureScale; |
| 1094 | float pressureScale; |
| 1095 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1096 | // Orientation |
| 1097 | enum OrientationCalibration { |
| 1098 | ORIENTATION_CALIBRATION_DEFAULT, |
| 1099 | ORIENTATION_CALIBRATION_NONE, |
| 1100 | ORIENTATION_CALIBRATION_INTERPOLATED, |
Jeff Brown | 517bb4c | 2011-01-14 19:09:23 -0800 | [diff] [blame] | 1101 | ORIENTATION_CALIBRATION_VECTOR, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1102 | }; |
| 1103 | |
| 1104 | OrientationCalibration orientationCalibration; |
Jeff Brown | 80fd47c | 2011-05-24 01:07:44 -0700 | [diff] [blame] | 1105 | |
| 1106 | // Distance |
| 1107 | enum DistanceCalibration { |
| 1108 | DISTANCE_CALIBRATION_DEFAULT, |
| 1109 | DISTANCE_CALIBRATION_NONE, |
| 1110 | DISTANCE_CALIBRATION_SCALED, |
| 1111 | }; |
| 1112 | |
| 1113 | DistanceCalibration distanceCalibration; |
| 1114 | bool haveDistanceScale; |
| 1115 | float distanceScale; |
Jeff Brown | a1f89ce | 2011-08-11 00:05:01 -0700 | [diff] [blame] | 1116 | |
| 1117 | inline void applySizeScaleAndBias(float* outSize) const { |
| 1118 | if (haveSizeScale) { |
| 1119 | *outSize *= sizeScale; |
| 1120 | } |
| 1121 | if (haveSizeBias) { |
| 1122 | *outSize += sizeBias; |
| 1123 | } |
| 1124 | } |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1125 | } mCalibration; |
| 1126 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1127 | // Raw pointer axis information from the driver. |
| 1128 | RawPointerAxes mRawPointerAxes; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1129 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1130 | // Raw pointer sample data. |
| 1131 | RawPointerData mCurrentRawPointerData; |
| 1132 | RawPointerData mLastRawPointerData; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1133 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1134 | // Cooked pointer sample data. |
| 1135 | CookedPointerData mCurrentCookedPointerData; |
| 1136 | CookedPointerData mLastCookedPointerData; |
| 1137 | |
| 1138 | // Button state. |
| 1139 | int32_t mCurrentButtonState; |
| 1140 | int32_t mLastButtonState; |
| 1141 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1142 | // Scroll state. |
| 1143 | int32_t mCurrentRawVScroll; |
| 1144 | int32_t mCurrentRawHScroll; |
| 1145 | |
| 1146 | // Id bits used to differentiate fingers, stylus and mouse tools. |
| 1147 | BitSet32 mCurrentFingerIdBits; // finger or unknown |
| 1148 | BitSet32 mLastFingerIdBits; |
| 1149 | BitSet32 mCurrentStylusIdBits; // stylus or eraser |
| 1150 | BitSet32 mLastStylusIdBits; |
| 1151 | BitSet32 mCurrentMouseIdBits; // mouse or lens |
| 1152 | BitSet32 mLastMouseIdBits; |
| 1153 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1154 | // True if we sent a HOVER_ENTER event. |
| 1155 | bool mSentHoverEnter; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1156 | |
| 1157 | // The time the primary pointer last went down. |
| 1158 | nsecs_t mDownTime; |
| 1159 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1160 | // The pointer controller, or null if the device is not a pointer. |
| 1161 | sp<PointerControllerInterface> mPointerController; |
| 1162 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1163 | Vector<VirtualKey> mVirtualKeys; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1164 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1165 | virtual void configureParameters(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 1166 | virtual void dumpParameters(String8& dump); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1167 | virtual void configureRawPointerAxes(); |
| 1168 | virtual void dumpRawPointerAxes(String8& dump); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1169 | virtual void configureSurface(nsecs_t when, bool* outResetNeeded); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1170 | virtual void dumpSurface(String8& dump); |
| 1171 | virtual void configureVirtualKeys(); |
| 1172 | virtual void dumpVirtualKeys(String8& dump); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 1173 | virtual void parseCalibration(); |
| 1174 | virtual void resolveCalibration(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 1175 | virtual void dumpCalibration(String8& dump); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1176 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1177 | virtual void syncTouch(nsecs_t when, bool* outHavePointerIds) = 0; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1178 | |
| 1179 | private: |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1180 | // The surface orientation and width and height set by configureSurface(). |
| 1181 | int32_t mSurfaceOrientation; |
| 1182 | int32_t mSurfaceWidth; |
| 1183 | int32_t mSurfaceHeight; |
| 1184 | |
| 1185 | // The associated display orientation and width and height set by configureSurface(). |
| 1186 | int32_t mAssociatedDisplayOrientation; |
| 1187 | int32_t mAssociatedDisplayWidth; |
| 1188 | int32_t mAssociatedDisplayHeight; |
| 1189 | |
| 1190 | // Translation and scaling factors, orientation-independent. |
| 1191 | float mXScale; |
| 1192 | float mXPrecision; |
| 1193 | |
| 1194 | float mYScale; |
| 1195 | float mYPrecision; |
| 1196 | |
| 1197 | float mGeometricScale; |
| 1198 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1199 | float mPressureScale; |
| 1200 | |
| 1201 | float mSizeScale; |
| 1202 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1203 | float mOrientationCenter; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1204 | float mOrientationScale; |
| 1205 | |
| 1206 | float mDistanceScale; |
| 1207 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1208 | bool mHaveTilt; |
| 1209 | float mTiltXCenter; |
| 1210 | float mTiltXScale; |
| 1211 | float mTiltYCenter; |
| 1212 | float mTiltYScale; |
| 1213 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1214 | // Oriented motion ranges for input device info. |
| 1215 | struct OrientedRanges { |
| 1216 | InputDeviceInfo::MotionRange x; |
| 1217 | InputDeviceInfo::MotionRange y; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1218 | InputDeviceInfo::MotionRange pressure; |
| 1219 | |
| 1220 | bool haveSize; |
| 1221 | InputDeviceInfo::MotionRange size; |
| 1222 | |
| 1223 | bool haveTouchSize; |
| 1224 | InputDeviceInfo::MotionRange touchMajor; |
| 1225 | InputDeviceInfo::MotionRange touchMinor; |
| 1226 | |
| 1227 | bool haveToolSize; |
| 1228 | InputDeviceInfo::MotionRange toolMajor; |
| 1229 | InputDeviceInfo::MotionRange toolMinor; |
| 1230 | |
| 1231 | bool haveOrientation; |
| 1232 | InputDeviceInfo::MotionRange orientation; |
| 1233 | |
| 1234 | bool haveDistance; |
| 1235 | InputDeviceInfo::MotionRange distance; |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1236 | |
| 1237 | bool haveTilt; |
| 1238 | InputDeviceInfo::MotionRange tilt; |
| 1239 | |
| 1240 | OrientedRanges() { |
| 1241 | clear(); |
| 1242 | } |
| 1243 | |
| 1244 | void clear() { |
| 1245 | haveSize = false; |
| 1246 | haveTouchSize = false; |
| 1247 | haveToolSize = false; |
| 1248 | haveOrientation = false; |
| 1249 | haveDistance = false; |
| 1250 | haveTilt = false; |
| 1251 | } |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1252 | } mOrientedRanges; |
| 1253 | |
| 1254 | // Oriented dimensions and precision. |
| 1255 | float mOrientedSurfaceWidth; |
| 1256 | float mOrientedSurfaceHeight; |
| 1257 | float mOrientedXPrecision; |
| 1258 | float mOrientedYPrecision; |
| 1259 | |
| 1260 | struct CurrentVirtualKeyState { |
| 1261 | bool down; |
| 1262 | bool ignored; |
| 1263 | nsecs_t downTime; |
| 1264 | int32_t keyCode; |
| 1265 | int32_t scanCode; |
| 1266 | } mCurrentVirtualKey; |
| 1267 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1268 | // Scale factor for gesture or mouse based pointer movements. |
| 1269 | float mPointerXMovementScale; |
| 1270 | float mPointerYMovementScale; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1271 | |
| 1272 | // Scale factor for gesture based zooming and other freeform motions. |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1273 | float mPointerXZoomScale; |
| 1274 | float mPointerYZoomScale; |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1275 | |
| 1276 | // The maximum swipe width. |
| 1277 | float mPointerGestureMaxSwipeWidth; |
| 1278 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1279 | struct PointerDistanceHeapElement { |
| 1280 | uint32_t currentPointerIndex : 8; |
| 1281 | uint32_t lastPointerIndex : 8; |
| 1282 | uint64_t distance : 48; // squared distance |
| 1283 | }; |
| 1284 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1285 | enum PointerUsage { |
| 1286 | POINTER_USAGE_NONE, |
| 1287 | POINTER_USAGE_GESTURES, |
| 1288 | POINTER_USAGE_STYLUS, |
| 1289 | POINTER_USAGE_MOUSE, |
| 1290 | }; |
| 1291 | PointerUsage mPointerUsage; |
| 1292 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1293 | struct PointerGesture { |
| 1294 | enum Mode { |
| 1295 | // No fingers, button is not pressed. |
| 1296 | // Nothing happening. |
| 1297 | NEUTRAL, |
| 1298 | |
| 1299 | // No fingers, button is not pressed. |
| 1300 | // Tap detected. |
| 1301 | // Emits DOWN and UP events at the pointer location. |
| 1302 | TAP, |
| 1303 | |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1304 | // Exactly one finger dragging following a tap. |
| 1305 | // Pointer follows the active finger. |
| 1306 | // Emits DOWN, MOVE and UP events at the pointer location. |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 1307 | // |
| 1308 | // Detect double-taps when the finger goes up while in TAP_DRAG mode. |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1309 | TAP_DRAG, |
| 1310 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1311 | // Button is pressed. |
| 1312 | // Pointer follows the active finger if there is one. Other fingers are ignored. |
| 1313 | // Emits DOWN, MOVE and UP events at the pointer location. |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1314 | BUTTON_CLICK_OR_DRAG, |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1315 | |
| 1316 | // Exactly one finger, button is not pressed. |
| 1317 | // Pointer follows the active finger. |
| 1318 | // Emits HOVER_MOVE events at the pointer location. |
Jeff Brown | 214eaf4 | 2011-05-26 19:17:02 -0700 | [diff] [blame] | 1319 | // |
| 1320 | // Detect taps when the finger goes up while in HOVER mode. |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1321 | HOVER, |
| 1322 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1323 | // Exactly two fingers but neither have moved enough to clearly indicate |
| 1324 | // whether a swipe or freeform gesture was intended. We consider the |
| 1325 | // pointer to be pressed so this enables clicking or long-pressing on buttons. |
| 1326 | // Pointer does not move. |
| 1327 | // Emits DOWN, MOVE and UP events with a single stationary pointer coordinate. |
| 1328 | PRESS, |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1329 | |
| 1330 | // Exactly two fingers moving in the same direction, button is not pressed. |
| 1331 | // Pointer does not move. |
| 1332 | // Emits DOWN, MOVE and UP events with a single pointer coordinate that |
| 1333 | // follows the midpoint between both fingers. |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1334 | SWIPE, |
| 1335 | |
| 1336 | // Two or more fingers moving in arbitrary directions, button is not pressed. |
| 1337 | // Pointer does not move. |
| 1338 | // Emits DOWN, POINTER_DOWN, MOVE, POINTER_UP and UP events that follow |
| 1339 | // each finger individually relative to the initial centroid of the finger. |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1340 | FREEFORM, |
| 1341 | |
| 1342 | // Waiting for quiet time to end before starting the next gesture. |
| 1343 | QUIET, |
| 1344 | }; |
| 1345 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1346 | // Time the first finger went down. |
| 1347 | nsecs_t firstTouchTime; |
| 1348 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1349 | // The active pointer id from the raw touch data. |
| 1350 | int32_t activeTouchId; // -1 if none |
| 1351 | |
| 1352 | // The active pointer id from the gesture last delivered to the application. |
| 1353 | int32_t activeGestureId; // -1 if none |
| 1354 | |
| 1355 | // Pointer coords and ids for the current and previous pointer gesture. |
| 1356 | Mode currentGestureMode; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1357 | BitSet32 currentGestureIdBits; |
| 1358 | uint32_t currentGestureIdToIndex[MAX_POINTER_ID + 1]; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1359 | PointerProperties currentGestureProperties[MAX_POINTERS]; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1360 | PointerCoords currentGestureCoords[MAX_POINTERS]; |
| 1361 | |
| 1362 | Mode lastGestureMode; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1363 | BitSet32 lastGestureIdBits; |
| 1364 | uint32_t lastGestureIdToIndex[MAX_POINTER_ID + 1]; |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1365 | PointerProperties lastGestureProperties[MAX_POINTERS]; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1366 | PointerCoords lastGestureCoords[MAX_POINTERS]; |
| 1367 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1368 | // Time the pointer gesture last went down. |
| 1369 | nsecs_t downTime; |
| 1370 | |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1371 | // Time when the pointer went down for a TAP. |
| 1372 | nsecs_t tapDownTime; |
| 1373 | |
| 1374 | // Time when the pointer went up for a TAP. |
| 1375 | nsecs_t tapUpTime; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1376 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1377 | // Location of initial tap. |
| 1378 | float tapX, tapY; |
| 1379 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1380 | // Time we started waiting for quiescence. |
| 1381 | nsecs_t quietTime; |
| 1382 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1383 | // Reference points for multitouch gestures. |
| 1384 | float referenceTouchX; // reference touch X/Y coordinates in surface units |
| 1385 | float referenceTouchY; |
| 1386 | float referenceGestureX; // reference gesture X/Y coordinates in pixels |
| 1387 | float referenceGestureY; |
| 1388 | |
Jeff Brown | 538881e | 2011-05-25 18:23:38 -0700 | [diff] [blame] | 1389 | // Distance that each pointer has traveled which has not yet been |
| 1390 | // subsumed into the reference gesture position. |
| 1391 | BitSet32 referenceIdBits; |
| 1392 | struct Delta { |
| 1393 | float dx, dy; |
| 1394 | }; |
| 1395 | Delta referenceDeltas[MAX_POINTER_ID + 1]; |
| 1396 | |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1397 | // Describes how touch ids are mapped to gesture ids for freeform gestures. |
| 1398 | uint32_t freeformTouchToGestureIdMap[MAX_POINTER_ID + 1]; |
| 1399 | |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1400 | // A velocity tracker for determining whether to switch active pointers during drags. |
| 1401 | VelocityTracker velocityTracker; |
| 1402 | |
| 1403 | void reset() { |
Jeff Brown | 2352b97 | 2011-04-12 22:39:53 -0700 | [diff] [blame] | 1404 | firstTouchTime = LLONG_MIN; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1405 | activeTouchId = -1; |
| 1406 | activeGestureId = -1; |
| 1407 | currentGestureMode = NEUTRAL; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1408 | currentGestureIdBits.clear(); |
| 1409 | lastGestureMode = NEUTRAL; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1410 | lastGestureIdBits.clear(); |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1411 | downTime = 0; |
| 1412 | velocityTracker.clear(); |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1413 | resetTap(); |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1414 | resetQuietTime(); |
| 1415 | } |
| 1416 | |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1417 | void resetTap() { |
| 1418 | tapDownTime = LLONG_MIN; |
| 1419 | tapUpTime = LLONG_MIN; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | void resetQuietTime() { |
| 1423 | quietTime = LLONG_MIN; |
| 1424 | } |
| 1425 | } mPointerGesture; |
| 1426 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1427 | struct PointerSimple { |
| 1428 | PointerCoords currentCoords; |
| 1429 | PointerProperties currentProperties; |
| 1430 | PointerCoords lastCoords; |
| 1431 | PointerProperties lastProperties; |
| 1432 | |
| 1433 | // True if the pointer is down. |
| 1434 | bool down; |
| 1435 | |
| 1436 | // True if the pointer is hovering. |
| 1437 | bool hovering; |
| 1438 | |
| 1439 | // Time the pointer last went down. |
| 1440 | nsecs_t downTime; |
| 1441 | |
| 1442 | void reset() { |
| 1443 | currentCoords.clear(); |
| 1444 | currentProperties.clear(); |
| 1445 | lastCoords.clear(); |
| 1446 | lastProperties.clear(); |
| 1447 | down = false; |
| 1448 | hovering = false; |
| 1449 | downTime = 0; |
| 1450 | } |
| 1451 | } mPointerSimple; |
| 1452 | |
| 1453 | // The pointer and scroll velocity controls. |
| 1454 | VelocityControl mPointerVelocityControl; |
| 1455 | VelocityControl mWheelXVelocityControl; |
| 1456 | VelocityControl mWheelYVelocityControl; |
| 1457 | |
| 1458 | void sync(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1459 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1460 | bool consumeRawTouches(nsecs_t when, uint32_t policyFlags); |
| 1461 | void dispatchVirtualKey(nsecs_t when, uint32_t policyFlags, |
| 1462 | int32_t keyEventAction, int32_t keyEventFlags); |
| 1463 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1464 | void dispatchTouches(nsecs_t when, uint32_t policyFlags); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1465 | void dispatchHoverExit(nsecs_t when, uint32_t policyFlags); |
| 1466 | void dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags); |
| 1467 | void cookPointerData(); |
| 1468 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1469 | void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage); |
| 1470 | void abortPointerUsage(nsecs_t when, uint32_t policyFlags); |
| 1471 | |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1472 | void dispatchPointerGestures(nsecs_t when, uint32_t policyFlags, bool isTimeout); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1473 | void abortPointerGestures(nsecs_t when, uint32_t policyFlags); |
Jeff Brown | 79ac969 | 2011-04-19 21:20:10 -0700 | [diff] [blame] | 1474 | bool preparePointerGestures(nsecs_t when, |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1475 | bool* outCancelPreviousGesture, bool* outFinishPreviousGesture, |
| 1476 | bool isTimeout); |
| 1477 | |
| 1478 | void dispatchPointerStylus(nsecs_t when, uint32_t policyFlags); |
| 1479 | void abortPointerStylus(nsecs_t when, uint32_t policyFlags); |
| 1480 | |
| 1481 | void dispatchPointerMouse(nsecs_t when, uint32_t policyFlags); |
| 1482 | void abortPointerMouse(nsecs_t when, uint32_t policyFlags); |
| 1483 | |
| 1484 | void dispatchPointerSimple(nsecs_t when, uint32_t policyFlags, |
| 1485 | bool down, bool hovering); |
| 1486 | void abortPointerSimple(nsecs_t when, uint32_t policyFlags); |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1487 | |
| 1488 | // Dispatches a motion event. |
| 1489 | // If the changedId is >= 0 and the action is POINTER_DOWN or POINTER_UP, the |
| 1490 | // method will take care of setting the index and transmuting the action to DOWN or UP |
| 1491 | // it is the first / last pointer to go down / up. |
| 1492 | void dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source, |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1493 | int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, |
| 1494 | int32_t edgeFlags, |
| 1495 | const PointerProperties* properties, const PointerCoords* coords, |
| 1496 | const uint32_t* idToIndex, BitSet32 idBits, |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1497 | int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime); |
| 1498 | |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1499 | // Updates pointer coords and properties for pointers with specified ids that have moved. |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1500 | // Returns true if any of them changed. |
Jeff Brown | fe9f8ab | 2011-05-06 18:20:01 -0700 | [diff] [blame] | 1501 | bool updateMovedPointers(const PointerProperties* inProperties, |
| 1502 | const PointerCoords* inCoords, const uint32_t* inIdToIndex, |
| 1503 | PointerProperties* outProperties, PointerCoords* outCoords, |
| 1504 | const uint32_t* outIdToIndex, BitSet32 idBits) const; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1505 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1506 | bool isPointInsideSurface(int32_t x, int32_t y); |
| 1507 | const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1508 | |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1509 | void assignPointerIds(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1510 | }; |
| 1511 | |
| 1512 | |
| 1513 | class SingleTouchInputMapper : public TouchInputMapper { |
| 1514 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 1515 | SingleTouchInputMapper(InputDevice* device); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1516 | virtual ~SingleTouchInputMapper(); |
| 1517 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1518 | virtual void reset(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1519 | virtual void process(const RawEvent* rawEvent); |
| 1520 | |
| 1521 | protected: |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1522 | virtual void syncTouch(nsecs_t when, bool* outHavePointerIds); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1523 | virtual void configureRawPointerAxes(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1524 | |
| 1525 | private: |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1526 | SingleTouchMotionAccumulator mSingleTouchMotionAccumulator; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1527 | }; |
| 1528 | |
| 1529 | |
| 1530 | class MultiTouchInputMapper : public TouchInputMapper { |
| 1531 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 1532 | MultiTouchInputMapper(InputDevice* device); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1533 | virtual ~MultiTouchInputMapper(); |
| 1534 | |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1535 | virtual void reset(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1536 | virtual void process(const RawEvent* rawEvent); |
| 1537 | |
| 1538 | protected: |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1539 | virtual void syncTouch(nsecs_t when, bool* outHavePointerIds); |
Jeff Brown | be1aa82 | 2011-07-27 16:04:54 -0700 | [diff] [blame] | 1540 | virtual void configureRawPointerAxes(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1541 | |
| 1542 | private: |
Jeff Brown | 49754db | 2011-07-01 17:37:58 -0700 | [diff] [blame] | 1543 | MultiTouchMotionAccumulator mMultiTouchMotionAccumulator; |
Jeff Brown | ace13b1 | 2011-03-09 17:39:48 -0800 | [diff] [blame] | 1544 | |
Jeff Brown | 6894a29 | 2011-07-01 17:59:27 -0700 | [diff] [blame] | 1545 | // Specifies the pointer id bits that are in use, and their associated tracking id. |
| 1546 | BitSet32 mPointerIdBits; |
| 1547 | int32_t mPointerTrackingIdMap[MAX_POINTER_ID + 1]; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 1548 | }; |
| 1549 | |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1550 | |
| 1551 | class JoystickInputMapper : public InputMapper { |
| 1552 | public: |
| 1553 | JoystickInputMapper(InputDevice* device); |
| 1554 | virtual ~JoystickInputMapper(); |
| 1555 | |
| 1556 | virtual uint32_t getSources(); |
| 1557 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
| 1558 | virtual void dump(String8& dump); |
Jeff Brown | 65fd251 | 2011-08-18 11:20:58 -0700 | [diff] [blame^] | 1559 | virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes); |
| 1560 | virtual void reset(nsecs_t when); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1561 | virtual void process(const RawEvent* rawEvent); |
| 1562 | |
| 1563 | private: |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1564 | struct Axis { |
| 1565 | RawAbsoluteAxisInfo rawAxisInfo; |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1566 | AxisInfo axisInfo; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1567 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1568 | bool explicitlyMapped; // true if the axis was explicitly assigned an axis id |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1569 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1570 | float scale; // scale factor from raw to normalized values |
| 1571 | float offset; // offset to add after scaling for normalization |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1572 | float highScale; // scale factor from raw to normalized values of high split |
| 1573 | float highOffset; // offset to add after scaling for normalization of high split |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1574 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1575 | float min; // normalized inclusive minimum |
| 1576 | float max; // normalized inclusive maximum |
| 1577 | float flat; // normalized flat region size |
| 1578 | float fuzz; // normalized error tolerance |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1579 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1580 | float filter; // filter out small variations of this size |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1581 | float currentValue; // current value |
| 1582 | float newValue; // most recent value |
| 1583 | float highCurrentValue; // current value of high split |
| 1584 | float highNewValue; // most recent value of high split |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1585 | |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1586 | void initialize(const RawAbsoluteAxisInfo& rawAxisInfo, const AxisInfo& axisInfo, |
| 1587 | bool explicitlyMapped, float scale, float offset, |
| 1588 | float highScale, float highOffset, |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1589 | float min, float max, float flat, float fuzz) { |
| 1590 | this->rawAxisInfo = rawAxisInfo; |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1591 | this->axisInfo = axisInfo; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1592 | this->explicitlyMapped = explicitlyMapped; |
| 1593 | this->scale = scale; |
| 1594 | this->offset = offset; |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1595 | this->highScale = highScale; |
| 1596 | this->highOffset = highOffset; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1597 | this->min = min; |
| 1598 | this->max = max; |
| 1599 | this->flat = flat; |
| 1600 | this->fuzz = fuzz; |
| 1601 | this->filter = 0; |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1602 | resetValue(); |
| 1603 | } |
| 1604 | |
| 1605 | void resetValue() { |
| 1606 | this->currentValue = 0; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1607 | this->newValue = 0; |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1608 | this->highCurrentValue = 0; |
| 1609 | this->highNewValue = 0; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1610 | } |
| 1611 | }; |
| 1612 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1613 | // Axes indexed by raw ABS_* axis index. |
| 1614 | KeyedVector<int32_t, Axis> mAxes; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1615 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1616 | void sync(nsecs_t when, bool force); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1617 | |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1618 | bool haveAxis(int32_t axisId); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1619 | void pruneAxes(bool ignoreExplicitlyMappedAxes); |
Jeff Brown | 8529745 | 2011-03-04 13:07:49 -0800 | [diff] [blame] | 1620 | bool filterAxes(bool force); |
| 1621 | |
| 1622 | static bool hasValueChangedSignificantly(float filter, |
| 1623 | float newValue, float currentValue, float min, float max); |
| 1624 | static bool hasMovedNearerToValueWithinFilteredRange(float filter, |
| 1625 | float newValue, float currentValue, float thresholdValue); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1626 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1627 | static bool isCenteredAxis(int32_t axis); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1628 | }; |
| 1629 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1630 | } // namespace android |
| 1631 | |
| 1632 | #endif // _UI_INPUT_READER_H |