Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 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 |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 23 | #include <log/log.h> |
| 24 | #include <log/log_event_list.h> |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 25 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 26 | namespace 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 | */ |
| 31 | const bool DEBUG_RAW_EVENTS = |
| 32 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "RawEvents", ANDROID_LOG_INFO); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 33 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 34 | /** |
| 35 | * Log debug messages about virtual key processing. |
| 36 | * Enable this via "adb shell setprop log.tag.InputReaderVirtualKeys DEBUG" (requires restart) |
| 37 | */ |
| 38 | const bool DEBUG_VIRTUAL_KEYS = |
| 39 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "VirtualKeys", ANDROID_LOG_INFO); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 40 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 41 | /** |
| 42 | * Log debug messages about pointers. |
| 43 | * Enable this via "adb shell setprop log.tag.InputReaderPointers DEBUG" (requires restart) |
| 44 | */ |
| 45 | const bool DEBUG_POINTERS = |
| 46 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Pointers", ANDROID_LOG_INFO); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 47 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 48 | /** |
| 49 | * Log debug messages about pointer assignment calculations. |
| 50 | * Enable this via "adb shell setprop log.tag.InputReaderPointerAssignment DEBUG" (requires restart) |
| 51 | */ |
| 52 | const 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 | */ |
| 58 | const bool DEBUG_GESTURES = |
| 59 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Gestures", ANDROID_LOG_INFO); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 60 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 61 | /** |
| 62 | * Log debug messages about the vibrator. |
| 63 | * Enable this via "adb shell setprop log.tag.InputReaderVibrator DEBUG" (requires restart) |
| 64 | */ |
| 65 | const bool DEBUG_VIBRATOR = |
| 66 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Vibrator", ANDROID_LOG_INFO); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 67 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 68 | /** |
| 69 | * Log debug messages about fusing stylus data. |
| 70 | * Enable this via "adb shell setprop log.tag.InputReaderStylusFusion DEBUG" (requires restart) |
| 71 | */ |
| 72 | const bool DEBUG_STYLUS_FUSION = |
| 73 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "StylusFusion", ANDROID_LOG_INFO); |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 74 | |
Arthur Hung | b060def | 2022-05-26 07:41:33 +0000 | [diff] [blame] | 75 | /** |
| 76 | * Log detailed debug messages about input device lights. |
| 77 | * Enable this via "adb shell setprop log.tag.InputReaderLightDetails DEBUG" (requires restart) |
| 78 | */ |
| 79 | const bool DEBUG_LIGHT_DETAILS = |
| 80 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "LightDetails", ANDROID_LOG_INFO); |
| 81 | } // namespace android |
Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 82 | |
| 83 | #define INDENT " " |
| 84 | #define INDENT2 " " |
| 85 | #define INDENT3 " " |
| 86 | #define INDENT4 " " |
| 87 | #define INDENT5 " " |
| 88 | |
| 89 | #include <input/Input.h> |
| 90 | |
| 91 | namespace android { |
| 92 | |
| 93 | // --- Static Functions --- |
| 94 | |
| 95 | template <typename T> |
| 96 | inline static T abs(const T& value) { |
| 97 | return value < 0 ? -value : value; |
| 98 | } |
| 99 | |
| 100 | template <typename T> |
| 101 | inline static T min(const T& a, const T& b) { |
| 102 | return a < b ? a : b; |
| 103 | } |
| 104 | |
| 105 | inline static float avg(float x, float y) { |
| 106 | return (x + y) / 2; |
| 107 | } |
| 108 | |
| 109 | static inline const char* toString(bool value) { |
| 110 | return value ? "true" : "false"; |
| 111 | } |
| 112 | |
| 113 | static 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 |