Loading include/input/Input.h +4 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,10 @@ class Parcel; const char* inputEventTypeToString(int32_t type); std::string inputEventSourceToString(int32_t source); bool isFromSource(uint32_t source, uint32_t test); /* * Flags that flow alongside events in the input dispatch system to help with certain * policy decisions such as waking from device sleep. Loading libs/input/Input.cpp +43 −4 Original line number Diff line number Diff line Loading @@ -66,10 +66,6 @@ vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy) return transformedXy - transformedOrigin; } bool isFromSource(uint32_t source, uint32_t test) { return (source & test) == test; } bool shouldDisregardTransformation(uint32_t source) { // Do not apply any transformations to axes from joysticks or touchpads. return isFromSource(source, AINPUT_SOURCE_CLASS_JOYSTICK) || Loading Loading @@ -148,6 +144,49 @@ const char* inputEventTypeToString(int32_t type) { return "UNKNOWN"; } std::string inputEventSourceToString(int32_t source) { if (source == AINPUT_SOURCE_UNKNOWN) { return "UNKNOWN"; } if (source == static_cast<int32_t>(AINPUT_SOURCE_ANY)) { return "ANY"; } static const std::map<int32_t, const char*> SOURCES{ {AINPUT_SOURCE_KEYBOARD, "KEYBOARD"}, {AINPUT_SOURCE_DPAD, "DPAD"}, {AINPUT_SOURCE_GAMEPAD, "GAMEPAD"}, {AINPUT_SOURCE_TOUCHSCREEN, "TOUCHSCREEN"}, {AINPUT_SOURCE_MOUSE, "MOUSE"}, {AINPUT_SOURCE_STYLUS, "STYLUS"}, {AINPUT_SOURCE_BLUETOOTH_STYLUS, "BLUETOOTH_STYLUS"}, {AINPUT_SOURCE_TRACKBALL, "TRACKBALL"}, {AINPUT_SOURCE_MOUSE_RELATIVE, "MOUSE_RELATIVE"}, {AINPUT_SOURCE_TOUCHPAD, "TOUCHPAD"}, {AINPUT_SOURCE_TOUCH_NAVIGATION, "TOUCH_NAVIGATION"}, {AINPUT_SOURCE_JOYSTICK, "JOYSTICK"}, {AINPUT_SOURCE_HDMI, "HDMI"}, {AINPUT_SOURCE_SENSOR, "SENSOR"}, {AINPUT_SOURCE_ROTARY_ENCODER, "ROTARY_ENCODER"}, }; std::string result; for (const auto& [source_entry, str] : SOURCES) { if ((source & source_entry) == source_entry) { if (!result.empty()) { result += " | "; } result += str; } } if (result.empty()) { result = StringPrintf("0x%08x", source); } return result; } bool isFromSource(uint32_t source, uint32_t test) { return (source & test) == test; } VerifiedKeyEvent verifiedKeyEventFromKeyEvent(const KeyEvent& event) { return {{VerifiedInputEvent::Type::KEY, event.getDeviceId(), event.getEventTime(), event.getSource(), event.getDisplayId()}, Loading libs/input/InputDevice.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -208,10 +208,8 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange( int32_t axis, uint32_t source) const { size_t numRanges = mMotionRanges.size(); for (size_t i = 0; i < numRanges; i++) { const MotionRange& range = mMotionRanges[i]; if (range.axis == axis && range.source == source) { for (const MotionRange& range : mMotionRanges) { if (range.axis == axis && isFromSource(range.source, source)) { return ⦥ } } Loading services/inputflinger/InputClassifier.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,8 @@ static MotionClassification getMotionClassification(common::V1_0::Classification } static bool isTouchEvent(const NotifyMotionArgs& args) { return args.source == AINPUT_SOURCE_TOUCHPAD || args.source == AINPUT_SOURCE_TOUCHSCREEN; return isFromSource(args.source, AINPUT_SOURCE_TOUCHPAD) || isFromSource(args.source, AINPUT_SOURCE_TOUCHSCREEN); } // --- ClassifierEvent --- Loading services/inputflinger/dispatcher/Entry.cpp +11 −9 Original line number Diff line number Diff line Loading @@ -175,13 +175,13 @@ std::string KeyEntry::getDescription() const { if (!GetBoolProperty("ro.debuggable", false)) { return "KeyEvent"; } return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 ", source=0x%08x, displayId=%" PRId32 ", action=%s, " return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 ", source=%s, displayId=%" PRId32 ", action=%s, " "flags=0x%08x, keyCode=%s(%d), scanCode=%d, metaState=0x%08x, " "repeatCount=%d), policyFlags=0x%08x", deviceId, eventTime, source, displayId, KeyEvent::actionToString(action), flags, KeyEvent::getLabel(keyCode), keyCode, scanCode, metaState, repeatCount, policyFlags); deviceId, eventTime, inputEventSourceToString(source).c_str(), displayId, KeyEvent::actionToString(action), flags, KeyEvent::getLabel(keyCode), keyCode, scanCode, metaState, repeatCount, policyFlags); } void KeyEntry::recycle() { Loading Loading @@ -249,12 +249,12 @@ std::string MotionEntry::getDescription() const { } std::string msg; msg += StringPrintf("MotionEvent(deviceId=%d, eventTime=%" PRIu64 ", source=0x%08x, displayId=%" PRId32 ", source=%s, displayId=%" PRId32 ", action=%s, actionButton=0x%08x, flags=0x%08x, metaState=0x%08x, " "buttonState=0x%08x, " "classification=%s, edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, " "xCursorPosition=%0.1f, yCursorPosition=%0.1f, pointers=[", deviceId, eventTime, source, displayId, deviceId, eventTime, inputEventSourceToString(source).c_str(), displayId, MotionEvent::actionToString(action).c_str(), actionButton, flags, metaState, buttonState, motionClassificationToString(classification), edgeFlags, xPrecision, yPrecision, xCursorPosition, yCursorPosition); Loading Loading @@ -289,9 +289,11 @@ SensorEntry::~SensorEntry() {} std::string SensorEntry::getDescription() const { std::string msg; msg += StringPrintf("SensorEntry(deviceId=%d, source=0x%08x, sensorType=0x%08x, " std::string sensorTypeStr(ftl::enum_name(sensorType).value_or("?")); msg += StringPrintf("SensorEntry(deviceId=%d, source=%s, sensorType=%s, " "accuracy=0x%08x, hwTimestamp=%" PRId64, deviceId, source, sensorType, accuracy, hwTimestamp); deviceId, inputEventSourceToString(source).c_str(), sensorTypeStr.c_str(), accuracy, hwTimestamp); if (!GetBoolProperty("ro.debuggable", false)) { for (size_t i = 0; i < values.size(); i++) { Loading Loading
include/input/Input.h +4 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,10 @@ class Parcel; const char* inputEventTypeToString(int32_t type); std::string inputEventSourceToString(int32_t source); bool isFromSource(uint32_t source, uint32_t test); /* * Flags that flow alongside events in the input dispatch system to help with certain * policy decisions such as waking from device sleep. Loading
libs/input/Input.cpp +43 −4 Original line number Diff line number Diff line Loading @@ -66,10 +66,6 @@ vec2 transformWithoutTranslation(const ui::Transform& transform, const vec2& xy) return transformedXy - transformedOrigin; } bool isFromSource(uint32_t source, uint32_t test) { return (source & test) == test; } bool shouldDisregardTransformation(uint32_t source) { // Do not apply any transformations to axes from joysticks or touchpads. return isFromSource(source, AINPUT_SOURCE_CLASS_JOYSTICK) || Loading Loading @@ -148,6 +144,49 @@ const char* inputEventTypeToString(int32_t type) { return "UNKNOWN"; } std::string inputEventSourceToString(int32_t source) { if (source == AINPUT_SOURCE_UNKNOWN) { return "UNKNOWN"; } if (source == static_cast<int32_t>(AINPUT_SOURCE_ANY)) { return "ANY"; } static const std::map<int32_t, const char*> SOURCES{ {AINPUT_SOURCE_KEYBOARD, "KEYBOARD"}, {AINPUT_SOURCE_DPAD, "DPAD"}, {AINPUT_SOURCE_GAMEPAD, "GAMEPAD"}, {AINPUT_SOURCE_TOUCHSCREEN, "TOUCHSCREEN"}, {AINPUT_SOURCE_MOUSE, "MOUSE"}, {AINPUT_SOURCE_STYLUS, "STYLUS"}, {AINPUT_SOURCE_BLUETOOTH_STYLUS, "BLUETOOTH_STYLUS"}, {AINPUT_SOURCE_TRACKBALL, "TRACKBALL"}, {AINPUT_SOURCE_MOUSE_RELATIVE, "MOUSE_RELATIVE"}, {AINPUT_SOURCE_TOUCHPAD, "TOUCHPAD"}, {AINPUT_SOURCE_TOUCH_NAVIGATION, "TOUCH_NAVIGATION"}, {AINPUT_SOURCE_JOYSTICK, "JOYSTICK"}, {AINPUT_SOURCE_HDMI, "HDMI"}, {AINPUT_SOURCE_SENSOR, "SENSOR"}, {AINPUT_SOURCE_ROTARY_ENCODER, "ROTARY_ENCODER"}, }; std::string result; for (const auto& [source_entry, str] : SOURCES) { if ((source & source_entry) == source_entry) { if (!result.empty()) { result += " | "; } result += str; } } if (result.empty()) { result = StringPrintf("0x%08x", source); } return result; } bool isFromSource(uint32_t source, uint32_t test) { return (source & test) == test; } VerifiedKeyEvent verifiedKeyEventFromKeyEvent(const KeyEvent& event) { return {{VerifiedInputEvent::Type::KEY, event.getDeviceId(), event.getEventTime(), event.getSource(), event.getDisplayId()}, Loading
libs/input/InputDevice.cpp +2 −4 Original line number Diff line number Diff line Loading @@ -208,10 +208,8 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange( int32_t axis, uint32_t source) const { size_t numRanges = mMotionRanges.size(); for (size_t i = 0; i < numRanges; i++) { const MotionRange& range = mMotionRanges[i]; if (range.axis == axis && range.source == source) { for (const MotionRange& range : mMotionRanges) { if (range.axis == axis && isFromSource(range.source, source)) { return ⦥ } } Loading
services/inputflinger/InputClassifier.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,8 @@ static MotionClassification getMotionClassification(common::V1_0::Classification } static bool isTouchEvent(const NotifyMotionArgs& args) { return args.source == AINPUT_SOURCE_TOUCHPAD || args.source == AINPUT_SOURCE_TOUCHSCREEN; return isFromSource(args.source, AINPUT_SOURCE_TOUCHPAD) || isFromSource(args.source, AINPUT_SOURCE_TOUCHSCREEN); } // --- ClassifierEvent --- Loading
services/inputflinger/dispatcher/Entry.cpp +11 −9 Original line number Diff line number Diff line Loading @@ -175,13 +175,13 @@ std::string KeyEntry::getDescription() const { if (!GetBoolProperty("ro.debuggable", false)) { return "KeyEvent"; } return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 ", source=0x%08x, displayId=%" PRId32 ", action=%s, " return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 ", source=%s, displayId=%" PRId32 ", action=%s, " "flags=0x%08x, keyCode=%s(%d), scanCode=%d, metaState=0x%08x, " "repeatCount=%d), policyFlags=0x%08x", deviceId, eventTime, source, displayId, KeyEvent::actionToString(action), flags, KeyEvent::getLabel(keyCode), keyCode, scanCode, metaState, repeatCount, policyFlags); deviceId, eventTime, inputEventSourceToString(source).c_str(), displayId, KeyEvent::actionToString(action), flags, KeyEvent::getLabel(keyCode), keyCode, scanCode, metaState, repeatCount, policyFlags); } void KeyEntry::recycle() { Loading Loading @@ -249,12 +249,12 @@ std::string MotionEntry::getDescription() const { } std::string msg; msg += StringPrintf("MotionEvent(deviceId=%d, eventTime=%" PRIu64 ", source=0x%08x, displayId=%" PRId32 ", source=%s, displayId=%" PRId32 ", action=%s, actionButton=0x%08x, flags=0x%08x, metaState=0x%08x, " "buttonState=0x%08x, " "classification=%s, edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, " "xCursorPosition=%0.1f, yCursorPosition=%0.1f, pointers=[", deviceId, eventTime, source, displayId, deviceId, eventTime, inputEventSourceToString(source).c_str(), displayId, MotionEvent::actionToString(action).c_str(), actionButton, flags, metaState, buttonState, motionClassificationToString(classification), edgeFlags, xPrecision, yPrecision, xCursorPosition, yCursorPosition); Loading Loading @@ -289,9 +289,11 @@ SensorEntry::~SensorEntry() {} std::string SensorEntry::getDescription() const { std::string msg; msg += StringPrintf("SensorEntry(deviceId=%d, source=0x%08x, sensorType=0x%08x, " std::string sensorTypeStr(ftl::enum_name(sensorType).value_or("?")); msg += StringPrintf("SensorEntry(deviceId=%d, source=%s, sensorType=%s, " "accuracy=0x%08x, hwTimestamp=%" PRId64, deviceId, source, sensorType, accuracy, hwTimestamp); deviceId, inputEventSourceToString(source).c_str(), sensorTypeStr.c_str(), accuracy, hwTimestamp); if (!GetBoolProperty("ro.debuggable", false)) { for (size_t i = 0; i < values.size(); i++) { Loading