1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef _UI_INPUTREADER_MACROS_H
18 #define _UI_INPUTREADER_MACROS_H
19
20 #define LOG_TAG "InputReader"
21
22 //#define LOG_NDEBUG 0
23
24 // Log debug messages for each raw event received from the EventHub.
25 static constexpr bool DEBUG_RAW_EVENTS = false;
26
27 // Log debug messages about virtual key processing.
28 static constexpr bool DEBUG_VIRTUAL_KEYS = false;
29
30 // Log debug messages about pointers.
31 static constexpr bool DEBUG_POINTERS = false;
32
33 // Log debug messages about pointer assignment calculations.
34 static constexpr bool DEBUG_POINTER_ASSIGNMENT = false;
35
36 // Log debug messages about gesture detection.
37 static constexpr bool DEBUG_GESTURES = false;
38
39 // Log debug messages about the vibrator.
40 static constexpr bool DEBUG_VIBRATOR = false;
41
42 // Log debug messages about fusing stylus data.
43 static constexpr bool DEBUG_STYLUS_FUSION = false;
44
45 #define INDENT " "
46 #define INDENT2 " "
47 #define INDENT3 " "
48 #define INDENT4 " "
49 #define INDENT5 " "
50
51 #include <input/Input.h>
52
53 namespace android {
54
55 // --- Static Functions ---
56
57 template <typename T>
abs(const T & value)58 inline static T abs(const T& value) {
59 return value < 0 ? -value : value;
60 }
61
62 template <typename T>
min(const T & a,const T & b)63 inline static T min(const T& a, const T& b) {
64 return a < b ? a : b;
65 }
66
avg(float x,float y)67 inline static float avg(float x, float y) {
68 return (x + y) / 2;
69 }
70
toString(bool value)71 static inline const char* toString(bool value) {
72 return value ? "true" : "false";
73 }
74
sourcesMatchMask(uint32_t sources,uint32_t sourceMask)75 static inline bool sourcesMatchMask(uint32_t sources, uint32_t sourceMask) {
76 return (sources & sourceMask & ~AINPUT_SOURCE_CLASS_MASK) != 0;
77 }
78
79 } // namespace android
80
81 #endif // _UI_INPUTREADER_MACROS_H