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

Commit b9cb2961 authored by Volker Braun's avatar Volker Braun Committed by Ricardo Cerqueira
Browse files

Disable touch while using the stylus (Galaxy Note)

Android 4.0 cannot form multitouch events from multiple input
devices. So it is not possible to report one touchpoint from the
stylus position and, at the same time, another touchpoint from a
finger touch. Instead, when a new input device starts up the currently
active input is cancelled. This is highly undesirable while writing
with the pen.

The easiest solution is to ignore non-stylus touch events while the
stylus is within range (hovering) of the touchscreen. For example,
N-trig digitizers implement this in hardware. But wacom digitizers do
report pen data simultaneously with touch data. This patch disables
(non-stylus) touch input within 50ms of stylus data. On my Galaxy
Note this is necessary to make stylus input usable.

Change-Id: I9f458d85d8bf83d6cf03b467d46ce066fd55b7e0

Conflicts:
	services/input/InputReader.cpp
	services/input/InputReader.h
parent 3b63ea55
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -5417,6 +5417,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;
@@ -5499,6 +5500,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;

@@ -5616,6 +5622,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;
+3 −0
Original line number Diff line number Diff line
@@ -1630,6 +1630,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);