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

Commit 77f8a59a authored by Harry Cutts's avatar Harry Cutts Committed by Automerger Merge Worker
Browse files

Merge "Report motion ranges for touchpads in new stack" into udc-dev am: 398be870

parents 0823a7b8 398be870
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -206,6 +206,11 @@ uint32_t TouchpadInputMapper::getSources() const {
    return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD;
    return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD;
}
}


void TouchpadInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
    InputMapper::populateDeviceInfo(info);
    mGestureConverter.populateMotionRanges(*info);
}

void TouchpadInputMapper::dump(std::string& dump) {
void TouchpadInputMapper::dump(std::string& dump) {
    dump += INDENT2 "Touchpad Input Mapper:\n";
    dump += INDENT2 "Touchpad Input Mapper:\n";
    dump += INDENT3 "Gesture converter:\n";
    dump += INDENT3 "Gesture converter:\n";
+1 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ public:
    ~TouchpadInputMapper();
    ~TouchpadInputMapper();


    uint32_t getSources() const override;
    uint32_t getSources() const override;
    void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
    void dump(std::string& dump) override;
    void dump(std::string& dump) override;


    [[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
    [[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
+25 −5
Original line number Original line Diff line number Diff line
@@ -16,13 +16,14 @@


#include "gestures/GestureConverter.h"
#include "gestures/GestureConverter.h"


#include <optional>
#include <sstream>
#include <sstream>


#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <android/input.h>
#include <ftl/enum.h>
#include <ftl/enum.h>
#include <linux/input-event-codes.h>
#include <linux/input-event-codes.h>
#include <log/log_main.h>
#include <log/log_main.h>
#include <ui/FloatRect.h>


#include "TouchCursorInputMapperCommon.h"
#include "TouchCursorInputMapperCommon.h"
#include "input/Input.h"
#include "input/Input.h"
@@ -75,6 +76,28 @@ void GestureConverter::reset() {
    mButtonState = 0;
    mButtonState = 0;
}
}


void GestureConverter::populateMotionRanges(InputDeviceInfo& info) const {
    info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, SOURCE, 0.0f, 1.0f, 0, 0, 0);

    // TODO(b/259547750): set this using the raw axis ranges from the touchpad when pointer capture
    // is enabled.
    if (std::optional<FloatRect> rect = mPointerController->getBounds(); rect.has_value()) {
        info.addMotionRange(AMOTION_EVENT_AXIS_X, SOURCE, rect->left, rect->right, 0, 0, 0);
        info.addMotionRange(AMOTION_EVENT_AXIS_Y, SOURCE, rect->top, rect->bottom, 0, 0, 0);
    }

    info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0);
    info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0);

    // The other axes that can be reported don't have ranges that are easy to define. RELATIVE_X/Y
    // and GESTURE_SCROLL_X/Y_DISTANCE are the result of acceleration functions being applied to
    // finger movements, so their maximum values can't simply be derived from the size of the
    // touchpad. GESTURE_PINCH_SCALE_FACTOR's maximum value depends on the minimum finger separation
    // that the pad can report, which cannot be determined from its raw axis information. (Assuming
    // a minimum finger separation of 1 unit would let us calculate a theoretical maximum, but it
    // would be orders of magnitude too high, so probably not very useful.)
}

std::list<NotifyArgs> GestureConverter::handleGesture(nsecs_t when, nsecs_t readTime,
std::list<NotifyArgs> GestureConverter::handleGesture(nsecs_t when, nsecs_t readTime,
                                                      const Gesture& gesture) {
                                                      const Gesture& gesture) {
    switch (gesture.type) {
    switch (gesture.type) {
@@ -418,10 +441,7 @@ NotifyMotionArgs GestureConverter::makeMotionArgs(nsecs_t when, nsecs_t readTime
                                                  const PointerProperties* pointerProperties,
                                                  const PointerProperties* pointerProperties,
                                                  const PointerCoords* pointerCoords,
                                                  const PointerCoords* pointerCoords,
                                                  float xCursorPosition, float yCursorPosition) {
                                                  float xCursorPosition, float yCursorPosition) {
    // TODO(b/260226362): consider what the appropriate source for these events is.
    return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, SOURCE,
    const uint32_t source = AINPUT_SOURCE_MOUSE;

    return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, source,
                            mPointerController->getDisplayId(), /* policyFlags= */ POLICY_FLAG_WAKE,
                            mPointerController->getDisplayId(), /* policyFlags= */ POLICY_FLAG_WAKE,
                            action, /* actionButton= */ actionButton, /* flags= */ 0,
                            action, /* actionButton= */ actionButton, /* flags= */ 0,
                            mReaderContext.getGlobalMetaState(), buttonState,
                            mReaderContext.getGlobalMetaState(), buttonState,
+6 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include <memory>
#include <memory>


#include <PointerControllerInterface.h>
#include <PointerControllerInterface.h>
#include <android/input.h>
#include <utils/Timers.h>
#include <utils/Timers.h>


#include "EventHub.h"
#include "EventHub.h"
@@ -45,6 +46,8 @@ public:
    void setOrientation(ui::Rotation orientation) { mOrientation = orientation; }
    void setOrientation(ui::Rotation orientation) { mOrientation = orientation; }
    void reset();
    void reset();


    void populateMotionRanges(InputDeviceInfo& info) const;

    [[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime,
    [[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime,
                                                      const Gesture& gesture);
                                                      const Gesture& gesture);


@@ -98,6 +101,9 @@ private:
            {.id = 3, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER},
            {.id = 3, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER},
    }};
    }};
    std::array<PointerCoords, MAX_FAKE_FINGERS> mFakeFingerCoords = {};
    std::array<PointerCoords, MAX_FAKE_FINGERS> mFakeFingerCoords = {};

    // TODO(b/260226362): consider what the appropriate source for these events is.
    static constexpr uint32_t SOURCE = AINPUT_SOURCE_MOUSE;
};
};


} // namespace android
} // namespace android