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

Commit d363aa2e authored by Jeff Brown's avatar Jeff Brown Committed by Android Git Automerger
Browse files

am 36f0cb26: am 8d60866e: Input device calibration and capabilities.

Merge commit '36f0cb26cbb4ef62995ff2e5a540cf8814e7f030'

* commit '36f0cb26cbb4ef62995ff2e5a540cf8814e7f030':
  Input device calibration and capabilities.
parents 160ccc36 e0b0e897
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -82,6 +82,14 @@ struct RawAbsoluteAxisInfo {
    int32_t fuzz;      // error tolerance, eg. fuzz == 4 means value is +/- 4 due to noise

    inline int32_t getRange() { return maxValue - minValue; }

    inline void clear() {
        valid = false;
        minValue = 0;
        maxValue = 0;
        flat = 0;
        fuzz = 0;
    }
};

/*
+4 −0
Original line number Diff line number Diff line
@@ -453,6 +453,10 @@ public:
    inline void setKeyboardType(int32_t keyboardType) { mKeyboardType = keyboardType; }
    inline int32_t getKeyboardType() const { return mKeyboardType; }

    inline const KeyedVector<int32_t, MotionRange> getMotionRanges() const {
        return mMotionRanges;
    }

private:
    int32_t mId;
    String8 mName;
+134 −23
Original line number Diff line number Diff line
@@ -35,6 +35,34 @@ namespace android {
class InputDevice;
class InputMapper;

/* Describes a virtual key. */
struct VirtualKeyDefinition {
    int32_t scanCode;

    // configured position data, specified in display coords
    int32_t centerX;
    int32_t centerY;
    int32_t width;
    int32_t height;
};


/* Specifies input device calibration settings. */
class InputDeviceCalibration {
public:
    InputDeviceCalibration();

    void clear();
    void addProperty(const String8& key, const String8& value);

    bool tryGetProperty(const String8& key, String8& outValue) const;
    bool tryGetProperty(const String8& key, int32_t& outValue) const;
    bool tryGetProperty(const String8& key, float& outValue) const;

private:
    KeyedVector<String8, String8> mProperties;
};


/*
 * Input reader policy interface.
@@ -73,17 +101,6 @@ public:
        ACTION_APP_SWITCH_COMING = 0x00000002,
    };

    /* Describes a virtual key. */
    struct VirtualKeyDefinition {
        int32_t scanCode;

        // configured position data, specified in display coords
        int32_t centerX;
        int32_t centerY;
        int32_t width;
        int32_t height;
    };

    /* Gets information about the display with the specified id.
     * Returns true if the display info is available, false otherwise.
     */
@@ -135,6 +152,10 @@ public:
    virtual void getVirtualKeyDefinitions(const String8& deviceName,
            Vector<VirtualKeyDefinition>& outVirtualKeyDefinitions) = 0;

    /* Gets the calibration for an input device. */
    virtual void getInputDeviceCalibration(const String8& deviceName,
            InputDeviceCalibration& outCalibration) = 0;

    /* Gets the excluded device names for the platform. */
    virtual void getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames) = 0;
};
@@ -327,6 +348,10 @@ public:

    int32_t getMetaState();

    inline const InputDeviceCalibration& getCalibration() {
        return mCalibration;
    }

private:
    InputReaderContext* mContext;
    int32_t mId;
@@ -338,6 +363,8 @@ private:

    typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code);
    int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc);

    InputDeviceCalibration mCalibration;
};


@@ -538,12 +565,12 @@ protected:
        }
    };

    // Raw data for a single pointer.
    struct PointerData {
        uint32_t id;
        int32_t x;
        int32_t y;
        int32_t pressure;
        int32_t size;
        int32_t touchMajor;
        int32_t touchMinor;
        int32_t toolMajor;
@@ -551,6 +578,7 @@ protected:
        int32_t orientation;
    };

    // Raw data for a collection of pointers including a pointer id mapping table.
    struct TouchData {
        uint32_t pointerCount;
        PointerData pointers[MAX_POINTERS];
@@ -584,18 +612,82 @@ protected:
        bool useAveragingTouchFilter;
    } mParameters;

    // Raw axis information.
    struct Axes {
    // Immutable calibration parameters in parsed form.
    struct Calibration {
        // Touch Area
        enum TouchAreaCalibration {
            TOUCH_AREA_CALIBRATION_DEFAULT,
            TOUCH_AREA_CALIBRATION_NONE,
            TOUCH_AREA_CALIBRATION_GEOMETRIC,
            TOUCH_AREA_CALIBRATION_PRESSURE,
        };

        TouchAreaCalibration touchAreaCalibration;

        // Tool Area
        enum ToolAreaCalibration {
            TOOL_AREA_CALIBRATION_DEFAULT,
            TOOL_AREA_CALIBRATION_NONE,
            TOOL_AREA_CALIBRATION_GEOMETRIC,
            TOOL_AREA_CALIBRATION_LINEAR,
        };

        ToolAreaCalibration toolAreaCalibration;
        bool haveToolAreaLinearScale;
        float toolAreaLinearScale;
        bool haveToolAreaLinearBias;
        float toolAreaLinearBias;
        bool haveToolAreaIsSummed;
        int32_t toolAreaIsSummed;

        // Pressure
        enum PressureCalibration {
            PRESSURE_CALIBRATION_DEFAULT,
            PRESSURE_CALIBRATION_NONE,
            PRESSURE_CALIBRATION_PHYSICAL,
            PRESSURE_CALIBRATION_AMPLITUDE,
        };
        enum PressureSource {
            PRESSURE_SOURCE_DEFAULT,
            PRESSURE_SOURCE_PRESSURE,
            PRESSURE_SOURCE_TOUCH,
        };

        PressureCalibration pressureCalibration;
        PressureSource pressureSource;
        bool havePressureScale;
        float pressureScale;

        // Size
        enum SizeCalibration {
            SIZE_CALIBRATION_DEFAULT,
            SIZE_CALIBRATION_NONE,
            SIZE_CALIBRATION_NORMALIZED,
        };

        SizeCalibration sizeCalibration;

        // Orientation
        enum OrientationCalibration {
            ORIENTATION_CALIBRATION_DEFAULT,
            ORIENTATION_CALIBRATION_NONE,
            ORIENTATION_CALIBRATION_INTERPOLATED,
        };

        OrientationCalibration orientationCalibration;
    } mCalibration;

    // Raw axis information from the driver.
    struct RawAxes {
        RawAbsoluteAxisInfo x;
        RawAbsoluteAxisInfo y;
        RawAbsoluteAxisInfo pressure;
        RawAbsoluteAxisInfo size;
        RawAbsoluteAxisInfo touchMajor;
        RawAbsoluteAxisInfo touchMinor;
        RawAbsoluteAxisInfo toolMajor;
        RawAbsoluteAxisInfo toolMinor;
        RawAbsoluteAxisInfo orientation;
    } mAxes;
    } mRawAxes;

    // Current and previous touch sample data.
    TouchData mCurrentTouch;
@@ -620,10 +712,13 @@ protected:
        float yScale;
        float yPrecision;

        int32_t pressureOrigin;
        float geometricScale;

        float toolAreaLinearScale;
        float toolAreaLinearBias;

        float pressureScale;

        int32_t sizeOrigin;
        float sizeScale;

        float orientationScale;
@@ -632,12 +727,22 @@ protected:
        struct OrientedRanges {
            InputDeviceInfo::MotionRange x;
            InputDeviceInfo::MotionRange y;

            bool havePressure;
            InputDeviceInfo::MotionRange pressure;

            bool haveSize;
            InputDeviceInfo::MotionRange size;

            bool haveTouchArea;
            InputDeviceInfo::MotionRange touchMajor;
            InputDeviceInfo::MotionRange touchMinor;

            bool haveToolArea;
            InputDeviceInfo::MotionRange toolMajor;
            InputDeviceInfo::MotionRange toolMinor;

            bool haveOrientation;
            InputDeviceInfo::MotionRange orientation;
        } orientedRanges;

@@ -653,9 +758,14 @@ protected:
        } currentVirtualKey;
    } mLocked;

    virtual void configureAxes();
    virtual void configureParameters();
    virtual void configureRawAxes();
    virtual void logRawAxes();
    virtual bool configureSurfaceLocked();
    virtual void configureVirtualKeysLocked();
    virtual void parseCalibration();
    virtual void resolveCalibration();
    virtual void logCalibration();

    enum TouchResult {
        // Dispatch the touch normally.
@@ -713,7 +823,8 @@ private:
    TouchResult consumeOffScreenTouches(nsecs_t when, uint32_t policyFlags);
    void dispatchTouches(nsecs_t when, uint32_t policyFlags);
    void dispatchTouch(nsecs_t when, uint32_t policyFlags, TouchData* touch,
            BitSet32 idBits, uint32_t changedId, int32_t motionEventAction);
            BitSet32 idBits, uint32_t changedId, uint32_t pointerCount,
            int32_t motionEventAction);

    void applyPolicyAndDispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
            int32_t keyEventAction, int32_t keyEventFlags,
@@ -738,7 +849,7 @@ public:
    virtual void process(const RawEvent* rawEvent);

protected:
    virtual void configureAxes();
    virtual void configureRawAxes();

private:
    struct Accumulator {
@@ -767,7 +878,7 @@ private:
    int32_t mX;
    int32_t mY;
    int32_t mPressure;
    int32_t mSize;
    int32_t mToolWidth;

    void initialize();

@@ -784,7 +895,7 @@ public:
    virtual void process(const RawEvent* rawEvent);

protected:
    virtual void configureAxes();
    virtual void configureRawAxes();

private:
    struct Accumulator {
+2 −7
Original line number Diff line number Diff line
@@ -139,11 +139,7 @@ uint32_t EventHub::getDeviceClasses(int32_t deviceId) const

status_t EventHub::getAbsoluteAxisInfo(int32_t deviceId, int axis,
        RawAbsoluteAxisInfo* outAxisInfo) const {
    outAxisInfo->valid = false;
    outAxisInfo->minValue = 0;
    outAxisInfo->maxValue = 0;
    outAxisInfo->flat = 0;
    outAxisInfo->fuzz = 0;
    outAxisInfo->clear();

    AutoMutex _l(mLock);
    device_t* device = getDevice(deviceId);
@@ -709,8 +705,7 @@ int EventHub::open_device(const char *deviceName)
    LOGV("Getting absolute controllers...");
    if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask) >= 0) {
        // Is this a new modern multi-touch driver?
        if (test_bit(ABS_MT_TOUCH_MAJOR, abs_bitmask)
                && test_bit(ABS_MT_POSITION_X, abs_bitmask)
        if (test_bit(ABS_MT_POSITION_X, abs_bitmask)
                && test_bit(ABS_MT_POSITION_Y, abs_bitmask)) {
            device->classes |= INPUT_DEVICE_CLASS_TOUCHSCREEN | INPUT_DEVICE_CLASS_TOUCHSCREEN_MT;

+15 −7
Original line number Diff line number Diff line
@@ -405,12 +405,15 @@ void InputDispatcher::processMotionLockedInterruptible(
        sampleCount += 1;
    }
    for (uint32_t i = 0; i < entry->pointerCount; i++) {
        LOGD("  Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f",
        LOGD("  Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f, "
                "touchMajor=%f, touchMinor=%d, toolMajor=%f, toolMinor=%f, "
                "orientation=%f",
                i, entry->pointerIds[i],
                sample->pointerCoords[i].x,
                sample->pointerCoords[i].y,
                sample->pointerCoords[i].pressure,
                sample->pointerCoords[i].size);
                sample->pointerCoords[i].x, sample->pointerCoords[i].y,
                sample->pointerCoords[i].pressure, sample->pointerCoords[i].size,
                sample->pointerCoords[i].touchMajor, sample->pointerCoords[i].touchMinor,
                sample->pointerCoords[i].toolMajor, sample->pointerCoords[i].toolMinor,
                sample->pointerCoords[i].orientation);
    }

    // Keep in mind that due to batching, it is possible for the number of samples actually
@@ -1080,9 +1083,14 @@ void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t
            eventTime, deviceId, source, policyFlags, action, metaState, edgeFlags,
            xPrecision, yPrecision, downTime);
    for (uint32_t i = 0; i < pointerCount; i++) {
        LOGD("  Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f",
        LOGD("  Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f, "
                "touchMajor=%f, touchMinor=%d, toolMajor=%f, toolMinor=%f, "
                "orientation=%f",
                i, pointerIds[i], pointerCoords[i].x, pointerCoords[i].y,
                pointerCoords[i].pressure, pointerCoords[i].size);
                pointerCoords[i].pressure, pointerCoords[i].size,
                pointerCoords[i].touchMajor, pointerCoords[i].touchMinor,
                pointerCoords[i].toolMajor, pointerCoords[i].toolMinor,
                pointerCoords[i].orientation);
    }
#endif

Loading