blob: e107d882b7e9ae172856ad9c2a3742560d18a249 [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
Prabir Pradhan48108662022-09-09 21:22:04 +000017#pragma once
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070018
19#define LOG_TAG "InputReader"
20
21//#define LOG_NDEBUG 0
Arthur Hungb060def2022-05-26 07:41:33 +000022#include <log/log.h>
23#include <log/log_event_list.h>
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070024
Arthur Hungb060def2022-05-26 07:41:33 +000025namespace android {
26/**
27 * Log debug messages for each raw event received from the EventHub.
28 * Enable this via "adb shell setprop log.tag.InputReaderRawEvents DEBUG" (requires restart)
29 */
30const bool DEBUG_RAW_EVENTS =
31 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "RawEvents", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070032
Arthur Hungb060def2022-05-26 07:41:33 +000033/**
34 * Log debug messages about virtual key processing.
35 * Enable this via "adb shell setprop log.tag.InputReaderVirtualKeys DEBUG" (requires restart)
36 */
37const bool DEBUG_VIRTUAL_KEYS =
38 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "VirtualKeys", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070039
Arthur Hungb060def2022-05-26 07:41:33 +000040/**
41 * Log debug messages about pointers.
42 * Enable this via "adb shell setprop log.tag.InputReaderPointers DEBUG" (requires restart)
43 */
44const bool DEBUG_POINTERS =
45 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Pointers", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070046
Arthur Hungb060def2022-05-26 07:41:33 +000047/**
48 * Log debug messages about pointer assignment calculations.
49 * Enable this via "adb shell setprop log.tag.InputReaderPointerAssignment DEBUG" (requires restart)
50 */
51const bool DEBUG_POINTER_ASSIGNMENT =
52 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "PointerAssignment", ANDROID_LOG_INFO);
53/**
54 * Log debug messages about gesture detection.
55 * Enable this via "adb shell setprop log.tag.InputReaderGestures DEBUG" (requires restart)
56 */
57const bool DEBUG_GESTURES =
58 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Gestures", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070059
Arthur Hungb060def2022-05-26 07:41:33 +000060/**
61 * Log debug messages about the vibrator.
62 * Enable this via "adb shell setprop log.tag.InputReaderVibrator DEBUG" (requires restart)
63 */
64const bool DEBUG_VIBRATOR =
65 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Vibrator", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070066
Arthur Hungb060def2022-05-26 07:41:33 +000067/**
68 * Log debug messages about fusing stylus data.
69 * Enable this via "adb shell setprop log.tag.InputReaderStylusFusion DEBUG" (requires restart)
70 */
71const bool DEBUG_STYLUS_FUSION =
72 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "StylusFusion", ANDROID_LOG_INFO);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070073
Arthur Hungb060def2022-05-26 07:41:33 +000074/**
75 * Log detailed debug messages about input device lights.
76 * Enable this via "adb shell setprop log.tag.InputReaderLightDetails DEBUG" (requires restart)
77 */
78const bool DEBUG_LIGHT_DETAILS =
79 __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "LightDetails", ANDROID_LOG_INFO);
80} // namespace android
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070081
82#define INDENT " "
83#define INDENT2 " "
84#define INDENT3 " "
85#define INDENT4 " "
86#define INDENT5 " "
87
88#include <input/Input.h>
89
90namespace android {
91
92// --- Static Functions ---
93
94template <typename T>
95inline static T abs(const T& value) {
96 return value < 0 ? -value : value;
97}
98
99template <typename T>
100inline static T min(const T& a, const T& b) {
101 return a < b ? a : b;
102}
103
104inline static float avg(float x, float y) {
105 return (x + y) / 2;
106}
107
108static inline const char* toString(bool value) {
109 return value ? "true" : "false";
110}
111
112static inline bool sourcesMatchMask(uint32_t sources, uint32_t sourceMask) {
113 return (sources & sourceMask & ~AINPUT_SOURCE_CLASS_MASK) != 0;
114}
115
116} // namespace android