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