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