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; |
Siarhei Vishniakou | 7400794 | 2022-06-13 13:57:47 -0700 | [diff] [blame] | 150 | bool markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes, |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 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 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 251 | std::optional<float> sizeScale; |
| 252 | std::optional<float> sizeBias; |
| 253 | std::optional<bool> sizeIsSummed; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 254 | |
| 255 | // Pressure |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 256 | enum class PressureCalibration { |
| 257 | DEFAULT, |
| 258 | NONE, |
| 259 | PHYSICAL, |
| 260 | AMPLITUDE, |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | PressureCalibration pressureCalibration; |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 264 | std::optional<float> pressureScale; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 265 | |
| 266 | // Orientation |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 267 | enum class OrientationCalibration { |
| 268 | DEFAULT, |
| 269 | NONE, |
| 270 | INTERPOLATED, |
| 271 | VECTOR, |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | OrientationCalibration orientationCalibration; |
| 275 | |
| 276 | // Distance |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 277 | enum class DistanceCalibration { |
| 278 | DEFAULT, |
| 279 | NONE, |
| 280 | SCALED, |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | DistanceCalibration distanceCalibration; |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 284 | std::optional<float> distanceScale; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 285 | |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 286 | enum class CoverageCalibration { |
| 287 | DEFAULT, |
| 288 | NONE, |
| 289 | BOX, |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 290 | }; |
| 291 | |
| 292 | CoverageCalibration coverageCalibration; |
| 293 | |
| 294 | inline void applySizeScaleAndBias(float* outSize) const { |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 295 | if (sizeScale) { |
| 296 | *outSize *= *sizeScale; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 297 | } |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 298 | if (sizeBias) { |
| 299 | *outSize += *sizeBias; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 300 | } |
| 301 | if (*outSize < 0) { |
| 302 | *outSize = 0; |
| 303 | } |
| 304 | } |
| 305 | } mCalibration; |
| 306 | |
| 307 | // Affine location transformation/calibration |
| 308 | struct TouchAffineTransformation mAffineTransform; |
| 309 | |
| 310 | RawPointerAxes mRawPointerAxes; |
| 311 | |
| 312 | struct RawState { |
| 313 | nsecs_t when; |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 314 | nsecs_t readTime; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 315 | |
| 316 | // Raw pointer sample data. |
| 317 | RawPointerData rawPointerData; |
| 318 | |
| 319 | int32_t buttonState; |
| 320 | |
| 321 | // Scroll state. |
| 322 | int32_t rawVScroll; |
| 323 | int32_t rawHScroll; |
| 324 | |
| 325 | void copyFrom(const RawState& other) { |
| 326 | when = other.when; |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 327 | readTime = other.readTime; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 328 | rawPointerData.copyFrom(other.rawPointerData); |
| 329 | buttonState = other.buttonState; |
| 330 | rawVScroll = other.rawVScroll; |
| 331 | rawHScroll = other.rawHScroll; |
| 332 | } |
| 333 | |
| 334 | void clear() { |
| 335 | when = 0; |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 336 | readTime = 0; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 337 | rawPointerData.clear(); |
| 338 | buttonState = 0; |
| 339 | rawVScroll = 0; |
| 340 | rawHScroll = 0; |
| 341 | } |
| 342 | }; |
| 343 | |
| 344 | struct CookedState { |
| 345 | // Cooked pointer sample data. |
| 346 | CookedPointerData cookedPointerData; |
| 347 | |
| 348 | // Id bits used to differentiate fingers, stylus and mouse tools. |
| 349 | BitSet32 fingerIdBits; |
| 350 | BitSet32 stylusIdBits; |
| 351 | BitSet32 mouseIdBits; |
| 352 | |
| 353 | int32_t buttonState; |
| 354 | |
| 355 | void copyFrom(const CookedState& other) { |
| 356 | cookedPointerData.copyFrom(other.cookedPointerData); |
| 357 | fingerIdBits = other.fingerIdBits; |
| 358 | stylusIdBits = other.stylusIdBits; |
| 359 | mouseIdBits = other.mouseIdBits; |
| 360 | buttonState = other.buttonState; |
| 361 | } |
| 362 | |
| 363 | void clear() { |
| 364 | cookedPointerData.clear(); |
| 365 | fingerIdBits.clear(); |
| 366 | stylusIdBits.clear(); |
| 367 | mouseIdBits.clear(); |
| 368 | buttonState = 0; |
| 369 | } |
| 370 | }; |
| 371 | |
| 372 | std::vector<RawState> mRawStatesPending; |
| 373 | RawState mCurrentRawState; |
| 374 | CookedState mCurrentCookedState; |
| 375 | RawState mLastRawState; |
| 376 | CookedState mLastCookedState; |
| 377 | |
| 378 | // State provided by an external stylus |
| 379 | StylusState mExternalStylusState; |
| 380 | int64_t mExternalStylusId; |
| 381 | nsecs_t mExternalStylusFusionTimeout; |
| 382 | bool mExternalStylusDataPending; |
| 383 | |
| 384 | // True if we sent a HOVER_ENTER event. |
| 385 | bool mSentHoverEnter; |
| 386 | |
| 387 | // Have we assigned pointer IDs for this stream |
| 388 | bool mHavePointerIds; |
| 389 | |
| 390 | // Is the current stream of direct touch events aborted |
| 391 | bool mCurrentMotionAborted; |
| 392 | |
| 393 | // The time the primary pointer last went down. |
| 394 | nsecs_t mDownTime; |
| 395 | |
| 396 | // The pointer controller, or null if the device is not a pointer. |
Michael Wright | 17db18e | 2020-06-26 20:51:44 +0100 | [diff] [blame] | 397 | std::shared_ptr<PointerControllerInterface> mPointerController; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 398 | |
| 399 | std::vector<VirtualKey> mVirtualKeys; |
| 400 | |
| 401 | virtual void configureParameters(); |
| 402 | virtual void dumpParameters(std::string& dump); |
| 403 | virtual void configureRawPointerAxes(); |
| 404 | virtual void dumpRawPointerAxes(std::string& dump); |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 405 | virtual void configureInputDevice(nsecs_t when, bool* outResetNeeded); |
| 406 | virtual void dumpDisplay(std::string& dump); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 407 | virtual void configureVirtualKeys(); |
| 408 | virtual void dumpVirtualKeys(std::string& dump); |
| 409 | virtual void parseCalibration(); |
| 410 | virtual void resolveCalibration(); |
| 411 | virtual void dumpCalibration(std::string& dump); |
| 412 | virtual void updateAffineTransformation(); |
| 413 | virtual void dumpAffineTransformation(std::string& dump); |
| 414 | virtual void resolveExternalStylusPresence(); |
| 415 | virtual bool hasStylus() const = 0; |
| 416 | virtual bool hasExternalStylus() const; |
| 417 | |
| 418 | virtual void syncTouch(nsecs_t when, RawState* outState) = 0; |
| 419 | |
| 420 | private: |
| 421 | // The current viewport. |
| 422 | // The components of the viewport are specified in the display's rotated orientation. |
| 423 | DisplayViewport mViewport; |
| 424 | |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 425 | // The width and height are obtained from the viewport and are specified |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 426 | // in the natural orientation. |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 427 | int32_t mDisplayWidth; |
| 428 | int32_t mDisplayHeight; |
Arthur Hung | 4197f6b | 2020-03-16 15:39:59 +0800 | [diff] [blame] | 429 | |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 430 | // The physical frame is the rectangle in the display's coordinate space that maps to the |
| 431 | // the logical display frame. |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 432 | int32_t mPhysicalWidth; |
| 433 | int32_t mPhysicalHeight; |
| 434 | int32_t mPhysicalLeft; |
| 435 | int32_t mPhysicalTop; |
| 436 | |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 437 | // The orientation of the input device relative to that of the display panel. It specifies |
| 438 | // the rotation of the input device coordinates required to produce the display panel |
| 439 | // orientation, so it will depend on whether the device is orientation aware. |
| 440 | int32_t mInputDeviceOrientation; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 441 | |
| 442 | // Translation and scaling factors, orientation-independent. |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 443 | float mXScale; |
| 444 | float mXPrecision; |
| 445 | |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 446 | float mYScale; |
| 447 | float mYPrecision; |
| 448 | |
| 449 | float mGeometricScale; |
| 450 | |
| 451 | float mPressureScale; |
| 452 | |
| 453 | float mSizeScale; |
| 454 | |
| 455 | float mOrientationScale; |
| 456 | |
| 457 | float mDistanceScale; |
| 458 | |
| 459 | bool mHaveTilt; |
| 460 | float mTiltXCenter; |
| 461 | float mTiltXScale; |
| 462 | float mTiltYCenter; |
| 463 | float mTiltYScale; |
| 464 | |
| 465 | bool mExternalStylusConnected; |
| 466 | |
| 467 | // Oriented motion ranges for input device info. |
| 468 | struct OrientedRanges { |
| 469 | InputDeviceInfo::MotionRange x; |
| 470 | InputDeviceInfo::MotionRange y; |
| 471 | InputDeviceInfo::MotionRange pressure; |
| 472 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 473 | std::optional<InputDeviceInfo::MotionRange> size; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 474 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 475 | std::optional<InputDeviceInfo::MotionRange> touchMajor; |
| 476 | std::optional<InputDeviceInfo::MotionRange> touchMinor; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 477 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 478 | std::optional<InputDeviceInfo::MotionRange> toolMajor; |
| 479 | std::optional<InputDeviceInfo::MotionRange> toolMinor; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 480 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 481 | std::optional<InputDeviceInfo::MotionRange> orientation; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 482 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 483 | std::optional<InputDeviceInfo::MotionRange> distance; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 484 | |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 485 | std::optional<InputDeviceInfo::MotionRange> tilt; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 486 | |
| 487 | void clear() { |
Siarhei Vishniakou | 2421088 | 2022-07-15 09:42:04 -0700 | [diff] [blame^] | 488 | size = std::nullopt; |
| 489 | touchMajor = std::nullopt; |
| 490 | touchMinor = std::nullopt; |
| 491 | toolMajor = std::nullopt; |
| 492 | toolMinor = std::nullopt; |
| 493 | orientation = std::nullopt; |
| 494 | distance = std::nullopt; |
| 495 | tilt = std::nullopt; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 496 | } |
| 497 | } mOrientedRanges; |
| 498 | |
| 499 | // Oriented dimensions and precision. |
| 500 | float mOrientedXPrecision; |
| 501 | float mOrientedYPrecision; |
| 502 | |
| 503 | struct CurrentVirtualKeyState { |
| 504 | bool down; |
| 505 | bool ignored; |
| 506 | nsecs_t downTime; |
| 507 | int32_t keyCode; |
| 508 | int32_t scanCode; |
| 509 | } mCurrentVirtualKey; |
| 510 | |
| 511 | // Scale factor for gesture or mouse based pointer movements. |
| 512 | float mPointerXMovementScale; |
| 513 | float mPointerYMovementScale; |
| 514 | |
| 515 | // Scale factor for gesture based zooming and other freeform motions. |
| 516 | float mPointerXZoomScale; |
| 517 | float mPointerYZoomScale; |
| 518 | |
HQ Liu | e6983c7 | 2022-04-19 22:14:56 +0000 | [diff] [blame] | 519 | // The maximum swipe width between pointers to detect a swipe gesture |
| 520 | // in the number of pixels.Touches that are wider than this are translated |
| 521 | // into freeform gestures. |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 522 | float mPointerGestureMaxSwipeWidth; |
| 523 | |
| 524 | struct PointerDistanceHeapElement { |
| 525 | uint32_t currentPointerIndex : 8; |
| 526 | uint32_t lastPointerIndex : 8; |
| 527 | uint64_t distance : 48; // squared distance |
| 528 | }; |
| 529 | |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 530 | enum class PointerUsage { |
| 531 | NONE, |
| 532 | GESTURES, |
| 533 | STYLUS, |
| 534 | MOUSE, |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 535 | }; |
| 536 | PointerUsage mPointerUsage; |
| 537 | |
| 538 | struct PointerGesture { |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 539 | enum class Mode { |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 540 | // No fingers, button is not pressed. |
| 541 | // Nothing happening. |
| 542 | NEUTRAL, |
| 543 | |
| 544 | // No fingers, button is not pressed. |
| 545 | // Tap detected. |
| 546 | // Emits DOWN and UP events at the pointer location. |
| 547 | TAP, |
| 548 | |
| 549 | // Exactly one finger dragging following a tap. |
| 550 | // Pointer follows the active finger. |
| 551 | // Emits DOWN, MOVE and UP events at the pointer location. |
| 552 | // |
| 553 | // Detect double-taps when the finger goes up while in TAP_DRAG mode. |
| 554 | TAP_DRAG, |
| 555 | |
| 556 | // Button is pressed. |
| 557 | // Pointer follows the active finger if there is one. Other fingers are ignored. |
| 558 | // Emits DOWN, MOVE and UP events at the pointer location. |
| 559 | BUTTON_CLICK_OR_DRAG, |
| 560 | |
| 561 | // Exactly one finger, button is not pressed. |
| 562 | // Pointer follows the active finger. |
| 563 | // Emits HOVER_MOVE events at the pointer location. |
| 564 | // |
| 565 | // Detect taps when the finger goes up while in HOVER mode. |
| 566 | HOVER, |
| 567 | |
| 568 | // Exactly two fingers but neither have moved enough to clearly indicate |
| 569 | // whether a swipe or freeform gesture was intended. We consider the |
| 570 | // pointer to be pressed so this enables clicking or long-pressing on buttons. |
| 571 | // Pointer does not move. |
| 572 | // Emits DOWN, MOVE and UP events with a single stationary pointer coordinate. |
| 573 | PRESS, |
| 574 | |
| 575 | // Exactly two fingers moving in the same direction, button is not pressed. |
| 576 | // Pointer does not move. |
| 577 | // Emits DOWN, MOVE and UP events with a single pointer coordinate that |
| 578 | // follows the midpoint between both fingers. |
| 579 | SWIPE, |
| 580 | |
| 581 | // Two or more fingers moving in arbitrary directions, button is not pressed. |
| 582 | // Pointer does not move. |
| 583 | // Emits DOWN, POINTER_DOWN, MOVE, POINTER_UP and UP events that follow |
| 584 | // each finger individually relative to the initial centroid of the finger. |
| 585 | FREEFORM, |
| 586 | |
| 587 | // Waiting for quiet time to end before starting the next gesture. |
| 588 | QUIET, |
| 589 | }; |
| 590 | |
Prabir Pradhan | 47cf0a0 | 2021-03-11 20:30:57 -0800 | [diff] [blame] | 591 | // When a gesture is sent to an unfocused window, return true if it can bring that window |
| 592 | // into focus, false otherwise. |
| 593 | static bool canGestureAffectWindowFocus(Mode mode) { |
| 594 | switch (mode) { |
| 595 | case Mode::TAP: |
| 596 | case Mode::TAP_DRAG: |
| 597 | case Mode::BUTTON_CLICK_OR_DRAG: |
| 598 | // Taps can affect window focus. |
| 599 | return true; |
| 600 | case Mode::FREEFORM: |
| 601 | case Mode::HOVER: |
| 602 | case Mode::NEUTRAL: |
| 603 | case Mode::PRESS: |
| 604 | case Mode::QUIET: |
| 605 | case Mode::SWIPE: |
| 606 | // Most gestures can be performed on an unfocused window, so they should not |
| 607 | // not affect window focus. |
| 608 | return false; |
| 609 | } |
| 610 | } |
| 611 | |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 612 | // Time the first finger went down. |
| 613 | nsecs_t firstTouchTime; |
| 614 | |
| 615 | // The active pointer id from the raw touch data. |
| 616 | int32_t activeTouchId; // -1 if none |
| 617 | |
| 618 | // The active pointer id from the gesture last delivered to the application. |
| 619 | int32_t activeGestureId; // -1 if none |
| 620 | |
| 621 | // Pointer coords and ids for the current and previous pointer gesture. |
| 622 | Mode currentGestureMode; |
| 623 | BitSet32 currentGestureIdBits; |
| 624 | uint32_t currentGestureIdToIndex[MAX_POINTER_ID + 1]; |
| 625 | PointerProperties currentGestureProperties[MAX_POINTERS]; |
| 626 | PointerCoords currentGestureCoords[MAX_POINTERS]; |
| 627 | |
| 628 | Mode lastGestureMode; |
| 629 | BitSet32 lastGestureIdBits; |
| 630 | uint32_t lastGestureIdToIndex[MAX_POINTER_ID + 1]; |
| 631 | PointerProperties lastGestureProperties[MAX_POINTERS]; |
| 632 | PointerCoords lastGestureCoords[MAX_POINTERS]; |
| 633 | |
| 634 | // Time the pointer gesture last went down. |
| 635 | nsecs_t downTime; |
| 636 | |
| 637 | // Time when the pointer went down for a TAP. |
| 638 | nsecs_t tapDownTime; |
| 639 | |
| 640 | // Time when the pointer went up for a TAP. |
| 641 | nsecs_t tapUpTime; |
| 642 | |
| 643 | // Location of initial tap. |
| 644 | float tapX, tapY; |
| 645 | |
| 646 | // Time we started waiting for quiescence. |
| 647 | nsecs_t quietTime; |
| 648 | |
| 649 | // Reference points for multitouch gestures. |
| 650 | float referenceTouchX; // reference touch X/Y coordinates in surface units |
| 651 | float referenceTouchY; |
| 652 | float referenceGestureX; // reference gesture X/Y coordinates in pixels |
| 653 | float referenceGestureY; |
| 654 | |
| 655 | // Distance that each pointer has traveled which has not yet been |
| 656 | // subsumed into the reference gesture position. |
| 657 | BitSet32 referenceIdBits; |
| 658 | struct Delta { |
| 659 | float dx, dy; |
| 660 | }; |
| 661 | Delta referenceDeltas[MAX_POINTER_ID + 1]; |
| 662 | |
| 663 | // Describes how touch ids are mapped to gesture ids for freeform gestures. |
| 664 | uint32_t freeformTouchToGestureIdMap[MAX_POINTER_ID + 1]; |
| 665 | |
| 666 | // A velocity tracker for determining whether to switch active pointers during drags. |
| 667 | VelocityTracker velocityTracker; |
| 668 | |
| 669 | void reset() { |
| 670 | firstTouchTime = LLONG_MIN; |
| 671 | activeTouchId = -1; |
| 672 | activeGestureId = -1; |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 673 | currentGestureMode = Mode::NEUTRAL; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 674 | currentGestureIdBits.clear(); |
Michael Wright | 227c554 | 2020-07-02 18:30:52 +0100 | [diff] [blame] | 675 | lastGestureMode = Mode::NEUTRAL; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 676 | lastGestureIdBits.clear(); |
| 677 | downTime = 0; |
| 678 | velocityTracker.clear(); |
| 679 | resetTap(); |
| 680 | resetQuietTime(); |
| 681 | } |
| 682 | |
| 683 | void resetTap() { |
| 684 | tapDownTime = LLONG_MIN; |
| 685 | tapUpTime = LLONG_MIN; |
| 686 | } |
| 687 | |
| 688 | void resetQuietTime() { quietTime = LLONG_MIN; } |
| 689 | } mPointerGesture; |
| 690 | |
| 691 | struct PointerSimple { |
| 692 | PointerCoords currentCoords; |
| 693 | PointerProperties currentProperties; |
| 694 | PointerCoords lastCoords; |
| 695 | PointerProperties lastProperties; |
| 696 | |
| 697 | // True if the pointer is down. |
| 698 | bool down; |
| 699 | |
| 700 | // True if the pointer is hovering. |
| 701 | bool hovering; |
| 702 | |
| 703 | // Time the pointer last went down. |
| 704 | nsecs_t downTime; |
| 705 | |
| 706 | void reset() { |
| 707 | currentCoords.clear(); |
| 708 | currentProperties.clear(); |
| 709 | lastCoords.clear(); |
| 710 | lastProperties.clear(); |
| 711 | down = false; |
| 712 | hovering = false; |
| 713 | downTime = 0; |
| 714 | } |
| 715 | } mPointerSimple; |
| 716 | |
| 717 | // The pointer and scroll velocity controls. |
| 718 | VelocityControl mPointerVelocityControl; |
| 719 | VelocityControl mWheelXVelocityControl; |
| 720 | VelocityControl mWheelYVelocityControl; |
| 721 | |
| 722 | std::optional<DisplayViewport> findViewport(); |
| 723 | |
| 724 | void resetExternalStylus(); |
| 725 | void clearStylusDataPendingFlags(); |
| 726 | |
Siarhei Vishniakou | 12c0fcb | 2021-12-17 13:40:44 -0800 | [diff] [blame] | 727 | int32_t clampResolution(const char* axisName, int32_t resolution) const; |
Siarhei Vishniakou | 4e837cc | 2021-12-20 23:24:33 -0800 | [diff] [blame] | 728 | void initializeOrientedRanges(); |
| 729 | void initializeSizeRanges(); |
| 730 | |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 731 | void sync(nsecs_t when, nsecs_t readTime); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 732 | |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 733 | bool consumeRawTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 734 | void processRawTouches(bool timeout); |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 735 | void cookAndDispatch(nsecs_t when, nsecs_t readTime); |
| 736 | void dispatchVirtualKey(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, |
| 737 | int32_t keyEventAction, int32_t keyEventFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 738 | |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 739 | void dispatchTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
| 740 | void dispatchHoverExit(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
| 741 | void dispatchHoverEnterAndMove(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
| 742 | void dispatchButtonRelease(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
| 743 | void dispatchButtonPress(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 744 | const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData); |
| 745 | void cookPointerData(); |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 746 | void abortTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
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 dispatchPointerUsage(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, |
| 749 | PointerUsage pointerUsage); |
| 750 | void abortPointerUsage(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 751 | |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 752 | void dispatchPointerGestures(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, |
| 753 | bool isTimeout); |
| 754 | void abortPointerGestures(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 755 | bool preparePointerGestures(nsecs_t when, bool* outCancelPreviousGesture, |
| 756 | bool* outFinishPreviousGesture, bool isTimeout); |
| 757 | |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 758 | void dispatchPointerStylus(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
| 759 | void abortPointerStylus(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 dispatchPointerMouse(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
| 762 | void abortPointerMouse(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 763 | |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 764 | void dispatchPointerSimple(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, bool down, |
| 765 | bool hovering); |
| 766 | void abortPointerSimple(nsecs_t when, nsecs_t readTime, uint32_t policyFlags); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 767 | |
| 768 | bool assignExternalStylusId(const RawState& state, bool timeout); |
| 769 | void applyExternalStylusButtonState(nsecs_t when); |
| 770 | void applyExternalStylusTouchState(nsecs_t when); |
| 771 | |
| 772 | // Dispatches a motion event. |
| 773 | // If the changedId is >= 0 and the action is POINTER_DOWN or POINTER_UP, the |
| 774 | // method will take care of setting the index and transmuting the action to DOWN or UP |
| 775 | // it is the first / last pointer to go down / up. |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 776 | void dispatchMotion(nsecs_t when, nsecs_t readTime, uint32_t policyFlags, uint32_t source, |
| 777 | int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, |
| 778 | int32_t buttonState, int32_t edgeFlags, const PointerProperties* properties, |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 779 | const PointerCoords* coords, const uint32_t* idToIndex, BitSet32 idBits, |
| 780 | int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime); |
| 781 | |
| 782 | // Updates pointer coords and properties for pointers with specified ids that have moved. |
| 783 | // Returns true if any of them changed. |
| 784 | bool updateMovedPointers(const PointerProperties* inProperties, const PointerCoords* inCoords, |
| 785 | const uint32_t* inIdToIndex, PointerProperties* outProperties, |
| 786 | PointerCoords* outCoords, const uint32_t* outIdToIndex, |
| 787 | BitSet32 idBits) const; |
| 788 | |
Garfield Tan | c734e4f | 2021-01-15 20:01:39 -0800 | [diff] [blame] | 789 | // Returns if this touch device is a touch screen with an associated display. |
| 790 | bool isTouchScreen(); |
| 791 | // Updates touch spots if they are enabled. Should only be used when this device is a |
| 792 | // touchscreen. |
| 793 | void updateTouchSpots(); |
| 794 | |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 795 | bool isPointInsidePhysicalFrame(int32_t x, int32_t y) const; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 796 | const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y); |
| 797 | |
Siarhei Vishniakou | 5747998 | 2021-03-03 01:32:21 +0000 | [diff] [blame] | 798 | static void assignPointerIds(const RawState& last, RawState& current); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 799 | |
| 800 | const char* modeToString(DeviceMode deviceMode); |
Prabir Pradhan | 1728b21 | 2021-10-19 16:00:03 -0700 | [diff] [blame] | 801 | void rotateAndScale(float& x, float& y) const; |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 802 | }; |
| 803 | |
| 804 | } // namespace android |
| 805 | |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 806 | #endif // _UI_INPUTREADER_TOUCH_INPUT_MAPPER_H |