blob: d4589f53b5d6f7979a3b7f919e9c47740bf958c1 [file] [log] [blame]
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -08001/*
2 * Copyright (C) 2023 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#pragma once
18
19#include <input/Input.h>
20#include <map>
21
22namespace android {
23
24/*
25 * Crash if the provided touch stream is inconsistent.
26 *
27 * TODO(b/211379801): Add support for hover events:
28 * - No hover move without enter
29 * - No touching pointers when hover enter
30 * - No hovering pointers when touching
31 * - Only 1 hovering pointer max
32 */
33class InputVerifier {
34public:
35 InputVerifier(const std::string& name);
36
37 void processMovement(int32_t deviceId, int32_t action, uint32_t pointerCount,
38 const PointerProperties* pointerProperties,
39 const PointerCoords* pointerCoords, int32_t flags);
40
41private:
42 const std::string mName;
43 std::map<int32_t /*deviceId*/, std::bitset<MAX_POINTER_ID + 1>> mTouchingPointerIdsByDevice;
44 void ensureTouchingPointersMatch(int32_t deviceId, uint32_t pointerCount,
45 const PointerProperties* pointerProperties,
46 const char* action) const;
47};
48
49} // namespace android