Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 1 | /* |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 2 | * Copyright 2023 The Android Open Source Project |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 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 | |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 19 | #include <android-base/result.h> |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 20 | #include <input/Input.h> |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 21 | #include "rust/cxx.h" |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 25 | namespace input { |
| 26 | namespace verifier { |
| 27 | struct InputVerifier; |
| 28 | } |
| 29 | } // namespace input |
| 30 | |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 31 | /* |
| 32 | * Crash if the provided touch stream is inconsistent. |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 33 | * 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 Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 38 | * |
| 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 | */ |
| 45 | class InputVerifier { |
| 46 | public: |
| 47 | InputVerifier(const std::string& name); |
| 48 | |
Siarhei Vishniakou | 2d151ac | 2023-09-19 13:30:24 -0700 | [diff] [blame] | 49 | android::base::Result<void> processMovement(int32_t deviceId, int32_t source, int32_t action, |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 50 | uint32_t pointerCount, |
| 51 | const PointerProperties* pointerProperties, |
| 52 | const PointerCoords* pointerCoords, int32_t flags); |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 53 | |
Siarhei Vishniakou | 1160ecd | 2023-06-28 15:57:47 -0700 | [diff] [blame] | 54 | void resetDevice(int32_t deviceId); |
| 55 | |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 56 | private: |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 57 | rust::Box<android::input::verifier::InputVerifier> mVerifier; |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace android |