1*38e8c45fSAndroid Build Coastguard Worker /* 2*38e8c45fSAndroid Build Coastguard Worker * Copyright (C) 2019 The Android Open Source Project 3*38e8c45fSAndroid Build Coastguard Worker * 4*38e8c45fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*38e8c45fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*38e8c45fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*38e8c45fSAndroid Build Coastguard Worker * 8*38e8c45fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*38e8c45fSAndroid Build Coastguard Worker * 10*38e8c45fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*38e8c45fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*38e8c45fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*38e8c45fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*38e8c45fSAndroid Build Coastguard Worker * limitations under the License. 15*38e8c45fSAndroid Build Coastguard Worker */ 16*38e8c45fSAndroid Build Coastguard Worker 17*38e8c45fSAndroid Build Coastguard Worker #pragma once 18*38e8c45fSAndroid Build Coastguard Worker 19*38e8c45fSAndroid Build Coastguard Worker #include "trace/EventTrackerInterface.h" 20*38e8c45fSAndroid Build Coastguard Worker 21*38e8c45fSAndroid Build Coastguard Worker #include <input/Input.h> 22*38e8c45fSAndroid Build Coastguard Worker #include <bitset> 23*38e8c45fSAndroid Build Coastguard Worker #include <optional> 24*38e8c45fSAndroid Build Coastguard Worker 25*38e8c45fSAndroid Build Coastguard Worker namespace android { 26*38e8c45fSAndroid Build Coastguard Worker namespace inputdispatcher { 27*38e8c45fSAndroid Build Coastguard Worker 28*38e8c45fSAndroid Build Coastguard Worker /* Specifies which events are to be canceled and why. */ 29*38e8c45fSAndroid Build Coastguard Worker struct CancelationOptions { 30*38e8c45fSAndroid Build Coastguard Worker enum class Mode { 31*38e8c45fSAndroid Build Coastguard Worker CANCEL_ALL_EVENTS = 0, 32*38e8c45fSAndroid Build Coastguard Worker CANCEL_POINTER_EVENTS = 1, 33*38e8c45fSAndroid Build Coastguard Worker CANCEL_NON_POINTER_EVENTS = 2, 34*38e8c45fSAndroid Build Coastguard Worker CANCEL_FALLBACK_EVENTS = 3, 35*38e8c45fSAndroid Build Coastguard Worker CANCEL_HOVER_EVENTS = 4, 36*38e8c45fSAndroid Build Coastguard Worker ftl_last = CANCEL_HOVER_EVENTS 37*38e8c45fSAndroid Build Coastguard Worker }; 38*38e8c45fSAndroid Build Coastguard Worker 39*38e8c45fSAndroid Build Coastguard Worker // The criterion to use to determine which events should be canceled. 40*38e8c45fSAndroid Build Coastguard Worker Mode mode; 41*38e8c45fSAndroid Build Coastguard Worker 42*38e8c45fSAndroid Build Coastguard Worker // Descriptive reason for the cancelation. 43*38e8c45fSAndroid Build Coastguard Worker const char* reason; 44*38e8c45fSAndroid Build Coastguard Worker 45*38e8c45fSAndroid Build Coastguard Worker // The specific keycode of the key event to cancel, or nullopt to cancel any key event. 46*38e8c45fSAndroid Build Coastguard Worker std::optional<int32_t> keyCode = std::nullopt; 47*38e8c45fSAndroid Build Coastguard Worker 48*38e8c45fSAndroid Build Coastguard Worker // The specific device id of events to cancel, or nullopt to cancel events from any device. 49*38e8c45fSAndroid Build Coastguard Worker std::optional<int32_t> deviceId = std::nullopt; 50*38e8c45fSAndroid Build Coastguard Worker 51*38e8c45fSAndroid Build Coastguard Worker // The specific display id of events to cancel, or nullopt to cancel events on any display. 52*38e8c45fSAndroid Build Coastguard Worker std::optional<ui::LogicalDisplayId> displayId = std::nullopt; 53*38e8c45fSAndroid Build Coastguard Worker 54*38e8c45fSAndroid Build Coastguard Worker // The specific pointers to cancel, or nullopt to cancel all pointer events 55*38e8c45fSAndroid Build Coastguard Worker std::optional<std::bitset<MAX_POINTER_ID + 1>> pointerIds = std::nullopt; 56*38e8c45fSAndroid Build Coastguard Worker 57*38e8c45fSAndroid Build Coastguard Worker const std::unique_ptr<trace::EventTrackerInterface>& traceTracker; 58*38e8c45fSAndroid Build Coastguard Worker CancelationOptionsCancelationOptions59*38e8c45fSAndroid Build Coastguard Worker explicit CancelationOptions(Mode mode, const char* reason, 60*38e8c45fSAndroid Build Coastguard Worker const std::unique_ptr<trace::EventTrackerInterface>& traceTracker) 61*38e8c45fSAndroid Build Coastguard Worker : mode(mode), reason(reason), traceTracker(traceTracker) {} 62*38e8c45fSAndroid Build Coastguard Worker CancelationOptions(const CancelationOptions&) = delete; 63*38e8c45fSAndroid Build Coastguard Worker CancelationOptions operator=(const CancelationOptions&) = delete; 64*38e8c45fSAndroid Build Coastguard Worker }; 65*38e8c45fSAndroid Build Coastguard Worker 66*38e8c45fSAndroid Build Coastguard Worker } // namespace inputdispatcher 67*38e8c45fSAndroid Build Coastguard Worker } // namespace android 68