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

Commit 645da6d2 authored by Daniel Hillenbrand's avatar Daniel Hillenbrand Committed by Gerrit Code Review
Browse files

Merge "Disable touch while using the stylus (Galaxy Note)" into jellybean

parents 9d92c5c4 83585890
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -5215,6 +5215,7 @@ void TouchInputMapper::dispatchPointerStylus(nsecs_t when, uint32_t policyFlags)
        mPointerSimple.currentProperties.id = 0;
        mPointerSimple.currentProperties.toolType =
                mCurrentCookedPointerData.pointerProperties[index].toolType;
        mLastStylusTime = when;
    } else {
        down = false;
        hovering = false;
@@ -5297,6 +5298,11 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
        }
    }

    if (rejectPalm(when)) {     // stylus is currently active
        mPointerSimple.reset();
        return;
    }

    if (mPointerSimple.down && !down) {
        mPointerSimple.down = false;

@@ -5407,6 +5413,9 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32
        const PointerProperties* properties, const PointerCoords* coords,
        const uint32_t* idToIndex, BitSet32 idBits,
        int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime) {

    if (rejectPalm(when)) return;

    PointerCoords pointerCoords[MAX_POINTERS];
    PointerProperties pointerProperties[MAX_POINTERS];
    uint32_t pointerCount = 0;
@@ -5479,6 +5488,13 @@ void TouchInputMapper::fadePointer() {
    }
}

nsecs_t TouchInputMapper::mLastStylusTime = 0;

bool TouchInputMapper::rejectPalm(nsecs_t when) {
  return (when - mLastStylusTime < mConfig.stylusPalmRejectionTime) &&
    mPointerSimple.currentProperties.toolType != AMOTION_EVENT_TOOL_TYPE_STYLUS;
}

bool TouchInputMapper::isPointInsideSurface(int32_t x, int32_t y) {
    return x >= mRawPointerAxes.x.minValue && x <= mRawPointerAxes.x.maxValue
            && y >= mRawPointerAxes.y.minValue && y <= mRawPointerAxes.y.maxValue;
+11 −1
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ struct InputReaderConfiguration {
    // True to show the location of touches on the touch screen as spots.
    bool showTouches;

    // Ignore finger touches this long after the stylus has been used (including hover)
    nsecs_t stylusPalmRejectionTime;

    InputReaderConfiguration() :
            virtualKeyQuietTime(0),
            pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f, 3.0f),
@@ -178,7 +181,9 @@ struct InputReaderConfiguration {
            pointerGestureSwipeMaxWidthRatio(0.25f),
            pointerGestureMovementSpeedRatio(0.8f),
            pointerGestureZoomSpeedRatio(0.3f),
            showTouches(false) { }
            showTouches(false),
            stylusPalmRejectionTime(50 * 10000000LL) // 50 ms
    { }

    bool getDisplayInfo(int32_t displayId, bool external,
            int32_t* width, int32_t* height, int32_t* orientation) const;
@@ -1549,6 +1554,9 @@ private:
    VelocityControl mWheelXVelocityControl;
    VelocityControl mWheelYVelocityControl;

    // The time the stylus event was processed by any TouchInputMapper
    static nsecs_t mLastStylusTime;

    void sync(nsecs_t when);

    bool consumeRawTouches(nsecs_t when, uint32_t policyFlags);
@@ -1601,6 +1609,8 @@ private:
    const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y);

    void assignPointerIds();

    bool rejectPalm(nsecs_t when);
};