blob: ef0e02f40c500a221dcf440c4cde27b77fa6ed9c [file] [log] [blame]
Prabir Pradhanbaa5c822019-08-30 15:27:05 -07001/*
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
Prabir Pradhan48108662022-09-09 21:22:04 +000017#pragma once
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070018
Harry Cutts3f570c72024-04-05 16:44:28 +000019#include <array>
20#include <climits>
21#include <limits>
22#include <list>
23#include <memory>
Harry Cuttsf13161a2023-03-08 14:15:49 +000024#include <optional>
25#include <string>
Harry Cutts3f570c72024-04-05 16:44:28 +000026#include <utility>
27#include <vector>
Harry Cuttsf13161a2023-03-08 14:15:49 +000028
Harry Cutts3f570c72024-04-05 16:44:28 +000029#include <input/DisplayViewport.h>
30#include <input/Input.h>
31#include <input/InputDevice.h>
32#include <input/VelocityControl.h>
33#include <input/VelocityTracker.h>
Linnan Li13bf76a2024-05-05 19:18:02 +080034#include <stdint.h>
Harry Cutts3f570c72024-04-05 16:44:28 +000035#include <ui/Rect.h>
Michael Wrighta9cf4192022-12-01 23:46:39 +000036#include <ui/Rotation.h>
Harry Cutts3f570c72024-04-05 16:44:28 +000037#include <ui/Size.h>
38#include <ui/Transform.h>
39#include <utils/BitSet.h>
40#include <utils/Timers.h>
Michael Wright227c5542020-07-02 18:30:52 +010041
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070042#include "CursorButtonAccumulator.h"
43#include "CursorScrollAccumulator.h"
44#include "EventHub.h"
45#include "InputMapper.h"
46#include "InputReaderBase.h"
Harry Cutts3f570c72024-04-05 16:44:28 +000047#include "NotifyArgs.h"
Harry Cutts3f570c72024-04-05 16:44:28 +000048#include "StylusState.h"
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070049#include "TouchButtonAccumulator.h"
50
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070051namespace android {
52
Prabir Pradhan7d04c4b2022-10-28 19:23:26 +000053// Maximum amount of latency to add to touch events while waiting for data from an
54// external stylus.
55static constexpr nsecs_t EXTERNAL_STYLUS_DATA_TIMEOUT = ms2ns(72);
56
57// Maximum amount of time to wait on touch data before pushing out new pressure data.
58static constexpr nsecs_t TOUCH_DATA_TIMEOUT = ms2ns(20);
59
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070060/* Raw axis information from the driver. */
61struct RawPointerAxes {
Prabir Pradhand6ccedb2022-09-27 21:04:06 +000062 RawAbsoluteAxisInfo x{};
63 RawAbsoluteAxisInfo y{};
Prabir Pradhan132f21c2024-07-25 16:48:30 +000064 std::optional<RawAbsoluteAxisInfo> pressure{};
65 std::optional<RawAbsoluteAxisInfo> touchMajor{};
66 std::optional<RawAbsoluteAxisInfo> touchMinor{};
67 std::optional<RawAbsoluteAxisInfo> toolMajor{};
68 std::optional<RawAbsoluteAxisInfo> toolMinor{};
69 std::optional<RawAbsoluteAxisInfo> orientation{};
70 std::optional<RawAbsoluteAxisInfo> distance{};
71 std::optional<RawAbsoluteAxisInfo> tiltX{};
72 std::optional<RawAbsoluteAxisInfo> tiltY{};
73 std::optional<RawAbsoluteAxisInfo> trackingId{};
74 std::optional<RawAbsoluteAxisInfo> slot{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070075
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070076 inline int32_t getRawWidth() const { return x.maxValue - x.minValue + 1; }
77 inline int32_t getRawHeight() const { return y.maxValue - y.minValue + 1; }
Prabir Pradhand6ccedb2022-09-27 21:04:06 +000078 inline void clear() { *this = RawPointerAxes(); }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070079};
80
Prabir Pradhand6ccedb2022-09-27 21:04:06 +000081using PropertiesArray = std::array<PointerProperties, MAX_POINTERS>;
82using CoordsArray = std::array<PointerCoords, MAX_POINTERS>;
83using IdToIndexArray = std::array<uint32_t, MAX_POINTER_ID + 1>;
84
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070085/* Raw data for a collection of pointers including a pointer id mapping table. */
86struct RawPointerData {
87 struct Pointer {
Prabir Pradhand6ccedb2022-09-27 21:04:06 +000088 uint32_t id{0xFFFFFFFF};
89 int32_t x{};
90 int32_t y{};
91 int32_t pressure{};
92 int32_t touchMajor{};
93 int32_t touchMinor{};
94 int32_t toolMajor{};
95 int32_t toolMinor{};
96 int32_t orientation{};
97 int32_t distance{};
98 int32_t tiltX{};
99 int32_t tiltY{};
Siarhei Vishniakou6d73f832022-07-21 17:27:03 -0700100 // A fully decoded ToolType constant.
101 ToolType toolType{ToolType::UNKNOWN};
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000102 bool isHovering{false};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700103 };
104
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000105 uint32_t pointerCount{};
106 std::array<Pointer, MAX_POINTERS> pointers{};
107 BitSet32 hoveringIdBits{}, touchingIdBits{}, canceledIdBits{};
108 IdToIndexArray idToIndex{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700109
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000110 inline void clear() { *this = RawPointerData(); }
111
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700112 void getCentroidOfTouchingPointers(float* outX, float* outY) const;
113
114 inline void markIdBit(uint32_t id, bool isHovering) {
115 if (isHovering) {
116 hoveringIdBits.markBit(id);
117 } else {
118 touchingIdBits.markBit(id);
119 }
120 }
121
122 inline void clearIdBits() {
123 hoveringIdBits.clear();
124 touchingIdBits.clear();
arthurhungcc7f9802020-04-30 17:55:40 +0800125 canceledIdBits.clear();
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700126 }
127
128 inline const Pointer& pointerForId(uint32_t id) const { return pointers[idToIndex[id]]; }
129
130 inline bool isHovering(uint32_t pointerIndex) { return pointers[pointerIndex].isHovering; }
131};
132
133/* Cooked data for a collection of pointers including a pointer id mapping table. */
134struct CookedPointerData {
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000135 uint32_t pointerCount{};
136 PropertiesArray pointerProperties{};
137 CoordsArray pointerCoords{};
138 BitSet32 hoveringIdBits{}, touchingIdBits{}, canceledIdBits{}, validIdBits{};
139 IdToIndexArray idToIndex{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700140
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000141 inline void clear() { *this = CookedPointerData(); }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700142
143 inline const PointerCoords& pointerCoordsForId(uint32_t id) const {
144 return pointerCoords[idToIndex[id]];
145 }
146
147 inline PointerCoords& editPointerCoordsWithId(uint32_t id) {
148 return pointerCoords[idToIndex[id]];
149 }
150
151 inline PointerProperties& editPointerPropertiesWithId(uint32_t id) {
152 return pointerProperties[idToIndex[id]];
153 }
154
155 inline bool isHovering(uint32_t pointerIndex) const {
156 return hoveringIdBits.hasBit(pointerProperties[pointerIndex].id);
157 }
158
159 inline bool isTouching(uint32_t pointerIndex) const {
160 return touchingIdBits.hasBit(pointerProperties[pointerIndex].id);
161 }
Nathaniel R. Lewisadb58ea2019-08-21 04:46:29 +0000162
163 inline bool hasPointerCoordsForId(uint32_t id) const { return validIdBits.hasBit(id); }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700164};
165
166class TouchInputMapper : public InputMapper {
167public:
Michael Wright227c5542020-07-02 18:30:52 +0100168 ~TouchInputMapper() override;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700169
Philip Junker4af3b3d2021-12-14 10:36:55 +0100170 uint32_t getSources() const override;
Harry Cuttsd02ea102023-03-17 18:21:30 +0000171 void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
Michael Wright227c5542020-07-02 18:30:52 +0100172 void dump(std::string& dump) override;
Arpit Singh4be4eef2023-03-28 14:26:01 +0000173 [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
Arpit Singhed6c3de2023-04-05 19:24:37 +0000174 const InputReaderConfiguration& config,
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000175 ConfigurationChanges changes) override;
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700176 [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
Harry Cuttsa32a1192024-06-04 15:10:31 +0000177 [[nodiscard]] std::list<NotifyArgs> process(const RawEvent& rawEvent) override;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700178
Michael Wright227c5542020-07-02 18:30:52 +0100179 int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode) override;
180 int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode) override;
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700181 bool markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
Michael Wright227c5542020-07-02 18:30:52 +0100182 uint8_t* outFlags) override;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700183
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700184 [[nodiscard]] std::list<NotifyArgs> cancelTouch(nsecs_t when, nsecs_t readTime) override;
185 [[nodiscard]] std::list<NotifyArgs> timeoutExpired(nsecs_t when) override;
186 [[nodiscard]] std::list<NotifyArgs> updateExternalStylusState(
187 const StylusState& state) override;
Linnan Li13bf76a2024-05-05 19:18:02 +0800188 std::optional<ui::LogicalDisplayId> getAssociatedDisplayId() override;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700189
190protected:
191 CursorButtonAccumulator mCursorButtonAccumulator;
192 CursorScrollAccumulator mCursorScrollAccumulator;
193 TouchButtonAccumulator mTouchButtonAccumulator;
194
195 struct VirtualKey {
196 int32_t keyCode;
197 int32_t scanCode;
198 uint32_t flags;
199
200 // computed hit box, specified in touch screen coords based on known display size
201 int32_t hitLeft;
202 int32_t hitTop;
203 int32_t hitRight;
204 int32_t hitBottom;
205
206 inline bool isHit(int32_t x, int32_t y) const {
207 return x >= hitLeft && x <= hitRight && y >= hitTop && y <= hitBottom;
208 }
209 };
210
211 // Input sources and device mode.
Arpit Singh403e53c2023-04-18 11:46:56 +0000212 uint32_t mSource{0};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700213
Michael Wright227c5542020-07-02 18:30:52 +0100214 enum class DeviceMode {
215 DISABLED, // input is disabled
216 DIRECT, // direct mapping (touchscreen)
Michael Wright227c5542020-07-02 18:30:52 +0100217 NAVIGATION, // unscaled mapping with assist gesture (touch navigation)
Harry Cuttse3aaf392023-06-19 17:13:43 +0000218 POINTER, // pointer mapping (e.g. uncaptured touchpad, drawing tablet)
Dominik Laskowski75788452021-02-09 18:51:25 -0800219
220 ftl_last = POINTER
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700221 };
Arpit Singh403e53c2023-04-18 11:46:56 +0000222 DeviceMode mDeviceMode{DeviceMode::DISABLED};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700223
224 // The reader's configuration.
225 InputReaderConfiguration mConfig;
226
227 // Immutable configuration parameters.
228 struct Parameters {
Michael Wright227c5542020-07-02 18:30:52 +0100229 enum class DeviceType {
230 TOUCH_SCREEN,
Michael Wright227c5542020-07-02 18:30:52 +0100231 TOUCH_NAVIGATION,
232 POINTER,
Dominik Laskowski75788452021-02-09 18:51:25 -0800233
234 ftl_last = POINTER
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700235 };
236
237 DeviceType deviceType;
238 bool hasAssociatedDisplay;
239 bool associatedDisplayIsExternal;
240 bool orientationAware;
Prabir Pradhanac1c74f2021-08-20 16:09:32 -0700241
Michael Wrighta9cf4192022-12-01 23:46:39 +0000242 ui::Rotation orientation;
Prabir Pradhanac1c74f2021-08-20 16:09:32 -0700243
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700244 bool hasButtonUnderPad;
245 std::string uniqueDisplayId;
246
Michael Wright227c5542020-07-02 18:30:52 +0100247 enum class GestureMode {
248 SINGLE_TOUCH,
249 MULTI_TOUCH,
Dominik Laskowski75788452021-02-09 18:51:25 -0800250
251 ftl_last = MULTI_TOUCH
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700252 };
253 GestureMode gestureMode;
254
255 bool wake;
Prabir Pradhan167c2702022-09-14 00:37:24 +0000256
Prabir Pradhane04ffaa2022-12-13 23:04:04 +0000257 // The Universal Stylus Initiative (USI) protocol version supported by this device.
258 std::optional<InputDeviceUsiVersion> usiVersion;
Yuncheol Heo50c19b12022-11-02 20:33:08 -0700259
260 // Allows touches while the display is off.
261 bool enableForInactiveViewport;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700262 } mParameters;
263
264 // Immutable calibration parameters in parsed form.
265 struct Calibration {
266 // Size
Michael Wright227c5542020-07-02 18:30:52 +0100267 enum class SizeCalibration {
268 DEFAULT,
269 NONE,
270 GEOMETRIC,
271 DIAMETER,
272 BOX,
273 AREA,
Siarhei Vishniakou4e837cc2021-12-20 23:24:33 -0800274 ftl_last = AREA
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700275 };
276
277 SizeCalibration sizeCalibration;
278
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700279 std::optional<float> sizeScale;
280 std::optional<float> sizeBias;
281 std::optional<bool> sizeIsSummed;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700282
283 // Pressure
Michael Wright227c5542020-07-02 18:30:52 +0100284 enum class PressureCalibration {
285 DEFAULT,
286 NONE,
287 PHYSICAL,
288 AMPLITUDE,
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700289 };
290
291 PressureCalibration pressureCalibration;
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700292 std::optional<float> pressureScale;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700293
294 // Orientation
Michael Wright227c5542020-07-02 18:30:52 +0100295 enum class OrientationCalibration {
296 DEFAULT,
297 NONE,
298 INTERPOLATED,
299 VECTOR,
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700300 };
301
302 OrientationCalibration orientationCalibration;
303
304 // Distance
Michael Wright227c5542020-07-02 18:30:52 +0100305 enum class DistanceCalibration {
306 DEFAULT,
307 NONE,
308 SCALED,
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700309 };
310
311 DistanceCalibration distanceCalibration;
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700312 std::optional<float> distanceScale;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700313
Siarhei Vishniakou07247342022-07-15 14:27:37 -0700314 inline void applySizeScaleAndBias(float& outSize) const {
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700315 if (sizeScale) {
Siarhei Vishniakou07247342022-07-15 14:27:37 -0700316 outSize *= *sizeScale;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700317 }
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700318 if (sizeBias) {
Siarhei Vishniakou07247342022-07-15 14:27:37 -0700319 outSize += *sizeBias;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700320 }
Siarhei Vishniakou07247342022-07-15 14:27:37 -0700321 if (outSize < 0) {
322 outSize = 0;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700323 }
324 }
325 } mCalibration;
326
327 // Affine location transformation/calibration
328 struct TouchAffineTransformation mAffineTransform;
329
330 RawPointerAxes mRawPointerAxes;
331
332 struct RawState {
Prabir Pradhan2f37bcb2022-11-08 20:41:28 +0000333 nsecs_t when{std::numeric_limits<nsecs_t>::min()};
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000334 nsecs_t readTime{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700335
336 // Raw pointer sample data.
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000337 RawPointerData rawPointerData{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700338
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000339 int32_t buttonState{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700340
341 // Scroll state.
Biswarup Pal8ff5e5e2024-06-15 12:58:20 +0000342 float rawVScroll{};
343 float rawHScroll{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700344
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000345 inline void clear() { *this = RawState(); }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700346 };
347
348 struct CookedState {
349 // Cooked pointer sample data.
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000350 CookedPointerData cookedPointerData{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700351
352 // Id bits used to differentiate fingers, stylus and mouse tools.
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000353 BitSet32 fingerIdBits{};
354 BitSet32 stylusIdBits{};
355 BitSet32 mouseIdBits{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700356
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000357 int32_t buttonState{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700358
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000359 inline void clear() { *this = CookedState(); }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700360 };
361
362 std::vector<RawState> mRawStatesPending;
363 RawState mCurrentRawState;
364 CookedState mCurrentCookedState;
365 RawState mLastRawState;
366 CookedState mLastCookedState;
367
Prabir Pradhan7ff19a12024-07-29 22:40:31 +0000368 enum class ExternalStylusPresence {
369 // No external stylus connected.
370 NONE,
371 // An external stylus that can report touch/pressure that can be fused with the touchscreen.
372 TOUCH_FUSION,
373 // An external stylus that can only report buttons.
374 BUTTON_FUSION,
375 ftl_last = BUTTON_FUSION,
376 };
377 ExternalStylusPresence mExternalStylusPresence{ExternalStylusPresence::NONE};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700378 // State provided by an external stylus
379 StylusState mExternalStylusState;
Prabir Pradhan8d9ba912022-11-11 22:26:33 +0000380 // If an external stylus is capable of reporting pointer-specific data like pressure, we will
381 // attempt to fuse the pointer data reported by the stylus to the first touch pointer. This is
382 // the id of the pointer to which the external stylus data is fused.
383 std::optional<uint32_t> mFusedStylusPointerId;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700384 nsecs_t mExternalStylusFusionTimeout;
385 bool mExternalStylusDataPending;
Prabir Pradhan124ea442022-10-28 20:27:44 +0000386 // A subset of the buttons in mCurrentRawState that came from an external stylus.
Arpit Singha8c236b2023-04-25 13:56:05 +0000387 int32_t mExternalStylusButtonsApplied{0};
Prabir Pradhanb08a0e82023-09-14 22:28:32 +0000388 // True if the current cooked pointer data was modified due to the state of an external stylus.
389 bool mCurrentStreamModifiedByExternalStylus{false};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700390
391 // True if we sent a HOVER_ENTER event.
Arpit Singha8c236b2023-04-25 13:56:05 +0000392 bool mSentHoverEnter{false};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700393
394 // Have we assigned pointer IDs for this stream
Arpit Singha8c236b2023-04-25 13:56:05 +0000395 bool mHavePointerIds{false};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700396
397 // Is the current stream of direct touch events aborted
Arpit Singha8c236b2023-04-25 13:56:05 +0000398 bool mCurrentMotionAborted{false};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700399
400 // The time the primary pointer last went down.
Arpit Singha8c236b2023-04-25 13:56:05 +0000401 nsecs_t mDownTime{0};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700402
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700403 std::vector<VirtualKey> mVirtualKeys;
404
Arpit Singha8c236b2023-04-25 13:56:05 +0000405 explicit TouchInputMapper(InputDeviceContext& deviceContext,
406 const InputReaderConfiguration& readerConfig);
407
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700408 virtual void dumpParameters(std::string& dump);
409 virtual void configureRawPointerAxes();
410 virtual void dumpRawPointerAxes(std::string& dump);
Prabir Pradhan1728b212021-10-19 16:00:03 -0700411 virtual void configureInputDevice(nsecs_t when, bool* outResetNeeded);
412 virtual void dumpDisplay(std::string& dump);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700413 virtual void configureVirtualKeys();
414 virtual void dumpVirtualKeys(std::string& dump);
415 virtual void parseCalibration();
416 virtual void resolveCalibration();
417 virtual void dumpCalibration(std::string& dump);
418 virtual void updateAffineTransformation();
419 virtual void dumpAffineTransformation(std::string& dump);
420 virtual void resolveExternalStylusPresence();
421 virtual bool hasStylus() const = 0;
422 virtual bool hasExternalStylus() const;
423
424 virtual void syncTouch(nsecs_t when, RawState* outState) = 0;
425
426private:
427 // The current viewport.
428 // The components of the viewport are specified in the display's rotated orientation.
429 DisplayViewport mViewport;
430
Prabir Pradhan2d613f42022-11-10 20:22:06 +0000431 // We refer to the display as being in the "natural orientation" when there is no rotation
432 // applied. The display size obtained from the viewport in the natural orientation.
Prabir Pradhan7ddbc952022-11-09 22:03:40 +0000433 // Always starts at (0, 0).
434 ui::Size mDisplayBounds{ui::kInvalidSize};
Arthur Hung4197f6b2020-03-16 15:39:59 +0800435
Prabir Pradhan675f25a2022-11-10 22:04:07 +0000436 // The physical frame is the rectangle in the rotated display's coordinate space that maps to
Prabir Pradhan1728b212021-10-19 16:00:03 -0700437 // the logical display frame.
Prabir Pradhan675f25a2022-11-10 22:04:07 +0000438 Rect mPhysicalFrameInRotatedDisplay{Rect::INVALID_RECT};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700439
Prabir Pradhan1728b212021-10-19 16:00:03 -0700440 // The orientation of the input device relative to that of the display panel. It specifies
441 // the rotation of the input device coordinates required to produce the display panel
442 // orientation, so it will depend on whether the device is orientation aware.
Arpit Singh403e53c2023-04-18 11:46:56 +0000443 ui::Rotation mInputDeviceOrientation{ui::ROTATION_0};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700444
Prabir Pradhanea31d4f2022-11-10 20:48:01 +0000445 // The transform that maps the input device's raw coordinate space to the un-rotated display's
446 // coordinate space. InputReader generates events in the un-rotated display's coordinate space.
447 ui::Transform mRawToDisplay;
448
Prabir Pradhan675f25a2022-11-10 22:04:07 +0000449 // The transform that maps the input device's raw coordinate space to the rotated display's
450 // coordinate space. This used to perform hit-testing of raw events with the physical frame in
451 // the rotated coordinate space. See mPhysicalFrameInRotatedDisplay.
452 ui::Transform mRawToRotatedDisplay;
453
Prabir Pradhane2e10b42022-11-17 20:59:36 +0000454 // The transform used for non-planar raw axes, such as orientation and tilt.
455 ui::Transform mRawRotation;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700456
457 float mGeometricScale;
458
459 float mPressureScale;
460
461 float mSizeScale;
462
463 float mOrientationScale;
464
465 float mDistanceScale;
466
467 bool mHaveTilt;
468 float mTiltXCenter;
469 float mTiltXScale;
470 float mTiltYCenter;
471 float mTiltYScale;
472
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700473 // Oriented motion ranges for input device info.
474 struct OrientedRanges {
475 InputDeviceInfo::MotionRange x;
476 InputDeviceInfo::MotionRange y;
477 InputDeviceInfo::MotionRange pressure;
478
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700479 std::optional<InputDeviceInfo::MotionRange> size;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700480
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700481 std::optional<InputDeviceInfo::MotionRange> touchMajor;
482 std::optional<InputDeviceInfo::MotionRange> touchMinor;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700483
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700484 std::optional<InputDeviceInfo::MotionRange> toolMajor;
485 std::optional<InputDeviceInfo::MotionRange> toolMinor;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700486
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700487 std::optional<InputDeviceInfo::MotionRange> orientation;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700488
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700489 std::optional<InputDeviceInfo::MotionRange> distance;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700490
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700491 std::optional<InputDeviceInfo::MotionRange> tilt;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700492
493 void clear() {
Siarhei Vishniakou24210882022-07-15 09:42:04 -0700494 size = std::nullopt;
495 touchMajor = std::nullopt;
496 touchMinor = std::nullopt;
497 toolMajor = std::nullopt;
498 toolMinor = std::nullopt;
499 orientation = std::nullopt;
500 distance = std::nullopt;
501 tilt = std::nullopt;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700502 }
503 } mOrientedRanges;
504
505 // Oriented dimensions and precision.
506 float mOrientedXPrecision;
507 float mOrientedYPrecision;
508
509 struct CurrentVirtualKeyState {
510 bool down;
511 bool ignored;
512 nsecs_t downTime;
513 int32_t keyCode;
514 int32_t scanCode;
515 } mCurrentVirtualKey;
516
517 // Scale factor for gesture or mouse based pointer movements.
518 float mPointerXMovementScale;
519 float mPointerYMovementScale;
520
521 // Scale factor for gesture based zooming and other freeform motions.
522 float mPointerXZoomScale;
523 float mPointerYZoomScale;
524
HQ Liue6983c72022-04-19 22:14:56 +0000525 // The maximum swipe width between pointers to detect a swipe gesture
526 // in the number of pixels.Touches that are wider than this are translated
527 // into freeform gestures.
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700528 float mPointerGestureMaxSwipeWidth;
529
530 struct PointerDistanceHeapElement {
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000531 uint32_t currentPointerIndex : 8 {};
532 uint32_t lastPointerIndex : 8 {};
533 uint64_t distance : 48 {}; // squared distance
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700534 };
535
Michael Wright227c5542020-07-02 18:30:52 +0100536 enum class PointerUsage {
537 NONE,
538 GESTURES,
539 STYLUS,
540 MOUSE,
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700541 };
Arpit Singha8c236b2023-04-25 13:56:05 +0000542 PointerUsage mPointerUsage{PointerUsage::NONE};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700543
544 struct PointerGesture {
Michael Wright227c5542020-07-02 18:30:52 +0100545 enum class Mode {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700546 // No fingers, button is not pressed.
547 // Nothing happening.
548 NEUTRAL,
549
550 // No fingers, button is not pressed.
551 // Tap detected.
552 // Emits DOWN and UP events at the pointer location.
553 TAP,
554
555 // Exactly one finger dragging following a tap.
556 // Pointer follows the active finger.
557 // Emits DOWN, MOVE and UP events at the pointer location.
558 //
559 // Detect double-taps when the finger goes up while in TAP_DRAG mode.
560 TAP_DRAG,
561
562 // Button is pressed.
563 // Pointer follows the active finger if there is one. Other fingers are ignored.
564 // Emits DOWN, MOVE and UP events at the pointer location.
565 BUTTON_CLICK_OR_DRAG,
566
567 // Exactly one finger, button is not pressed.
568 // Pointer follows the active finger.
569 // Emits HOVER_MOVE events at the pointer location.
570 //
571 // Detect taps when the finger goes up while in HOVER mode.
572 HOVER,
573
574 // Exactly two fingers but neither have moved enough to clearly indicate
575 // whether a swipe or freeform gesture was intended. We consider the
576 // pointer to be pressed so this enables clicking or long-pressing on buttons.
577 // Pointer does not move.
578 // Emits DOWN, MOVE and UP events with a single stationary pointer coordinate.
579 PRESS,
580
581 // Exactly two fingers moving in the same direction, button is not pressed.
582 // Pointer does not move.
583 // Emits DOWN, MOVE and UP events with a single pointer coordinate that
584 // follows the midpoint between both fingers.
585 SWIPE,
586
587 // Two or more fingers moving in arbitrary directions, button is not pressed.
588 // Pointer does not move.
589 // Emits DOWN, POINTER_DOWN, MOVE, POINTER_UP and UP events that follow
590 // each finger individually relative to the initial centroid of the finger.
591 FREEFORM,
592
593 // Waiting for quiet time to end before starting the next gesture.
594 QUIET,
Harry Cuttsc57cd3c2024-04-24 13:52:55 +0000595
596 ftl_last = QUIET,
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700597 };
598
Prabir Pradhan47cf0a02021-03-11 20:30:57 -0800599 // When a gesture is sent to an unfocused window, return true if it can bring that window
600 // into focus, false otherwise.
601 static bool canGestureAffectWindowFocus(Mode mode) {
602 switch (mode) {
603 case Mode::TAP:
604 case Mode::TAP_DRAG:
605 case Mode::BUTTON_CLICK_OR_DRAG:
606 // Taps can affect window focus.
607 return true;
608 case Mode::FREEFORM:
609 case Mode::HOVER:
610 case Mode::NEUTRAL:
611 case Mode::PRESS:
612 case Mode::QUIET:
613 case Mode::SWIPE:
614 // Most gestures can be performed on an unfocused window, so they should not
615 // not affect window focus.
616 return false;
617 }
618 }
619
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700620 // Time the first finger went down.
621 nsecs_t firstTouchTime;
622
623 // The active pointer id from the raw touch data.
624 int32_t activeTouchId; // -1 if none
625
626 // The active pointer id from the gesture last delivered to the application.
627 int32_t activeGestureId; // -1 if none
628
629 // Pointer coords and ids for the current and previous pointer gesture.
630 Mode currentGestureMode;
631 BitSet32 currentGestureIdBits;
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000632 IdToIndexArray currentGestureIdToIndex{};
633 PropertiesArray currentGestureProperties{};
634 CoordsArray currentGestureCoords{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700635
636 Mode lastGestureMode;
637 BitSet32 lastGestureIdBits;
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000638 IdToIndexArray lastGestureIdToIndex{};
639 PropertiesArray lastGestureProperties{};
640 CoordsArray lastGestureCoords{};
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700641
642 // Time the pointer gesture last went down.
643 nsecs_t downTime;
644
645 // Time when the pointer went down for a TAP.
646 nsecs_t tapDownTime;
647
648 // Time when the pointer went up for a TAP.
649 nsecs_t tapUpTime;
650
651 // Location of initial tap.
652 float tapX, tapY;
653
654 // Time we started waiting for quiescence.
655 nsecs_t quietTime;
656
657 // Reference points for multitouch gestures.
658 float referenceTouchX; // reference touch X/Y coordinates in surface units
659 float referenceTouchY;
660 float referenceGestureX; // reference gesture X/Y coordinates in pixels
661 float referenceGestureY;
662
663 // Distance that each pointer has traveled which has not yet been
664 // subsumed into the reference gesture position.
665 BitSet32 referenceIdBits;
666 struct Delta {
667 float dx, dy;
668 };
669 Delta referenceDeltas[MAX_POINTER_ID + 1];
670
671 // Describes how touch ids are mapped to gesture ids for freeform gestures.
672 uint32_t freeformTouchToGestureIdMap[MAX_POINTER_ID + 1];
673
674 // A velocity tracker for determining whether to switch active pointers during drags.
675 VelocityTracker velocityTracker;
676
677 void reset() {
678 firstTouchTime = LLONG_MIN;
679 activeTouchId = -1;
680 activeGestureId = -1;
Michael Wright227c5542020-07-02 18:30:52 +0100681 currentGestureMode = Mode::NEUTRAL;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700682 currentGestureIdBits.clear();
Michael Wright227c5542020-07-02 18:30:52 +0100683 lastGestureMode = Mode::NEUTRAL;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700684 lastGestureIdBits.clear();
685 downTime = 0;
686 velocityTracker.clear();
687 resetTap();
688 resetQuietTime();
689 }
690
691 void resetTap() {
692 tapDownTime = LLONG_MIN;
693 tapUpTime = LLONG_MIN;
694 }
695
696 void resetQuietTime() { quietTime = LLONG_MIN; }
697 } mPointerGesture;
698
699 struct PointerSimple {
700 PointerCoords currentCoords;
701 PointerProperties currentProperties;
702 PointerCoords lastCoords;
703 PointerProperties lastProperties;
704
705 // True if the pointer is down.
706 bool down;
707
708 // True if the pointer is hovering.
709 bool hovering;
710
711 // Time the pointer last went down.
712 nsecs_t downTime;
713
Prabir Pradhanb80b6c02022-11-02 20:05:13 +0000714 // Values reported for the last pointer event.
715 uint32_t source;
Siarhei Vishniakoucfbee532024-05-10 13:41:35 -0700716 ui::LogicalDisplayId displayId{ui::LogicalDisplayId::INVALID};
Prabir Pradhanb80b6c02022-11-02 20:05:13 +0000717 float lastCursorX;
718 float lastCursorY;
719
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700720 void reset() {
721 currentCoords.clear();
722 currentProperties.clear();
723 lastCoords.clear();
724 lastProperties.clear();
725 down = false;
726 hovering = false;
727 downTime = 0;
Prabir Pradhanb80b6c02022-11-02 20:05:13 +0000728 source = 0;
Siarhei Vishniakoucfbee532024-05-10 13:41:35 -0700729 displayId = ui::LogicalDisplayId::INVALID;
Prabir Pradhanb80b6c02022-11-02 20:05:13 +0000730 lastCursorX = 0.f;
731 lastCursorY = 0.f;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700732 }
733 } mPointerSimple;
734
735 // The pointer and scroll velocity controls.
Harry Cuttse78184b2024-01-08 15:54:58 +0000736 SimpleVelocityControl mPointerVelocityControl;
737 SimpleVelocityControl mWheelXVelocityControl;
738 SimpleVelocityControl mWheelYVelocityControl;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700739
740 std::optional<DisplayViewport> findViewport();
741
742 void resetExternalStylus();
743 void clearStylusDataPendingFlags();
744
Siarhei Vishniakou12c0fcb2021-12-17 13:40:44 -0800745 int32_t clampResolution(const char* axisName, int32_t resolution) const;
Siarhei Vishniakou4e837cc2021-12-20 23:24:33 -0800746 void initializeOrientedRanges();
747 void initializeSizeRanges();
748
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700749 [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when, nsecs_t readTime);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700750
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700751 [[nodiscard]] std::list<NotifyArgs> consumeRawTouches(nsecs_t when, nsecs_t readTime,
752 uint32_t policyFlags, bool& outConsumed);
753 [[nodiscard]] std::list<NotifyArgs> processRawTouches(bool timeout);
754 [[nodiscard]] std::list<NotifyArgs> cookAndDispatch(nsecs_t when, nsecs_t readTime);
755 [[nodiscard]] NotifyKeyArgs dispatchVirtualKey(nsecs_t when, nsecs_t readTime,
756 uint32_t policyFlags, int32_t keyEventAction,
757 int32_t keyEventFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700758
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700759 [[nodiscard]] std::list<NotifyArgs> dispatchTouches(nsecs_t when, nsecs_t readTime,
760 uint32_t policyFlags);
761 [[nodiscard]] std::list<NotifyArgs> dispatchHoverExit(nsecs_t when, nsecs_t readTime,
762 uint32_t policyFlags);
763 [[nodiscard]] std::list<NotifyArgs> dispatchHoverEnterAndMove(nsecs_t when, nsecs_t readTime,
764 uint32_t policyFlags);
765 [[nodiscard]] std::list<NotifyArgs> dispatchButtonRelease(nsecs_t when, nsecs_t readTime,
766 uint32_t policyFlags);
767 [[nodiscard]] std::list<NotifyArgs> dispatchButtonPress(nsecs_t when, nsecs_t readTime,
768 uint32_t policyFlags);
LiZhihong758eb562022-11-03 15:28:29 +0800769 [[nodiscard]] std::list<NotifyArgs> dispatchGestureButtonPress(nsecs_t when,
770 uint32_t policyFlags,
771 BitSet32 idBits,
772 nsecs_t readTime);
773 [[nodiscard]] std::list<NotifyArgs> dispatchGestureButtonRelease(nsecs_t when,
774 uint32_t policyFlags,
775 BitSet32 idBits,
776 nsecs_t readTime);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700777 const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData);
778 void cookPointerData();
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700779 [[nodiscard]] std::list<NotifyArgs> abortTouches(nsecs_t when, nsecs_t readTime,
780 uint32_t policyFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700781
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700782 [[nodiscard]] std::list<NotifyArgs> dispatchPointerUsage(nsecs_t when, nsecs_t readTime,
783 uint32_t policyFlags,
784 PointerUsage pointerUsage);
785 [[nodiscard]] std::list<NotifyArgs> abortPointerUsage(nsecs_t when, nsecs_t readTime,
786 uint32_t policyFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700787
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700788 [[nodiscard]] std::list<NotifyArgs> dispatchPointerGestures(nsecs_t when, nsecs_t readTime,
789 uint32_t policyFlags,
790 bool isTimeout);
791 [[nodiscard]] std::list<NotifyArgs> abortPointerGestures(nsecs_t when, nsecs_t readTime,
792 uint32_t policyFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700793 bool preparePointerGestures(nsecs_t when, bool* outCancelPreviousGesture,
794 bool* outFinishPreviousGesture, bool isTimeout);
795
Harry Cuttsbea6ce52022-10-14 15:17:30 +0000796 // Returns true if we're in a period of "quiet time" when touchpad gestures should be ignored.
797 bool checkForTouchpadQuietTime(nsecs_t when);
798
799 std::pair<int32_t, float> getFastestFinger();
800
801 void prepareMultiFingerPointerGestures(nsecs_t when, bool* outCancelPreviousGesture,
802 bool* outFinishPreviousGesture);
803
Harry Cutts714d1ad2022-08-24 16:36:43 +0000804 // Moves the on-screen mouse pointer based on the movement of the pointer of the given ID
805 // between the last and current events. Uses a relative motion.
806 void moveMousePointerFromPointerDelta(nsecs_t when, uint32_t pointerId);
807
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700808 [[nodiscard]] std::list<NotifyArgs> dispatchPointerStylus(nsecs_t when, nsecs_t readTime,
809 uint32_t policyFlags);
810 [[nodiscard]] std::list<NotifyArgs> abortPointerStylus(nsecs_t when, nsecs_t readTime,
811 uint32_t policyFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700812
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700813 [[nodiscard]] std::list<NotifyArgs> dispatchPointerMouse(nsecs_t when, nsecs_t readTime,
814 uint32_t policyFlags);
815 [[nodiscard]] std::list<NotifyArgs> abortPointerMouse(nsecs_t when, nsecs_t readTime,
816 uint32_t policyFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700817
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700818 [[nodiscard]] std::list<NotifyArgs> dispatchPointerSimple(nsecs_t when, nsecs_t readTime,
819 uint32_t policyFlags, bool down,
Linnan Li13bf76a2024-05-05 19:18:02 +0800820 bool hovering,
821 ui::LogicalDisplayId displayId);
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700822 [[nodiscard]] std::list<NotifyArgs> abortPointerSimple(nsecs_t when, nsecs_t readTime,
823 uint32_t policyFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700824
Prabir Pradhan3f7545f2022-10-19 16:56:39 +0000825 // Attempts to assign a pointer id to the external stylus. Returns true if the state should be
826 // withheld from further processing while waiting for data from the stylus.
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700827 bool assignExternalStylusId(const RawState& state, bool timeout);
828 void applyExternalStylusButtonState(nsecs_t when);
829 void applyExternalStylusTouchState(nsecs_t when);
830
831 // Dispatches a motion event.
832 // If the changedId is >= 0 and the action is POINTER_DOWN or POINTER_UP, the
833 // method will take care of setting the index and transmuting the action to DOWN or UP
834 // it is the first / last pointer to go down / up.
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700835 [[nodiscard]] NotifyMotionArgs dispatchMotion(
836 nsecs_t when, nsecs_t readTime, uint32_t policyFlags, uint32_t source, int32_t action,
837 int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState,
Prabir Pradhand6ccedb2022-09-27 21:04:06 +0000838 int32_t edgeFlags, const PropertiesArray& properties, const CoordsArray& coords,
839 const IdToIndexArray& idToIndex, BitSet32 idBits, int32_t changedId, float xPrecision,
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700840 float yPrecision, nsecs_t downTime, MotionClassification classification);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700841
Garfield Tanc734e4f2021-01-15 20:01:39 -0800842 // Returns if this touch device is a touch screen with an associated display.
843 bool isTouchScreen();
Garfield Tanc734e4f2021-01-15 20:01:39 -0800844
Prabir Pradhan1728b212021-10-19 16:00:03 -0700845 bool isPointInsidePhysicalFrame(int32_t x, int32_t y) const;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700846 const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y);
847
Siarhei Vishniakou57479982021-03-03 01:32:21 +0000848 static void assignPointerIds(const RawState& last, RawState& current);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700849
Prabir Pradhan7d9cb5a2023-03-14 21:18:07 +0000850 // Compute input transforms for DIRECT and POINTER modes.
Prabir Pradhan675f25a2022-11-10 22:04:07 +0000851 void computeInputTransforms();
Arpit Singh403e53c2023-04-18 11:46:56 +0000852 static Parameters::DeviceType computeDeviceType(const InputDeviceContext& deviceContext);
853 static Parameters computeParameters(const InputDeviceContext& deviceContext);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700854};
855
856} // namespace android