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

Commit edb0ba73 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

TouchInputMapper: Use early return in populateDeviceInfo

Using the early return reduces the indentation level and is more
readable.

Bug: 245989146
Test: atest inputflinger_tests
Change-Id: I5ebaac48e8ec390824f2c8889c301f291c5d17ab
parent 12417baa
Loading
Loading
Loading
Loading
+59 −59
Original line number Diff line number Diff line
@@ -189,7 +189,10 @@ uint32_t TouchInputMapper::getSources() const {
void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
    InputMapper::populateDeviceInfo(info);

    if (mDeviceMode != DeviceMode::DISABLED) {
    if (mDeviceMode == DeviceMode::DISABLED) {
        return;
    }

    info->addMotionRange(mOrientedRanges.x);
    info->addMotionRange(mOrientedRanges.y);
    info->addMotionRange(mOrientedRanges.pressure);
@@ -202,10 +205,10 @@ void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
        // touchpad in one sample cycle.
        const InputDeviceInfo::MotionRange& x = mOrientedRanges.x;
        const InputDeviceInfo::MotionRange& y = mOrientedRanges.y;
            info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -x.max, x.max, x.flat,
                                 x.fuzz, x.resolution);
            info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -y.max, y.max, y.flat,
                                 y.fuzz, y.resolution);
        info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -x.max, x.max, x.flat, x.fuzz,
                             x.resolution);
        info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -y.max, y.max, y.flat, y.fuzz,
                             y.resolution);
    }

    if (mOrientedRanges.size) {
@@ -235,28 +238,25 @@ void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
    }

    if (mCursorScrollAccumulator.haveRelativeVWheel()) {
            info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
                                 0.0f);
        info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
    }
    if (mCursorScrollAccumulator.haveRelativeHWheel()) {
            info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
                                 0.0f);
        info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
    }
    if (mCalibration.coverageCalibration == Calibration::CoverageCalibration::BOX) {
        const InputDeviceInfo::MotionRange& x = mOrientedRanges.x;
        const InputDeviceInfo::MotionRange& y = mOrientedRanges.y;
            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_1, mSource, x.min, x.max, x.flat,
                                 x.fuzz, x.resolution);
            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_2, mSource, y.min, y.max, y.flat,
                                 y.fuzz, y.resolution);
            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_3, mSource, x.min, x.max, x.flat,
                                 x.fuzz, x.resolution);
            info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_4, mSource, y.min, y.max, y.flat,
                                 y.fuzz, y.resolution);
        info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_1, mSource, x.min, x.max, x.flat, x.fuzz,
                             x.resolution);
        info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_2, mSource, y.min, y.max, y.flat, y.fuzz,
                             y.resolution);
        info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_3, mSource, x.min, x.max, x.flat, x.fuzz,
                             x.resolution);
        info->addMotionRange(AMOTION_EVENT_AXIS_GENERIC_4, mSource, y.min, y.max, y.flat, y.fuzz,
                             y.resolution);
    }
    info->setButtonUnderPad(mParameters.hasButtonUnderPad);
}
}

void TouchInputMapper::dump(std::string& dump) {
    dump += StringPrintf(INDENT2 "Touch Input Mapper (mode - %s):\n",