Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea73eaa7 authored by Harry Cutts's avatar Harry Cutts
Browse files

TouchpadInputMapper: add dump method

This dumps the state from the gesture converter, and a list of gesture
properties, which is useful for debugging settings.

Bug: 251196347
Test: run dumpsys input with touchpad connected, check output
Change-Id: I036d0251b06489b645b883a239ff345a98448497
parent 1b217913
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <optional>
#include <set>
#include <string>
#include <vector>

namespace android {

@@ -28,6 +29,16 @@ inline std::string constToString(const T& v) {
    return std::to_string(v);
}

template <>
inline std::string constToString(const bool& value) {
    return value ? "true" : "false";
}

template <>
inline std::string constToString(const std::vector<bool>::reference& value) {
    return value ? "true" : "false";
}

inline std::string constToString(const std::string& s) {
    return s;
}
@@ -70,6 +81,19 @@ std::string dumpMap(const std::map<K, V>& map, std::string (*keyToString)(const
    return out;
}

/**
 * Convert a vector to a string. The values of the vector should be of a type supported by
 * constToString.
 */
template <typename T>
std::string dumpVector(std::vector<T> values) {
    std::string dump = constToString(values[0]);
    for (size_t i = 1; i < values.size(); i++) {
        dump += ", " + constToString(values[i]);
    }
    return dump;
}

const char* toString(bool value);

/**
+12 −0
Original line number Diff line number Diff line
@@ -515,6 +515,18 @@ ftl::Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis,
    return deviceClasses & InputDeviceClass::JOYSTICK;
}

// --- RawAbsoluteAxisInfo ---

std::ostream& operator<<(std::ostream& out, const RawAbsoluteAxisInfo& info) {
    if (info.valid) {
        out << "min=" << info.minValue << ", max=" << info.maxValue << ", flat=" << info.flat
            << ", fuzz=" << info.fuzz << ", resolution=" << info.resolution;
    } else {
        out << "unknown range";
    }
    return out;
}

// --- EventHub::Device ---

EventHub::Device::Device(int fd, int32_t id, std::string path, InputDeviceIdentifier identifier,
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include <bitset>
#include <climits>
#include <filesystem>
#include <ostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -77,6 +79,8 @@ struct RawAbsoluteAxisInfo {
    inline void clear() { *this = RawAbsoluteAxisInfo(); }
};

std::ostream& operator<<(std::ostream& out, const RawAbsoluteAxisInfo& info);

/*
 * Input device classes.
 */
+5 −6
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#include "InputMapper.h"

#include <sstream>

#include "InputDevice.h"
#include "input/PrintTools.h"

@@ -120,12 +122,9 @@ void InputMapper::bumpGeneration() {

void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump, const RawAbsoluteAxisInfo& axis,
                                          const char* name) {
    if (axis.valid) {
        dump += StringPrintf(INDENT4 "%s: min=%d, max=%d, flat=%d, fuzz=%d, resolution=%d\n", name,
                             axis.minValue, axis.maxValue, axis.flat, axis.fuzz, axis.resolution);
    } else {
        dump += StringPrintf(INDENT4 "%s: unknown range\n", name);
    }
    std::stringstream out;
    out << INDENT4 << name << ": " << axis << "\n";
    dump += out.str();
}

void InputMapper::dumpStylusState(std::string& dump, const StylusState& state) {
+9 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <optional>

#include <android/input.h>
#include <input/PrintTools.h>
#include <linux/input-event-codes.h>
#include <log/log_main.h>
#include "TouchCursorInputMapperCommon.h"
@@ -124,6 +125,14 @@ uint32_t TouchpadInputMapper::getSources() const {
    return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD;
}

void TouchpadInputMapper::dump(std::string& dump) {
    dump += INDENT2 "Touchpad Input Mapper:\n";
    dump += INDENT3 "Gesture converter:\n";
    dump += addLinePrefix(mGestureConverter.dump(), INDENT4);
    dump += INDENT3 "Gesture properties:\n";
    dump += addLinePrefix(mPropertyProvider.dump(), INDENT4);
}

std::list<NotifyArgs> TouchpadInputMapper::configure(nsecs_t when,
                                                     const InputReaderConfiguration* config,
                                                     uint32_t changes) {
Loading