Loading include/ui/InputReader.h +83 −67 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ public: * IMPORTANT INVARIANT: * Because the policy and dispatcher can potentially block or cause re-entrance into * the input reader, the input reader never calls into other components while holding * an exclusive internal lock. * an exclusive internal lock whenever re-entrance can happen. */ class InputReader : public InputReaderInterface, private InputReaderContext { public: Loading Loading @@ -414,6 +414,8 @@ public: virtual int32_t getMetaState(); private: Mutex mLock; struct KeyDown { int32_t keyCode; int32_t scanCode; Loading @@ -423,17 +425,22 @@ private: uint32_t mSources; int32_t mKeyboardType; Vector<KeyDown> mKeyDowns; // keys that are down int32_t mMetaState; nsecs_t mDownTime; // time of most recent key down struct LockedState { Vector<KeyDown> keyDowns; // keys that are down int32_t metaState; nsecs_t downTime; // time of most recent key down } mLocked; void initialize(); void initializeLocked(); bool isKeyboardOrGamepadKey(int32_t scanCode); void processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode, uint32_t policyFlags); void applyPolicyAndDispatch(nsecs_t when, uint32_t policyFlags, bool down, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime); ssize_t findKeyDown(int32_t scanCode); ssize_t findKeyDownLocked(int32_t scanCode); }; Loading @@ -451,6 +458,8 @@ private: // Amount that trackball needs to move in order to generate a key event. static const int32_t TRACKBALL_MOVEMENT_THRESHOLD = 6; Mutex mLock; int32_t mAssociatedDisplayId; struct Accumulator { Loading @@ -475,17 +484,21 @@ private: } } mAccumulator; bool mDown; nsecs_t mDownTime; float mXScale; float mYScale; float mXPrecision; float mYPrecision; void initialize(); struct LockedState { bool down; nsecs_t downTime; } mLocked; void initializeLocked(); void sync(nsecs_t when); void applyPolicyAndDispatch(nsecs_t when, int32_t motionEventAction, PointerCoords* pointerCoords, nsecs_t downTime); }; Loading @@ -509,6 +522,8 @@ protected: * (This is limited by our use of BitSet32 to track pointer assignments.) */ static const uint32_t MAX_POINTER_ID = 31; Mutex mLock; struct VirtualKey { int32_t keyCode; int32_t scanCode; Loading Loading @@ -561,7 +576,6 @@ protected: }; int32_t mAssociatedDisplayId; Vector<VirtualKey> mVirtualKeys; // Immutable configuration parameters. struct Parameters { Loading @@ -583,26 +597,36 @@ protected: RawAbsoluteAxisInfo orientation; } mAxes; // The surface orientation and width and height set by configureSurface(). int32_t mSurfaceOrientation; int32_t mSurfaceWidth, mSurfaceHeight; // Current and previous touch sample data. TouchData mCurrentTouch; TouchData mLastTouch; // The time the primary pointer last went down. nsecs_t mDownTime; struct LockedState { Vector<VirtualKey> virtualKeys; // The surface orientation and width and height set by configureSurfaceLocked(). int32_t surfaceOrientation; int32_t surfaceWidth, surfaceHeight; // Translation and scaling factors, orientation-independent. int32_t mXOrigin; float mXScale; float mXPrecision; int32_t xOrigin; float xScale; float xPrecision; int32_t mYOrigin; float mYScale; float mYPrecision; int32_t yOrigin; float yScale; float yPrecision; int32_t mPressureOrigin; float mPressureScale; int32_t pressureOrigin; float pressureScale; int32_t mSizeOrigin; float mSizeScale; int32_t sizeOrigin; float sizeScale; float mOrientationScale; float orientationScale; // Oriented motion ranges for input device info. struct OrientedRanges { Loading @@ -615,35 +639,23 @@ protected: InputDeviceInfo::MotionRange toolMajor; InputDeviceInfo::MotionRange toolMinor; InputDeviceInfo::MotionRange orientation; } mOrientedRanges; } orientedRanges; // Oriented dimensions and precision. float mOrientedSurfaceWidth, mOrientedSurfaceHeight; float mOrientedXPrecision, mOrientedYPrecision; // The touch data of the current sample being processed. TouchData mCurrentTouch; // The touch data of the previous sample that was processed. This is updated // incrementally while the current sample is being processed. TouchData mLastTouch; // The time the primary pointer last went down. nsecs_t mDownTime; float orientedSurfaceWidth, orientedSurfaceHeight; float orientedXPrecision, orientedYPrecision; struct CurrentVirtualKeyState { bool down; nsecs_t downTime; int32_t keyCode; int32_t scanCode; } mCurrentVirtualKey; // Lock for virtual key state. Mutex mVirtualKeyLock; // methods use "Lvk" suffix } currentVirtualKey; } mLocked; virtual void configureAxes(); virtual bool configureSurface(); virtual void configureVirtualKeys(); virtual bool configureSurfaceLocked(); virtual void configureVirtualKeysLocked(); enum TouchResult { // Dispatch the touch normally. Loading Loading @@ -696,15 +708,19 @@ private: uint64_t distance : 48; // squared distance }; void initialize(); void initializeLocked(); 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); bool isPointInsideSurface(int32_t x, int32_t y); const VirtualKey* findVirtualKeyHitLvk(int32_t x, int32_t y); void applyPolicyAndDispatchVirtualKey(nsecs_t when, uint32_t policyFlags, int32_t keyEventAction, int32_t keyEventFlags, int32_t keyCode, int32_t scanCode, nsecs_t downTime); bool isPointInsideSurfaceLocked(int32_t x, int32_t y); const VirtualKey* findVirtualKeyHitLocked(int32_t x, int32_t y); bool applyBadTouchFilter(); bool applyJumpyTouchFilter(); Loading libs/ui/InputReader.cpp +496 −423 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
include/ui/InputReader.h +83 −67 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ public: * IMPORTANT INVARIANT: * Because the policy and dispatcher can potentially block or cause re-entrance into * the input reader, the input reader never calls into other components while holding * an exclusive internal lock. * an exclusive internal lock whenever re-entrance can happen. */ class InputReader : public InputReaderInterface, private InputReaderContext { public: Loading Loading @@ -414,6 +414,8 @@ public: virtual int32_t getMetaState(); private: Mutex mLock; struct KeyDown { int32_t keyCode; int32_t scanCode; Loading @@ -423,17 +425,22 @@ private: uint32_t mSources; int32_t mKeyboardType; Vector<KeyDown> mKeyDowns; // keys that are down int32_t mMetaState; nsecs_t mDownTime; // time of most recent key down struct LockedState { Vector<KeyDown> keyDowns; // keys that are down int32_t metaState; nsecs_t downTime; // time of most recent key down } mLocked; void initialize(); void initializeLocked(); bool isKeyboardOrGamepadKey(int32_t scanCode); void processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode, uint32_t policyFlags); void applyPolicyAndDispatch(nsecs_t when, uint32_t policyFlags, bool down, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime); ssize_t findKeyDown(int32_t scanCode); ssize_t findKeyDownLocked(int32_t scanCode); }; Loading @@ -451,6 +458,8 @@ private: // Amount that trackball needs to move in order to generate a key event. static const int32_t TRACKBALL_MOVEMENT_THRESHOLD = 6; Mutex mLock; int32_t mAssociatedDisplayId; struct Accumulator { Loading @@ -475,17 +484,21 @@ private: } } mAccumulator; bool mDown; nsecs_t mDownTime; float mXScale; float mYScale; float mXPrecision; float mYPrecision; void initialize(); struct LockedState { bool down; nsecs_t downTime; } mLocked; void initializeLocked(); void sync(nsecs_t when); void applyPolicyAndDispatch(nsecs_t when, int32_t motionEventAction, PointerCoords* pointerCoords, nsecs_t downTime); }; Loading @@ -509,6 +522,8 @@ protected: * (This is limited by our use of BitSet32 to track pointer assignments.) */ static const uint32_t MAX_POINTER_ID = 31; Mutex mLock; struct VirtualKey { int32_t keyCode; int32_t scanCode; Loading Loading @@ -561,7 +576,6 @@ protected: }; int32_t mAssociatedDisplayId; Vector<VirtualKey> mVirtualKeys; // Immutable configuration parameters. struct Parameters { Loading @@ -583,26 +597,36 @@ protected: RawAbsoluteAxisInfo orientation; } mAxes; // The surface orientation and width and height set by configureSurface(). int32_t mSurfaceOrientation; int32_t mSurfaceWidth, mSurfaceHeight; // Current and previous touch sample data. TouchData mCurrentTouch; TouchData mLastTouch; // The time the primary pointer last went down. nsecs_t mDownTime; struct LockedState { Vector<VirtualKey> virtualKeys; // The surface orientation and width and height set by configureSurfaceLocked(). int32_t surfaceOrientation; int32_t surfaceWidth, surfaceHeight; // Translation and scaling factors, orientation-independent. int32_t mXOrigin; float mXScale; float mXPrecision; int32_t xOrigin; float xScale; float xPrecision; int32_t mYOrigin; float mYScale; float mYPrecision; int32_t yOrigin; float yScale; float yPrecision; int32_t mPressureOrigin; float mPressureScale; int32_t pressureOrigin; float pressureScale; int32_t mSizeOrigin; float mSizeScale; int32_t sizeOrigin; float sizeScale; float mOrientationScale; float orientationScale; // Oriented motion ranges for input device info. struct OrientedRanges { Loading @@ -615,35 +639,23 @@ protected: InputDeviceInfo::MotionRange toolMajor; InputDeviceInfo::MotionRange toolMinor; InputDeviceInfo::MotionRange orientation; } mOrientedRanges; } orientedRanges; // Oriented dimensions and precision. float mOrientedSurfaceWidth, mOrientedSurfaceHeight; float mOrientedXPrecision, mOrientedYPrecision; // The touch data of the current sample being processed. TouchData mCurrentTouch; // The touch data of the previous sample that was processed. This is updated // incrementally while the current sample is being processed. TouchData mLastTouch; // The time the primary pointer last went down. nsecs_t mDownTime; float orientedSurfaceWidth, orientedSurfaceHeight; float orientedXPrecision, orientedYPrecision; struct CurrentVirtualKeyState { bool down; nsecs_t downTime; int32_t keyCode; int32_t scanCode; } mCurrentVirtualKey; // Lock for virtual key state. Mutex mVirtualKeyLock; // methods use "Lvk" suffix } currentVirtualKey; } mLocked; virtual void configureAxes(); virtual bool configureSurface(); virtual void configureVirtualKeys(); virtual bool configureSurfaceLocked(); virtual void configureVirtualKeysLocked(); enum TouchResult { // Dispatch the touch normally. Loading Loading @@ -696,15 +708,19 @@ private: uint64_t distance : 48; // squared distance }; void initialize(); void initializeLocked(); 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); bool isPointInsideSurface(int32_t x, int32_t y); const VirtualKey* findVirtualKeyHitLvk(int32_t x, int32_t y); void applyPolicyAndDispatchVirtualKey(nsecs_t when, uint32_t policyFlags, int32_t keyEventAction, int32_t keyEventFlags, int32_t keyCode, int32_t scanCode, nsecs_t downTime); bool isPointInsideSurfaceLocked(int32_t x, int32_t y); const VirtualKey* findVirtualKeyHitLocked(int32_t x, int32_t y); bool applyBadTouchFilter(); bool applyJumpyTouchFilter(); Loading
libs/ui/InputReader.cpp +496 −423 File changed.Preview size limit exceeded, changes collapsed. Show changes