From d948957b396a9301e6e247023d8509f44f6cf87c Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Fri, 12 Nov 2021 20:08:38 -0800 Subject: Look up source using & instead of equality Source for an input device may be composite. On some devices, the source is specified as TOUCHSCREEN | STYLUS. That means a regular lookup of a MotionRange using just SOURCE_TOUCHSCREEN fails. Update the code to allow composite sources. Also, improve the source dump by printing words instead of numbers. Bug: 198472780 Test: adb shell dumpsys input Change-Id: I8d395f2bb5a6db031e5c2aa6c1f5152ff067a2bb --- libs/input/InputDevice.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'libs/input/InputDevice.cpp') diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp index 015bd81361..ac84627b3f 100644 --- a/libs/input/InputDevice.cpp +++ b/libs/input/InputDevice.cpp @@ -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 ⦥ } } -- cgit v1.2.3-59-g8ed1b