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

Commit 8a0d7dd9 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge changes I3dae9b50,I3d687a10

* changes:
  Input: Add isStylusToolType() utility function
  Differentiate fused and unfused external styluses
parents 88b5db0d e562696c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -209,6 +209,8 @@ std::string inputEventSourceToString(int32_t source);

bool isFromSource(uint32_t source, uint32_t test);

bool isStylusToolType(uint32_t toolType);

/*
 * Flags that flow alongside events in the input dispatch system to help with certain
 * policy decisions such as waking from device sleep.
+4 −0
Original line number Diff line number Diff line
@@ -238,6 +238,10 @@ bool isFromSource(uint32_t source, uint32_t test) {
    return (source & test) == test;
}

bool isStylusToolType(uint32_t toolType) {
    return toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS || toolType == AMOTION_EVENT_TOOL_TYPE_ERASER;
}

VerifiedKeyEvent verifiedKeyEventFromKeyEvent(const KeyEvent& event) {
    return {{VerifiedInputEvent::Type::KEY, event.getDeviceId(), event.getEventTime(),
             event.getSource(), event.getDisplayId()},
+1 −2
Original line number Diff line number Diff line
@@ -25,8 +25,7 @@ static std::pair<bool, bool> checkToolType(const NotifyMotionArgs& args) {
    for (size_t i = 0; i < args.pointerCount; i++) {
        // Make sure we are canceling stylus pointers
        const int32_t toolType = args.pointerProperties[i].toolType;
        if (toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS ||
            toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) {
        if (isStylusToolType(toolType)) {
            hasStylus = true;
        }
        if (toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) {
+11 −8
Original line number Diff line number Diff line
@@ -99,15 +99,18 @@ static bool isPalmRejectionEnabled() {
}

static int getLinuxToolCode(int toolType) {
    if (toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS) {
    switch (toolType) {
        case AMOTION_EVENT_TOOL_TYPE_STYLUS:
            return BTN_TOOL_PEN;
    }
    if (toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) {
        case AMOTION_EVENT_TOOL_TYPE_ERASER:
            return BTN_TOOL_RUBBER;
        case AMOTION_EVENT_TOOL_TYPE_FINGER:
            return BTN_TOOL_FINGER;
    }
        default:
            ALOGW("Got tool type %" PRId32 ", converting to BTN_TOOL_FINGER", toolType);
            return BTN_TOOL_FINGER;
    }
}

static int32_t getActionUpForPointerId(const NotifyMotionArgs& args, int32_t pointerId) {
    for (size_t i = 0; i < args.pointerCount; i++) {
@@ -195,7 +198,7 @@ NotifyMotionArgs removePointerIds(const NotifyMotionArgs& args,
static std::optional<NotifyMotionArgs> removeStylusPointerIds(const NotifyMotionArgs& args) {
    std::set<int32_t> stylusPointerIds;
    for (uint32_t i = 0; i < args.pointerCount; i++) {
        if (args.pointerProperties[i].toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS) {
        if (isStylusToolType(args.pointerProperties[i].toolType)) {
            stylusPointerIds.insert(args.pointerProperties[i].id);
        }
    }
+1 −2
Original line number Diff line number Diff line
@@ -481,8 +481,7 @@ bool windowAcceptsTouchAt(const WindowInfo& windowInfo, int32_t displayId, int32

bool isPointerFromStylus(const MotionEntry& entry, int32_t pointerIndex) {
    return isFromSource(entry.source, AINPUT_SOURCE_STYLUS) &&
            (entry.pointerProperties[pointerIndex].toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS ||
             entry.pointerProperties[pointerIndex].toolType == AMOTION_EVENT_TOOL_TYPE_ERASER);
            isStylusToolType(entry.pointerProperties[pointerIndex].toolType);
}

// Determines if the given window can be targeted as InputTarget::Flags::FOREGROUND.
Loading