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
This commit is contained in:
Jeff Brown
2011-07-01 17:37:58 -07:00
parent 44e504e089
commit 49754db5a3
8 changed files with 748 additions and 615 deletions

View File

@@ -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

View File

@@ -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.
* 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_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.
*
* @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.

View File

@@ -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,
};
/*

View File

@@ -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);

View File

@@ -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);

File diff suppressed because it is too large Load Diff

View File

@@ -430,9 +430,8 @@ public:
void fadePointer();
inline const PropertyMap& getConfiguration() {
return mConfiguration;
}
inline const PropertyMap& getConfiguration() { return mConfiguration; }
inline EventHubInterface* getEventHub() { return mContext->getEventHub(); }
private:
InputReaderContext* mContext;
@@ -452,6 +451,171 @@ private:
};
/* Keeps track of the state of mouse or touch pad buttons. */
class CursorButtonAccumulator {
public:
CursorButtonAccumulator();
void clearButtons();
void process(const RawEvent* rawEvent);
uint32_t getButtonState() const;
private:
bool mBtnLeft;
bool mBtnRight;
bool mBtnMiddle;
bool mBtnBack;
bool mBtnSide;
bool mBtnForward;
bool mBtnExtra;
bool mBtnTask;
};
/* Keeps track of cursor movements. */
class CursorMotionAccumulator {
public:
CursorMotionAccumulator();
void configure(InputDevice* device);
void clearRelativeAxes();
void process(const RawEvent* rawEvent);
inline bool haveRelativeVWheel() const { return mHaveRelWheel; }
inline bool haveRelativeHWheel() const { return mHaveRelHWheel; }
inline int32_t getRelativeX() const { return mRelX; }
inline int32_t getRelativeY() const { return mRelY; }
inline int32_t getRelativeVWheel() const { return mRelWheel; }
inline int32_t getRelativeHWheel() const { return mRelHWheel; }
private:
bool mHaveRelWheel;
bool mHaveRelHWheel;
int32_t mRelX;
int32_t mRelY;
int32_t mRelWheel;
int32_t mRelHWheel;
};
/* Keeps track of the state of touch, stylus and tool buttons. */
class TouchButtonAccumulator {
public:
TouchButtonAccumulator();
void configure(InputDevice* device);
void clearButtons();
void process(const RawEvent* rawEvent);
uint32_t getButtonState() const;
int32_t getToolType() const;
bool isActive() const;
bool isHovering() const;
private:
bool mHaveBtnTouch;
bool mBtnTouch;
bool mBtnStylus;
bool mBtnStylus2;
bool mBtnToolFinger;
bool mBtnToolPen;
bool mBtnToolRubber;
};
/* Keeps track of the state of single-touch protocol. */
class SingleTouchMotionAccumulator {
public:
SingleTouchMotionAccumulator();
void clearAbsoluteAxes();
void process(const RawEvent* rawEvent);
inline int32_t getAbsoluteX() const { return mAbsX; }
inline int32_t getAbsoluteY() const { return mAbsY; }
inline int32_t getAbsolutePressure() const { return mAbsPressure; }
inline int32_t getAbsoluteToolWidth() const { return mAbsToolWidth; }
inline int32_t getAbsoluteDistance() const { return mAbsDistance; }
private:
int32_t mAbsX;
int32_t mAbsY;
int32_t mAbsPressure;
int32_t mAbsToolWidth;
int32_t mAbsDistance;
};
/* Keeps track of the state of multi-touch protocol. */
class MultiTouchMotionAccumulator {
public:
class Slot {
public:
inline bool isInUse() const { return mInUse; }
inline int32_t getX() const { return mAbsMTPositionX; }
inline int32_t getY() const { return mAbsMTPositionY; }
inline int32_t getTouchMajor() const { return mAbsMTTouchMajor; }
inline int32_t getTouchMinor() const {
return mHaveAbsMTTouchMinor ? mAbsMTTouchMinor : mAbsMTTouchMajor; }
inline int32_t getToolMajor() const { return mAbsMTWidthMajor; }
inline int32_t getToolMinor() const {
return mHaveAbsMTWidthMinor ? mAbsMTWidthMinor : mAbsMTWidthMajor; }
inline int32_t getOrientation() const { return mAbsMTOrientation; }
inline int32_t getTrackingId() const { return mAbsMTTrackingId; }
inline int32_t getPressure() const { return mAbsMTPressure; }
inline int32_t getDistance() const { return mAbsMTDistance; }
inline int32_t getToolType() const;
private:
friend class MultiTouchMotionAccumulator;
bool mInUse;
bool mHaveAbsMTTouchMinor;
bool mHaveAbsMTWidthMinor;
bool mHaveAbsMTToolType;
int32_t mAbsMTPositionX;
int32_t mAbsMTPositionY;
int32_t mAbsMTTouchMajor;
int32_t mAbsMTTouchMinor;
int32_t mAbsMTWidthMajor;
int32_t mAbsMTWidthMinor;
int32_t mAbsMTOrientation;
int32_t mAbsMTTrackingId;
int32_t mAbsMTPressure;
int32_t mAbsMTToolType;
int32_t mAbsMTDistance;
Slot();
void clearIfInUse();
void clear();
};
MultiTouchMotionAccumulator();
~MultiTouchMotionAccumulator();
void configure(size_t slotCount, bool usingSlotsProtocol);
void process(const RawEvent* rawEvent);
void clearSlots(int32_t initialSlot);
inline bool isUsingSlotsProtocol() const { return mUsingSlotsProtocol; }
inline size_t getSlotCount() const { return mSlotCount; }
inline const Slot* getSlot(size_t index) const { return &mSlots[index]; }
private:
int32_t mCurrentSlot;
Slot* mSlots;
size_t mSlotCount;
bool mUsingSlotsProtocol;
};
/* An input mapper transforms raw input events into cooked event data.
* A single input device can have multiple associated input mappers in order to interpret
* different classes of events.
@@ -615,29 +779,8 @@ private:
bool orientationAware;
} mParameters;
struct Accumulator {
enum {
FIELD_BUTTONS = 1,
FIELD_REL_X = 2,
FIELD_REL_Y = 4,
FIELD_REL_WHEEL = 8,
FIELD_REL_HWHEEL = 16,
};
uint32_t fields;
uint32_t buttonDown;
uint32_t buttonUp;
int32_t relX;
int32_t relY;
int32_t relWheel;
int32_t relHWheel;
inline void clear() {
fields = 0;
}
} mAccumulator;
CursorButtonAccumulator mCursorButtonAccumulator;
CursorMotionAccumulator mCursorMotionAccumulator;
int32_t mSource;
float mXScale;
@@ -645,8 +788,6 @@ private:
float mXPrecision;
float mYPrecision;
bool mHaveVWheel;
bool mHaveHWheel;
float mVWheelScale;
float mHWheelScale;
@@ -722,7 +863,8 @@ protected:
int32_t toolMinor;
int32_t orientation;
int32_t distance;
bool isStylus;
int32_t toolType; // AMOTION_EVENT_TOOL_TYPE constant
bool isHovering;
inline bool operator== (const PointerData& other) const {
return id == other.id
@@ -734,7 +876,9 @@ protected:
&& toolMajor == other.toolMajor
&& toolMinor == other.toolMinor
&& orientation == other.orientation
&& distance == other.distance;
&& distance == other.distance
&& toolType == other.toolType
&& isHovering == other.isHovering;
}
inline bool operator!= (const PointerData& other) const {
return !(*this == other);
@@ -1201,7 +1345,6 @@ private:
void suppressSwipeOntoVirtualKeys(nsecs_t when);
int32_t getTouchToolType(bool isStylus) const;
bool isPointInsideSurfaceLocked(int32_t x, int32_t y);
const VirtualKey* findVirtualKeyHitLocked(int32_t x, int32_t y);
@@ -1221,40 +1364,9 @@ protected:
virtual void configureRawAxes();
private:
struct Accumulator {
enum {
FIELD_BTN_TOUCH = 1,
FIELD_ABS_X = 2,
FIELD_ABS_Y = 4,
FIELD_ABS_PRESSURE = 8,
FIELD_ABS_TOOL_WIDTH = 16,
FIELD_BUTTONS = 32,
};
uint32_t fields;
bool btnTouch;
int32_t absX;
int32_t absY;
int32_t absPressure;
int32_t absToolWidth;
uint32_t buttonDown;
uint32_t buttonUp;
inline void clear() {
fields = 0;
buttonDown = 0;
buttonUp = 0;
}
} mAccumulator;
bool mDown;
int32_t mX;
int32_t mY;
int32_t mPressure;
int32_t mToolWidth;
int32_t mButtonState;
CursorButtonAccumulator mCursorButtonAccumulator;
TouchButtonAccumulator mTouchButtonAccumulator;
SingleTouchMotionAccumulator mSingleTouchMotionAccumulator;
void clearState();
@@ -1274,83 +1386,9 @@ protected:
virtual void configureRawAxes();
private:
struct Accumulator {
enum {
FIELD_ABS_MT_POSITION_X = 1 << 0,
FIELD_ABS_MT_POSITION_Y = 1 << 1,
FIELD_ABS_MT_TOUCH_MAJOR = 1 << 2,
FIELD_ABS_MT_TOUCH_MINOR = 1 << 3,
FIELD_ABS_MT_WIDTH_MAJOR = 1 << 4,
FIELD_ABS_MT_WIDTH_MINOR = 1 << 5,
FIELD_ABS_MT_ORIENTATION = 1 << 6,
FIELD_ABS_MT_TRACKING_ID = 1 << 7,
FIELD_ABS_MT_PRESSURE = 1 << 8,
FIELD_ABS_MT_TOOL_TYPE = 1 << 9,
FIELD_ABS_MT_DISTANCE = 1 << 10,
};
struct Slot {
uint32_t fields; // 0 if slot is unused
int32_t absMTPositionX;
int32_t absMTPositionY;
int32_t absMTTouchMajor;
int32_t absMTTouchMinor;
int32_t absMTWidthMajor;
int32_t absMTWidthMinor;
int32_t absMTOrientation;
int32_t absMTTrackingId;
int32_t absMTPressure;
int32_t absMTToolType;
int32_t absMTDistance;
inline Slot() {
clear();
}
inline void clear() {
fields = 0;
}
};
// Current slot index.
int32_t currentSlot;
// Array of slots.
Slot* slots;
// Bitfield of buttons that went down or up.
uint32_t buttonDown;
uint32_t buttonUp;
Accumulator() : currentSlot(0), slots(NULL), buttonDown(0), buttonUp(0) {
}
~Accumulator() {
delete[] slots;
}
void allocateSlots(size_t slotCount) {
slots = new Slot[slotCount];
}
void clearSlots(size_t slotCount) {
for (size_t i = 0; i < slotCount; i++) {
slots[i].clear();
}
currentSlot = 0;
}
void clearButtons() {
buttonDown = 0;
buttonUp = 0;
}
} mAccumulator;
size_t mSlotCount;
bool mUsingSlotsProtocol;
int32_t mButtonState;
CursorButtonAccumulator mCursorButtonAccumulator;
TouchButtonAccumulator mTouchButtonAccumulator;
MultiTouchMotionAccumulator mMultiTouchMotionAccumulator;
// Specifies the pointer id bits that are in use, and their associated tracking id.
BitSet32 mPointerIdBits;

View File

@@ -707,6 +707,15 @@ private:
return result;
}
virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const {
Device* device = getDevice(deviceId);
if (device) {
ssize_t index = device->keys.indexOfKey(scanCode);
return index >= 0;
}
return false;
}
virtual bool hasLed(int32_t deviceId, int32_t led) const {
Device* device = getDevice(deviceId);
return device && device->leds.indexOfKey(led) >= 0;
@@ -2116,6 +2125,7 @@ TEST_F(CursorInputMapperTest, Process_ShouldSetAllFieldsAndIncludeGlobalMetaStat
// Button press.
// Mostly testing non x/y behavior here so we don't need to check again elsewhere.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 1, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
ASSERT_EQ(DEVICE_ID, args.deviceId);
@@ -2137,6 +2147,7 @@ TEST_F(CursorInputMapperTest, Process_ShouldSetAllFieldsAndIncludeGlobalMetaStat
// Button release. Should have same down time.
process(mapper, ARBITRARY_TIME + 1, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 0, 0);
process(mapper, ARBITRARY_TIME + 1, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(ARBITRARY_TIME + 1, args.eventTime);
ASSERT_EQ(DEVICE_ID, args.deviceId);
@@ -2190,6 +2201,7 @@ TEST_F(CursorInputMapperTest, Process_ShouldHandleIndependentButtonUpdates) {
// Button press without following sync.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 1, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
@@ -2197,6 +2209,7 @@ TEST_F(CursorInputMapperTest, Process_ShouldHandleIndependentButtonUpdates) {
// Button release without following sync.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 0, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
@@ -2233,6 +2246,7 @@ TEST_F(CursorInputMapperTest, Process_ShouldHandleCombinedXYAndButtonUpdates) {
// Release Button.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 0, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
@@ -2248,10 +2262,12 @@ TEST_F(CursorInputMapperTest, Reset_WhenButtonIsNotDown_ShouldNotSynthesizeButto
// Button press.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 1, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
// Button release.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 0, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
// Reset. Should not synthesize button up since button is not pressed.
@@ -2269,6 +2285,7 @@ TEST_F(CursorInputMapperTest, Reset_WhenButtonIsDown_ShouldSynthesizeButtonUp) {
// Button press.
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 1, 0);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
// Reset. Should synthesize button up.
@@ -2445,6 +2462,7 @@ float TouchInputMapperTest::toDisplayY(int32_t rawY) {
class SingleTouchInputMapperTest : public TouchInputMapperTest {
protected:
void prepareButtons();
void prepareAxes(int axes);
void processDown(SingleTouchInputMapper* mapper, int32_t x, int32_t y);
@@ -2455,6 +2473,10 @@ protected:
void processSync(SingleTouchInputMapper* mapper);
};
void SingleTouchInputMapperTest::prepareButtons() {
mFakeEventHub->addKey(DEVICE_ID, BTN_TOUCH, AKEYCODE_UNKNOWN, 0);
}
void SingleTouchInputMapperTest::prepareAxes(int axes) {
if (axes & POSITION) {
mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_X,
@@ -2504,6 +2526,7 @@ void SingleTouchInputMapperTest::processSync(SingleTouchInputMapper* mapper) {
TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndNotACursor_ReturnsPointer) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
prepareButtons();
prepareAxes(POSITION);
addMapperAndConfigure(mapper);
@@ -2514,6 +2537,7 @@ TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndIsA
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
mFakeEventHub->addRelativeAxis(DEVICE_ID, REL_X);
mFakeEventHub->addRelativeAxis(DEVICE_ID, REL_Y);
prepareButtons();
prepareAxes(POSITION);
addMapperAndConfigure(mapper);
@@ -2522,6 +2546,7 @@ TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndIsA
TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsTouchPad_ReturnsTouchPad) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
prepareButtons();
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchPad");
addMapperAndConfigure(mapper);
@@ -2531,6 +2556,7 @@ TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsTouchPad_ReturnsTo
TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsTouchScreen_ReturnsTouchScreen) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
prepareButtons();
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
addMapperAndConfigure(mapper);
@@ -2542,6 +2568,7 @@ TEST_F(SingleTouchInputMapperTest, GetKeyCodeState) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2570,6 +2597,7 @@ TEST_F(SingleTouchInputMapperTest, GetScanCodeState) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2598,6 +2626,7 @@ TEST_F(SingleTouchInputMapperTest, MarkSupportedKeyCodes) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2615,6 +2644,7 @@ TEST_F(SingleTouchInputMapperTest, Reset_WhenVirtualKeysAreDown_SendsUp) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2649,6 +2679,7 @@ TEST_F(SingleTouchInputMapperTest, Reset_WhenNothingIsPressed_NothingMuchHappens
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2676,6 +2707,7 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenVirtualKeyIsPressedAndReleasedNor
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2726,6 +2758,7 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenVirtualKeyIsPressedAndMovedOutOfB
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2847,6 +2880,7 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenTouchStartsOutsideDisplayAndMoves
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -2920,6 +2954,7 @@ TEST_F(SingleTouchInputMapperTest, Process_NormalSingleTouchGesture) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION);
prepareVirtualKeys();
addMapperAndConfigure(mapper);
@@ -3009,6 +3044,7 @@ TEST_F(SingleTouchInputMapperTest, Process_NormalSingleTouchGesture) {
TEST_F(SingleTouchInputMapperTest, Process_WhenNotOrientationAware_DoesNotRotateMotions) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareButtons();
prepareAxes(POSITION);
addConfigurationProperty("touch.orientationAware", "0");
addMapperAndConfigure(mapper);
@@ -3032,6 +3068,7 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenNotOrientationAware_DoesNotRotate
TEST_F(SingleTouchInputMapperTest, Process_WhenOrientationAware_RotatesMotions) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareButtons();
prepareAxes(POSITION);
addMapperAndConfigure(mapper);
@@ -3094,6 +3131,7 @@ TEST_F(SingleTouchInputMapperTest, Process_AllAxes_DefaultCalibration) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
prepareAxes(POSITION | PRESSURE | TOOL);
addMapperAndConfigure(mapper);
@@ -3815,6 +3853,7 @@ TEST_F(MultiTouchInputMapperTest, Process_TouchToolPressureSizeAxes_SummedLinear
FakeInputDispatcher::NotifyMotionArgs args;
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
ASSERT_NO_FATAL_FAILURE(mFakeDispatcher->assertNotifyMotionWasCalled(&args));
ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
args.action);