blob: 14dd463425a411a996e5df2ef048504ea93062b1 [file] [log] [blame]
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -08001/*
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -07002 * Copyright 2023 The Android Open Source Project
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -08003 *
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
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070019#include <android-base/result.h>
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080020#include <input/Input.h>
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070021#include "rust/cxx.h"
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080022
23namespace android {
24
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070025namespace input {
26namespace verifier {
27struct InputVerifier;
28}
29} // namespace input
30
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080031/*
32 * Crash if the provided touch stream is inconsistent.
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070033 * This class is a pass-through to the rust implementation of InputVerifier.
34 * The rust class could also be used directly, but it would be less convenient.
35 * We can't directly invoke the rust methods on a rust object. So, there's no way to do:
36 * mVerifier.process_movement(...).
37 * This C++ class makes it a bit easier to use.
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080038 *
39 * TODO(b/211379801): Add support for hover events:
40 * - No hover move without enter
41 * - No touching pointers when hover enter
42 * - No hovering pointers when touching
43 * - Only 1 hovering pointer max
44 */
45class InputVerifier {
46public:
47 InputVerifier(const std::string& name);
48
Siarhei Vishniakou2d151ac2023-09-19 13:30:24 -070049 android::base::Result<void> processMovement(int32_t deviceId, int32_t source, int32_t action,
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070050 uint32_t pointerCount,
51 const PointerProperties* pointerProperties,
52 const PointerCoords* pointerCoords, int32_t flags);
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080053
Siarhei Vishniakou1160ecd2023-06-28 15:57:47 -070054 void resetDevice(int32_t deviceId);
55
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080056private:
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070057 rust::Box<android::input::verifier::InputVerifier> mVerifier;
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -080058};
59
60} // namespace android