1 /*
2 * Copyright (C) 2022 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 LOG_TAG
18 #define LOG_TAG "Gestures"
19 #endif
20
21 #include <stdio.h>
22
23 #include <log/log.h>
24
25 #include "include/gestures.h"
26
27 extern "C" {
28
29 namespace {
30
31 /**
32 * Log details of each gesture output by the gestures library.
33 * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires
34 * restarting the shell)
35 */
36 const bool DEBUG_TOUCHPAD_GESTURES =
37 __android_log_is_loggable(ANDROID_LOG_DEBUG, "TouchpadInputMapperGestures",
38 ANDROID_LOG_INFO);
39
40 } // namespace
41
gestures_log(int verb,const char * fmt,...)42 void gestures_log(int verb, const char* fmt, ...) {
43 va_list args;
44 va_start(args, fmt);
45 if (verb == GESTURES_LOG_ERROR) {
46 LOG_PRI_VA(ANDROID_LOG_ERROR, LOG_TAG, fmt, args);
47 } else if (DEBUG_TOUCHPAD_GESTURES) {
48 if (verb == GESTURES_LOG_INFO) {
49 LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, fmt, args);
50 } else {
51 LOG_PRI_VA(ANDROID_LOG_DEBUG, LOG_TAG, fmt, args);
52 }
53 }
54 va_end(args);
55 }
56 }
57