• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INPUT_HANDLER_TYPE_H
17 #define INPUT_HANDLER_TYPE_H
18 #include <limits>
19 
20 namespace OHOS {
21 namespace MMI {
22 namespace {
23     constexpr size_t    MAX_N_INPUT_HANDLERS { 16 };
24     constexpr size_t    MAX_N_INPUT_MONITORS { MAX_N_INPUT_HANDLERS };
25     constexpr size_t    MAX_N_INPUT_INTERCEPTORS { MAX_N_INPUT_HANDLERS };
26     constexpr int32_t   MIN_HANDLER_ID { 1 };
27     constexpr int32_t   INVALID_HANDLER_ID { -1 };
28 }
29 
30 enum InputHandlerType : int32_t {
31     NONE,
32     INTERCEPTOR,
33     MONITOR,
34 };
35 
IsValidHandlerType(InputHandlerType handlerType)36 inline bool IsValidHandlerType(InputHandlerType handlerType)
37 {
38     return ((handlerType == InputHandlerType::INTERCEPTOR) ||
39         (handlerType == InputHandlerType::MONITOR));
40 }
41 
IsValidHandlerId(int32_t handlerId)42 inline bool IsValidHandlerId(int32_t handlerId)
43 {
44     return ((handlerId >= MIN_HANDLER_ID) && (handlerId < std::numeric_limits<int32_t>::max()));
45 }
46 } // namespace MMI
47 } // namespace OHOS
48 #endif // INPUT_HANDLER_TYPE_H