blob: d8376894f6075583bd5e9b392e3acd94a3d54b4d [file] [log] [blame]
Prabir Pradhanbaa5c822019-08-30 15:27:05 -07001/*
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.
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -080025static constexpr bool DEBUG_RAW_EVENTS = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070026
27// Log debug messages about virtual key processing.
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -080028static constexpr bool DEBUG_VIRTUAL_KEYS = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070029
30// Log debug messages about pointers.
Siarhei Vishniakoue3ce49d2020-09-29 19:08:13 -050031static constexpr bool DEBUG_POINTERS = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070032
33// Log debug messages about pointer assignment calculations.
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -080034static constexpr bool DEBUG_POINTER_ASSIGNMENT = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070035
36// Log debug messages about gesture detection.
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -080037static constexpr bool DEBUG_GESTURES = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070038
39// Log debug messages about the vibrator.
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -080040static constexpr bool DEBUG_VIBRATOR = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070041
42// Log debug messages about fusing stylus data.
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -080043static constexpr bool DEBUG_STYLUS_FUSION = false;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070044
45#define INDENT " "
46#define INDENT2 " "
47#define INDENT3 " "
48#define INDENT4 " "
49#define INDENT5 " "
50
51#include <input/Input.h>
52
53namespace android {
54
55// --- Static Functions ---
56
57template <typename T>
58inline static T abs(const T& value) {
59 return value < 0 ? -value : value;
60}
61
62template <typename T>
63inline static T min(const T& a, const T& b) {
64 return a < b ? a : b;
65}
66
67inline static float avg(float x, float y) {
68 return (x + y) / 2;
69}
70
71static inline const char* toString(bool value) {
72 return value ? "true" : "false";
73}
74
75static 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