Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -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 | |
Prabir Pradhan | 4810866 | 2022-09-09 21:22:04 +0000 | [diff] [blame] | 17 | #pragma once |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 18 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 19 | #include <utils/BitSet.h> |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 20 | #include <optional> |
| 21 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 22 | namespace android { |
| 23 | namespace inputdispatcher { |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 24 | |
| 25 | /* Specifies which events are to be canceled and why. */ |
| 26 | struct CancelationOptions { |
Michael Wright | fb04fd5 | 2022-11-24 22:31:11 +0000 | [diff] [blame^] | 27 | enum class Mode { |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 28 | CANCEL_ALL_EVENTS = 0, |
| 29 | CANCEL_POINTER_EVENTS = 1, |
| 30 | CANCEL_NON_POINTER_EVENTS = 2, |
| 31 | CANCEL_FALLBACK_EVENTS = 3, |
| 32 | }; |
| 33 | |
| 34 | // The criterion to use to determine which events should be canceled. |
| 35 | Mode mode; |
| 36 | |
| 37 | // Descriptive reason for the cancelation. |
| 38 | const char* reason; |
| 39 | |
| 40 | // The specific keycode of the key event to cancel, or nullopt to cancel any key event. |
| 41 | std::optional<int32_t> keyCode = std::nullopt; |
| 42 | |
| 43 | // The specific device id of events to cancel, or nullopt to cancel events from any device. |
| 44 | std::optional<int32_t> deviceId = std::nullopt; |
| 45 | |
| 46 | // The specific display id of events to cancel, or nullopt to cancel events on any display. |
| 47 | std::optional<int32_t> displayId = std::nullopt; |
| 48 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 49 | // The specific pointers to cancel, or nullopt to cancel all pointer events |
| 50 | std::optional<BitSet32> pointerIds = std::nullopt; |
| 51 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 52 | CancelationOptions(Mode mode, const char* reason) : mode(mode), reason(reason) {} |
| 53 | }; |
| 54 | |
Vaibhav Devmurari | ff798f3 | 2022-05-09 23:45:04 +0000 | [diff] [blame] | 55 | } // namespace inputdispatcher |
| 56 | } // namespace android |