Revert "Add new MotionEvent actions for button press and release."

This reverts commit 48a8a0e432.
This commit is contained in:
Michael Wright 2015-05-14 14:46:17 +01:00
parent 48a8a0e432
commit 70b41ef580
12 changed files with 108 additions and 231 deletions

View File

@ -305,12 +305,6 @@ enum {
/* The pointer is not down but has exited the boundaries of a window or view. /* The pointer is not down but has exited the boundaries of a window or view.
*/ */
AMOTION_EVENT_ACTION_HOVER_EXIT = 10, AMOTION_EVENT_ACTION_HOVER_EXIT = 10,
/* One or more buttons have been pressed. */
AMOTION_EVENT_ACTION_BUTTON_PRESS = 11,
/* One or more buttons have been released. */
AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12,
}; };
/* /*
@ -411,8 +405,6 @@ enum {
AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,
AMOTION_EVENT_BUTTON_BACK = 1 << 3, AMOTION_EVENT_BUTTON_BACK = 1 << 3,
AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
}; };
/* /*

View File

@ -379,10 +379,6 @@ public:
inline int32_t getButtonState() const { return mButtonState; } inline int32_t getButtonState() const { return mButtonState; }
inline int32_t setButtonState(int32_t buttonState) { mButtonState = buttonState; }
inline int32_t getActionButton() const { return mActionButton; }
inline float getXOffset() const { return mXOffset; } inline float getXOffset() const { return mXOffset; }
inline float getYOffset() const { return mYOffset; } inline float getYOffset() const { return mYOffset; }
@ -536,7 +532,6 @@ public:
int32_t deviceId, int32_t deviceId,
int32_t source, int32_t source,
int32_t action, int32_t action,
int32_t actionButton,
int32_t flags, int32_t flags,
int32_t edgeFlags, int32_t edgeFlags,
int32_t metaState, int32_t metaState,
@ -589,7 +584,6 @@ public:
protected: protected:
int32_t mAction; int32_t mAction;
int32_t mActionButton;
int32_t mFlags; int32_t mFlags;
int32_t mEdgeFlags; int32_t mEdgeFlags;
int32_t mMetaState; int32_t mMetaState;

View File

@ -84,7 +84,6 @@ struct InputMessage {
int32_t deviceId; int32_t deviceId;
int32_t source; int32_t source;
int32_t action; int32_t action;
int32_t actionButton;
int32_t flags; int32_t flags;
int32_t metaState; int32_t metaState;
int32_t buttonState; int32_t buttonState;
@ -233,7 +232,6 @@ public:
int32_t deviceId, int32_t deviceId,
int32_t source, int32_t source,
int32_t action, int32_t action,
int32_t actionButton,
int32_t flags, int32_t flags,
int32_t edgeFlags, int32_t edgeFlags,
int32_t metaState, int32_t metaState,

View File

@ -216,7 +216,6 @@ void MotionEvent::initialize(
int32_t deviceId, int32_t deviceId,
int32_t source, int32_t source,
int32_t action, int32_t action,
int32_t actionButton,
int32_t flags, int32_t flags,
int32_t edgeFlags, int32_t edgeFlags,
int32_t metaState, int32_t metaState,
@ -232,7 +231,6 @@ void MotionEvent::initialize(
const PointerCoords* pointerCoords) { const PointerCoords* pointerCoords) {
InputEvent::initialize(deviceId, source); InputEvent::initialize(deviceId, source);
mAction = action; mAction = action;
mActionButton = actionButton;
mFlags = flags; mFlags = flags;
mEdgeFlags = edgeFlags; mEdgeFlags = edgeFlags;
mMetaState = metaState; mMetaState = metaState;
@ -252,7 +250,6 @@ void MotionEvent::initialize(
void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) { void MotionEvent::copyFrom(const MotionEvent* other, bool keepHistory) {
InputEvent::initialize(other->mDeviceId, other->mSource); InputEvent::initialize(other->mDeviceId, other->mSource);
mAction = other->mAction; mAction = other->mAction;
mActionButton = other->mActionButton;
mFlags = other->mFlags; mFlags = other->mFlags;
mEdgeFlags = other->mEdgeFlags; mEdgeFlags = other->mEdgeFlags;
mMetaState = other->mMetaState; mMetaState = other->mMetaState;
@ -431,7 +428,6 @@ status_t MotionEvent::readFromParcel(Parcel* parcel) {
mDeviceId = parcel->readInt32(); mDeviceId = parcel->readInt32();
mSource = parcel->readInt32(); mSource = parcel->readInt32();
mAction = parcel->readInt32(); mAction = parcel->readInt32();
mActionButton = parcel->readInt32();
mFlags = parcel->readInt32(); mFlags = parcel->readInt32();
mEdgeFlags = parcel->readInt32(); mEdgeFlags = parcel->readInt32();
mMetaState = parcel->readInt32(); mMetaState = parcel->readInt32();
@ -479,7 +475,6 @@ status_t MotionEvent::writeToParcel(Parcel* parcel) const {
parcel->writeInt32(mDeviceId); parcel->writeInt32(mDeviceId);
parcel->writeInt32(mSource); parcel->writeInt32(mSource);
parcel->writeInt32(mAction); parcel->writeInt32(mAction);
parcel->writeInt32(mActionButton);
parcel->writeInt32(mFlags); parcel->writeInt32(mFlags);
parcel->writeInt32(mEdgeFlags); parcel->writeInt32(mEdgeFlags);
parcel->writeInt32(mMetaState); parcel->writeInt32(mMetaState);

View File

@ -283,7 +283,6 @@ status_t InputPublisher::publishMotionEvent(
int32_t deviceId, int32_t deviceId,
int32_t source, int32_t source,
int32_t action, int32_t action,
int32_t actionButton,
int32_t flags, int32_t flags,
int32_t edgeFlags, int32_t edgeFlags,
int32_t metaState, int32_t metaState,
@ -299,12 +298,12 @@ status_t InputPublisher::publishMotionEvent(
const PointerCoords* pointerCoords) { const PointerCoords* pointerCoords) {
#if DEBUG_TRANSPORT_ACTIONS #if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, " ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "
"action=0x%x, actionButton=0x%08x, flags=0x%x, edgeFlags=0x%x, " "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, buttonState=0x%x, "
"metaState=0x%x, buttonState=0x%x, xOffset=%f, yOffset=%f, " "xOffset=%f, yOffset=%f, "
"xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, " "xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, "
"pointerCount=%" PRIu32, "pointerCount=%" PRIu32,
mChannel->getName().string(), seq, mChannel->getName().string(), seq,
deviceId, source, action, actionButton, flags, edgeFlags, metaState, buttonState, deviceId, source, action, flags, edgeFlags, metaState, buttonState,
xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount); xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
#endif #endif
@ -325,7 +324,6 @@ status_t InputPublisher::publishMotionEvent(
msg.body.motion.deviceId = deviceId; msg.body.motion.deviceId = deviceId;
msg.body.motion.source = source; msg.body.motion.source = source;
msg.body.motion.action = action; msg.body.motion.action = action;
msg.body.motion.actionButton = actionButton;
msg.body.motion.flags = flags; msg.body.motion.flags = flags;
msg.body.motion.edgeFlags = edgeFlags; msg.body.motion.edgeFlags = edgeFlags;
msg.body.motion.metaState = metaState; msg.body.motion.metaState = metaState;
@ -909,7 +907,6 @@ void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage
msg->body.motion.deviceId, msg->body.motion.deviceId,
msg->body.motion.source, msg->body.motion.source,
msg->body.motion.action, msg->body.motion.action,
msg->body.motion.actionButton,
msg->body.motion.flags, msg->body.motion.flags,
msg->body.motion.edgeFlags, msg->body.motion.edgeFlags,
msg->body.motion.metaState, msg->body.motion.metaState,

View File

@ -119,7 +119,7 @@ static bool validateKeyEvent(int32_t action) {
return true; return true;
} }
static bool isValidMotionAction(int32_t action, int32_t actionButton, int32_t pointerCount) { static bool isValidMotionAction(int32_t action, size_t pointerCount) {
switch (action & AMOTION_EVENT_ACTION_MASK) { switch (action & AMOTION_EVENT_ACTION_MASK) {
case AMOTION_EVENT_ACTION_DOWN: case AMOTION_EVENT_ACTION_DOWN:
case AMOTION_EVENT_ACTION_UP: case AMOTION_EVENT_ACTION_UP:
@ -136,17 +136,14 @@ static bool isValidMotionAction(int32_t action, int32_t actionButton, int32_t po
int32_t index = getMotionEventActionPointerIndex(action); int32_t index = getMotionEventActionPointerIndex(action);
return index >= 0 && size_t(index) < pointerCount; return index >= 0 && size_t(index) < pointerCount;
} }
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
case AMOTION_EVENT_ACTION_BUTTON_RELEASE:
return actionButton != 0;
default: default:
return false; return false;
} }
} }
static bool validateMotionEvent(int32_t action, int32_t actionButton, size_t pointerCount, static bool validateMotionEvent(int32_t action, size_t pointerCount,
const PointerProperties* pointerProperties) { const PointerProperties* pointerProperties) {
if (! isValidMotionAction(action, actionButton, pointerCount)) { if (! isValidMotionAction(action, pointerCount)) {
ALOGE("Motion event has invalid action code 0x%x", action); ALOGE("Motion event has invalid action code 0x%x", action);
return false; return false;
} }
@ -877,12 +874,12 @@ bool InputDispatcher::dispatchMotionLocked(
void InputDispatcher::logOutboundMotionDetailsLocked(const char* prefix, const MotionEntry* entry) { void InputDispatcher::logOutboundMotionDetailsLocked(const char* prefix, const MotionEntry* entry) {
#if DEBUG_OUTBOUND_EVENT_DETAILS #if DEBUG_OUTBOUND_EVENT_DETAILS
ALOGD("%seventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, " ALOGD("%seventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
"action=0x%x, actionButton=0x%x, flags=0x%x, " "action=0x%x, flags=0x%x, "
"metaState=0x%x, buttonState=0x%x, " "metaState=0x%x, buttonState=0x%x, "
"edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld", "edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld",
prefix, prefix,
entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, entry->eventTime, entry->deviceId, entry->source, entry->policyFlags,
entry->action, entry->actionButton entry->flags, entry->action, entry->flags,
entry->metaState, entry->buttonState, entry->metaState, entry->buttonState,
entry->edgeFlags, entry->xPrecision, entry->yPrecision, entry->edgeFlags, entry->xPrecision, entry->yPrecision,
entry->downTime); entry->downTime);
@ -1984,10 +1981,10 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
// Publish the motion event. // Publish the motion event.
status = connection->inputPublisher.publishMotionEvent(dispatchEntry->seq, status = connection->inputPublisher.publishMotionEvent(dispatchEntry->seq,
motionEntry->deviceId, motionEntry->source, motionEntry->deviceId, motionEntry->source,
dispatchEntry->resolvedAction, motionEntry->actionButton, dispatchEntry->resolvedAction, dispatchEntry->resolvedFlags,
dispatchEntry->resolvedFlags, motionEntry->edgeFlags, motionEntry->edgeFlags, motionEntry->metaState, motionEntry->buttonState,
motionEntry->metaState, motionEntry->buttonState, xOffset, yOffset,
xOffset, yOffset, motionEntry->xPrecision, motionEntry->yPrecision, motionEntry->xPrecision, motionEntry->yPrecision,
motionEntry->downTime, motionEntry->eventTime, motionEntry->downTime, motionEntry->eventTime,
motionEntry->pointerCount, motionEntry->pointerProperties, motionEntry->pointerCount, motionEntry->pointerProperties,
usingCoords); usingCoords);
@ -2301,7 +2298,6 @@ InputDispatcher::splitMotionEvent(const MotionEntry* originalMotionEntry, BitSet
originalMotionEntry->source, originalMotionEntry->source,
originalMotionEntry->policyFlags, originalMotionEntry->policyFlags,
action, action,
originalMotionEntry->actionButton,
originalMotionEntry->flags, originalMotionEntry->flags,
originalMotionEntry->metaState, originalMotionEntry->metaState,
originalMotionEntry->buttonState, originalMotionEntry->buttonState,
@ -2436,10 +2432,10 @@ bool InputDispatcher::shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args
void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) { void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
#if DEBUG_INBOUND_EVENT_DETAILS #if DEBUG_INBOUND_EVENT_DETAILS
ALOGD("notifyMotion - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, " ALOGD("notifyMotion - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
"action=0x%x, actionButton=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x," "action=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x, edgeFlags=0x%x, "
"edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld", "xPrecision=%f, yPrecision=%f, downTime=%lld",
args->eventTime, args->deviceId, args->source, args->policyFlags, args->eventTime, args->deviceId, args->source, args->policyFlags,
args->action, args->actionButton, args->flags, args->metaState, args->buttonState, args->action, args->flags, args->metaState, args->buttonState,
args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime); args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime);
for (uint32_t i = 0; i < args->pointerCount; i++) { for (uint32_t i = 0; i < args->pointerCount; i++) {
ALOGD(" Pointer %d: id=%d, toolType=%d, " ALOGD(" Pointer %d: id=%d, toolType=%d, "
@ -2459,8 +2455,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION)); args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
} }
#endif #endif
if (!validateMotionEvent(args->action, args->actionButton, if (!validateMotionEvent(args->action, args->pointerCount, args->pointerProperties)) {
args->pointerCount, args->pointerProperties)) {
return; return;
} }
@ -2476,9 +2471,9 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
mLock.unlock(); mLock.unlock();
MotionEvent event; MotionEvent event;
event.initialize(args->deviceId, args->source, args->action, args->actionButton, event.initialize(args->deviceId, args->source, args->action, args->flags,
args->flags, args->edgeFlags, args->metaState, args->buttonState, args->edgeFlags, args->metaState, args->buttonState, 0, 0,
0, 0, args->xPrecision, args->yPrecision, args->xPrecision, args->yPrecision,
args->downTime, args->eventTime, args->downTime, args->eventTime,
args->pointerCount, args->pointerProperties, args->pointerCoords); args->pointerCount, args->pointerProperties, args->pointerCoords);
@ -2493,8 +2488,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
// Just enqueue a new motion event. // Just enqueue a new motion event.
MotionEntry* newEntry = new MotionEntry(args->eventTime, MotionEntry* newEntry = new MotionEntry(args->eventTime,
args->deviceId, args->source, policyFlags, args->deviceId, args->source, policyFlags,
args->action, args->actionButton, args->flags, args->action, args->flags, args->metaState, args->buttonState,
args->metaState, args->buttonState,
args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime, args->edgeFlags, args->xPrecision, args->yPrecision, args->downTime,
args->displayId, args->displayId,
args->pointerCount, args->pointerProperties, args->pointerCoords, 0, 0); args->pointerCount, args->pointerProperties, args->pointerCoords, 0, 0);
@ -2595,8 +2589,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, int32_t displ
int32_t action = motionEvent->getAction(); int32_t action = motionEvent->getAction();
size_t pointerCount = motionEvent->getPointerCount(); size_t pointerCount = motionEvent->getPointerCount();
const PointerProperties* pointerProperties = motionEvent->getPointerProperties(); const PointerProperties* pointerProperties = motionEvent->getPointerProperties();
int32_t actionButton = motionEvent->getActionButton(); if (! validateMotionEvent(action, pointerCount, pointerProperties)) {
if (! validateMotionEvent(action, actionButton, pointerCount, pointerProperties)) {
return INPUT_EVENT_INJECTION_FAILED; return INPUT_EVENT_INJECTION_FAILED;
} }
@ -2610,7 +2603,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, int32_t displ
const PointerCoords* samplePointerCoords = motionEvent->getSamplePointerCoords(); const PointerCoords* samplePointerCoords = motionEvent->getSamplePointerCoords();
firstInjectedEntry = new MotionEntry(*sampleEventTimes, firstInjectedEntry = new MotionEntry(*sampleEventTimes,
motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags, motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags,
action, actionButton, motionEvent->getFlags(), action, motionEvent->getFlags(),
motionEvent->getMetaState(), motionEvent->getButtonState(), motionEvent->getMetaState(), motionEvent->getButtonState(),
motionEvent->getEdgeFlags(), motionEvent->getEdgeFlags(),
motionEvent->getXPrecision(), motionEvent->getYPrecision(), motionEvent->getXPrecision(), motionEvent->getYPrecision(),
@ -2623,7 +2616,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event, int32_t displ
samplePointerCoords += pointerCount; samplePointerCoords += pointerCount;
MotionEntry* nextInjectedEntry = new MotionEntry(*sampleEventTimes, MotionEntry* nextInjectedEntry = new MotionEntry(*sampleEventTimes,
motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags, motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags,
action, actionButton, motionEvent->getFlags(), action, motionEvent->getFlags(),
motionEvent->getMetaState(), motionEvent->getButtonState(), motionEvent->getMetaState(), motionEvent->getButtonState(),
motionEvent->getEdgeFlags(), motionEvent->getEdgeFlags(),
motionEvent->getXPrecision(), motionEvent->getYPrecision(), motionEvent->getXPrecision(), motionEvent->getYPrecision(),
@ -3914,18 +3907,18 @@ void InputDispatcher::KeyEntry::recycle() {
// --- InputDispatcher::MotionEntry --- // --- InputDispatcher::MotionEntry ---
InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime, int32_t deviceId, InputDispatcher::MotionEntry::MotionEntry(nsecs_t eventTime,
uint32_t source, uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t deviceId, uint32_t source, uint32_t policyFlags, int32_t action, int32_t flags,
int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, int32_t metaState, int32_t buttonState,
float xPrecision, float yPrecision, nsecs_t downTime, int32_t edgeFlags, float xPrecision, float yPrecision,
int32_t displayId, uint32_t pointerCount, nsecs_t downTime, int32_t displayId, uint32_t pointerCount,
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
float xOffset, float yOffset) : float xOffset, float yOffset) :
EventEntry(TYPE_MOTION, eventTime, policyFlags), EventEntry(TYPE_MOTION, eventTime, policyFlags),
eventTime(eventTime), eventTime(eventTime),
deviceId(deviceId), source(source), action(action), actionButton(actionButton), deviceId(deviceId), source(source), action(action), flags(flags),
flags(flags), metaState(metaState), buttonState(buttonState), metaState(metaState), buttonState(buttonState), edgeFlags(edgeFlags),
edgeFlags(edgeFlags), xPrecision(xPrecision), yPrecision(yPrecision), xPrecision(xPrecision), yPrecision(yPrecision),
downTime(downTime), displayId(displayId), pointerCount(pointerCount) { downTime(downTime), displayId(displayId), pointerCount(pointerCount) {
for (uint32_t i = 0; i < pointerCount; i++) { for (uint32_t i = 0; i < pointerCount; i++) {
this->pointerProperties[i].copyFrom(pointerProperties[i]); this->pointerProperties[i].copyFrom(pointerProperties[i]);
@ -3940,10 +3933,10 @@ InputDispatcher::MotionEntry::~MotionEntry() {
} }
void InputDispatcher::MotionEntry::appendDescription(String8& msg) const { void InputDispatcher::MotionEntry::appendDescription(String8& msg) const {
msg.appendFormat("MotionEvent(deviceId=%d, source=0x%08x, action=%d, actionButton=0x%08x, " msg.appendFormat("MotionEvent(deviceId=%d, source=0x%08x, action=%d, "
"flags=0x%08x, metaState=0x%08x, buttonState=0x%08x, " "flags=0x%08x, metaState=0x%08x, buttonState=0x%08x, edgeFlags=0x%08x, "
"edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, displayId=%d, pointers=[", "xPrecision=%.1f, yPrecision=%.1f, displayId=%d, pointers=[",
deviceId, source, action, actionButton, flags, metaState, buttonState, edgeFlags, deviceId, source, action, flags, metaState, buttonState, edgeFlags,
xPrecision, yPrecision, displayId); xPrecision, yPrecision, displayId);
for (uint32_t i = 0; i < pointerCount; i++) { for (uint32_t i = 0; i < pointerCount; i++) {
if (i) { if (i) {
@ -4244,7 +4237,7 @@ void InputDispatcher::InputState::synthesizeCancelationEvents(nsecs_t currentTim
memento.hovering memento.hovering
? AMOTION_EVENT_ACTION_HOVER_EXIT ? AMOTION_EVENT_ACTION_HOVER_EXIT
: AMOTION_EVENT_ACTION_CANCEL, : AMOTION_EVENT_ACTION_CANCEL,
memento.flags, 0, 0, 0, 0, memento.flags, 0, 0, 0,
memento.xPrecision, memento.yPrecision, memento.downTime, memento.xPrecision, memento.yPrecision, memento.downTime,
memento.displayId, memento.displayId,
memento.pointerCount, memento.pointerProperties, memento.pointerCoords, memento.pointerCount, memento.pointerProperties, memento.pointerCoords,

View File

@ -504,7 +504,6 @@ private:
int32_t deviceId; int32_t deviceId;
uint32_t source; uint32_t source;
int32_t action; int32_t action;
int32_t actionButton;
int32_t flags; int32_t flags;
int32_t metaState; int32_t metaState;
int32_t buttonState; int32_t buttonState;
@ -519,10 +518,10 @@ private:
MotionEntry(nsecs_t eventTime, MotionEntry(nsecs_t eventTime,
int32_t deviceId, uint32_t source, uint32_t policyFlags, int32_t deviceId, uint32_t source, uint32_t policyFlags,
int32_t action, int32_t actionButton, int32_t flags, int32_t action, int32_t flags,
int32_t metaState, int32_t buttonState, int32_t edgeFlags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
float xPrecision, float yPrecision, nsecs_t downTime, float xPrecision, float yPrecision,
int32_t displayId, uint32_t pointerCount, nsecs_t downTime, int32_t displayId, uint32_t pointerCount,
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
float xOffset, float yOffset); float xOffset, float yOffset);
virtual void appendDescription(String8& msg) const; virtual void appendDescription(String8& msg) const;

View File

@ -68,13 +68,12 @@ void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const {
NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source,
uint32_t policyFlags, uint32_t policyFlags,
int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
int32_t buttonState, int32_t edgeFlags, int32_t displayId, uint32_t pointerCount, int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime) : float xPrecision, float yPrecision, nsecs_t downTime) :
eventTime(eventTime), deviceId(deviceId), source(source), policyFlags(policyFlags), eventTime(eventTime), deviceId(deviceId), source(source), policyFlags(policyFlags),
action(action), actionButton(actionButton), action(action), flags(flags), metaState(metaState), buttonState(buttonState),
flags(flags), metaState(metaState), buttonState(buttonState),
edgeFlags(edgeFlags), displayId(displayId), pointerCount(pointerCount), edgeFlags(edgeFlags), displayId(displayId), pointerCount(pointerCount),
xPrecision(xPrecision), yPrecision(yPrecision), downTime(downTime) { xPrecision(xPrecision), yPrecision(yPrecision), downTime(downTime) {
for (uint32_t i = 0; i < pointerCount; i++) { for (uint32_t i = 0; i < pointerCount; i++) {
@ -86,9 +85,10 @@ NotifyMotionArgs::NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t
NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) : NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) :
eventTime(other.eventTime), deviceId(other.deviceId), source(other.source), eventTime(other.eventTime), deviceId(other.deviceId), source(other.source),
policyFlags(other.policyFlags), policyFlags(other.policyFlags),
action(other.action), actionButton(other.actionButton), flags(other.flags), action(other.action), flags(other.flags),
metaState(other.metaState), buttonState(other.buttonState), metaState(other.metaState), buttonState(other.buttonState),
edgeFlags(other.edgeFlags), displayId(other.displayId), pointerCount(other.pointerCount), edgeFlags(other.edgeFlags), displayId(other.displayId),
pointerCount(other.pointerCount),
xPrecision(other.xPrecision), yPrecision(other.yPrecision), downTime(other.downTime) { xPrecision(other.xPrecision), yPrecision(other.yPrecision), downTime(other.downTime) {
for (uint32_t i = 0; i < pointerCount; i++) { for (uint32_t i = 0; i < pointerCount; i++) {
pointerProperties[i].copyFrom(other.pointerProperties[i]); pointerProperties[i].copyFrom(other.pointerProperties[i]);

View File

@ -84,7 +84,6 @@ struct NotifyMotionArgs : public NotifyArgs {
uint32_t source; uint32_t source;
uint32_t policyFlags; uint32_t policyFlags;
int32_t action; int32_t action;
int32_t actionButton;
int32_t flags; int32_t flags;
int32_t metaState; int32_t metaState;
int32_t buttonState; int32_t buttonState;
@ -100,8 +99,7 @@ struct NotifyMotionArgs : public NotifyArgs {
inline NotifyMotionArgs() { } inline NotifyMotionArgs() { }
NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags, NotifyMotionArgs(nsecs_t eventTime, int32_t deviceId, uint32_t source, uint32_t policyFlags,
int32_t action, int32_t actionButton, int32_t flags, int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
int32_t metaState, int32_t buttonState,
int32_t edgeFlags, int32_t displayId, uint32_t pointerCount, int32_t edgeFlags, int32_t displayId, uint32_t pointerCount,
const PointerProperties* pointerProperties, const PointerCoords* pointerCoords, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime); float xPrecision, float yPrecision, nsecs_t downTime);

View File

@ -1442,10 +1442,10 @@ void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
uint32_t TouchButtonAccumulator::getButtonState() const { uint32_t TouchButtonAccumulator::getButtonState() const {
uint32_t result = 0; uint32_t result = 0;
if (mBtnStylus) { if (mBtnStylus) {
result |= AMOTION_EVENT_BUTTON_STYLUS_PRIMARY; result |= AMOTION_EVENT_BUTTON_SECONDARY;
} }
if (mBtnStylus2) { if (mBtnStylus2) {
result |= AMOTION_EVENT_BUTTON_STYLUS_SECONDARY; result |= AMOTION_EVENT_BUTTON_TERTIARY;
} }
return result; return result;
} }
@ -2547,8 +2547,7 @@ void CursorInputMapper::sync(nsecs_t when) {
} }
nsecs_t downTime = mDownTime; nsecs_t downTime = mDownTime;
bool buttonsChanged = currentButtonState != lastButtonState; bool buttonsChanged = currentButtonState != lastButtonState;
int32_t buttonsPressed = currentButtonState & ~lastButtonState; bool buttonsPressed = currentButtonState & ~lastButtonState;
int32_t buttonsReleased = lastButtonState & ~currentButtonState;
float deltaX = mCursorMotionAccumulator.getRelativeX() * mXScale; float deltaX = mCursorMotionAccumulator.getRelativeX() * mXScale;
float deltaY = mCursorMotionAccumulator.getRelativeY() * mYScale; float deltaY = mCursorMotionAccumulator.getRelativeY() * mYScale;
@ -2624,7 +2623,6 @@ void CursorInputMapper::sync(nsecs_t when) {
// Send motion event. // Send motion event.
if (downChanged || moved || scrolled || buttonsChanged) { if (downChanged || moved || scrolled || buttonsChanged) {
int32_t metaState = mContext->getGlobalMetaState(); int32_t metaState = mContext->getGlobalMetaState();
int32_t buttonState = lastButtonState;
int32_t motionEventAction; int32_t motionEventAction;
if (downChanged) { if (downChanged) {
motionEventAction = down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP; motionEventAction = down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
@ -2634,48 +2632,17 @@ void CursorInputMapper::sync(nsecs_t when) {
motionEventAction = AMOTION_EVENT_ACTION_HOVER_MOVE; motionEventAction = AMOTION_EVENT_ACTION_HOVER_MOVE;
} }
if (buttonsReleased) {
BitSet32 released(buttonsReleased);
while (!released.isEmpty()) {
int32_t actionButton = BitSet32::valueForBit(released.clearFirstMarkedBit());
buttonState &= ~actionButton;
NotifyMotionArgs releaseArgs(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_BUTTON_RELEASE, actionButton, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
displayId, 1, &pointerProperties, &pointerCoords,
mXPrecision, mYPrecision, downTime);
getListener()->notifyMotion(&releaseArgs);
}
}
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
motionEventAction, 0, 0, metaState, currentButtonState, motionEventAction, 0, metaState, currentButtonState, 0,
AMOTION_EVENT_EDGE_FLAG_NONE,
displayId, 1, &pointerProperties, &pointerCoords, displayId, 1, &pointerProperties, &pointerCoords,
mXPrecision, mYPrecision, downTime); mXPrecision, mYPrecision, downTime);
getListener()->notifyMotion(&args); getListener()->notifyMotion(&args);
if (buttonsPressed) {
BitSet32 pressed(buttonsPressed);
while (!pressed.isEmpty()) {
int32_t actionButton = BitSet32::valueForBit(pressed.clearFirstMarkedBit());
buttonState |= actionButton;
NotifyMotionArgs pressArgs(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_BUTTON_PRESS, actionButton, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
displayId, 1, &pointerProperties, &pointerCoords,
mXPrecision, mYPrecision, downTime);
getListener()->notifyMotion(&pressArgs);
}
}
ALOG_ASSERT(buttonState == currentButtonState);
// Send hover move after UP to tell the application that the mouse is hovering now. // Send hover move after UP to tell the application that the mouse is hovering now.
if (motionEventAction == AMOTION_EVENT_ACTION_UP if (motionEventAction == AMOTION_EVENT_ACTION_UP
&& mPointerController != NULL) { && mPointerController != NULL) {
NotifyMotionArgs hoverArgs(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs hoverArgs(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, AMOTION_EVENT_ACTION_HOVER_MOVE, 0,
metaState, currentButtonState, AMOTION_EVENT_EDGE_FLAG_NONE, metaState, currentButtonState, AMOTION_EVENT_EDGE_FLAG_NONE,
displayId, 1, &pointerProperties, &pointerCoords, displayId, 1, &pointerProperties, &pointerCoords,
mXPrecision, mYPrecision, downTime); mXPrecision, mYPrecision, downTime);
@ -2688,7 +2655,7 @@ void CursorInputMapper::sync(nsecs_t when) {
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll);
NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, currentButtonState, AMOTION_EVENT_ACTION_SCROLL, 0, metaState, currentButtonState,
AMOTION_EVENT_EDGE_FLAG_NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
displayId, 1, &pointerProperties, &pointerCoords, displayId, 1, &pointerProperties, &pointerCoords,
mXPrecision, mYPrecision, downTime); mXPrecision, mYPrecision, downTime);
@ -2820,7 +2787,8 @@ void TouchInputMapper::dump(String8& dump) {
dump.appendFormat(INDENT4 "TiltYCenter: %0.3f\n", mTiltYCenter); dump.appendFormat(INDENT4 "TiltYCenter: %0.3f\n", mTiltYCenter);
dump.appendFormat(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale); dump.appendFormat(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale);
dump.appendFormat(INDENT3 "Last Raw Button State: 0x%08x\n", mLastRawState.buttonState); dump.appendFormat(INDENT3 "Last Button State: 0x%08x\n", mLastRawState.buttonState);
dump.appendFormat(INDENT3 "Last Raw Touch: pointerCount=%d\n", dump.appendFormat(INDENT3 "Last Raw Touch: pointerCount=%d\n",
mLastRawState.rawPointerData.pointerCount); mLastRawState.rawPointerData.pointerCount);
for (uint32_t i = 0; i < mLastRawState.rawPointerData.pointerCount; i++) { for (uint32_t i = 0; i < mLastRawState.rawPointerData.pointerCount; i++) {
@ -2836,7 +2804,6 @@ void TouchInputMapper::dump(String8& dump) {
pointer.toolType, toString(pointer.isHovering)); pointer.toolType, toString(pointer.isHovering));
} }
dump.appendFormat(INDENT3 "Last Cooked Button State: 0x%08x\n", mLastCookedState.buttonState);
dump.appendFormat(INDENT3 "Last Cooked Touch: pointerCount=%d\n", dump.appendFormat(INDENT3 "Last Cooked Touch: pointerCount=%d\n",
mLastCookedState.cookedPointerData.pointerCount); mLastCookedState.cookedPointerData.pointerCount);
for (uint32_t i = 0; i < mLastCookedState.cookedPointerData.pointerCount; i++) { for (uint32_t i = 0; i < mLastCookedState.cookedPointerData.pointerCount; i++) {
@ -4027,7 +3994,7 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) {
// Synthesize key down from raw buttons if needed. // Synthesize key down from raw buttons if needed.
synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_DOWN, when, getDeviceId(), mSource, synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_DOWN, when, getDeviceId(), mSource,
policyFlags, mLastCookedState.buttonState, mCurrentCookedState.buttonState); policyFlags, mLastRawState.buttonState, mCurrentRawState.buttonState);
// Dispatch the touches either directly or by translation through a pointer on screen. // Dispatch the touches either directly or by translation through a pointer on screen.
if (mDeviceMode == DEVICE_MODE_POINTER) { if (mDeviceMode == DEVICE_MODE_POINTER) {
@ -4084,16 +4051,14 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) {
mCurrentCookedState.cookedPointerData.touchingIdBits); mCurrentCookedState.cookedPointerData.touchingIdBits);
} }
dispatchButtonRelease(when, policyFlags);
dispatchHoverExit(when, policyFlags); dispatchHoverExit(when, policyFlags);
dispatchTouches(when, policyFlags); dispatchTouches(when, policyFlags);
dispatchHoverEnterAndMove(when, policyFlags); dispatchHoverEnterAndMove(when, policyFlags);
dispatchButtonPress(when, policyFlags);
} }
// Synthesize key up from raw buttons if needed. // Synthesize key up from raw buttons if needed.
synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource, synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource,
policyFlags, mLastCookedState.buttonState, mCurrentCookedState.buttonState); policyFlags, mLastRawState.buttonState, mCurrentRawState.buttonState);
// Clear some transient state. // Clear some transient state.
mCurrentRawState.rawVScroll = 0; mCurrentRawState.rawVScroll = 0;
@ -4105,7 +4070,7 @@ void TouchInputMapper::cookAndDispatch(nsecs_t when) {
} }
void TouchInputMapper::applyExternalStylusButtonState(nsecs_t when) { void TouchInputMapper::applyExternalStylusButtonState(nsecs_t when) {
if (mDeviceMode == DEVICE_MODE_DIRECT && hasExternalStylus() && mExternalStylusId != -1) { if (mDeviceMode == DEVICE_MODE_DIRECT && hasExternalStylus()) {
mCurrentRawState.buttonState |= mExternalStylusState.buttons; mCurrentRawState.buttonState |= mExternalStylusState.buttons;
} }
} }
@ -4317,14 +4282,14 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits; BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits;
BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits; BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits;
int32_t metaState = getContext()->getGlobalMetaState(); int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mCurrentCookedState.buttonState; int32_t buttonState = mCurrentRawState.buttonState;
if (currentIdBits == lastIdBits) { if (currentIdBits == lastIdBits) {
if (!currentIdBits.isEmpty()) { if (!currentIdBits.isEmpty()) {
// No pointer id changes so this is a move event. // No pointer id changes so this is a move event.
// The listener takes care of batching moves so we don't have to deal with that here. // The listener takes care of batching moves so we don't have to deal with that here.
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState,
AMOTION_EVENT_EDGE_FLAG_NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
mCurrentCookedState.cookedPointerData.pointerProperties, mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords, mCurrentCookedState.cookedPointerData.pointerCoords,
@ -4350,7 +4315,7 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
mLastCookedState.cookedPointerData.pointerCoords, mLastCookedState.cookedPointerData.pointerCoords,
mLastCookedState.cookedPointerData.idToIndex, mLastCookedState.cookedPointerData.idToIndex,
moveIdBits); moveIdBits);
if (buttonState != mLastCookedState.buttonState) { if (buttonState != mLastRawState.buttonState) {
moveNeeded = true; moveNeeded = true;
} }
@ -4359,11 +4324,12 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
uint32_t upId = upIdBits.clearFirstMarkedBit(); uint32_t upId = upIdBits.clearFirstMarkedBit();
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_UP, 0, 0, metaState, buttonState, 0, AMOTION_EVENT_ACTION_POINTER_UP, 0, metaState, buttonState, 0,
mLastCookedState.cookedPointerData.pointerProperties, mLastCookedState.cookedPointerData.pointerProperties,
mLastCookedState.cookedPointerData.pointerCoords, mLastCookedState.cookedPointerData.pointerCoords,
mLastCookedState.cookedPointerData.idToIndex, mLastCookedState.cookedPointerData.idToIndex,
dispatchedIdBits, upId, mOrientedXPrecision, mOrientedYPrecision, mDownTime); dispatchedIdBits, upId,
mOrientedXPrecision, mOrientedYPrecision, mDownTime);
dispatchedIdBits.clearBit(upId); dispatchedIdBits.clearBit(upId);
} }
@ -4373,11 +4339,12 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
if (moveNeeded && !moveIdBits.isEmpty()) { if (moveNeeded && !moveIdBits.isEmpty()) {
ALOG_ASSERT(moveIdBits.value == dispatchedIdBits.value); ALOG_ASSERT(moveIdBits.value == dispatchedIdBits.value);
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, 0, AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, 0,
mCurrentCookedState.cookedPointerData.pointerProperties, mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords, mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, mCurrentCookedState.cookedPointerData.idToIndex,
dispatchedIdBits, -1, mOrientedXPrecision, mOrientedYPrecision, mDownTime); dispatchedIdBits, -1,
mOrientedXPrecision, mOrientedYPrecision, mDownTime);
} }
// Dispatch pointer down events using the new pointer locations. // Dispatch pointer down events using the new pointer locations.
@ -4391,11 +4358,12 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
} }
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_DOWN, 0, 0, metaState, buttonState, 0, AMOTION_EVENT_ACTION_POINTER_DOWN, 0, metaState, buttonState, 0,
mCurrentCookedState.cookedPointerData.pointerProperties, mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords, mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, mCurrentCookedState.cookedPointerData.idToIndex,
dispatchedIdBits, downId, mOrientedXPrecision, mOrientedYPrecision, mDownTime); dispatchedIdBits, downId,
mOrientedXPrecision, mOrientedYPrecision, mDownTime);
} }
} }
} }
@ -4406,7 +4374,7 @@ void TouchInputMapper::dispatchHoverExit(nsecs_t when, uint32_t policyFlags) {
|| !mCurrentCookedState.cookedPointerData.touchingIdBits.isEmpty())) { || !mCurrentCookedState.cookedPointerData.touchingIdBits.isEmpty())) {
int32_t metaState = getContext()->getGlobalMetaState(); int32_t metaState = getContext()->getGlobalMetaState();
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState, mLastCookedState.buttonState, 0, AMOTION_EVENT_ACTION_HOVER_EXIT, 0, metaState, mLastRawState.buttonState, 0,
mLastCookedState.cookedPointerData.pointerProperties, mLastCookedState.cookedPointerData.pointerProperties,
mLastCookedState.cookedPointerData.pointerCoords, mLastCookedState.cookedPointerData.pointerCoords,
mLastCookedState.cookedPointerData.idToIndex, mLastCookedState.cookedPointerData.idToIndex,
@ -4422,7 +4390,7 @@ void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFl
int32_t metaState = getContext()->getGlobalMetaState(); int32_t metaState = getContext()->getGlobalMetaState();
if (!mSentHoverEnter) { if (!mSentHoverEnter) {
dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_HOVER_ENTER, dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_HOVER_ENTER,
0, 0, metaState, mCurrentRawState.buttonState, 0, 0, metaState, mCurrentRawState.buttonState, 0,
mCurrentCookedState.cookedPointerData.pointerProperties, mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords, mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, mCurrentCookedState.cookedPointerData.idToIndex,
@ -4432,7 +4400,7 @@ void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFl
} }
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, metaState, AMOTION_EVENT_ACTION_HOVER_MOVE, 0, metaState,
mCurrentRawState.buttonState, 0, mCurrentRawState.buttonState, 0,
mCurrentCookedState.cookedPointerData.pointerProperties, mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords, mCurrentCookedState.cookedPointerData.pointerCoords,
@ -4442,48 +4410,6 @@ void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFl
} }
} }
void TouchInputMapper::dispatchButtonRelease(nsecs_t when, uint32_t policyFlags) {
BitSet32 releasedButtons(mLastCookedState.buttonState & ~mCurrentCookedState.buttonState);
const BitSet32& idBits = findActiveIdBits(mLastCookedState.cookedPointerData);
const int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mLastCookedState.buttonState;
while (!releasedButtons.isEmpty()) {
int32_t actionButton = BitSet32::valueForBit(releasedButtons.clearFirstMarkedBit());
buttonState &= ~actionButton;
dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_BUTTON_RELEASE, actionButton,
0, metaState, buttonState, 0,
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
mOrientedXPrecision, mOrientedYPrecision, mDownTime);
}
}
void TouchInputMapper::dispatchButtonPress(nsecs_t when, uint32_t policyFlags) {
BitSet32 pressedButtons(mCurrentCookedState.buttonState & ~mLastCookedState.buttonState);
const BitSet32& idBits = findActiveIdBits(mCurrentCookedState.cookedPointerData);
const int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mLastCookedState.buttonState;
while (!pressedButtons.isEmpty()) {
int32_t actionButton = BitSet32::valueForBit(pressedButtons.clearFirstMarkedBit());
buttonState |= actionButton;
dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_BUTTON_PRESS, actionButton,
0, metaState, buttonState, 0,
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
mOrientedXPrecision, mOrientedYPrecision, mDownTime);
}
}
const BitSet32& TouchInputMapper::findActiveIdBits(const CookedPointerData& cookedPointerData) {
if (!cookedPointerData.touchingIdBits.isEmpty()) {
return cookedPointerData.touchingIdBits;
}
return cookedPointerData.hoveringIdBits;
}
void TouchInputMapper::cookPointerData() { void TouchInputMapper::cookPointerData() {
uint32_t currentPointerCount = mCurrentRawState.rawPointerData.pointerCount; uint32_t currentPointerCount = mCurrentRawState.rawPointerData.pointerCount;
@ -4494,12 +4420,6 @@ void TouchInputMapper::cookPointerData() {
mCurrentCookedState.cookedPointerData.touchingIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits =
mCurrentRawState.rawPointerData.touchingIdBits; mCurrentRawState.rawPointerData.touchingIdBits;
if (mCurrentCookedState.cookedPointerData.pointerCount == 0) {
mCurrentCookedState.buttonState = 0;
} else {
mCurrentCookedState.buttonState = mCurrentRawState.buttonState;
}
// Walk through the the active pointers and map device coordinates onto // Walk through the the active pointers and map device coordinates onto
// surface coordinates and adjust for display orientation. // surface coordinates and adjust for display orientation.
for (uint32_t i = 0; i < currentPointerCount; i++) { for (uint32_t i = 0; i < currentPointerCount; i++) {
@ -4846,7 +4766,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
// Send events! // Send events!
int32_t metaState = getContext()->getGlobalMetaState(); int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mCurrentCookedState.buttonState; int32_t buttonState = mCurrentRawState.buttonState;
// Update last coordinates of pointers that have moved so that we observe the new // Update last coordinates of pointers that have moved so that we observe the new
// pointer positions at the same time as other pointers that have just gone up. // pointer positions at the same time as other pointers that have just gone up.
@ -4867,7 +4787,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
mPointerGesture.lastGestureProperties, mPointerGesture.lastGestureProperties,
mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
movedGestureIdBits); movedGestureIdBits);
if (buttonState != mLastCookedState.buttonState) { if (buttonState != mLastRawState.buttonState) {
moveNeeded = true; moveNeeded = true;
} }
} }
@ -4877,12 +4797,12 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
if (!dispatchedGestureIdBits.isEmpty()) { if (!dispatchedGestureIdBits.isEmpty()) {
if (cancelPreviousGesture) { if (cancelPreviousGesture) {
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_CANCEL, 0, 0, metaState, buttonState, AMOTION_EVENT_ACTION_CANCEL, 0, metaState, buttonState,
AMOTION_EVENT_EDGE_FLAG_NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties, mPointerGesture.lastGestureProperties,
mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
dispatchedGestureIdBits, -1, 0, dispatchedGestureIdBits, -1,
0, mPointerGesture.downTime); 0, 0, mPointerGesture.downTime);
dispatchedGestureIdBits.clear(); dispatchedGestureIdBits.clear();
} else { } else {
@ -4897,7 +4817,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
uint32_t id = upGestureIdBits.clearFirstMarkedBit(); uint32_t id = upGestureIdBits.clearFirstMarkedBit();
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_UP, 0, 0, AMOTION_EVENT_ACTION_POINTER_UP, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties, mPointerGesture.lastGestureProperties,
mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
@ -4912,8 +4832,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
// Send motion events for all pointers that moved. // Send motion events for all pointers that moved.
if (moveNeeded) { if (moveNeeded) {
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.currentGestureProperties, mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
dispatchedGestureIdBits, -1, dispatchedGestureIdBits, -1,
@ -4933,7 +4852,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
} }
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_DOWN, 0, 0, metaState, buttonState, 0, AMOTION_EVENT_ACTION_POINTER_DOWN, 0, metaState, buttonState, 0,
mPointerGesture.currentGestureProperties, mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
dispatchedGestureIdBits, id, dispatchedGestureIdBits, id,
@ -4944,7 +4863,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
// Send motion events for hover. // Send motion events for hover.
if (mPointerGesture.currentGestureMode == PointerGesture::HOVER) { if (mPointerGesture.currentGestureMode == PointerGesture::HOVER) {
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, AMOTION_EVENT_ACTION_HOVER_MOVE, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.currentGestureProperties, mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
@ -4970,7 +4889,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, AMOTION_EVENT_ACTION_HOVER_MOVE, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mViewport.displayId, 1, &pointerProperties, &pointerCoords, mViewport.displayId, 1, &pointerProperties, &pointerCoords,
0, 0, mPointerGesture.downTime); 0, 0, mPointerGesture.downTime);
@ -5001,7 +4920,7 @@ void TouchInputMapper::abortPointerGestures(nsecs_t when, uint32_t policyFlags)
int32_t metaState = getContext()->getGlobalMetaState(); int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mCurrentRawState.buttonState; int32_t buttonState = mCurrentRawState.buttonState;
dispatchMotion(when, policyFlags, mSource, dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_CANCEL, 0, 0, metaState, buttonState, AMOTION_EVENT_ACTION_CANCEL, 0, metaState, buttonState,
AMOTION_EVENT_EDGE_FLAG_NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties, mPointerGesture.lastGestureProperties,
mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex, mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
@ -5896,7 +5815,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
// Send up. // Send up.
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_UP, 0, 0, metaState, mLastRawState.buttonState, 0, AMOTION_EVENT_ACTION_UP, 0, metaState, mLastRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords, 1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
mOrientedXPrecision, mOrientedYPrecision, mOrientedXPrecision, mOrientedYPrecision,
@ -5909,7 +5828,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
// Send hover exit. // Send hover exit.
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState, mLastRawState.buttonState, 0, AMOTION_EVENT_ACTION_HOVER_EXIT, 0, metaState, mLastRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords, 1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
mOrientedXPrecision, mOrientedYPrecision, mOrientedXPrecision, mOrientedYPrecision,
@ -5924,7 +5843,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
// Send down. // Send down.
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_DOWN, 0, 0, metaState, mCurrentRawState.buttonState, 0, AMOTION_EVENT_ACTION_DOWN, 0, metaState, mCurrentRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords, 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
mOrientedXPrecision, mOrientedYPrecision, mOrientedXPrecision, mOrientedYPrecision,
@ -5934,7 +5853,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
// Send move. // Send move.
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, mCurrentRawState.buttonState, 0, AMOTION_EVENT_ACTION_MOVE, 0, metaState, mCurrentRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords, 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
mOrientedXPrecision, mOrientedYPrecision, mOrientedXPrecision, mOrientedYPrecision,
@ -5948,7 +5867,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
// Send hover enter. // Send hover enter.
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_HOVER_ENTER, 0, 0, metaState, AMOTION_EVENT_ACTION_HOVER_ENTER, 0, metaState,
mCurrentRawState.buttonState, 0, mCurrentRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords, 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
@ -5959,7 +5878,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
// Send hover move. // Send hover move.
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, metaState, AMOTION_EVENT_ACTION_HOVER_MOVE, 0, metaState,
mCurrentRawState.buttonState, 0, mCurrentRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords, 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
@ -5981,7 +5900,7 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll); pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll);
NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags, NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, mCurrentRawState.buttonState, 0, AMOTION_EVENT_ACTION_SCROLL, 0, metaState, mCurrentRawState.buttonState, 0,
mViewport.displayId, mViewport.displayId,
1, &mPointerSimple.currentProperties, &pointerCoords, 1, &mPointerSimple.currentProperties, &pointerCoords,
mOrientedXPrecision, mOrientedYPrecision, mOrientedXPrecision, mOrientedYPrecision,
@ -6006,11 +5925,10 @@ void TouchInputMapper::abortPointerSimple(nsecs_t when, uint32_t policyFlags) {
} }
void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source, void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source,
int32_t action, int32_t actionButton, int32_t flags, int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
int32_t metaState, int32_t buttonState, int32_t edgeFlags,
const PointerProperties* properties, const PointerCoords* coords, const PointerProperties* properties, const PointerCoords* coords,
const uint32_t* idToIndex, BitSet32 idBits, int32_t changedId, const uint32_t* idToIndex, BitSet32 idBits,
float xPrecision, float yPrecision, nsecs_t downTime) { int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime) {
PointerCoords pointerCoords[MAX_POINTERS]; PointerCoords pointerCoords[MAX_POINTERS];
PointerProperties pointerProperties[MAX_POINTERS]; PointerProperties pointerProperties[MAX_POINTERS];
uint32_t pointerCount = 0; uint32_t pointerCount = 0;
@ -6044,7 +5962,7 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32
} }
NotifyMotionArgs args(when, getDeviceId(), source, policyFlags, NotifyMotionArgs args(when, getDeviceId(), source, policyFlags,
action, actionButton, flags, metaState, buttonState, edgeFlags, action, flags, metaState, buttonState, edgeFlags,
mViewport.displayId, pointerCount, pointerProperties, pointerCoords, mViewport.displayId, pointerCount, pointerProperties, pointerCoords,
xPrecision, yPrecision, downTime); xPrecision, yPrecision, downTime);
getListener()->notifyMotion(&args); getListener()->notifyMotion(&args);
@ -6961,7 +6879,7 @@ void JoystickInputMapper::sync(nsecs_t when, bool force) {
uint32_t policyFlags = 0; uint32_t policyFlags = 0;
NotifyMotionArgs args(when, getDeviceId(), AINPUT_SOURCE_JOYSTICK, policyFlags, NotifyMotionArgs args(when, getDeviceId(), AINPUT_SOURCE_JOYSTICK, policyFlags,
AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
ADISPLAY_ID_NONE, 1, &pointerProperties, &pointerCoords, 0, 0, 0); ADISPLAY_ID_NONE, 1, &pointerProperties, &pointerCoords, 0, 0, 0);
getListener()->notifyMotion(&args); getListener()->notifyMotion(&args);
} }

View File

@ -1432,14 +1432,11 @@ protected:
BitSet32 stylusIdBits; BitSet32 stylusIdBits;
BitSet32 mouseIdBits; BitSet32 mouseIdBits;
int32_t buttonState;
void copyFrom(const CookedState& other) { void copyFrom(const CookedState& other) {
cookedPointerData.copyFrom(other.cookedPointerData); cookedPointerData.copyFrom(other.cookedPointerData);
fingerIdBits = other.fingerIdBits; fingerIdBits = other.fingerIdBits;
stylusIdBits = other.stylusIdBits; stylusIdBits = other.stylusIdBits;
mouseIdBits = other.mouseIdBits; mouseIdBits = other.mouseIdBits;
buttonState = other.buttonState;
} }
void clear() { void clear() {
@ -1447,7 +1444,6 @@ protected:
fingerIdBits.clear(); fingerIdBits.clear();
stylusIdBits.clear(); stylusIdBits.clear();
mouseIdBits.clear(); mouseIdBits.clear();
buttonState = 0;
} }
}; };
@ -1798,9 +1794,6 @@ private:
void dispatchTouches(nsecs_t when, uint32_t policyFlags); void dispatchTouches(nsecs_t when, uint32_t policyFlags);
void dispatchHoverExit(nsecs_t when, uint32_t policyFlags); void dispatchHoverExit(nsecs_t when, uint32_t policyFlags);
void dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags); void dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags);
void dispatchButtonRelease(nsecs_t when, uint32_t policyFlags);
void dispatchButtonPress(nsecs_t when, uint32_t policyFlags);
const BitSet32& findActiveIdBits(const CookedPointerData& cookedPointerData);
void cookPointerData(); void cookPointerData();
void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage); void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage);
@ -1831,8 +1824,8 @@ private:
// method will take care of setting the index and transmuting the action to DOWN or UP // method will take care of setting the index and transmuting the action to DOWN or UP
// it is the first / last pointer to go down / up. // it is the first / last pointer to go down / up.
void dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source, void dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source,
int32_t action, int32_t actionButton, int32_t action, int32_t flags, int32_t metaState, int32_t buttonState,
int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags, int32_t edgeFlags,
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);

View File

@ -150,7 +150,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
// Rejects undefined motion actions. // Rejects undefined motion actions.
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
/*action*/ -1, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, /*action*/ -1, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -161,7 +161,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
// Rejects pointer down with invalid index. // Rejects pointer down with invalid index.
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), AMOTION_EVENT_ACTION_POINTER_DOWN | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -171,7 +171,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_POINTER_DOWN | (-1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), AMOTION_EVENT_ACTION_POINTER_DOWN | (-1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -182,7 +182,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
// Rejects pointer up with invalid index. // Rejects pointer up with invalid index.
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_POINTER_UP | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), AMOTION_EVENT_ACTION_POINTER_UP | (1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -192,7 +192,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_POINTER_UP | (-1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT), AMOTION_EVENT_ACTION_POINTER_UP | (-1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -202,7 +202,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
// Rejects motion events with invalid number of pointers. // Rejects motion events with invalid number of pointers.
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, AMOTION_EVENT_ACTION_DOWN, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 0, pointerProperties, pointerCoords); /*pointerCount*/ 0, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -211,7 +211,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
<< "Should reject motion events with 0 pointers."; << "Should reject motion events with 0 pointers.";
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, AMOTION_EVENT_ACTION_DOWN, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ MAX_POINTERS + 1, pointerProperties, pointerCoords); /*pointerCount*/ MAX_POINTERS + 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -222,7 +222,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
// Rejects motion events with invalid pointer ids. // Rejects motion events with invalid pointer ids.
pointerProperties[0].id = -1; pointerProperties[0].id = -1;
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, AMOTION_EVENT_ACTION_DOWN, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -232,7 +232,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
pointerProperties[0].id = MAX_POINTER_ID + 1; pointerProperties[0].id = MAX_POINTER_ID + 1;
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, AMOTION_EVENT_ACTION_DOWN, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 1, pointerProperties, pointerCoords); /*pointerCount*/ 1, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(
@ -244,7 +244,7 @@ TEST_F(InputDispatcherTest, InjectInputEvent_ValidatesMotionEvents) {
pointerProperties[0].id = 1; pointerProperties[0].id = 1;
pointerProperties[1].id = 1; pointerProperties[1].id = 1;
event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, event.initialize(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
AMOTION_EVENT_ACTION_DOWN, 0, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0, AMOTION_EVENT_ACTION_DOWN, 0, 0, AMETA_NONE, 0, 0, 0, 0, 0,
ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME, ARBITRARY_TIME,
/*pointerCount*/ 2, pointerProperties, pointerCoords); /*pointerCount*/ 2, pointerProperties, pointerCoords);
ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent( ASSERT_EQ(INPUT_EVENT_INJECTION_FAILED, mDispatcher->injectInputEvent(