• 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 
19 namespace OHOS {
20 namespace MMI {
21 inline constexpr size_t    MAX_N_INPUT_HANDLERS { 16 };
22 inline constexpr size_t    MAX_N_INPUT_MONITORS { MAX_N_INPUT_HANDLERS };
23 inline constexpr size_t    MAX_N_INPUT_INTERCEPTORS { MAX_N_INPUT_HANDLERS };
24 inline constexpr int32_t   MIN_HANDLER_ID { 1 };
25 inline constexpr int32_t   INVALID_HANDLER_ID { -1 };
26 inline constexpr int32_t   ERROR_EXCEED_MAX_COUNT { -4100001 };
27 inline constexpr int32_t   DEFUALT_INTERCEPTOR_PRIORITY { 500 };
28 
29 enum InputHandlerType : int32_t {
30     NONE,
31     INTERCEPTOR,
32     MONITOR,
33 };
34 
35 using HandleEventType = uint32_t;
36 inline constexpr HandleEventType HANDLE_EVENT_TYPE_NONE { 0x0 };
37 inline constexpr HandleEventType HANDLE_EVENT_TYPE_KEY { 0x1 };
38 inline constexpr HandleEventType HANDLE_EVENT_TYPE_POINTER { 0x2 };
39 inline constexpr HandleEventType HANDLE_EVENT_TYPE_ALL { HANDLE_EVENT_TYPE_KEY | HANDLE_EVENT_TYPE_POINTER };
40 
IsValidHandlerType(InputHandlerType handlerType)41 inline bool IsValidHandlerType(InputHandlerType handlerType)
42 {
43     return ((handlerType == InputHandlerType::INTERCEPTOR) ||
44         (handlerType == InputHandlerType::MONITOR));
45 }
46 
IsValidHandlerId(int32_t handlerId)47 inline bool IsValidHandlerId(int32_t handlerId)
48 {
49     return ((handlerId >= MIN_HANDLER_ID) && (handlerId < std::numeric_limits<int32_t>::max()));
50 }
51 } // namespace MMI
52 } // namespace OHOS
53 #endif // INPUT_HANDLER_TYPE_H