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

Commit bea3f86b authored by Volker Braun's avatar Volker Braun Committed by Espen Fjellvær Olsen
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 6de4ca65
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -5295,6 +5295,7 @@ void TouchInputMapper::dispatchPointerStylus(nsecs_t when, uint32_t policyFlags)
        mPointerSimple.currentProperties.id = 0;
        mPointerSimple.currentProperties.id = 0;
        mPointerSimple.currentProperties.toolType =
        mPointerSimple.currentProperties.toolType =
                mCurrentCookedPointerData.pointerProperties[index].toolType;
                mCurrentCookedPointerData.pointerProperties[index].toolType;
        mLastStylusTime = when;
    } else {
    } else {
        down = false;
        down = false;
        hovering = false;
        hovering = false;
@@ -5377,6 +5378,11 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
        }
        }
    }
    }


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

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


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

    if (rejectPalm(when)) return;

    PointerCoords pointerCoords[MAX_POINTERS];
    PointerCoords pointerCoords[MAX_POINTERS];
    PointerProperties pointerProperties[MAX_POINTERS];
    PointerProperties pointerProperties[MAX_POINTERS];
    uint32_t pointerCount = 0;
    uint32_t pointerCount = 0;
+3 −0
Original line number Original line Diff line number Diff line
@@ -1610,6 +1610,9 @@ private:
    VelocityControl mWheelXVelocityControl;
    VelocityControl mWheelXVelocityControl;
    VelocityControl mWheelYVelocityControl;
    VelocityControl mWheelYVelocityControl;


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

    void sync(nsecs_t when);
    void sync(nsecs_t when);


    bool consumeRawTouches(nsecs_t when, uint32_t policyFlags);
    bool consumeRawTouches(nsecs_t when, uint32_t policyFlags);