| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2019 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_INPUTREADER_TOUCH_INPUT_MAPPER_H | 
|  | 18 | #define _UI_INPUTREADER_TOUCH_INPUT_MAPPER_H | 
|  | 19 |  | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 20 | #include <stdint.h> | 
|  | 21 |  | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 22 | #include "CursorButtonAccumulator.h" | 
|  | 23 | #include "CursorScrollAccumulator.h" | 
|  | 24 | #include "EventHub.h" | 
|  | 25 | #include "InputMapper.h" | 
|  | 26 | #include "InputReaderBase.h" | 
|  | 27 | #include "TouchButtonAccumulator.h" | 
|  | 28 |  | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 29 | namespace android { | 
|  | 30 |  | 
|  | 31 | /* Raw axis information from the driver. */ | 
|  | 32 | struct RawPointerAxes { | 
|  | 33 | RawAbsoluteAxisInfo x; | 
|  | 34 | RawAbsoluteAxisInfo y; | 
|  | 35 | RawAbsoluteAxisInfo pressure; | 
|  | 36 | RawAbsoluteAxisInfo touchMajor; | 
|  | 37 | RawAbsoluteAxisInfo touchMinor; | 
|  | 38 | RawAbsoluteAxisInfo toolMajor; | 
|  | 39 | RawAbsoluteAxisInfo toolMinor; | 
|  | 40 | RawAbsoluteAxisInfo orientation; | 
|  | 41 | RawAbsoluteAxisInfo distance; | 
|  | 42 | RawAbsoluteAxisInfo tiltX; | 
|  | 43 | RawAbsoluteAxisInfo tiltY; | 
|  | 44 | RawAbsoluteAxisInfo trackingId; | 
|  | 45 | RawAbsoluteAxisInfo slot; | 
|  | 46 |  | 
|  | 47 | RawPointerAxes(); | 
|  | 48 | inline int32_t getRawWidth() const { return x.maxValue - x.minValue + 1; } | 
|  | 49 | inline int32_t getRawHeight() const { return y.maxValue - y.minValue + 1; } | 
|  | 50 | void clear(); | 
|  | 51 | }; | 
|  | 52 |  | 
|  | 53 | /* Raw data for a collection of pointers including a pointer id mapping table. */ | 
|  | 54 | struct RawPointerData { | 
|  | 55 | struct Pointer { | 
|  | 56 | uint32_t id; | 
|  | 57 | int32_t x; | 
|  | 58 | int32_t y; | 
|  | 59 | int32_t pressure; | 
|  | 60 | int32_t touchMajor; | 
|  | 61 | int32_t touchMinor; | 
|  | 62 | int32_t toolMajor; | 
|  | 63 | int32_t toolMinor; | 
|  | 64 | int32_t orientation; | 
|  | 65 | int32_t distance; | 
|  | 66 | int32_t tiltX; | 
|  | 67 | int32_t tiltY; | 
|  | 68 | int32_t toolType; // a fully decoded AMOTION_EVENT_TOOL_TYPE constant | 
|  | 69 | bool isHovering; | 
|  | 70 | }; | 
|  | 71 |  | 
|  | 72 | uint32_t pointerCount; | 
|  | 73 | Pointer pointers[MAX_POINTERS]; | 
| arthurhung | cc7f980 | 2020-04-30 17:55:40 +0800 | [diff] [blame] | 74 | BitSet32 hoveringIdBits, touchingIdBits, canceledIdBits; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 75 | uint32_t idToIndex[MAX_POINTER_ID + 1]; | 
|  | 76 |  | 
|  | 77 | RawPointerData(); | 
|  | 78 | void clear(); | 
|  | 79 | void copyFrom(const RawPointerData& other); | 
|  | 80 | void getCentroidOfTouchingPointers(float* outX, float* outY) const; | 
|  | 81 |  | 
|  | 82 | inline void markIdBit(uint32_t id, bool isHovering) { | 
|  | 83 | if (isHovering) { | 
|  | 84 | hoveringIdBits.markBit(id); | 
|  | 85 | } else { | 
|  | 86 | touchingIdBits.markBit(id); | 
|  | 87 | } | 
|  | 88 | } | 
|  | 89 |  | 
|  | 90 | inline void clearIdBits() { | 
|  | 91 | hoveringIdBits.clear(); | 
|  | 92 | touchingIdBits.clear(); | 
| arthurhung | cc7f980 | 2020-04-30 17:55:40 +0800 | [diff] [blame] | 93 | canceledIdBits.clear(); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 94 | } | 
|  | 95 |  | 
|  | 96 | inline const Pointer& pointerForId(uint32_t id) const { return pointers[idToIndex[id]]; } | 
|  | 97 |  | 
|  | 98 | inline bool isHovering(uint32_t pointerIndex) { return pointers[pointerIndex].isHovering; } | 
|  | 99 | }; | 
|  | 100 |  | 
|  | 101 | /* Cooked data for a collection of pointers including a pointer id mapping table. */ | 
|  | 102 | struct CookedPointerData { | 
|  | 103 | uint32_t pointerCount; | 
|  | 104 | PointerProperties pointerProperties[MAX_POINTERS]; | 
|  | 105 | PointerCoords pointerCoords[MAX_POINTERS]; | 
| Nathaniel R. Lewis | adb58ea | 2019-08-21 04:46:29 +0000 | [diff] [blame] | 106 | BitSet32 hoveringIdBits, touchingIdBits, canceledIdBits, validIdBits; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 107 | uint32_t idToIndex[MAX_POINTER_ID + 1]; | 
|  | 108 |  | 
|  | 109 | CookedPointerData(); | 
|  | 110 | void clear(); | 
|  | 111 | void copyFrom(const CookedPointerData& other); | 
|  | 112 |  | 
|  | 113 | inline const PointerCoords& pointerCoordsForId(uint32_t id) const { | 
|  | 114 | return pointerCoords[idToIndex[id]]; | 
|  | 115 | } | 
|  | 116 |  | 
|  | 117 | inline PointerCoords& editPointerCoordsWithId(uint32_t id) { | 
|  | 118 | return pointerCoords[idToIndex[id]]; | 
|  | 119 | } | 
|  | 120 |  | 
|  | 121 | inline PointerProperties& editPointerPropertiesWithId(uint32_t id) { | 
|  | 122 | return pointerProperties[idToIndex[id]]; | 
|  | 123 | } | 
|  | 124 |  | 
|  | 125 | inline bool isHovering(uint32_t pointerIndex) const { | 
|  | 126 | return hoveringIdBits.hasBit(pointerProperties[pointerIndex].id); | 
|  | 127 | } | 
|  | 128 |  | 
|  | 129 | inline bool isTouching(uint32_t pointerIndex) const { | 
|  | 130 | return touchingIdBits.hasBit(pointerProperties[pointerIndex].id); | 
|  | 131 | } | 
| Nathaniel R. Lewis | adb58ea | 2019-08-21 04:46:29 +0000 | [diff] [blame] | 132 |  | 
|  | 133 | inline bool hasPointerCoordsForId(uint32_t id) const { return validIdBits.hasBit(id); } | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 134 | }; | 
|  | 135 |  | 
|  | 136 | class TouchInputMapper : public InputMapper { | 
|  | 137 | public: | 
| Nathaniel R. Lewis | 26ec222 | 2020-01-10 16:30:54 -0800 | [diff] [blame] | 138 | explicit TouchInputMapper(InputDeviceContext& deviceContext); | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 139 | ~TouchInputMapper() override; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 140 |  | 
| Philip Junker | 4af3b3d | 2021-12-14 10:36:55 +0100 | [diff] [blame] | 141 | uint32_t getSources() const override; | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 142 | void populateDeviceInfo(InputDeviceInfo* deviceInfo) override; | 
|  | 143 | void dump(std::string& dump) override; | 
|  | 144 | void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) override; | 
|  | 145 | void reset(nsecs_t when) override; | 
|  | 146 | void process(const RawEvent* rawEvent) override; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 147 |  | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 148 | int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode) override; | 
|  | 149 | int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode) override; | 
|  | 150 | bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes, | 
|  | 151 | uint8_t* outFlags) override; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 152 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 153 | void cancelTouch(nsecs_t when, nsecs_t readTime) override; | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 154 | void timeoutExpired(nsecs_t when) override; | 
|  | 155 | void updateExternalStylusState(const StylusState& state) override; | 
|  | 156 | std::optional<int32_t> getAssociatedDisplayId() override; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 157 |  | 
|  | 158 | protected: | 
|  | 159 | CursorButtonAccumulator mCursorButtonAccumulator; | 
|  | 160 | CursorScrollAccumulator mCursorScrollAccumulator; | 
|  | 161 | TouchButtonAccumulator mTouchButtonAccumulator; | 
|  | 162 |  | 
|  | 163 | struct VirtualKey { | 
|  | 164 | int32_t keyCode; | 
|  | 165 | int32_t scanCode; | 
|  | 166 | uint32_t flags; | 
|  | 167 |  | 
|  | 168 | // computed hit box, specified in touch screen coords based on known display size | 
|  | 169 | int32_t hitLeft; | 
|  | 170 | int32_t hitTop; | 
|  | 171 | int32_t hitRight; | 
|  | 172 | int32_t hitBottom; | 
|  | 173 |  | 
|  | 174 | inline bool isHit(int32_t x, int32_t y) const { | 
|  | 175 | return x >= hitLeft && x <= hitRight && y >= hitTop && y <= hitBottom; | 
|  | 176 | } | 
|  | 177 | }; | 
|  | 178 |  | 
|  | 179 | // Input sources and device mode. | 
|  | 180 | uint32_t mSource; | 
|  | 181 |  | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 182 | enum class DeviceMode { | 
|  | 183 | DISABLED,   // input is disabled | 
|  | 184 | DIRECT,     // direct mapping (touchscreen) | 
|  | 185 | UNSCALED,   // unscaled mapping (touchpad) | 
|  | 186 | NAVIGATION, // unscaled mapping with assist gesture (touch navigation) | 
|  | 187 | POINTER,    // pointer mapping (pointer) | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 188 |  | 
|  | 189 | ftl_last = POINTER | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 190 | }; | 
|  | 191 | DeviceMode mDeviceMode; | 
|  | 192 |  | 
|  | 193 | // The reader's configuration. | 
|  | 194 | InputReaderConfiguration mConfig; | 
|  | 195 |  | 
|  | 196 | // Immutable configuration parameters. | 
|  | 197 | struct Parameters { | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 198 | enum class DeviceType { | 
|  | 199 | TOUCH_SCREEN, | 
|  | 200 | TOUCH_PAD, | 
|  | 201 | TOUCH_NAVIGATION, | 
|  | 202 | POINTER, | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 203 |  | 
|  | 204 | ftl_last = POINTER | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 205 | }; | 
|  | 206 |  | 
|  | 207 | DeviceType deviceType; | 
|  | 208 | bool hasAssociatedDisplay; | 
|  | 209 | bool associatedDisplayIsExternal; | 
|  | 210 | bool orientationAware; | 
| Prabir Pradhan | ac1c74f | 2021-08-20 16:09:32 -0700 | [diff] [blame] | 211 |  | 
|  | 212 | enum class Orientation : int32_t { | 
|  | 213 | ORIENTATION_0 = DISPLAY_ORIENTATION_0, | 
|  | 214 | ORIENTATION_90 = DISPLAY_ORIENTATION_90, | 
|  | 215 | ORIENTATION_180 = DISPLAY_ORIENTATION_180, | 
|  | 216 | ORIENTATION_270 = DISPLAY_ORIENTATION_270, | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 217 |  | 
|  | 218 | ftl_last = ORIENTATION_270 | 
| Prabir Pradhan | ac1c74f | 2021-08-20 16:09:32 -0700 | [diff] [blame] | 219 | }; | 
|  | 220 | Orientation orientation; | 
|  | 221 |  | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 222 | bool hasButtonUnderPad; | 
|  | 223 | std::string uniqueDisplayId; | 
|  | 224 |  | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 225 | enum class GestureMode { | 
|  | 226 | SINGLE_TOUCH, | 
|  | 227 | MULTI_TOUCH, | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 228 |  | 
|  | 229 | ftl_last = MULTI_TOUCH | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 230 | }; | 
|  | 231 | GestureMode gestureMode; | 
|  | 232 |  | 
|  | 233 | bool wake; | 
|  | 234 | } mParameters; | 
|  | 235 |  | 
|  | 236 | // Immutable calibration parameters in parsed form. | 
|  | 237 | struct Calibration { | 
|  | 238 | // Size | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 239 | enum class SizeCalibration { | 
|  | 240 | DEFAULT, | 
|  | 241 | NONE, | 
|  | 242 | GEOMETRIC, | 
|  | 243 | DIAMETER, | 
|  | 244 | BOX, | 
|  | 245 | AREA, | 
| Siarhei Vishniakou | 4e837cc | 2021-12-20 23:24:33 -0800 | [diff] [blame] | 246 | ftl_last = AREA | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 247 | }; | 
|  | 248 |  | 
|  | 249 | SizeCalibration sizeCalibration; | 
|  | 250 |  | 
|  | 251 | bool haveSizeScale; | 
|  | 252 | float sizeScale; | 
|  | 253 | bool haveSizeBias; | 
|  | 254 | float sizeBias; | 
|  | 255 | bool haveSizeIsSummed; | 
|  | 256 | bool sizeIsSummed; | 
|  | 257 |  | 
|  | 258 | // Pressure | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 259 | enum class PressureCalibration { | 
|  | 260 | DEFAULT, | 
|  | 261 | NONE, | 
|  | 262 | PHYSICAL, | 
|  | 263 | AMPLITUDE, | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 264 | }; | 
|  | 265 |  | 
|  | 266 | PressureCalibration pressureCalibration; | 
|  | 267 | bool havePressureScale; | 
|  | 268 | float pressureScale; | 
|  | 269 |  | 
|  | 270 | // Orientation | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 271 | enum class OrientationCalibration { | 
|  | 272 | DEFAULT, | 
|  | 273 | NONE, | 
|  | 274 | INTERPOLATED, | 
|  | 275 | VECTOR, | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 276 | }; | 
|  | 277 |  | 
|  | 278 | OrientationCalibration orientationCalibration; | 
|  | 279 |  | 
|  | 280 | // Distance | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 281 | enum class DistanceCalibration { | 
|  | 282 | DEFAULT, | 
|  | 283 | NONE, | 
|  | 284 | SCALED, | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 285 | }; | 
|  | 286 |  | 
|  | 287 | DistanceCalibration distanceCalibration; | 
|  | 288 | bool haveDistanceScale; | 
|  | 289 | float distanceScale; | 
|  | 290 |  | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 291 | enum class CoverageCalibration { | 
|  | 292 | DEFAULT, | 
|  | 293 | NONE, | 
|  | 294 | BOX, | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 295 | }; | 
|  | 296 |  | 
|  | 297 | CoverageCalibration coverageCalibration; | 
|  | 298 |  | 
|  | 299 | inline void applySizeScaleAndBias(float* outSize) const { | 
|  | 300 | if (haveSizeScale) { | 
|  | 301 | *outSize *= sizeScale; | 
|  | 302 | } | 
|  | 303 | if (haveSizeBias) { | 
|  | 304 | *outSize += sizeBias; | 
|  | 305 | } | 
|  | 306 | if (*outSize < 0) { | 
|  | 307 | *outSize = 0; | 
|  | 308 | } | 
|  | 309 | } | 
|  | 310 | } mCalibration; | 
|  | 311 |  | 
|  | 312 | // Affine location transformation/calibration | 
|  | 313 | struct TouchAffineTransformation mAffineTransform; | 
|  | 314 |  | 
|  | 315 | RawPointerAxes mRawPointerAxes; | 
|  | 316 |  | 
|  | 317 | struct RawState { | 
|  | 318 | nsecs_t when; | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 319 | nsecs_t readTime; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 320 |  | 
|  | 321 | // Raw pointer sample data. | 
|  | 322 | RawPointerData rawPointerData; | 
|  | 323 |  | 
|  | 324 | int32_t buttonState; | 
|  | 325 |  | 
|  | 326 | // Scroll state. | 
|  | 327 | int32_t rawVScroll; | 
|  | 328 | int32_t rawHScroll; | 
|  | 329 |  | 
|  | 330 | void copyFrom(const RawState& other) { | 
|  | 331 | when = other.when; | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 332 | readTime = other.readTime; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 333 | rawPointerData.copyFrom(other.rawPointerData); | 
|  | 334 | buttonState = other.buttonState; | 
|  | 335 | rawVScroll = other.rawVScroll; | 
|  | 336 | rawHScroll = other.rawHScroll; | 
|  | 337 | } | 
|  | 338 |  | 
|  | 339 | void clear() { | 
|  | 340 | when = 0; | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 341 | readTime = 0; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 342 | rawPointerData.clear(); | 
|  | 343 | buttonState = 0; | 
|  | 344 | rawVScroll = 0; | 
|  | 345 | rawHScroll = 0; | 
|  | 346 | } | 
|  | 347 | }; | 
|  | 348 |  | 
|  | 349 | struct CookedState { | 
|  | 350 | // Cooked pointer sample data. | 
|  | 351 | CookedPointerData cookedPointerData; | 
|  | 352 |  | 
|  | 353 | // Id bits used to differentiate fingers, stylus and mouse tools. | 
|  | 354 | BitSet32 fingerIdBits; | 
|  | 355 | BitSet32 stylusIdBits; | 
|  | 356 | BitSet32 mouseIdBits; | 
|  | 357 |  | 
|  | 358 | int32_t buttonState; | 
|  | 359 |  | 
|  | 360 | void copyFrom(const CookedState& other) { | 
|  | 361 | cookedPointerData.copyFrom(other.cookedPointerData); | 
|  | 362 | fingerIdBits = other.fingerIdBits; | 
|  | 363 | stylusIdBits = other.stylusIdBits; | 
|  | 364 | mouseIdBits = other.mouseIdBits; | 
|  | 365 | buttonState = other.buttonState; | 
|  | 366 | } | 
|  | 367 |  | 
|  | 368 | void clear() { | 
|  | 369 | cookedPointerData.clear(); | 
|  | 370 | fingerIdBits.clear(); | 
|  | 371 | stylusIdBits.clear(); | 
|  | 372 | mouseIdBits.clear(); | 
|  | 373 | buttonState = 0; | 
|  | 374 | } | 
|  | 375 | }; | 
|  | 376 |  | 
|  | 377 | std::vector<RawState> mRawStatesPending; | 
|  | 378 | RawState mCurrentRawState; | 
|  | 379 | CookedState mCurrentCookedState; | 
|  | 380 | RawState mLastRawState; | 
|  | 381 | CookedState mLastCookedState; | 
|  | 382 |  | 
|  | 383 | // State provided by an external stylus | 
|  | 384 | StylusState mExternalStylusState; | 
|  | 385 | int64_t mExternalStylusId; | 
|  | 386 | nsecs_t mExternalStylusFusionTimeout; | 
|  | 387 | bool mExternalStylusDataPending; | 
|  | 388 |  | 
|  | 389 | // True if we sent a HOVER_ENTER event. | 
|  | 390 | bool mSentHoverEnter; | 
|  | 391 |  | 
|  | 392 | // Have we assigned pointer IDs for this stream | 
|  | 393 | bool mHavePointerIds; | 
|  | 394 |  | 
|  | 395 | // Is the current stream of direct touch events aborted | 
|  | 396 | bool mCurrentMotionAborted; | 
|  | 397 |  | 
|  | 398 | // The time the primary pointer last went down. | 
|  | 399 | nsecs_t mDownTime; | 
|  | 400 |  | 
|  | 401 | // The pointer controller, or null if the device is not a pointer. | 
| Michael Wright | 17db18e | 2020-06-26 20:51:44 +0100 | [diff] [blame] | 402 | std::shared_ptr<PointerControllerInterface> mPointerController; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 403 |  | 
|  | 404 | std::vector<VirtualKey> mVirtualKeys; | 
|  | 405 |  | 
|  | 406 | virtual void configureParameters(); | 
|  | 407 | virtual void dumpParameters(std::string& dump); | 
|  | 408 | virtual void configureRawPointerAxes(); | 
|  | 409 | virtual void dumpRawPointerAxes(std::string& dump); | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 410 | virtual void configureInputDevice(nsecs_t when, bool* outResetNeeded); | 
|  | 411 | virtual void dumpDisplay(std::string& dump); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 412 | virtual void configureVirtualKeys(); | 
|  | 413 | virtual void dumpVirtualKeys(std::string& dump); | 
|  | 414 | virtual void parseCalibration(); | 
|  | 415 | virtual void resolveCalibration(); | 
|  | 416 | virtual void dumpCalibration(std::string& dump); | 
|  | 417 | virtual void updateAffineTransformation(); | 
|  | 418 | virtual void dumpAffineTransformation(std::string& dump); | 
|  | 419 | virtual void resolveExternalStylusPresence(); | 
|  | 420 | virtual bool hasStylus() const = 0; | 
|  | 421 | virtual bool hasExternalStylus() const; | 
|  | 422 |  | 
|  | 423 | virtual void syncTouch(nsecs_t when, RawState* outState) = 0; | 
|  | 424 |  | 
|  | 425 | private: | 
|  | 426 | // The current viewport. | 
|  | 427 | // The components of the viewport are specified in the display's rotated orientation. | 
|  | 428 | DisplayViewport mViewport; | 
|  | 429 |  | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 430 | // The width and height are obtained from the viewport and are specified | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 431 | // in the natural orientation. | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 432 | int32_t mDisplayWidth; | 
|  | 433 | int32_t mDisplayHeight; | 
| Arthur Hung | 4197f6b | 2020-03-16 15:39:59 +0800 | [diff] [blame] | 434 |  | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 435 | // The physical frame is the rectangle in the display's coordinate space that maps to the | 
|  | 436 | // the logical display frame. | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 437 | int32_t mPhysicalWidth; | 
|  | 438 | int32_t mPhysicalHeight; | 
|  | 439 | int32_t mPhysicalLeft; | 
|  | 440 | int32_t mPhysicalTop; | 
|  | 441 |  | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 442 | // The orientation of the input device relative to that of the display panel. It specifies | 
|  | 443 | // the rotation of the input device coordinates required to produce the display panel | 
|  | 444 | // orientation, so it will depend on whether the device is orientation aware. | 
|  | 445 | int32_t mInputDeviceOrientation; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 446 |  | 
|  | 447 | // Translation and scaling factors, orientation-independent. | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 448 | float mXScale; | 
|  | 449 | float mXPrecision; | 
|  | 450 |  | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 451 | float mYScale; | 
|  | 452 | float mYPrecision; | 
|  | 453 |  | 
|  | 454 | float mGeometricScale; | 
|  | 455 |  | 
|  | 456 | float mPressureScale; | 
|  | 457 |  | 
|  | 458 | float mSizeScale; | 
|  | 459 |  | 
|  | 460 | float mOrientationScale; | 
|  | 461 |  | 
|  | 462 | float mDistanceScale; | 
|  | 463 |  | 
|  | 464 | bool mHaveTilt; | 
|  | 465 | float mTiltXCenter; | 
|  | 466 | float mTiltXScale; | 
|  | 467 | float mTiltYCenter; | 
|  | 468 | float mTiltYScale; | 
|  | 469 |  | 
|  | 470 | bool mExternalStylusConnected; | 
|  | 471 |  | 
|  | 472 | // Oriented motion ranges for input device info. | 
|  | 473 | struct OrientedRanges { | 
|  | 474 | InputDeviceInfo::MotionRange x; | 
|  | 475 | InputDeviceInfo::MotionRange y; | 
|  | 476 | InputDeviceInfo::MotionRange pressure; | 
|  | 477 |  | 
|  | 478 | bool haveSize; | 
|  | 479 | InputDeviceInfo::MotionRange size; | 
|  | 480 |  | 
|  | 481 | bool haveTouchSize; | 
|  | 482 | InputDeviceInfo::MotionRange touchMajor; | 
|  | 483 | InputDeviceInfo::MotionRange touchMinor; | 
|  | 484 |  | 
|  | 485 | bool haveToolSize; | 
|  | 486 | InputDeviceInfo::MotionRange toolMajor; | 
|  | 487 | InputDeviceInfo::MotionRange toolMinor; | 
|  | 488 |  | 
|  | 489 | bool haveOrientation; | 
|  | 490 | InputDeviceInfo::MotionRange orientation; | 
|  | 491 |  | 
|  | 492 | bool haveDistance; | 
|  | 493 | InputDeviceInfo::MotionRange distance; | 
|  | 494 |  | 
|  | 495 | bool haveTilt; | 
|  | 496 | InputDeviceInfo::MotionRange tilt; | 
|  | 497 |  | 
|  | 498 | OrientedRanges() { clear(); } | 
|  | 499 |  | 
|  | 500 | void clear() { | 
|  | 501 | haveSize = false; | 
|  | 502 | haveTouchSize = false; | 
|  | 503 | haveToolSize = false; | 
|  | 504 | haveOrientation = false; | 
|  | 505 | haveDistance = false; | 
|  | 506 | haveTilt = false; | 
|  | 507 | } | 
|  | 508 | } mOrientedRanges; | 
|  | 509 |  | 
|  | 510 | // Oriented dimensions and precision. | 
|  | 511 | float mOrientedXPrecision; | 
|  | 512 | float mOrientedYPrecision; | 
|  | 513 |  | 
|  | 514 | struct CurrentVirtualKeyState { | 
|  | 515 | bool down; | 
|  | 516 | bool ignored; | 
|  | 517 | nsecs_t downTime; | 
|  | 518 | int32_t keyCode; | 
|  | 519 | int32_t scanCode; | 
|  | 520 | } mCurrentVirtualKey; | 
|  | 521 |  | 
|  | 522 | // Scale factor for gesture or mouse based pointer movements. | 
|  | 523 | float mPointerXMovementScale; | 
|  | 524 | float mPointerYMovementScale; | 
|  | 525 |  | 
|  | 526 | // Scale factor for gesture based zooming and other freeform motions. | 
|  | 527 | float mPointerXZoomScale; | 
|  | 528 | float mPointerYZoomScale; | 
|  | 529 |  | 
|  | 530 | // The maximum swipe width. | 
|  | 531 | float mPointerGestureMaxSwipeWidth; | 
|  | 532 |  | 
|  | 533 | struct PointerDistanceHeapElement { | 
|  | 534 | uint32_t currentPointerIndex : 8; | 
|  | 535 | uint32_t lastPointerIndex : 8; | 
|  | 536 | uint64_t distance : 48; // squared distance | 
|  | 537 | }; | 
|  | 538 |  | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 539 | enum class PointerUsage { | 
|  | 540 | NONE, | 
|  | 541 | GESTURES, | 
|  | 542 | STYLUS, | 
|  | 543 | MOUSE, | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 544 | }; | 
|  | 545 | PointerUsage mPointerUsage; | 
|  | 546 |  | 
|  | 547 | struct PointerGesture { | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 548 | enum class Mode { | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 549 | // No fingers, button is not pressed. | 
|  | 550 | // Nothing happening. | 
|  | 551 | NEUTRAL, | 
|  | 552 |  | 
|  | 553 | // No fingers, button is not pressed. | 
|  | 554 | // Tap detected. | 
|  | 555 | // Emits DOWN and UP events at the pointer location. | 
|  | 556 | TAP, | 
|  | 557 |  | 
|  | 558 | // Exactly one finger dragging following a tap. | 
|  | 559 | // Pointer follows the active finger. | 
|  | 560 | // Emits DOWN, MOVE and UP events at the pointer location. | 
|  | 561 | // | 
|  | 562 | // Detect double-taps when the finger goes up while in TAP_DRAG mode. | 
|  | 563 | TAP_DRAG, | 
|  | 564 |  | 
|  | 565 | // Button is pressed. | 
|  | 566 | // Pointer follows the active finger if there is one.  Other fingers are ignored. | 
|  | 567 | // Emits DOWN, MOVE and UP events at the pointer location. | 
|  | 568 | BUTTON_CLICK_OR_DRAG, | 
|  | 569 |  | 
|  | 570 | // Exactly one finger, button is not pressed. | 
|  | 571 | // Pointer follows the active finger. | 
|  | 572 | // Emits HOVER_MOVE events at the pointer location. | 
|  | 573 | // | 
|  | 574 | // Detect taps when the finger goes up while in HOVER mode. | 
|  | 575 | HOVER, | 
|  | 576 |  | 
|  | 577 | // Exactly two fingers but neither have moved enough to clearly indicate | 
|  | 578 | // whether a swipe or freeform gesture was intended.  We consider the | 
|  | 579 | // pointer to be pressed so this enables clicking or long-pressing on buttons. | 
|  | 580 | // Pointer does not move. | 
|  | 581 | // Emits DOWN, MOVE and UP events with a single stationary pointer coordinate. | 
|  | 582 | PRESS, | 
|  | 583 |  | 
|  | 584 | // Exactly two fingers moving in the same direction, button is not pressed. | 
|  | 585 | // Pointer does not move. | 
|  | 586 | // Emits DOWN, MOVE and UP events with a single pointer coordinate that | 
|  | 587 | // follows the midpoint between both fingers. | 
|  | 588 | SWIPE, | 
|  | 589 |  | 
|  | 590 | // Two or more fingers moving in arbitrary directions, button is not pressed. | 
|  | 591 | // Pointer does not move. | 
|  | 592 | // Emits DOWN, POINTER_DOWN, MOVE, POINTER_UP and UP events that follow | 
|  | 593 | // each finger individually relative to the initial centroid of the finger. | 
|  | 594 | FREEFORM, | 
|  | 595 |  | 
|  | 596 | // Waiting for quiet time to end before starting the next gesture. | 
|  | 597 | QUIET, | 
|  | 598 | }; | 
|  | 599 |  | 
| Prabir Pradhan | 47cf0a0 | 2021-03-11 20:30:57 -0800 | [diff] [blame] | 600 | // When a gesture is sent to an unfocused window, return true if it can bring that window | 
|  | 601 | // into focus, false otherwise. | 
|  | 602 | static bool canGestureAffectWindowFocus(Mode mode) { | 
|  | 603 | switch (mode) { | 
|  | 604 | case Mode::TAP: | 
|  | 605 | case Mode::TAP_DRAG: | 
|  | 606 | case Mode::BUTTON_CLICK_OR_DRAG: | 
|  | 607 | // Taps can affect window focus. | 
|  | 608 | return true; | 
|  | 609 | case Mode::FREEFORM: | 
|  | 610 | case Mode::HOVER: | 
|  | 611 | case Mode::NEUTRAL: | 
|  | 612 | case Mode::PRESS: | 
|  | 613 | case Mode::QUIET: | 
|  | 614 | case Mode::SWIPE: | 
|  | 615 | // Most gestures can be performed on an unfocused window, so they should not | 
|  | 616 | // not affect window focus. | 
|  | 617 | return false; | 
|  | 618 | } | 
|  | 619 | } | 
|  | 620 |  | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 621 | // Time the first finger went down. | 
|  | 622 | nsecs_t firstTouchTime; | 
|  | 623 |  | 
|  | 624 | // The active pointer id from the raw touch data. | 
|  | 625 | int32_t activeTouchId; // -1 if none | 
|  | 626 |  | 
|  | 627 | // The active pointer id from the gesture last delivered to the application. | 
|  | 628 | int32_t activeGestureId; // -1 if none | 
|  | 629 |  | 
|  | 630 | // Pointer coords and ids for the current and previous pointer gesture. | 
|  | 631 | Mode currentGestureMode; | 
|  | 632 | BitSet32 currentGestureIdBits; | 
|  | 633 | uint32_t currentGestureIdToIndex[MAX_POINTER_ID + 1]; | 
|  | 634 | PointerProperties currentGestureProperties[MAX_POINTERS]; | 
|  | 635 | PointerCoords currentGestureCoords[MAX_POINTERS]; | 
|  | 636 |  | 
|  | 637 | Mode lastGestureMode; | 
|  | 638 | BitSet32 lastGestureIdBits; | 
|  | 639 | uint32_t lastGestureIdToIndex[MAX_POINTER_ID + 1]; | 
|  | 640 | PointerProperties lastGestureProperties[MAX_POINTERS]; | 
|  | 641 | PointerCoords lastGestureCoords[MAX_POINTERS]; | 
|  | 642 |  | 
|  | 643 | // Time the pointer gesture last went down. | 
|  | 644 | nsecs_t downTime; | 
|  | 645 |  | 
|  | 646 | // Time when the pointer went down for a TAP. | 
|  | 647 | nsecs_t tapDownTime; | 
|  | 648 |  | 
|  | 649 | // Time when the pointer went up for a TAP. | 
|  | 650 | nsecs_t tapUpTime; | 
|  | 651 |  | 
|  | 652 | // Location of initial tap. | 
|  | 653 | float tapX, tapY; | 
|  | 654 |  | 
|  | 655 | // Time we started waiting for quiescence. | 
|  | 656 | nsecs_t quietTime; | 
|  | 657 |  | 
|  | 658 | // Reference points for multitouch gestures. | 
|  | 659 | float referenceTouchX; // reference touch X/Y coordinates in surface units | 
|  | 660 | float referenceTouchY; | 
|  | 661 | float referenceGestureX; // reference gesture X/Y coordinates in pixels | 
|  | 662 | float referenceGestureY; | 
|  | 663 |  | 
|  | 664 | // Distance that each pointer has traveled which has not yet been | 
|  | 665 | // subsumed into the reference gesture position. | 
|  | 666 | BitSet32 referenceIdBits; | 
|  | 667 | struct Delta { | 
|  | 668 | float dx, dy; | 
|  | 669 | }; | 
|  | 670 | Delta referenceDeltas[MAX_POINTER_ID + 1]; | 
|  | 671 |  | 
|  | 672 | // Describes how touch ids are mapped to gesture ids for freeform gestures. | 
|  | 673 | uint32_t freeformTouchToGestureIdMap[MAX_POINTER_ID + 1]; | 
|  | 674 |  | 
|  | 675 | // A velocity tracker for determining whether to switch active pointers during drags. | 
|  | 676 | VelocityTracker velocityTracker; | 
|  | 677 |  | 
|  | 678 | void reset() { | 
|  | 679 | firstTouchTime = LLONG_MIN; | 
|  | 680 | activeTouchId = -1; | 
|  | 681 | activeGestureId = -1; | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 682 | currentGestureMode = Mode::NEUTRAL; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 683 | currentGestureIdBits.clear(); | 
| Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 684 | lastGestureMode = Mode::NEUTRAL; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 685 | lastGestureIdBits.clear(); | 
|  | 686 | downTime = 0; | 
|  | 687 | velocityTracker.clear(); | 
|  | 688 | resetTap(); | 
|  | 689 | resetQuietTime(); | 
|  | 690 | } | 
|  | 691 |  | 
|  | 692 | void resetTap() { | 
|  | 693 | tapDownTime = LLONG_MIN; | 
|  | 694 | tapUpTime = LLONG_MIN; | 
|  | 695 | } | 
|  | 696 |  | 
|  | 697 | void resetQuietTime() { quietTime = LLONG_MIN; } | 
|  | 698 | } mPointerGesture; | 
|  | 699 |  | 
|  | 700 | struct PointerSimple { | 
|  | 701 | PointerCoords currentCoords; | 
|  | 702 | PointerProperties currentProperties; | 
|  | 703 | PointerCoords lastCoords; | 
|  | 704 | PointerProperties lastProperties; | 
|  | 705 |  | 
|  | 706 | // True if the pointer is down. | 
|  | 707 | bool down; | 
|  | 708 |  | 
|  | 709 | // True if the pointer is hovering. | 
|  | 710 | bool hovering; | 
|  | 711 |  | 
|  | 712 | // Time the pointer last went down. | 
|  | 713 | nsecs_t downTime; | 
|  | 714 |  | 
|  | 715 | void reset() { | 
|  | 716 | currentCoords.clear(); | 
|  | 717 | currentProperties.clear(); | 
|  | 718 | lastCoords.clear(); | 
|  | 719 | lastProperties.clear(); | 
|  | 720 | down = false; | 
|  | 721 | hovering = false; | 
|  | 722 | downTime = 0; | 
|  | 723 | } | 
|  | 724 | } mPointerSimple; | 
|  | 725 |  | 
|  | 726 | // The pointer and scroll velocity controls. | 
|  | 727 | VelocityControl mPointerVelocityControl; | 
|  | 728 | VelocityControl mWheelXVelocityControl; | 
|  | 729 | VelocityControl mWheelYVelocityControl; | 
|  | 730 |  | 
|  | 731 | std::optional<DisplayViewport> findViewport(); | 
|  | 732 |  | 
|  | 733 | void resetExternalStylus(); | 
|  | 734 | void clearStylusDataPendingFlags(); | 
|  | 735 |  | 
| Siarhei Vishniakou | 12c0fcb | 2021-12-17 13:40:44 -0800 | [diff] [blame] | 736 | int32_t clampResolution(const char* axisName, int32_t resolution) const; | 
| Siarhei Vishniakou | 4e837cc | 2021-12-20 23:24:33 -0800 | [diff] [blame] | 737 | void initializeOrientedRanges(); | 
|  | 738 | void initializeSizeRanges(); | 
|  | 739 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 740 | void sync(nsecs_t when, nsecs_t readTime); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 741 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 742 | bool consumeRawTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 743 | void processRawTouches(bool timeout); | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 744 | void cookAndDispatch(nsecs_t when, nsecs_t readTime); | 
|  | 745 | void dispatchVirtualKey(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, | 
|  | 746 | int32_t keyEventAction, int32_t keyEventFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 747 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 748 | void dispatchTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
|  | 749 | void dispatchHoverExit(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
|  | 750 | void dispatchHoverEnterAndMove(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
|  | 751 | void dispatchButtonRelease(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
|  | 752 | void dispatchButtonPress(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 753 | const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData); | 
|  | 754 | void cookPointerData(); | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 755 | void abortTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 756 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 757 | void dispatchPointerUsage(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, | 
|  | 758 | PointerUsage pointerUsage); | 
|  | 759 | void abortPointerUsage(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 760 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 761 | void dispatchPointerGestures(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, | 
|  | 762 | bool isTimeout); | 
|  | 763 | void abortPointerGestures(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 764 | bool preparePointerGestures(nsecs_t when, bool* outCancelPreviousGesture, | 
|  | 765 | bool* outFinishPreviousGesture, bool isTimeout); | 
|  | 766 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 767 | void dispatchPointerStylus(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
|  | 768 | void abortPointerStylus(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 769 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 770 | void dispatchPointerMouse(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
|  | 771 | void abortPointerMouse(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 772 |  | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 773 | void dispatchPointerSimple(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, bool down, | 
|  | 774 | bool hovering); | 
|  | 775 | void abortPointerSimple(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 776 |  | 
|  | 777 | bool assignExternalStylusId(const RawState& state, bool timeout); | 
|  | 778 | void applyExternalStylusButtonState(nsecs_t when); | 
|  | 779 | void applyExternalStylusTouchState(nsecs_t when); | 
|  | 780 |  | 
|  | 781 | // Dispatches a motion event. | 
|  | 782 | // If the changedId is >= 0 and the action is POINTER_DOWN or POINTER_UP, the | 
|  | 783 | // method will take care of setting the index and transmuting the action to DOWN or UP | 
|  | 784 | // it is the first / last pointer to go down / up. | 
| Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 785 | void dispatchMotion(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, uint32_t source, | 
|  | 786 | int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, | 
|  | 787 | int32_t buttonState, int32_t edgeFlags, const PointerProperties* properties, | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 788 | const PointerCoords* coords, const uint32_t* idToIndex, BitSet32 idBits, | 
|  | 789 | int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime); | 
|  | 790 |  | 
|  | 791 | // Updates pointer coords and properties for pointers with specified ids that have moved. | 
|  | 792 | // Returns true if any of them changed. | 
|  | 793 | bool updateMovedPointers(const PointerProperties* inProperties, const PointerCoords* inCoords, | 
|  | 794 | const uint32_t* inIdToIndex, PointerProperties* outProperties, | 
|  | 795 | PointerCoords* outCoords, const uint32_t* outIdToIndex, | 
|  | 796 | BitSet32 idBits) const; | 
|  | 797 |  | 
| Garfield Tan | c734e4f | 2021-01-15 20:01:39 -0800 | [diff] [blame] | 798 | // Returns if this touch device is a touch screen with an associated display. | 
|  | 799 | bool isTouchScreen(); | 
|  | 800 | // Updates touch spots if they are enabled. Should only be used when this device is a | 
|  | 801 | // touchscreen. | 
|  | 802 | void updateTouchSpots(); | 
|  | 803 |  | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 804 | bool isPointInsidePhysicalFrame(int32_t x, int32_t y) const; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 805 | const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y); | 
|  | 806 |  | 
| Siarhei Vishniakou | 5747998 | 2021-03-03 01:32:21 +0000 | [diff] [blame] | 807 | static void assignPointerIds(const RawState& last, RawState& current); | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 808 |  | 
|  | 809 | const char* modeToString(DeviceMode deviceMode); | 
| Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 810 | void rotateAndScale(float& x, float& y) const; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 811 | }; | 
|  | 812 |  | 
|  | 813 | } // namespace android | 
|  | 814 |  | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 815 | #endif // _UI_INPUTREADER_TOUCH_INPUT_MAPPER_H |