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