blob: 1bbf38676abfd747441545ba06eb11e134aeabb4 [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
Arthur Hungb060def2022-05-26 07:41:33 +000023#include <log/log.h>
24#include <log/log_event_list.h>
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070025
Arthur Hungb060def2022-05-26 07:41:33 +000026namespace android {
27/**
28 * Log debug messages for each raw event received from the EventHub.
29 * Enable this via "adb shell setprop log.tag.InputReaderRawEvents DEBUG" (requires restart)
30 */
31const bool DEBUG_RAW_EVENTS =
32 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "RawEvents", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070033
Arthur Hungb060def2022-05-26 07:41:33 +000034/**
35 * Log debug messages about virtual key processing.
36 * Enable this via "adb shell setprop log.tag.InputReaderVirtualKeys DEBUG" (requires restart)
37 */
38const bool DEBUG_VIRTUAL_KEYS =
39 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "VirtualKeys", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070040
Arthur Hungb060def2022-05-26 07:41:33 +000041/**
42 * Log debug messages about pointers.
43 * Enable this via "adb shell setprop log.tag.InputReaderPointers DEBUG" (requires restart)
44 */
45const bool DEBUG_POINTERS =
46 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Pointers", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070047
Arthur Hungb060def2022-05-26 07:41:33 +000048/**
49 * Log debug messages about pointer assignment calculations.
50 * Enable this via "adb shell setprop log.tag.InputReaderPointerAssignment DEBUG" (requires restart)
51 */
52const bool DEBUG_POINTER_ASSIGNMENT =
53 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "PointerAssignment", ANDROID_LOG_INFO);
54/**
55 * Log debug messages about gesture detection.
56 * Enable this via "adb shell setprop log.tag.InputReaderGestures DEBUG" (requires restart)
57 */
58const bool DEBUG_GESTURES =
59 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Gestures", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070060
Arthur Hungb060def2022-05-26 07:41:33 +000061/**
62 * Log debug messages about the vibrator.
63 * Enable this via "adb shell setprop log.tag.InputReaderVibrator DEBUG" (requires restart)
64 */
65const bool DEBUG_VIBRATOR =
66 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Vibrator", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070067
Arthur Hungb060def2022-05-26 07:41:33 +000068/**
69 * Log debug messages about fusing stylus data.
70 * Enable this via "adb shell setprop log.tag.InputReaderStylusFusion DEBUG" (requires restart)
71 */
72const bool DEBUG_STYLUS_FUSION =
73 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "StylusFusion", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070074
Arthur Hungb060def2022-05-26 07:41:33 +000075/**
76 * Log detailed debug messages about input device lights.
77 * Enable this via "adb shell setprop log.tag.InputReaderLightDetails DEBUG" (requires restart)
78 */
79const bool DEBUG_LIGHT_DETAILS =
80 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "LightDetails", ANDROID_LOG_INFO);
81} // namespace android
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070082
83#define INDENT " "
84#define INDENT2 " "
85#define INDENT3 " "
86#define INDENT4 " "
87#define INDENT5 " "
88
89#include <input/Input.h>
90
91namespace android {
92
93// --- Static Functions ---
94
95template <typename T>
96inline static T abs(const T& value) {
97 return value < 0 ? -value : value;
98}
99
100template <typename T>
101inline static T min(const T& a, const T& b) {
102 return a < b ? a : b;
103}
104
105inline static float avg(float x, float y) {
106 return (x + y) / 2;
107}
108
109static inline const char* toString(bool value) {
110 return value ? "true" : "false";
111}
112
113static inline bool sourcesMatchMask(uint32_t sources, uint32_t sourceMask) {
114 return (sources & sourceMask & ~AINPUT_SOURCE_CLASS_MASK) != 0;
115}
116
117} // namespace android
118
119#endif // _UI_INPUTREADER_MACROS_H