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

Commit 79cc9fa5 authored by Harry Cutts's avatar Harry Cutts
Browse files

Add new `TouchpadInputMapper` class

This will replace `MultiTouchInputMapper` and `SingleTouchInputMapper`
for touchpad devices, and will be the wrapper for the gestures library.

Bug: 251196347
Test: connect Apple Magic Trackpad 2 to device, check logs come out
Test: atest inputflinger_tests
Change-Id: Ia8ee1779a40c6c6f98373e114c040bf13b7f213d
parent 4bd381e2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ filegroup {
        "mapper/SingleTouchInputMapper.cpp",
        "mapper/SwitchInputMapper.cpp",
        "mapper/TouchInputMapper.cpp",
        "mapper/TouchpadInputMapper.cpp",
        "mapper/VibratorInputMapper.cpp",
        "mapper/accumulator/CursorButtonAccumulator.cpp",
        "mapper/accumulator/CursorScrollAccumulator.cpp",
+4 −0
Original line number Diff line number Diff line
@@ -2215,6 +2215,10 @@ void EventHub::openDeviceLocked(const std::string& devicePath) {
        // a touch screen.
        if (device->keyBitmask.test(BTN_TOUCH) || !haveGamepadButtons) {
            device->classes |= (InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT);
            if (device->propBitmask.test(INPUT_PROP_POINTER) &&
                !device->keyBitmask.any(BTN_TOOL_PEN, BTN_TOOL_FINGER) && !haveStylusButtons) {
                device->classes |= InputDeviceClass::TOUCHPAD;
            }
        }
        // Is this an old style single-touch driver?
    } else if (device->keyBitmask.test(BTN_TOUCH) && device->absBitmask.test(ABS_X) &&
+6 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "SensorInputMapper.h"
#include "SingleTouchInputMapper.h"
#include "SwitchInputMapper.h"
#include "TouchpadInputMapper.h"
#include "VibratorInputMapper.h"

using android::hardware::input::InputDeviceCountryCode;
@@ -208,7 +209,11 @@ void InputDevice::addEventHubDevice(int32_t eventHubId, bool populateMappers) {
    }

    // Touchscreens and touchpad devices.
    if (classes.test(InputDeviceClass::TOUCH_MT)) {
    // TODO(b/251196347): replace this with a proper flag.
    constexpr bool ENABLE_NEW_TOUCHPAD_STACK = false;
    if (ENABLE_NEW_TOUCHPAD_STACK && classes.test(InputDeviceClass::TOUCHPAD)) {
        mappers.push_back(std::make_unique<TouchpadInputMapper>(*contextPtr));
    } else if (classes.test(InputDeviceClass::TOUCH_MT)) {
        mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr));
    } else if (classes.test(InputDeviceClass::TOUCH)) {
        mappers.push_back(std::make_unique<SingleTouchInputMapper>(*contextPtr));
+4 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ enum class InputDeviceClass : uint32_t {
    /* The input device is a cursor device such as a trackball or mouse. */
    CURSOR = 0x00000008,

    /* The input device is a multi-touch touchscreen. */
    /* The input device is a multi-touch touchscreen or touchpad. */
    TOUCH_MT = 0x00000010,

    /* The input device is a directional pad (implies keyboard, has DPAD keys). */
@@ -130,6 +130,9 @@ enum class InputDeviceClass : uint32_t {
    /* The input device has sysfs controllable lights */
    LIGHT = 0x00008000,

    /* The input device is a touchpad, requiring an on-screen cursor. */
    TOUCHPAD = 0x00010000,

    /* The input device is virtual (not a real device, not part of UI configuration). */
    VIRTUAL = 0x40000000,

+36 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "../Macros.h"

#include "TouchpadInputMapper.h"

namespace android {

TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext)
      : InputMapper(deviceContext) {}

uint32_t TouchpadInputMapper::getSources() const {
    return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD;
}

std::list<NotifyArgs> TouchpadInputMapper::process(const RawEvent* rawEvent) {
    ALOGD("TODO: process event type=0x%x code=0x%x value=0x%x", rawEvent->type, rawEvent->code,
          rawEvent->value);
    return {};
}

} // namespace android
Loading