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

Commit 49754db5 authored by Jeff Brown's avatar Jeff Brown
Browse files

Handle stylus buttons and tool types.

Added TOOL_TYPE_ERASER.

Refactored the InputReader to share more code between the
various input mappers that handle button states and to
simplify the accumulator implementations by having each
one only handle a single type of input.

Removed the concept of direct/indirect tool types from the API.
If we add it back, it should be done in a manner that is orthogonal
to the tool type itself, perhaps as a flags field on the pointer.
The device source may well provide sufficient information anyhow.

Change-Id: I811c22d95e8304269b6ee4f6d11a6b04f3cfc1b2
parent 44e504e0
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -21919,9 +21919,8 @@ package android.view {
    field public static final int EDGE_TOP = 1; // 0x1
    field public static final int FLAG_WINDOW_IS_OBSCURED = 1; // 0x1
    field public static final int INVALID_POINTER_ID = -1; // 0xffffffff
    field public static final int TOOL_TYPE_ERASER = 4; // 0x4
    field public static final int TOOL_TYPE_FINGER = 1; // 0x1
    field public static final int TOOL_TYPE_INDIRECT_FINGER = 4; // 0x4
    field public static final int TOOL_TYPE_INDIRECT_STYLUS = 5; // 0x5
    field public static final int TOOL_TYPE_MOUSE = 3; // 0x3
    field public static final int TOOL_TYPE_STYLUS = 2; // 0x2
    field public static final int TOOL_TYPE_UNKNOWN = 0; // 0x0
+10 −31
Original line number Diff line number Diff line
@@ -1123,7 +1123,10 @@ public final class MotionEvent extends InputEvent implements Parcelable {
    }

    /**
     * Button constant: Primary button (left mouse button, stylus tip).
     * Button constant: Primary button (left mouse button).
     *
     * This button constant is not set in response to simple touches with a finger
     * or stylus tip.  The user must actually push a button.
     *
     * @see #getButtonState
     */
@@ -1215,55 +1218,32 @@ public final class MotionEvent extends InputEvent implements Parcelable {
    public static final int TOOL_TYPE_UNKNOWN = 0;

    /**
     * Tool type constant: The tool is a finger directly touching the display.
     *
     * This is a <em>direct</em> positioning tool.
     * Tool type constant: The tool is a finger.
     *
     * @see #getToolType
     */
    public static final int TOOL_TYPE_FINGER = 1;

    /**
     * Tool type constant: The tool is a stylus directly touching the display
     * or hovering slightly above it.
     *
     * This is a <em>direct</em> positioning tool.
     * Tool type constant: The tool is a stylus.
     *
     * @see #getToolType
     */
    public static final int TOOL_TYPE_STYLUS = 2;

    /**
     * Tool type constant: The tool is a mouse or trackpad that translates
     * relative motions into cursor movements on the display.
     *
     * This is an <em>indirect</em> positioning tool.
     * Tool type constant: The tool is a mouse or trackpad.
     *
     * @see #getToolType
     */
    public static final int TOOL_TYPE_MOUSE = 3;

    /**
     * Tool type constant: The tool is a finger on a touch pad that is not
     * directly attached to the display.  Finger movements on the touch pad
     * may be translated into touches on the display, possibly with visual feedback.
     *
     * This is an <em>indirect</em> positioning tool.
     *
     * @see #getToolType
     */
    public static final int TOOL_TYPE_INDIRECT_FINGER = 4;

    /**
     * Tool type constant: The tool is a stylus on a digitizer tablet that is not
     * attached to the display.  Stylus movements on the digitizer may be translated
     * into touches on the display, possibly with visual feedback.
     *
     * This is an <em>indirect</em> positioning tool.
     * Tool type constant: The tool is an eraser or a stylus being used in an inverted posture.
     *
     * @see #getToolType
     */
    public static final int TOOL_TYPE_INDIRECT_STYLUS = 5;
    public static final int TOOL_TYPE_ERASER = 4;

    // NOTE: If you add a new tool type here you must also add it to:
    //  native/include/android/input.h
@@ -1276,8 +1256,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
        names.append(TOOL_TYPE_FINGER, "TOOL_TYPE_FINGER");
        names.append(TOOL_TYPE_STYLUS, "TOOL_TYPE_STYLUS");
        names.append(TOOL_TYPE_MOUSE, "TOOL_TYPE_MOUSE");
        names.append(TOOL_TYPE_INDIRECT_FINGER, "TOOL_TYPE_INDIRECT_FINGER");
        names.append(TOOL_TYPE_INDIRECT_STYLUS, "TOOL_TYPE_INDIRECT_STYLUS");
        names.append(TOOL_TYPE_ERASER, "TOOL_TYPE_ERASER");
    }

    // Private value for history pos that obtains the current sample.
+1 −2
Original line number Diff line number Diff line
@@ -415,8 +415,7 @@ enum {
    AMOTION_EVENT_TOOL_TYPE_FINGER = 1,
    AMOTION_EVENT_TOOL_TYPE_STYLUS = 2,
    AMOTION_EVENT_TOOL_TYPE_MOUSE = 3,
    AMOTION_EVENT_TOOL_TYPE_INDIRECT_FINGER = 4,
    AMOTION_EVENT_TOOL_TYPE_INDIRECT_STYLUS = 5,
    AMOTION_EVENT_TOOL_TYPE_ERASER = 4,
};

/*
+11 −0
Original line number Diff line number Diff line
@@ -460,6 +460,17 @@ void EventHub::setExcludedDevices(const Vector<String8>& devices) {
    mExcludedDevices = devices;
}

bool EventHub::hasScanCode(int32_t deviceId, int32_t scanCode) const {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
    if (device && scanCode >= 0 && scanCode <= KEY_MAX) {
        if (test_bit(scanCode, device->keyBitmask)) {
            return true;
        }
    }
    return false;
}

bool EventHub::hasLed(int32_t deviceId, int32_t led) const {
    AutoMutex _l(mLock);
    Device* device = getDeviceLocked(deviceId);
+2 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ public:
    virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes, const int32_t* keyCodes,
            uint8_t* outFlags) const = 0;

    virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const = 0;
    virtual bool hasLed(int32_t deviceId, int32_t led) const = 0;
    virtual void setLedState(int32_t deviceId, int32_t led, bool on) = 0;

@@ -246,6 +247,7 @@ public:

    virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize);

    virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const;
    virtual bool hasLed(int32_t deviceId, int32_t led) const;
    virtual void setLedState(int32_t deviceId, int32_t led, bool on);

Loading