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" |
| 21 | #include "InputDispatcher.h" |
| 22 | #include "PointerController.h" |
| 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 | /* |
| 43 | * Input reader policy interface. |
| 44 | * |
| 45 | * The input reader policy is used by the input reader to interact with the Window Manager |
| 46 | * and other system components. |
| 47 | * |
| 48 | * The actual implementation is partially supported by callbacks into the DVM |
| 49 | * via JNI. This interface is also mocked in the unit tests. |
| 50 | */ |
| 51 | class InputReaderPolicyInterface : public virtual RefBase { |
| 52 | protected: |
| 53 | InputReaderPolicyInterface() { } |
| 54 | virtual ~InputReaderPolicyInterface() { } |
| 55 | |
| 56 | public: |
| 57 | /* Display orientations. */ |
| 58 | enum { |
| 59 | ROTATION_0 = 0, |
| 60 | ROTATION_90 = 1, |
| 61 | ROTATION_180 = 2, |
| 62 | ROTATION_270 = 3 |
| 63 | }; |
| 64 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 65 | /* Gets information about the display with the specified id. |
| 66 | * Returns true if the display info is available, false otherwise. |
| 67 | */ |
| 68 | virtual bool getDisplayInfo(int32_t displayId, |
| 69 | int32_t* width, int32_t* height, int32_t* orientation) = 0; |
| 70 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 71 | /* Determines whether to turn on some hacks we have to improve the touch interaction with a |
| 72 | * certain device whose screen currently is not all that good. |
| 73 | */ |
| 74 | virtual bool filterTouchEvents() = 0; |
| 75 | |
| 76 | /* Determines whether to turn on some hacks to improve touch interaction with another device |
| 77 | * where touch coordinate data can get corrupted. |
| 78 | */ |
| 79 | virtual bool filterJumpyTouchEvents() = 0; |
| 80 | |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 81 | /* Gets the amount of time to disable virtual keys after the screen is touched |
| 82 | * in order to filter out accidental virtual key presses due to swiping gestures |
| 83 | * or taps near the edge of the display. May be 0 to disable the feature. |
| 84 | */ |
| 85 | virtual nsecs_t getVirtualKeyQuietTime() = 0; |
| 86 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 87 | /* Gets the excluded device names for the platform. */ |
| 88 | virtual void getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames) = 0; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 89 | |
| 90 | /* Gets a pointer controller associated with the specified cursor device (ie. a mouse). */ |
| 91 | virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId) = 0; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | |
| 95 | /* Processes raw input events and sends cooked event data to an input dispatcher. */ |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 96 | class InputReaderInterface : public virtual RefBase { |
| 97 | protected: |
| 98 | InputReaderInterface() { } |
| 99 | virtual ~InputReaderInterface() { } |
| 100 | |
| 101 | public: |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 102 | /* Dumps the state of the input reader. |
| 103 | * |
| 104 | * This method may be called on any thread (usually by the input manager). */ |
| 105 | virtual void dump(String8& dump) = 0; |
| 106 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 107 | /* Runs a single iteration of the processing loop. |
| 108 | * Nominally reads and processes one incoming message from the EventHub. |
| 109 | * |
| 110 | * This method should be called on the input reader thread. |
| 111 | */ |
| 112 | virtual void loopOnce() = 0; |
| 113 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 114 | /* Gets the current input device configuration. |
| 115 | * |
| 116 | * This method may be called on any thread (usually by the input manager). |
| 117 | */ |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 118 | virtual void getInputConfiguration(InputConfiguration* outConfiguration) = 0; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 119 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 120 | /* Gets information about the specified input device. |
| 121 | * Returns OK if the device information was obtained or NAME_NOT_FOUND if there |
| 122 | * was no such device. |
| 123 | * |
| 124 | * 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] | 125 | */ |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 126 | virtual status_t getInputDeviceInfo(int32_t deviceId, InputDeviceInfo* outDeviceInfo) = 0; |
| 127 | |
| 128 | /* Gets the list of all registered device ids. */ |
| 129 | virtual void getInputDeviceIds(Vector<int32_t>& outDeviceIds) = 0; |
| 130 | |
| 131 | /* Query current input state. */ |
| 132 | virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, |
| 133 | int32_t scanCode) = 0; |
| 134 | virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, |
| 135 | int32_t keyCode) = 0; |
| 136 | virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, |
| 137 | int32_t sw) = 0; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 138 | |
| 139 | /* Determine whether physical keys exist for the given framework-domain key codes. */ |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 140 | virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, |
| 141 | size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) = 0; |
| 142 | }; |
| 143 | |
| 144 | |
| 145 | /* Internal interface used by individual input devices to access global input device state |
| 146 | * and parameters maintained by the input reader. |
| 147 | */ |
| 148 | class InputReaderContext { |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 149 | public: |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 150 | InputReaderContext() { } |
| 151 | virtual ~InputReaderContext() { } |
| 152 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 153 | virtual void updateGlobalMetaState() = 0; |
| 154 | virtual int32_t getGlobalMetaState() = 0; |
| 155 | |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 156 | virtual void disableVirtualKeysUntil(nsecs_t time) = 0; |
| 157 | virtual bool shouldDropVirtualKey(nsecs_t now, |
| 158 | InputDevice* device, int32_t keyCode, int32_t scanCode) = 0; |
| 159 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame^] | 160 | virtual void fadePointer() = 0; |
| 161 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 162 | virtual InputReaderPolicyInterface* getPolicy() = 0; |
| 163 | virtual InputDispatcherInterface* getDispatcher() = 0; |
| 164 | virtual EventHubInterface* getEventHub() = 0; |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 165 | }; |
| 166 | |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 167 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 168 | /* The input reader reads raw event data from the event hub and processes it into input events |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 169 | * that it sends to the input dispatcher. Some functions of the input reader, such as early |
| 170 | * event filtering in low power states, are controlled by a separate policy object. |
| 171 | * |
| 172 | * IMPORTANT INVARIANT: |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 173 | * Because the policy and dispatcher can potentially block or cause re-entrance into |
| 174 | * the input reader, the input reader never calls into other components while holding |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 175 | * an exclusive internal lock whenever re-entrance can happen. |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 176 | */ |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 177 | class InputReader : public InputReaderInterface, protected InputReaderContext { |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 178 | public: |
| 179 | InputReader(const sp<EventHubInterface>& eventHub, |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 180 | const sp<InputReaderPolicyInterface>& policy, |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 181 | const sp<InputDispatcherInterface>& dispatcher); |
| 182 | virtual ~InputReader(); |
| 183 | |
Jeff Brown | b88102f | 2010-09-08 11:49:43 -0700 | [diff] [blame] | 184 | virtual void dump(String8& dump); |
| 185 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 186 | virtual void loopOnce(); |
| 187 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 188 | virtual void getInputConfiguration(InputConfiguration* outConfiguration); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 189 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 190 | virtual status_t getInputDeviceInfo(int32_t deviceId, InputDeviceInfo* outDeviceInfo); |
| 191 | virtual void getInputDeviceIds(Vector<int32_t>& outDeviceIds); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 192 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 193 | virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, |
| 194 | int32_t scanCode); |
| 195 | virtual int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, |
| 196 | int32_t keyCode); |
| 197 | virtual int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, |
| 198 | int32_t sw); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 199 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 200 | virtual bool hasKeys(int32_t deviceId, uint32_t sourceMask, |
| 201 | size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 202 | |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 203 | protected: |
| 204 | // These methods are protected virtual so they can be overridden and instrumented |
| 205 | // by test cases. |
| 206 | virtual InputDevice* createDevice(int32_t deviceId, const String8& name, uint32_t classes); |
| 207 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 208 | private: |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 209 | sp<EventHubInterface> mEventHub; |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 210 | sp<InputReaderPolicyInterface> mPolicy; |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 211 | sp<InputDispatcherInterface> mDispatcher; |
| 212 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 213 | virtual InputReaderPolicyInterface* getPolicy() { return mPolicy.get(); } |
| 214 | virtual InputDispatcherInterface* getDispatcher() { return mDispatcher.get(); } |
| 215 | virtual EventHubInterface* getEventHub() { return mEventHub.get(); } |
| 216 | |
| 217 | // This reader/writer lock guards the list of input devices. |
| 218 | // The writer lock must be held whenever the list of input devices is modified |
| 219 | // and then promptly released. |
| 220 | // The reader lock must be held whenever the list of input devices is traversed or an |
| 221 | // input device in the list is accessed. |
| 222 | // This lock only protects the registry and prevents inadvertent deletion of device objects |
| 223 | // that are in use. Individual devices are responsible for guarding their own internal state |
| 224 | // as needed for concurrent operation. |
| 225 | RWLock mDeviceRegistryLock; |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 226 | KeyedVector<int32_t, InputDevice*> mDevices; |
| 227 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 228 | // low-level input event decoding and device management |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 229 | void process(const RawEvent* rawEvent); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 230 | |
Jeff Brown | 7342bb9 | 2010-10-01 18:55:43 -0700 | [diff] [blame] | 231 | void addDevice(int32_t deviceId); |
| 232 | void removeDevice(int32_t deviceId); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 233 | void configureExcludedDevices(); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 234 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 235 | void consumeEvent(const RawEvent* rawEvent); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 236 | |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 237 | void handleConfigurationChanged(nsecs_t when); |
Jeff Brown | 9c3cda0 | 2010-06-15 01:31:58 -0700 | [diff] [blame] | 238 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 239 | // state management for all devices |
| 240 | Mutex mStateLock; |
| 241 | |
| 242 | int32_t mGlobalMetaState; |
| 243 | virtual void updateGlobalMetaState(); |
| 244 | virtual int32_t getGlobalMetaState(); |
| 245 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame^] | 246 | virtual void fadePointer(); |
| 247 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 248 | InputConfiguration mInputConfiguration; |
| 249 | void updateInputConfiguration(); |
| 250 | |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 251 | nsecs_t mDisableVirtualKeysTimeout; |
| 252 | virtual void disableVirtualKeysUntil(nsecs_t time); |
| 253 | virtual bool shouldDropVirtualKey(nsecs_t now, |
| 254 | InputDevice* device, int32_t keyCode, int32_t scanCode); |
| 255 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 256 | // state queries |
| 257 | typedef int32_t (InputDevice::*GetStateFunc)(uint32_t sourceMask, int32_t code); |
| 258 | int32_t getState(int32_t deviceId, uint32_t sourceMask, int32_t code, |
| 259 | GetStateFunc getStateFunc); |
| 260 | bool markSupportedKeyCodes(int32_t deviceId, uint32_t sourceMask, size_t numCodes, |
| 261 | const int32_t* keyCodes, uint8_t* outFlags); |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 262 | }; |
| 263 | |
| 264 | |
| 265 | /* Reads raw events from the event hub and processes them, endlessly. */ |
| 266 | class InputReaderThread : public Thread { |
| 267 | public: |
| 268 | InputReaderThread(const sp<InputReaderInterface>& reader); |
| 269 | virtual ~InputReaderThread(); |
| 270 | |
| 271 | private: |
| 272 | sp<InputReaderInterface> mReader; |
| 273 | |
| 274 | virtual bool threadLoop(); |
| 275 | }; |
| 276 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 277 | |
| 278 | /* Represents the state of a single input device. */ |
| 279 | class InputDevice { |
| 280 | public: |
| 281 | InputDevice(InputReaderContext* context, int32_t id, const String8& name); |
| 282 | ~InputDevice(); |
| 283 | |
| 284 | inline InputReaderContext* getContext() { return mContext; } |
| 285 | inline int32_t getId() { return mId; } |
| 286 | inline const String8& getName() { return mName; } |
| 287 | inline uint32_t getSources() { return mSources; } |
| 288 | |
| 289 | inline bool isIgnored() { return mMappers.isEmpty(); } |
| 290 | |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 291 | void dump(String8& dump); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 292 | void addMapper(InputMapper* mapper); |
| 293 | void configure(); |
| 294 | void reset(); |
| 295 | void process(const RawEvent* rawEvent); |
| 296 | |
| 297 | void getDeviceInfo(InputDeviceInfo* outDeviceInfo); |
| 298 | int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 299 | int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 300 | int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode); |
| 301 | bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 302 | const int32_t* keyCodes, uint8_t* outFlags); |
| 303 | |
| 304 | int32_t getMetaState(); |
| 305 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame^] | 306 | void fadePointer(); |
| 307 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 308 | inline const PropertyMap& getConfiguration() { |
| 309 | return mConfiguration; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 312 | private: |
| 313 | InputReaderContext* mContext; |
| 314 | int32_t mId; |
| 315 | |
| 316 | Vector<InputMapper*> mMappers; |
| 317 | |
| 318 | String8 mName; |
| 319 | uint32_t mSources; |
| 320 | |
| 321 | typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code); |
| 322 | int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 323 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 324 | PropertyMap mConfiguration; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | |
| 328 | /* An input mapper transforms raw input events into cooked event data. |
| 329 | * A single input device can have multiple associated input mappers in order to interpret |
| 330 | * different classes of events. |
| 331 | */ |
| 332 | class InputMapper { |
| 333 | public: |
| 334 | InputMapper(InputDevice* device); |
| 335 | virtual ~InputMapper(); |
| 336 | |
| 337 | inline InputDevice* getDevice() { return mDevice; } |
| 338 | inline int32_t getDeviceId() { return mDevice->getId(); } |
| 339 | inline const String8 getDeviceName() { return mDevice->getName(); } |
| 340 | inline InputReaderContext* getContext() { return mContext; } |
| 341 | inline InputReaderPolicyInterface* getPolicy() { return mContext->getPolicy(); } |
| 342 | inline InputDispatcherInterface* getDispatcher() { return mContext->getDispatcher(); } |
| 343 | inline EventHubInterface* getEventHub() { return mContext->getEventHub(); } |
| 344 | |
| 345 | virtual uint32_t getSources() = 0; |
| 346 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 347 | virtual void dump(String8& dump); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 348 | virtual void configure(); |
| 349 | virtual void reset(); |
| 350 | virtual void process(const RawEvent* rawEvent) = 0; |
| 351 | |
| 352 | virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 353 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 354 | virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode); |
| 355 | virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 356 | const int32_t* keyCodes, uint8_t* outFlags); |
| 357 | |
| 358 | virtual int32_t getMetaState(); |
| 359 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame^] | 360 | virtual void fadePointer(); |
| 361 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 362 | protected: |
| 363 | InputDevice* mDevice; |
| 364 | InputReaderContext* mContext; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 365 | |
| 366 | static void dumpRawAbsoluteAxisInfo(String8& dump, |
| 367 | const RawAbsoluteAxisInfo& axis, const char* name); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 368 | }; |
| 369 | |
| 370 | |
| 371 | class SwitchInputMapper : public InputMapper { |
| 372 | public: |
| 373 | SwitchInputMapper(InputDevice* device); |
| 374 | virtual ~SwitchInputMapper(); |
| 375 | |
| 376 | virtual uint32_t getSources(); |
| 377 | virtual void process(const RawEvent* rawEvent); |
| 378 | |
| 379 | virtual int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode); |
| 380 | |
| 381 | private: |
| 382 | void processSwitch(nsecs_t when, int32_t switchCode, int32_t switchValue); |
| 383 | }; |
| 384 | |
| 385 | |
| 386 | class KeyboardInputMapper : public InputMapper { |
| 387 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 388 | KeyboardInputMapper(InputDevice* device, uint32_t sources, int32_t keyboardType); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 389 | virtual ~KeyboardInputMapper(); |
| 390 | |
| 391 | virtual uint32_t getSources(); |
| 392 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 393 | virtual void dump(String8& dump); |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 394 | virtual void configure(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 395 | virtual void reset(); |
| 396 | virtual void process(const RawEvent* rawEvent); |
| 397 | |
| 398 | virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 399 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 400 | virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 401 | const int32_t* keyCodes, uint8_t* outFlags); |
| 402 | |
| 403 | virtual int32_t getMetaState(); |
| 404 | |
| 405 | private: |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 406 | Mutex mLock; |
| 407 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 408 | struct KeyDown { |
| 409 | int32_t keyCode; |
| 410 | int32_t scanCode; |
| 411 | }; |
| 412 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 413 | uint32_t mSources; |
| 414 | int32_t mKeyboardType; |
| 415 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 416 | // Immutable configuration parameters. |
| 417 | struct Parameters { |
| 418 | int32_t associatedDisplayId; |
| 419 | bool orientationAware; |
| 420 | } mParameters; |
| 421 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 422 | struct LockedState { |
| 423 | Vector<KeyDown> keyDowns; // keys that are down |
| 424 | int32_t metaState; |
| 425 | nsecs_t downTime; // time of most recent key down |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 426 | |
| 427 | struct LedState { |
| 428 | bool avail; // led is available |
| 429 | bool on; // we think the led is currently on |
| 430 | }; |
| 431 | LedState capsLockLedState; |
| 432 | LedState numLockLedState; |
| 433 | LedState scrollLockLedState; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 434 | } mLocked; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 435 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 436 | void initializeLocked(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 437 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 438 | void configureParameters(); |
| 439 | void dumpParameters(String8& dump); |
| 440 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 441 | bool isKeyboardOrGamepadKey(int32_t scanCode); |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 442 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 443 | void processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode, |
| 444 | uint32_t policyFlags); |
| 445 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 446 | ssize_t findKeyDownLocked(int32_t scanCode); |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 447 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 448 | void resetLedStateLocked(); |
| 449 | void initializeLedStateLocked(LockedState::LedState& ledState, int32_t led); |
Jeff Brown | 497a92c | 2010-09-12 17:55:08 -0700 | [diff] [blame] | 450 | void updateLedStateLocked(bool reset); |
| 451 | void updateLedStateForModifierLocked(LockedState::LedState& ledState, int32_t led, |
| 452 | int32_t modifier, bool reset); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 453 | }; |
| 454 | |
| 455 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 456 | class CursorInputMapper : public InputMapper { |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 457 | public: |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 458 | CursorInputMapper(InputDevice* device); |
| 459 | virtual ~CursorInputMapper(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 460 | |
| 461 | virtual uint32_t getSources(); |
| 462 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 463 | virtual void dump(String8& dump); |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 464 | virtual void configure(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 465 | virtual void reset(); |
| 466 | virtual void process(const RawEvent* rawEvent); |
| 467 | |
Jeff Brown | c3fc2d0 | 2010-08-10 15:47:53 -0700 | [diff] [blame] | 468 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 469 | |
Jeff Brown | 05dc66a | 2011-03-02 14:41:58 -0800 | [diff] [blame^] | 470 | virtual void fadePointer(); |
| 471 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 472 | private: |
| 473 | // Amount that trackball needs to move in order to generate a key event. |
| 474 | static const int32_t TRACKBALL_MOVEMENT_THRESHOLD = 6; |
| 475 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 476 | Mutex mLock; |
| 477 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 478 | // Immutable configuration parameters. |
| 479 | struct Parameters { |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 480 | enum Mode { |
| 481 | MODE_POINTER, |
| 482 | MODE_NAVIGATION, |
| 483 | }; |
| 484 | |
| 485 | Mode mode; |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 486 | int32_t associatedDisplayId; |
| 487 | bool orientationAware; |
| 488 | } mParameters; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 489 | |
| 490 | struct Accumulator { |
| 491 | enum { |
| 492 | FIELD_BTN_MOUSE = 1, |
| 493 | FIELD_REL_X = 2, |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 494 | FIELD_REL_Y = 4, |
| 495 | FIELD_REL_WHEEL = 8, |
| 496 | FIELD_REL_HWHEEL = 16, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 497 | }; |
| 498 | |
| 499 | uint32_t fields; |
| 500 | |
| 501 | bool btnMouse; |
| 502 | int32_t relX; |
| 503 | int32_t relY; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 504 | int32_t relWheel; |
| 505 | int32_t relHWheel; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 506 | |
| 507 | inline void clear() { |
| 508 | fields = 0; |
| 509 | } |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 510 | } mAccumulator; |
| 511 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 512 | int32_t mSources; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 513 | float mXScale; |
| 514 | float mYScale; |
| 515 | float mXPrecision; |
| 516 | float mYPrecision; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 517 | |
| 518 | bool mHaveVWheel; |
| 519 | bool mHaveHWheel; |
| 520 | float mVWheelScale; |
| 521 | float mHWheelScale; |
| 522 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 523 | sp<PointerControllerInterface> mPointerController; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 524 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 525 | struct LockedState { |
| 526 | bool down; |
| 527 | nsecs_t downTime; |
| 528 | } mLocked; |
| 529 | |
| 530 | void initializeLocked(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 531 | |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 532 | void configureParameters(); |
| 533 | void dumpParameters(String8& dump); |
| 534 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 535 | void sync(nsecs_t when); |
| 536 | }; |
| 537 | |
| 538 | |
| 539 | class TouchInputMapper : public InputMapper { |
| 540 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 541 | TouchInputMapper(InputDevice* device); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 542 | virtual ~TouchInputMapper(); |
| 543 | |
| 544 | virtual uint32_t getSources(); |
| 545 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 546 | virtual void dump(String8& dump); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 547 | virtual void configure(); |
| 548 | virtual void reset(); |
| 549 | |
| 550 | virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode); |
| 551 | virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode); |
| 552 | virtual bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, |
| 553 | const int32_t* keyCodes, uint8_t* outFlags); |
| 554 | |
| 555 | protected: |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 556 | Mutex mLock; |
| 557 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 558 | struct VirtualKey { |
| 559 | int32_t keyCode; |
| 560 | int32_t scanCode; |
| 561 | uint32_t flags; |
| 562 | |
| 563 | // computed hit box, specified in touch screen coords based on known display size |
| 564 | int32_t hitLeft; |
| 565 | int32_t hitTop; |
| 566 | int32_t hitRight; |
| 567 | int32_t hitBottom; |
| 568 | |
| 569 | inline bool isHit(int32_t x, int32_t y) const { |
| 570 | return x >= hitLeft && x <= hitRight && y >= hitTop && y <= hitBottom; |
| 571 | } |
| 572 | }; |
| 573 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 574 | // Raw data for a single pointer. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 575 | struct PointerData { |
| 576 | uint32_t id; |
| 577 | int32_t x; |
| 578 | int32_t y; |
| 579 | int32_t pressure; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 580 | int32_t touchMajor; |
| 581 | int32_t touchMinor; |
| 582 | int32_t toolMajor; |
| 583 | int32_t toolMinor; |
| 584 | int32_t orientation; |
Jeff Brown | c3db858 | 2010-10-20 15:33:38 -0700 | [diff] [blame] | 585 | |
| 586 | inline bool operator== (const PointerData& other) const { |
| 587 | return id == other.id |
| 588 | && x == other.x |
| 589 | && y == other.y |
| 590 | && pressure == other.pressure |
| 591 | && touchMajor == other.touchMajor |
| 592 | && touchMinor == other.touchMinor |
| 593 | && toolMajor == other.toolMajor |
| 594 | && toolMinor == other.toolMinor |
| 595 | && orientation == other.orientation; |
| 596 | } |
| 597 | inline bool operator!= (const PointerData& other) const { |
| 598 | return !(*this == other); |
| 599 | } |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 600 | }; |
| 601 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 602 | // Raw data for a collection of pointers including a pointer id mapping table. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 603 | struct TouchData { |
| 604 | uint32_t pointerCount; |
| 605 | PointerData pointers[MAX_POINTERS]; |
| 606 | BitSet32 idBits; |
| 607 | uint32_t idToIndex[MAX_POINTER_ID + 1]; |
| 608 | |
| 609 | void copyFrom(const TouchData& other) { |
| 610 | pointerCount = other.pointerCount; |
| 611 | idBits = other.idBits; |
| 612 | |
| 613 | for (uint32_t i = 0; i < pointerCount; i++) { |
| 614 | pointers[i] = other.pointers[i]; |
Jeff Brown | 9e2ad36 | 2010-07-30 19:20:11 -0700 | [diff] [blame] | 615 | |
| 616 | int id = pointers[i].id; |
| 617 | idToIndex[id] = other.idToIndex[id]; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 618 | } |
| 619 | } |
| 620 | |
| 621 | inline void clear() { |
| 622 | pointerCount = 0; |
| 623 | idBits.clear(); |
| 624 | } |
| 625 | }; |
| 626 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 627 | // Input sources supported by the device. |
| 628 | int32_t mSources; |
| 629 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 630 | // Immutable configuration parameters. |
| 631 | struct Parameters { |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 632 | enum DeviceType { |
| 633 | DEVICE_TYPE_TOUCH_SCREEN, |
| 634 | DEVICE_TYPE_TOUCH_PAD, |
| 635 | }; |
| 636 | |
| 637 | DeviceType deviceType; |
| 638 | int32_t associatedDisplayId; |
| 639 | bool orientationAware; |
| 640 | |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 641 | bool useBadTouchFilter; |
| 642 | bool useJumpyTouchFilter; |
| 643 | bool useAveragingTouchFilter; |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 644 | nsecs_t virtualKeyQuietTime; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 645 | } mParameters; |
| 646 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 647 | // Immutable calibration parameters in parsed form. |
| 648 | struct Calibration { |
Jeff Brown | 511ee5f | 2010-10-18 13:32:20 -0700 | [diff] [blame] | 649 | // Position |
| 650 | bool haveXOrigin; |
| 651 | int32_t xOrigin; |
| 652 | bool haveYOrigin; |
| 653 | int32_t yOrigin; |
| 654 | bool haveXScale; |
| 655 | float xScale; |
| 656 | bool haveYScale; |
| 657 | float yScale; |
| 658 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 659 | // Touch Size |
| 660 | enum TouchSizeCalibration { |
| 661 | TOUCH_SIZE_CALIBRATION_DEFAULT, |
| 662 | TOUCH_SIZE_CALIBRATION_NONE, |
| 663 | TOUCH_SIZE_CALIBRATION_GEOMETRIC, |
| 664 | TOUCH_SIZE_CALIBRATION_PRESSURE, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 665 | }; |
| 666 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 667 | TouchSizeCalibration touchSizeCalibration; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 668 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 669 | // Tool Size |
| 670 | enum ToolSizeCalibration { |
| 671 | TOOL_SIZE_CALIBRATION_DEFAULT, |
| 672 | TOOL_SIZE_CALIBRATION_NONE, |
| 673 | TOOL_SIZE_CALIBRATION_GEOMETRIC, |
| 674 | TOOL_SIZE_CALIBRATION_LINEAR, |
| 675 | TOOL_SIZE_CALIBRATION_AREA, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 676 | }; |
| 677 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 678 | ToolSizeCalibration toolSizeCalibration; |
| 679 | bool haveToolSizeLinearScale; |
| 680 | float toolSizeLinearScale; |
| 681 | bool haveToolSizeLinearBias; |
| 682 | float toolSizeLinearBias; |
| 683 | bool haveToolSizeAreaScale; |
| 684 | float toolSizeAreaScale; |
| 685 | bool haveToolSizeAreaBias; |
| 686 | float toolSizeAreaBias; |
| 687 | bool haveToolSizeIsSummed; |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 688 | bool toolSizeIsSummed; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 689 | |
| 690 | // Pressure |
| 691 | enum PressureCalibration { |
| 692 | PRESSURE_CALIBRATION_DEFAULT, |
| 693 | PRESSURE_CALIBRATION_NONE, |
| 694 | PRESSURE_CALIBRATION_PHYSICAL, |
| 695 | PRESSURE_CALIBRATION_AMPLITUDE, |
| 696 | }; |
| 697 | enum PressureSource { |
| 698 | PRESSURE_SOURCE_DEFAULT, |
| 699 | PRESSURE_SOURCE_PRESSURE, |
| 700 | PRESSURE_SOURCE_TOUCH, |
| 701 | }; |
| 702 | |
| 703 | PressureCalibration pressureCalibration; |
| 704 | PressureSource pressureSource; |
| 705 | bool havePressureScale; |
| 706 | float pressureScale; |
| 707 | |
| 708 | // Size |
| 709 | enum SizeCalibration { |
| 710 | SIZE_CALIBRATION_DEFAULT, |
| 711 | SIZE_CALIBRATION_NONE, |
| 712 | SIZE_CALIBRATION_NORMALIZED, |
| 713 | }; |
| 714 | |
| 715 | SizeCalibration sizeCalibration; |
| 716 | |
| 717 | // Orientation |
| 718 | enum OrientationCalibration { |
| 719 | ORIENTATION_CALIBRATION_DEFAULT, |
| 720 | ORIENTATION_CALIBRATION_NONE, |
| 721 | ORIENTATION_CALIBRATION_INTERPOLATED, |
Jeff Brown | 517bb4c | 2011-01-14 19:09:23 -0800 | [diff] [blame] | 722 | ORIENTATION_CALIBRATION_VECTOR, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 723 | }; |
| 724 | |
| 725 | OrientationCalibration orientationCalibration; |
| 726 | } mCalibration; |
| 727 | |
| 728 | // Raw axis information from the driver. |
| 729 | struct RawAxes { |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 730 | RawAbsoluteAxisInfo x; |
| 731 | RawAbsoluteAxisInfo y; |
| 732 | RawAbsoluteAxisInfo pressure; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 733 | RawAbsoluteAxisInfo touchMajor; |
| 734 | RawAbsoluteAxisInfo touchMinor; |
| 735 | RawAbsoluteAxisInfo toolMajor; |
| 736 | RawAbsoluteAxisInfo toolMinor; |
| 737 | RawAbsoluteAxisInfo orientation; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 738 | } mRawAxes; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 739 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 740 | // Current and previous touch sample data. |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 741 | TouchData mCurrentTouch; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 742 | TouchData mLastTouch; |
| 743 | |
| 744 | // The time the primary pointer last went down. |
| 745 | nsecs_t mDownTime; |
| 746 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 747 | struct LockedState { |
| 748 | Vector<VirtualKey> virtualKeys; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 749 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 750 | // The surface orientation and width and height set by configureSurfaceLocked(). |
| 751 | int32_t surfaceOrientation; |
| 752 | int32_t surfaceWidth, surfaceHeight; |
| 753 | |
| 754 | // Translation and scaling factors, orientation-independent. |
| 755 | int32_t xOrigin; |
| 756 | float xScale; |
| 757 | float xPrecision; |
| 758 | |
| 759 | int32_t yOrigin; |
| 760 | float yScale; |
| 761 | float yPrecision; |
| 762 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 763 | float geometricScale; |
| 764 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 765 | float toolSizeLinearScale; |
| 766 | float toolSizeLinearBias; |
| 767 | float toolSizeAreaScale; |
| 768 | float toolSizeAreaBias; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 769 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 770 | float pressureScale; |
| 771 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 772 | float sizeScale; |
| 773 | |
| 774 | float orientationScale; |
| 775 | |
| 776 | // Oriented motion ranges for input device info. |
| 777 | struct OrientedRanges { |
| 778 | InputDeviceInfo::MotionRange x; |
| 779 | InputDeviceInfo::MotionRange y; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 780 | |
| 781 | bool havePressure; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 782 | InputDeviceInfo::MotionRange pressure; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 783 | |
| 784 | bool haveSize; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 785 | InputDeviceInfo::MotionRange size; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 786 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 787 | bool haveTouchSize; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 788 | InputDeviceInfo::MotionRange touchMajor; |
| 789 | InputDeviceInfo::MotionRange touchMinor; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 790 | |
Jeff Brown | c6d282b | 2010-10-14 21:42:15 -0700 | [diff] [blame] | 791 | bool haveToolSize; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 792 | InputDeviceInfo::MotionRange toolMajor; |
| 793 | InputDeviceInfo::MotionRange toolMinor; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 794 | |
| 795 | bool haveOrientation; |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 796 | InputDeviceInfo::MotionRange orientation; |
| 797 | } orientedRanges; |
| 798 | |
| 799 | // Oriented dimensions and precision. |
| 800 | float orientedSurfaceWidth, orientedSurfaceHeight; |
| 801 | float orientedXPrecision, orientedYPrecision; |
| 802 | |
| 803 | struct CurrentVirtualKeyState { |
| 804 | bool down; |
| 805 | nsecs_t downTime; |
| 806 | int32_t keyCode; |
| 807 | int32_t scanCode; |
| 808 | } currentVirtualKey; |
| 809 | } mLocked; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 810 | |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 811 | virtual void configureParameters(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 812 | virtual void dumpParameters(String8& dump); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 813 | virtual void configureRawAxes(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 814 | virtual void dumpRawAxes(String8& dump); |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 815 | virtual bool configureSurfaceLocked(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 816 | virtual void dumpSurfaceLocked(String8& dump); |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 817 | virtual void configureVirtualKeysLocked(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 818 | virtual void dumpVirtualKeysLocked(String8& dump); |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 819 | virtual void parseCalibration(); |
| 820 | virtual void resolveCalibration(); |
Jeff Brown | ef3d7e8 | 2010-09-30 14:33:04 -0700 | [diff] [blame] | 821 | virtual void dumpCalibration(String8& dump); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 822 | |
| 823 | enum TouchResult { |
| 824 | // Dispatch the touch normally. |
| 825 | DISPATCH_TOUCH, |
| 826 | // Do not dispatch the touch, but keep tracking the current stroke. |
| 827 | SKIP_TOUCH, |
| 828 | // Do not dispatch the touch, and drop all information associated with the current stoke |
| 829 | // so the next movement will appear as a new down. |
| 830 | DROP_STROKE |
| 831 | }; |
| 832 | |
| 833 | void syncTouch(nsecs_t when, bool havePointerIds); |
| 834 | |
| 835 | private: |
| 836 | /* Maximum number of historical samples to average. */ |
| 837 | static const uint32_t AVERAGING_HISTORY_SIZE = 5; |
| 838 | |
| 839 | /* Slop distance for jumpy pointer detection. |
| 840 | * The vertical range of the screen divided by this is our epsilon value. */ |
| 841 | static const uint32_t JUMPY_EPSILON_DIVISOR = 212; |
| 842 | |
| 843 | /* Number of jumpy points to drop for touchscreens that need it. */ |
| 844 | static const uint32_t JUMPY_TRANSITION_DROPS = 3; |
| 845 | static const uint32_t JUMPY_DROP_LIMIT = 3; |
| 846 | |
| 847 | /* Maximum squared distance for averaging. |
| 848 | * If moving farther than this, turn of averaging to avoid lag in response. */ |
| 849 | static const uint64_t AVERAGING_DISTANCE_LIMIT = 75 * 75; |
| 850 | |
| 851 | struct AveragingTouchFilterState { |
| 852 | // Individual history tracks are stored by pointer id |
| 853 | uint32_t historyStart[MAX_POINTERS]; |
| 854 | uint32_t historyEnd[MAX_POINTERS]; |
| 855 | struct { |
| 856 | struct { |
| 857 | int32_t x; |
| 858 | int32_t y; |
| 859 | int32_t pressure; |
| 860 | } pointers[MAX_POINTERS]; |
| 861 | } historyData[AVERAGING_HISTORY_SIZE]; |
| 862 | } mAveragingTouchFilter; |
| 863 | |
Jeff Brown | 2dfd7a7 | 2010-08-17 20:38:35 -0700 | [diff] [blame] | 864 | struct JumpyTouchFilterState { |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 865 | uint32_t jumpyPointsDropped; |
| 866 | } mJumpyTouchFilter; |
| 867 | |
| 868 | struct PointerDistanceHeapElement { |
| 869 | uint32_t currentPointerIndex : 8; |
| 870 | uint32_t lastPointerIndex : 8; |
| 871 | uint64_t distance : 48; // squared distance |
| 872 | }; |
| 873 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 874 | void initializeLocked(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 875 | |
| 876 | TouchResult consumeOffScreenTouches(nsecs_t when, uint32_t policyFlags); |
| 877 | void dispatchTouches(nsecs_t when, uint32_t policyFlags); |
| 878 | void dispatchTouch(nsecs_t when, uint32_t policyFlags, TouchData* touch, |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 879 | BitSet32 idBits, uint32_t changedId, uint32_t pointerCount, |
| 880 | int32_t motionEventAction); |
Jeff Brown | fe50892 | 2011-01-18 15:10:10 -0800 | [diff] [blame] | 881 | void detectGestures(nsecs_t when); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 882 | |
Jeff Brown | 6328cdc | 2010-07-29 18:18:33 -0700 | [diff] [blame] | 883 | bool isPointInsideSurfaceLocked(int32_t x, int32_t y); |
| 884 | const VirtualKey* findVirtualKeyHitLocked(int32_t x, int32_t y); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 885 | |
| 886 | bool applyBadTouchFilter(); |
| 887 | bool applyJumpyTouchFilter(); |
| 888 | void applyAveragingTouchFilter(); |
| 889 | void calculatePointerIds(); |
| 890 | }; |
| 891 | |
| 892 | |
| 893 | class SingleTouchInputMapper : public TouchInputMapper { |
| 894 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 895 | SingleTouchInputMapper(InputDevice* device); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 896 | virtual ~SingleTouchInputMapper(); |
| 897 | |
| 898 | virtual void reset(); |
| 899 | virtual void process(const RawEvent* rawEvent); |
| 900 | |
| 901 | protected: |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 902 | virtual void configureRawAxes(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 903 | |
| 904 | private: |
| 905 | struct Accumulator { |
| 906 | enum { |
| 907 | FIELD_BTN_TOUCH = 1, |
| 908 | FIELD_ABS_X = 2, |
| 909 | FIELD_ABS_Y = 4, |
| 910 | FIELD_ABS_PRESSURE = 8, |
| 911 | FIELD_ABS_TOOL_WIDTH = 16 |
| 912 | }; |
| 913 | |
| 914 | uint32_t fields; |
| 915 | |
| 916 | bool btnTouch; |
| 917 | int32_t absX; |
| 918 | int32_t absY; |
| 919 | int32_t absPressure; |
| 920 | int32_t absToolWidth; |
| 921 | |
| 922 | inline void clear() { |
| 923 | fields = 0; |
| 924 | } |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 925 | } mAccumulator; |
| 926 | |
| 927 | bool mDown; |
| 928 | int32_t mX; |
| 929 | int32_t mY; |
| 930 | int32_t mPressure; |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 931 | int32_t mToolWidth; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 932 | |
| 933 | void initialize(); |
| 934 | |
| 935 | void sync(nsecs_t when); |
| 936 | }; |
| 937 | |
| 938 | |
| 939 | class MultiTouchInputMapper : public TouchInputMapper { |
| 940 | public: |
Jeff Brown | 47e6b1b | 2010-11-29 17:37:49 -0800 | [diff] [blame] | 941 | MultiTouchInputMapper(InputDevice* device); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 942 | virtual ~MultiTouchInputMapper(); |
| 943 | |
| 944 | virtual void reset(); |
| 945 | virtual void process(const RawEvent* rawEvent); |
| 946 | |
| 947 | protected: |
Jeff Brown | 8d60866 | 2010-08-30 03:02:23 -0700 | [diff] [blame] | 948 | virtual void configureRawAxes(); |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 949 | |
| 950 | private: |
| 951 | struct Accumulator { |
| 952 | enum { |
| 953 | FIELD_ABS_MT_POSITION_X = 1, |
| 954 | FIELD_ABS_MT_POSITION_Y = 2, |
| 955 | FIELD_ABS_MT_TOUCH_MAJOR = 4, |
| 956 | FIELD_ABS_MT_TOUCH_MINOR = 8, |
| 957 | FIELD_ABS_MT_WIDTH_MAJOR = 16, |
| 958 | FIELD_ABS_MT_WIDTH_MINOR = 32, |
| 959 | FIELD_ABS_MT_ORIENTATION = 64, |
Jeff Brown | 2dfd7a7 | 2010-08-17 20:38:35 -0700 | [diff] [blame] | 960 | FIELD_ABS_MT_TRACKING_ID = 128, |
| 961 | FIELD_ABS_MT_PRESSURE = 256, |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 962 | }; |
| 963 | |
| 964 | uint32_t pointerCount; |
| 965 | struct Pointer { |
| 966 | uint32_t fields; |
| 967 | |
| 968 | int32_t absMTPositionX; |
| 969 | int32_t absMTPositionY; |
| 970 | int32_t absMTTouchMajor; |
| 971 | int32_t absMTTouchMinor; |
| 972 | int32_t absMTWidthMajor; |
| 973 | int32_t absMTWidthMinor; |
| 974 | int32_t absMTOrientation; |
| 975 | int32_t absMTTrackingId; |
Jeff Brown | 2dfd7a7 | 2010-08-17 20:38:35 -0700 | [diff] [blame] | 976 | int32_t absMTPressure; |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 977 | |
| 978 | inline void clear() { |
| 979 | fields = 0; |
| 980 | } |
| 981 | } pointers[MAX_POINTERS + 1]; // + 1 to remove the need for extra range checks |
| 982 | |
| 983 | inline void clear() { |
| 984 | pointerCount = 0; |
| 985 | pointers[0].clear(); |
| 986 | } |
Jeff Brown | 6d0fec2 | 2010-07-23 21:28:06 -0700 | [diff] [blame] | 987 | } mAccumulator; |
| 988 | |
| 989 | void initialize(); |
| 990 | |
| 991 | void sync(nsecs_t when); |
| 992 | }; |
| 993 | |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 994 | |
| 995 | class JoystickInputMapper : public InputMapper { |
| 996 | public: |
| 997 | JoystickInputMapper(InputDevice* device); |
| 998 | virtual ~JoystickInputMapper(); |
| 999 | |
| 1000 | virtual uint32_t getSources(); |
| 1001 | virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo); |
| 1002 | virtual void dump(String8& dump); |
| 1003 | virtual void configure(); |
| 1004 | virtual void reset(); |
| 1005 | virtual void process(const RawEvent* rawEvent); |
| 1006 | |
| 1007 | private: |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1008 | struct Axis { |
| 1009 | RawAbsoluteAxisInfo rawAxisInfo; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1010 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1011 | int32_t axis; // axis id |
| 1012 | bool explicitlyMapped; // true if the axis was explicitly assigned an axis id |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1013 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1014 | float scale; // scale factor from raw to normalized values |
| 1015 | float offset; // offset to add after scaling for normalization |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1016 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1017 | float min; // normalized inclusive minimum |
| 1018 | float max; // normalized inclusive maximum |
| 1019 | float flat; // normalized flat region size |
| 1020 | float fuzz; // normalized error tolerance |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1021 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1022 | float oldValue; // previous value |
| 1023 | float newValue; // most recent value |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1024 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1025 | float filter; // filter out small variations of this size |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1026 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1027 | void initialize(const RawAbsoluteAxisInfo& rawAxisInfo, |
| 1028 | int32_t axis, bool explicitlyMapped, float scale, float offset, |
| 1029 | float min, float max, float flat, float fuzz) { |
| 1030 | this->rawAxisInfo = rawAxisInfo; |
| 1031 | this->axis = axis; |
| 1032 | this->explicitlyMapped = explicitlyMapped; |
| 1033 | this->scale = scale; |
| 1034 | this->offset = offset; |
| 1035 | this->min = min; |
| 1036 | this->max = max; |
| 1037 | this->flat = flat; |
| 1038 | this->fuzz = fuzz; |
| 1039 | this->filter = 0; |
| 1040 | this->oldValue = 0; |
| 1041 | this->newValue = 0; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1042 | } |
| 1043 | }; |
| 1044 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1045 | // Axes indexed by raw ABS_* axis index. |
| 1046 | KeyedVector<int32_t, Axis> mAxes; |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1047 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1048 | void sync(nsecs_t when, bool force); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1049 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1050 | bool haveAxis(int32_t axis); |
| 1051 | void pruneAxes(bool ignoreExplicitlyMappedAxes); |
| 1052 | bool haveAxesChangedSignificantly(); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1053 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1054 | static bool isCenteredAxis(int32_t axis); |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1055 | }; |
| 1056 | |
Jeff Brown | 46b9ac0a | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1057 | } // namespace android |
| 1058 | |
| 1059 | #endif // _UI_INPUT_READER_H |