Add support for new input sources.
Added several new coordinate values to MotionEvents to capture
touch major/minor area, tool major/minor area and orientation.
Renamed NDK input constants per convention.
Added InputDevice class in Java which will eventually provide
useful information about available input devices.
Added APIs for manufacturing new MotionEvent objects with multiple
pointers and all necessary coordinate data.
Fixed a bug in the input dispatcher where it could get stuck with
a pointer down forever.
Fixed a bug in the WindowManager where the input window list could
end up containing stale removed windows.
Fixed a bug in the WindowManager where the input channel was being
removed only after the final animation transition had taken place
which caused spurious WINDOW DIED log messages to be printed.
Change-Id: Ie55084da319b20aad29b28a0499b8dd98bb5da68
diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp
index 768b04e..33dd373 100644
--- a/libs/ui/EventHub.cpp
+++ b/libs/ui/EventHub.cpp
@@ -168,12 +168,12 @@
device_t* device = mDevicesById[i].device;
if (device != NULL && (device->classes & deviceClasses) != 0) {
int32_t result = getScanCodeStateLocked(device, scanCode);
- if (result >= KEY_STATE_DOWN) {
+ if (result >= AKEY_STATE_DOWN) {
return result;
}
}
}
- return KEY_STATE_UP;
+ return AKEY_STATE_UP;
} else {
device_t* device = getDevice(deviceId);
if (device != NULL) {
@@ -181,7 +181,7 @@
}
}
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getScanCodeStateLocked(device_t* device, int32_t scanCode) const {
@@ -189,9 +189,9 @@
memset(key_bitmask, 0, sizeof(key_bitmask));
if (ioctl(mFDs[id_to_index(device->id)].fd,
EVIOCGKEY(sizeof(key_bitmask)), key_bitmask) >= 0) {
- return test_bit(scanCode, key_bitmask) ? KEY_STATE_DOWN : KEY_STATE_UP;
+ return test_bit(scanCode, key_bitmask) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getKeyCodeState(int32_t deviceId, int32_t deviceClasses,
@@ -202,19 +202,19 @@
device_t* device = mDevicesById[i].device;
if (device != NULL && (device->classes & deviceClasses) != 0) {
int32_t result = getKeyCodeStateLocked(device, keyCode);
- if (result >= KEY_STATE_DOWN) {
+ if (result >= AKEY_STATE_DOWN) {
return result;
}
}
}
- return KEY_STATE_UP;
+ return AKEY_STATE_UP;
} else {
device_t* device = getDevice(deviceId);
if (device != NULL) {
return getKeyCodeStateLocked(device, keyCode);
}
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getKeyCodeStateLocked(device_t* device, int32_t keyCode) const {
@@ -235,12 +235,12 @@
int32_t sc = scanCodes.itemAt(i);
//LOGI("Code %d: down=%d", sc, test_bit(sc, key_bitmask));
if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, key_bitmask)) {
- return KEY_STATE_DOWN;
+ return AKEY_STATE_DOWN;
}
}
- return KEY_STATE_UP;
+ return AKEY_STATE_UP;
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getSwitchState(int32_t deviceId, int32_t deviceClasses, int32_t sw) const {
@@ -251,19 +251,19 @@
if (deviceId == -1) {
deviceId = mSwitches[sw];
if (deviceId == 0) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
}
device_t* device = getDevice(deviceId);
if (device == NULL) {
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
return getSwitchStateLocked(device, sw);
}
#endif
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getSwitchStateLocked(device_t* device, int32_t sw) const {
@@ -271,9 +271,9 @@
memset(sw_bitmask, 0, sizeof(sw_bitmask));
if (ioctl(mFDs[id_to_index(device->id)].fd,
EVIOCGSW(sizeof(sw_bitmask)), sw_bitmask) >= 0) {
- return test_bit(sw, sw_bitmask) ? KEY_STATE_DOWN : KEY_STATE_UP;
+ return test_bit(sw, sw_bitmask) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
}
- return KEY_STATE_UNKNOWN;
+ return AKEY_STATE_UNKNOWN;
}
status_t EventHub::scancodeToKeycode(int32_t deviceId, int scancode,
diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp
index 1f19c2c..e5f014f 100644
--- a/libs/ui/Input.cpp
+++ b/libs/ui/Input.cpp
@@ -13,9 +13,9 @@
// class InputEvent
-void InputEvent::initialize(int32_t deviceId, int32_t nature) {
+void InputEvent::initialize(int32_t deviceId, int32_t source) {
mDeviceId = deviceId;
- mNature = nature;
+ mSource = source;
}
// class KeyEvent
@@ -86,7 +86,7 @@
void KeyEvent::initialize(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@@ -95,7 +95,7 @@
int32_t repeatCount,
nsecs_t downTime,
nsecs_t eventTime) {
- InputEvent::initialize(deviceId, nature);
+ InputEvent::initialize(deviceId, source);
mAction = action;
mFlags = flags;
mKeyCode = keyCode;
@@ -110,7 +110,7 @@
void MotionEvent::initialize(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
@@ -123,7 +123,7 @@
size_t pointerCount,
const int32_t* pointerIds,
const PointerCoords* pointerCoords) {
- InputEvent::initialize(deviceId, nature);
+ InputEvent::initialize(deviceId, source);
mAction = action;
mEdgeFlags = edgeFlags;
mMetaState = metaState;
diff --git a/libs/ui/InputDevice.cpp b/libs/ui/InputDevice.cpp
index 6014017..b2a4d6c 100644
--- a/libs/ui/InputDevice.cpp
+++ b/libs/ui/InputDevice.cpp
@@ -108,7 +108,7 @@
// --- InputDevice::KeyboardState ---
void InputDevice::KeyboardState::reset() {
- current.metaState = META_NONE;
+ current.metaState = AMETA_NONE;
current.downTime = 0;
}
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index c4ffce1..a438c69 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -245,14 +245,14 @@
void InputDispatcher::processKeyLockedInterruptible(
nsecs_t currentTime, KeyEntry* entry, nsecs_t keyRepeatTimeout) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
- LOGD("processKey - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, action=0x%x, "
+ LOGD("processKey - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, "
"flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, downTime=%lld",
- entry->eventTime, entry->deviceId, entry->nature, entry->policyFlags, entry->action,
+ entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, entry->action,
entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
entry->downTime);
#endif
- if (entry->action == KEY_EVENT_ACTION_DOWN && ! entry->isInjected()) {
+ if (entry->action == AKEY_EVENT_ACTION_DOWN && ! entry->isInjected()) {
if (mKeyRepeatState.lastKeyEntry
&& mKeyRepeatState.lastKeyEntry->keyCode == entry->keyCode) {
// We have seen two identical key downs in a row which indicates that the device
@@ -287,7 +287,7 @@
if (queuedEntry->type == EventEntry::TYPE_KEY) {
KeyEntry* queuedKeyEntry = static_cast<KeyEntry*>(queuedEntry);
if (queuedKeyEntry->deviceId == entry->deviceId
- && entry->action == KEY_EVENT_ACTION_UP) {
+ && entry->action == AKEY_EVENT_ACTION_UP) {
resetKeyRepeatLocked();
return;
}
@@ -303,7 +303,7 @@
entry->repeatCount += 1;
} else {
KeyEntry* newEntry = mAllocator.obtainKeyEntry(currentTime,
- entry->deviceId, entry->nature, policyFlags,
+ entry->deviceId, entry->source, policyFlags,
entry->action, entry->flags, entry->keyCode, entry->scanCode,
entry->metaState, entry->repeatCount + 1, entry->downTime);
@@ -314,16 +314,16 @@
}
if (entry->repeatCount == 1) {
- entry->flags |= KEY_EVENT_FLAG_LONG_PRESS;
+ entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS;
}
mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatTimeout;
#if DEBUG_OUTBOUND_EVENT_DETAILS
- LOGD("processKeyRepeat - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, "
+ LOGD("processKeyRepeat - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, "
"action=0x%x, flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, "
"repeatCount=%d, downTime=%lld",
- entry->eventTime, entry->deviceId, entry->nature, entry->policyFlags,
+ entry->eventTime, entry->deviceId, entry->source, entry->policyFlags,
entry->action, entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
entry->repeatCount, entry->downTime);
#endif
@@ -334,9 +334,9 @@
void InputDispatcher::processMotionLockedInterruptible(
nsecs_t currentTime, MotionEntry* entry) {
#if DEBUG_OUTBOUND_EVENT_DETAILS
- LOGD("processMotion - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, action=0x%x, "
+ LOGD("processMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, "
"metaState=0x%x, edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld",
- entry->eventTime, entry->deviceId, entry->nature, entry->policyFlags, entry->action,
+ entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, entry->action,
entry->metaState, entry->edgeFlags, entry->xPrecision, entry->yPrecision,
entry->downTime);
@@ -357,7 +357,7 @@
// Keep in mind that due to batching, it is possible for the number of samples actually
// dispatched to change before the application finally consumed them.
- if (entry->action == MOTION_EVENT_ACTION_MOVE) {
+ if (entry->action == AMOTION_EVENT_ACTION_MOVE) {
LOGD(" ... Total movement samples currently batched %d ...", sampleCount);
}
#endif
@@ -375,7 +375,7 @@
mCurrentInputTargetsValid = false;
mLock.unlock();
- mReusableKeyEvent.initialize(entry->deviceId, entry->nature, entry->action, entry->flags,
+ mReusableKeyEvent.initialize(entry->deviceId, entry->source, entry->action, entry->flags,
entry->keyCode, entry->scanCode, entry->metaState, entry->repeatCount,
entry->downTime, entry->eventTime);
@@ -404,7 +404,7 @@
mCurrentInputTargetsValid = false;
mLock.unlock();
- mReusableMotionEvent.initialize(entry->deviceId, entry->nature, entry->action,
+ mReusableMotionEvent.initialize(entry->deviceId, entry->source, entry->action,
entry->edgeFlags, entry->metaState,
0, 0, entry->xPrecision, entry->yPrecision,
entry->downTime, entry->eventTime, entry->pointerCount, entry->pointerIds,
@@ -611,11 +611,11 @@
int32_t action = keyEntry->action;
int32_t flags = keyEntry->flags;
if (dispatchEntry->targetFlags & InputTarget::FLAG_CANCEL) {
- flags |= KEY_EVENT_FLAG_CANCELED;
+ flags |= AKEY_EVENT_FLAG_CANCELED;
}
// Publish the key event.
- status = connection->inputPublisher.publishKeyEvent(keyEntry->deviceId, keyEntry->nature,
+ status = connection->inputPublisher.publishKeyEvent(keyEntry->deviceId, keyEntry->source,
action, flags, keyEntry->keyCode, keyEntry->scanCode,
keyEntry->metaState, keyEntry->repeatCount, keyEntry->downTime,
keyEntry->eventTime);
@@ -635,10 +635,10 @@
// Apply target flags.
int32_t action = motionEntry->action;
if (dispatchEntry->targetFlags & InputTarget::FLAG_OUTSIDE) {
- action = MOTION_EVENT_ACTION_OUTSIDE;
+ action = AMOTION_EVENT_ACTION_OUTSIDE;
}
if (dispatchEntry->targetFlags & InputTarget::FLAG_CANCEL) {
- action = MOTION_EVENT_ACTION_CANCEL;
+ action = AMOTION_EVENT_ACTION_CANCEL;
}
// If headMotionSample is non-NULL, then it points to the first new sample that we
@@ -652,7 +652,7 @@
// Publish the motion event and the first motion sample.
status = connection->inputPublisher.publishMotionEvent(motionEntry->deviceId,
- motionEntry->nature, action, motionEntry->edgeFlags, motionEntry->metaState,
+ motionEntry->source, action, motionEntry->edgeFlags, motionEntry->metaState,
dispatchEntry->xOffset, dispatchEntry->yOffset,
motionEntry->xPrecision, motionEntry->yPrecision,
motionEntry->downTime, firstMotionSample->eventTime,
@@ -964,13 +964,13 @@
} // release lock
}
-void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t flags,
int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime) {
#if DEBUG_INBOUND_EVENT_DETAILS
- LOGD("notifyKey - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, action=0x%x, "
+ LOGD("notifyKey - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, "
"flags=0x%x, keyCode=0x%x, scanCode=0x%x, metaState=0x%x, downTime=%lld",
- eventTime, deviceId, nature, policyFlags, action, flags,
+ eventTime, deviceId, source, policyFlags, action, flags,
keyCode, scanCode, metaState, downTime);
#endif
@@ -980,7 +980,7 @@
int32_t repeatCount = 0;
KeyEntry* newEntry = mAllocator.obtainKeyEntry(eventTime,
- deviceId, nature, policyFlags, action, flags, keyCode, scanCode,
+ deviceId, source, policyFlags, action, flags, keyCode, scanCode,
metaState, repeatCount, downTime);
wasEmpty = mInboundQueue.isEmpty();
@@ -992,15 +992,15 @@
}
}
-void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t nature,
+void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source,
uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags,
uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords,
float xPrecision, float yPrecision, nsecs_t downTime) {
#if DEBUG_INBOUND_EVENT_DETAILS
- LOGD("notifyMotion - eventTime=%lld, deviceId=0x%x, nature=0x%x, policyFlags=0x%x, "
+ LOGD("notifyMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, "
"action=0x%x, metaState=0x%x, edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, "
"downTime=%lld",
- eventTime, deviceId, nature, policyFlags, action, metaState, edgeFlags,
+ eventTime, deviceId, source, policyFlags, action, metaState, edgeFlags,
xPrecision, yPrecision, downTime);
for (uint32_t i = 0; i < pointerCount; i++) {
LOGD(" Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f",
@@ -1014,7 +1014,7 @@
AutoMutex _l(mLock);
// Attempt batching and streaming of move events.
- if (action == MOTION_EVENT_ACTION_MOVE) {
+ if (action == AMOTION_EVENT_ACTION_MOVE) {
// BATCHING CASE
//
// Try to append a move sample to the tail of the inbound queue for this device.
@@ -1033,7 +1033,7 @@
continue;
}
- if (motionEntry->action != MOTION_EVENT_ACTION_MOVE
+ if (motionEntry->action != AMOTION_EVENT_ACTION_MOVE
|| motionEntry->pointerCount != pointerCount
|| motionEntry->isInjected()) {
// Last motion event in the queue for this device is not compatible for
@@ -1094,7 +1094,7 @@
MotionEntry* syncedMotionEntry = static_cast<MotionEntry*>(
dispatchEntry->eventEntry);
- if (syncedMotionEntry->action != MOTION_EVENT_ACTION_MOVE
+ if (syncedMotionEntry->action != AMOTION_EVENT_ACTION_MOVE
|| syncedMotionEntry->deviceId != deviceId
|| syncedMotionEntry->pointerCount != pointerCount
|| syncedMotionEntry->isInjected()) {
@@ -1124,7 +1124,7 @@
// Just enqueue a new motion event.
MotionEntry* newEntry = mAllocator.obtainMotionEntry(eventTime,
- deviceId, nature, policyFlags, action, metaState, edgeFlags,
+ deviceId, source, policyFlags, action, metaState, edgeFlags,
xPrecision, yPrecision, downTime,
pointerCount, pointerIds, pointerCoords);
@@ -1224,19 +1224,19 @@
InputDispatcher::EventEntry* InputDispatcher::createEntryFromInputEventLocked(
const InputEvent* event) {
switch (event->getType()) {
- case INPUT_EVENT_TYPE_KEY: {
+ case AINPUT_EVENT_TYPE_KEY: {
const KeyEvent* keyEvent = static_cast<const KeyEvent*>(event);
uint32_t policyFlags = 0; // XXX consider adding a policy flag to track injected events
KeyEntry* keyEntry = mAllocator.obtainKeyEntry(keyEvent->getEventTime(),
- keyEvent->getDeviceId(), keyEvent->getNature(), policyFlags,
+ keyEvent->getDeviceId(), keyEvent->getSource(), policyFlags,
keyEvent->getAction(), keyEvent->getFlags(),
keyEvent->getKeyCode(), keyEvent->getScanCode(), keyEvent->getMetaState(),
keyEvent->getRepeatCount(), keyEvent->getDownTime());
return keyEntry;
}
- case INPUT_EVENT_TYPE_MOTION: {
+ case AINPUT_EVENT_TYPE_MOTION: {
const MotionEvent* motionEvent = static_cast<const MotionEvent*>(event);
uint32_t policyFlags = 0; // XXX consider adding a policy flag to track injected events
@@ -1245,7 +1245,7 @@
size_t pointerCount = motionEvent->getPointerCount();
MotionEntry* motionEntry = mAllocator.obtainMotionEntry(*sampleEventTimes,
- motionEvent->getDeviceId(), motionEvent->getNature(), policyFlags,
+ motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags,
motionEvent->getAction(), motionEvent->getMetaState(), motionEvent->getEdgeFlags(),
motionEvent->getXPrecision(), motionEvent->getYPrecision(),
motionEvent->getDownTime(), uint32_t(pointerCount),
@@ -1500,14 +1500,14 @@
}
InputDispatcher::KeyEntry* InputDispatcher::Allocator::obtainKeyEntry(nsecs_t eventTime,
- int32_t deviceId, int32_t nature, uint32_t policyFlags, int32_t action,
+ int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
int32_t repeatCount, nsecs_t downTime) {
KeyEntry* entry = mKeyEntryPool.alloc();
initializeEventEntry(entry, EventEntry::TYPE_KEY, eventTime);
entry->deviceId = deviceId;
- entry->nature = nature;
+ entry->source = source;
entry->policyFlags = policyFlags;
entry->action = action;
entry->flags = flags;
@@ -1520,7 +1520,7 @@
}
InputDispatcher::MotionEntry* InputDispatcher::Allocator::obtainMotionEntry(nsecs_t eventTime,
- int32_t deviceId, int32_t nature, uint32_t policyFlags, int32_t action,
+ int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
int32_t metaState, int32_t edgeFlags, float xPrecision, float yPrecision,
nsecs_t downTime, uint32_t pointerCount,
const int32_t* pointerIds, const PointerCoords* pointerCoords) {
@@ -1529,7 +1529,7 @@
entry->eventTime = eventTime;
entry->deviceId = deviceId;
- entry->nature = nature;
+ entry->source = source;
entry->policyFlags = policyFlags;
entry->action = action;
entry->metaState = metaState;
diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp
index 0a21db7..cd4654a 100644
--- a/libs/ui/InputReader.cpp
+++ b/libs/ui/InputReader.cpp
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <errno.h>
#include <limits.h>
+#include <math.h>
/** Amount that trackball needs to move in order to generate a key event. */
#define TRACKBALL_MOVEMENT_THRESHOLD 6
@@ -60,33 +61,33 @@
int32_t mask;
switch (keyCode) {
case AKEYCODE_ALT_LEFT:
- mask = META_ALT_LEFT_ON;
+ mask = AMETA_ALT_LEFT_ON;
break;
case AKEYCODE_ALT_RIGHT:
- mask = META_ALT_RIGHT_ON;
+ mask = AMETA_ALT_RIGHT_ON;
break;
case AKEYCODE_SHIFT_LEFT:
- mask = META_SHIFT_LEFT_ON;
+ mask = AMETA_SHIFT_LEFT_ON;
break;
case AKEYCODE_SHIFT_RIGHT:
- mask = META_SHIFT_RIGHT_ON;
+ mask = AMETA_SHIFT_RIGHT_ON;
break;
case AKEYCODE_SYM:
- mask = META_SYM_ON;
+ mask = AMETA_SYM_ON;
break;
default:
return oldMetaState;
}
int32_t newMetaState = down ? oldMetaState | mask : oldMetaState & ~ mask
- & ~ (META_ALT_ON | META_SHIFT_ON);
+ & ~ (AMETA_ALT_ON | AMETA_SHIFT_ON);
- if (newMetaState & (META_ALT_LEFT_ON | META_ALT_RIGHT_ON)) {
- newMetaState |= META_ALT_ON;
+ if (newMetaState & (AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON)) {
+ newMetaState |= AMETA_ALT_ON;
}
- if (newMetaState & (META_SHIFT_LEFT_ON | META_SHIFT_RIGHT_ON)) {
- newMetaState |= META_SHIFT_ON;
+ if (newMetaState & (AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON)) {
+ newMetaState |= AMETA_SHIFT_ON;
}
return newMetaState;
@@ -324,11 +325,26 @@
InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TOUCH_MAJOR;
pointer->absMTTouchMajor = rawEvent->value;
break;
+ case ABS_MT_TOUCH_MINOR:
+ pointer->fields |=
+ InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TOUCH_MINOR;
+ pointer->absMTTouchMinor = rawEvent->value;
+ break;
case ABS_MT_WIDTH_MAJOR:
pointer->fields |=
InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_WIDTH_MAJOR;
pointer->absMTWidthMajor = rawEvent->value;
break;
+ case ABS_MT_WIDTH_MINOR:
+ pointer->fields |=
+ InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_WIDTH_MINOR;
+ pointer->absMTWidthMinor = rawEvent->value;
+ break;
+ case ABS_MT_ORIENTATION:
+ pointer->fields |=
+ InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_ORIENTATION;
+ pointer->absMTOrientation = rawEvent->value;
+ break;
case ABS_MT_TRACKING_ID:
pointer->fields |=
InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TRACKING_ID;
@@ -408,17 +424,17 @@
int32_t keyEventAction;
if (down) {
device->keyboard.current.downTime = when;
- keyEventAction = KEY_EVENT_ACTION_DOWN;
+ keyEventAction = AKEY_EVENT_ACTION_DOWN;
} else {
- keyEventAction = KEY_EVENT_ACTION_UP;
+ keyEventAction = AKEY_EVENT_ACTION_UP;
}
- int32_t keyEventFlags = KEY_EVENT_FLAG_FROM_SYSTEM;
+ int32_t keyEventFlags = AKEY_EVENT_FLAG_FROM_SYSTEM;
if (policyActions & InputReaderPolicyInterface::ACTION_WOKE_HERE) {
- keyEventFlags = keyEventFlags | KEY_EVENT_FLAG_WOKE_HERE;
+ keyEventFlags = keyEventFlags | AKEY_EVENT_FLAG_WOKE_HERE;
}
- mDispatcher->notifyKey(when, device->id, INPUT_EVENT_NATURE_KEY, policyFlags,
+ mDispatcher->notifyKey(when, device->id, AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode,
device->keyboard.current.metaState,
device->keyboard.current.downTime);
@@ -473,11 +489,29 @@
continue;
}
+ out->pointers[outCount].x = in->accumulator.pointers[inIndex].absMTPositionX;
+ out->pointers[outCount].y = in->accumulator.pointers[inIndex].absMTPositionY;
+
+ out->pointers[outCount].touchMajor = in->accumulator.pointers[inIndex].absMTTouchMajor;
+ out->pointers[outCount].touchMinor = (fields
+ & InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_TOUCH_MINOR) != 0
+ ? in->accumulator.pointers[inIndex].absMTTouchMinor
+ : in->accumulator.pointers[inIndex].absMTTouchMajor;
+
+ out->pointers[outCount].toolMajor = in->accumulator.pointers[inIndex].absMTWidthMajor;
+ out->pointers[outCount].toolMinor = (fields
+ & InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_WIDTH_MINOR) != 0
+ ? in->accumulator.pointers[inIndex].absMTWidthMinor
+ : in->accumulator.pointers[inIndex].absMTWidthMajor;
+
+ out->pointers[outCount].orientation = (fields
+ & InputDevice::MultiTouchScreenState::Accumulator::FIELD_ABS_MT_ORIENTATION) != 0
+ ? in->accumulator.pointers[inIndex].absMTOrientation : 0;
+
+ // Derive an approximation of pressure and size.
// FIXME assignment of pressure may be incorrect, probably better to let
// pressure = touch / width. Later on we pass width to MotionEvent as a size, which
// isn't quite right either. Should be using touch for that.
- out->pointers[outCount].x = in->accumulator.pointers[inIndex].absMTPositionX;
- out->pointers[outCount].y = in->accumulator.pointers[inIndex].absMTPositionY;
out->pointers[outCount].pressure = in->accumulator.pointers[inIndex].absMTTouchMajor;
out->pointers[outCount].size = in->accumulator.pointers[inIndex].absMTWidthMajor;
@@ -556,6 +590,11 @@
out->pointers[0].y = in->current.y;
out->pointers[0].pressure = in->current.pressure;
out->pointers[0].size = in->current.size;
+ out->pointers[0].touchMajor = in->current.pressure;
+ out->pointers[0].touchMinor = in->current.pressure;
+ out->pointers[0].toolMajor = in->current.size;
+ out->pointers[0].toolMinor = in->current.size;
+ out->pointers[0].orientation = 0;
out->idToIndex[0] = 0;
out->idBits.markBit(0);
}
@@ -635,8 +674,8 @@
device->touchScreen.currentVirtualKey.keyCode,
device->touchScreen.currentVirtualKey.scanCode);
#endif
- dispatchVirtualKey(when, device, policyFlags, KEY_EVENT_ACTION_UP,
- KEY_EVENT_FLAG_FROM_SYSTEM | KEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
+ dispatchVirtualKey(when, device, policyFlags, AKEY_EVENT_ACTION_UP,
+ AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
return true; // consumed
}
@@ -658,9 +697,9 @@
device->touchScreen.currentVirtualKey.keyCode,
device->touchScreen.currentVirtualKey.scanCode);
#endif
- dispatchVirtualKey(when, device, policyFlags, KEY_EVENT_ACTION_UP,
- KEY_EVENT_FLAG_FROM_SYSTEM | KEY_EVENT_FLAG_VIRTUAL_HARD_KEY
- | KEY_EVENT_FLAG_CANCELED);
+ dispatchVirtualKey(when, device, policyFlags, AKEY_EVENT_ACTION_UP,
+ AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY
+ | AKEY_EVENT_FLAG_CANCELED);
return true; // consumed
default:
@@ -679,8 +718,8 @@
device->touchScreen.currentVirtualKey.keyCode,
device->touchScreen.currentVirtualKey.scanCode);
#endif
- dispatchVirtualKey(when, device, policyFlags, KEY_EVENT_ACTION_DOWN,
- KEY_EVENT_FLAG_FROM_SYSTEM | KEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
+ dispatchVirtualKey(when, device, policyFlags, AKEY_EVENT_ACTION_DOWN,
+ AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY);
return true; // consumed
}
}
@@ -698,15 +737,15 @@
nsecs_t downTime = device->touchScreen.currentVirtualKey.downTime;
int32_t metaState = globalMetaState();
- if (keyEventAction == KEY_EVENT_ACTION_DOWN) {
+ if (keyEventAction == AKEY_EVENT_ACTION_DOWN) {
mPolicy->virtualKeyDownFeedback();
}
int32_t policyActions = mPolicy->interceptKey(when, device->id,
- keyEventAction == KEY_EVENT_ACTION_DOWN, keyCode, scanCode, policyFlags);
+ keyEventAction == AKEY_EVENT_ACTION_DOWN, keyCode, scanCode, policyFlags);
if (applyStandardInputDispatchPolicyActions(when, policyActions, & policyFlags)) {
- mDispatcher->notifyKey(when, device->id, INPUT_EVENT_NATURE_KEY, policyFlags,
+ mDispatcher->notifyKey(when, device->id, AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
}
}
@@ -725,7 +764,7 @@
if (currentIdBits == lastIdBits) {
// No pointer id changes so this is a move event.
// The dispatcher takes care of batching moves so we don't have to deal with that here.
- int32_t motionEventAction = MOTION_EVENT_ACTION_MOVE;
+ int32_t motionEventAction = AMOTION_EVENT_ACTION_MOVE;
dispatchTouch(when, device, policyFlags, & device->touchScreen.currentTouch,
currentIdBits, motionEventAction);
} else {
@@ -743,10 +782,10 @@
int32_t motionEventAction;
if (activeIdBits.isEmpty()) {
- motionEventAction = MOTION_EVENT_ACTION_UP;
+ motionEventAction = AMOTION_EVENT_ACTION_UP;
} else {
- motionEventAction = MOTION_EVENT_ACTION_POINTER_UP
- | (upId << MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
+ motionEventAction = AMOTION_EVENT_ACTION_POINTER_UP
+ | (upId << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
}
dispatchTouch(when, device, policyFlags, & device->touchScreen.lastTouch,
@@ -761,11 +800,11 @@
int32_t motionEventAction;
if (oldActiveIdBits.isEmpty()) {
- motionEventAction = MOTION_EVENT_ACTION_DOWN;
+ motionEventAction = AMOTION_EVENT_ACTION_DOWN;
device->touchScreen.downTime = when;
} else {
- motionEventAction = MOTION_EVENT_ACTION_POINTER_DOWN
- | (downId << MOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
+ motionEventAction = AMOTION_EVENT_ACTION_POINTER_DOWN
+ | (downId << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
}
dispatchTouch(when, device, policyFlags, & device->touchScreen.currentTouch,
@@ -813,11 +852,17 @@
float size = float(touch->pointers[index].size
- precalculated.sizeOrigin) * precalculated.sizeScale;
+ float orientation = float(touch->pointers[index].orientation)
+ * precalculated.orientationScale;
+
+ bool vertical = abs(orientation) <= M_PI / 8;
+
switch (mDisplayOrientation) {
case InputReaderPolicyInterface::ROTATION_90: {
float xTemp = x;
x = y;
y = mDisplayWidth - xTemp;
+ vertical = ! vertical;
break;
}
case InputReaderPolicyInterface::ROTATION_180: {
@@ -829,16 +874,35 @@
float xTemp = x;
x = mDisplayHeight - y;
y = xTemp;
+ vertical = ! vertical;
break;
}
}
+ float touchMajor, touchMinor, toolMajor, toolMinor;
+ if (vertical) {
+ touchMajor = float(touch->pointers[index].touchMajor) * precalculated.yScale;
+ touchMinor = float(touch->pointers[index].touchMinor) * precalculated.xScale;
+ toolMajor = float(touch->pointers[index].toolMajor) * precalculated.yScale;
+ toolMinor = float(touch->pointers[index].toolMinor) * precalculated.xScale;
+ } else {
+ touchMajor = float(touch->pointers[index].touchMajor) * precalculated.xScale;
+ touchMinor = float(touch->pointers[index].touchMinor) * precalculated.yScale;
+ toolMajor = float(touch->pointers[index].toolMajor) * precalculated.xScale;
+ toolMinor = float(touch->pointers[index].toolMinor) * precalculated.yScale;
+ }
+
pointerIds[pointerCount] = int32_t(id);
pointerCoords[pointerCount].x = x;
pointerCoords[pointerCount].y = y;
pointerCoords[pointerCount].pressure = pressure;
pointerCoords[pointerCount].size = size;
+ pointerCoords[pointerCount].touchMajor = touchMajor;
+ pointerCoords[pointerCount].touchMinor = touchMinor;
+ pointerCoords[pointerCount].toolMajor = toolMajor;
+ pointerCoords[pointerCount].toolMinor = toolMinor;
+ pointerCoords[pointerCount].orientation = orientation;
pointerCount += 1;
}
@@ -847,21 +911,21 @@
// global to the event.
// XXX Maybe we should revise the edge flags API to work on a per-pointer basis.
int32_t motionEventEdgeFlags = 0;
- if (motionEventAction == MOTION_EVENT_ACTION_DOWN) {
+ if (motionEventAction == AMOTION_EVENT_ACTION_DOWN) {
if (pointerCoords[0].x <= 0) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_LEFT;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_LEFT;
} else if (pointerCoords[0].x >= orientedWidth) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_RIGHT;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_RIGHT;
}
if (pointerCoords[0].y <= 0) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_TOP;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_TOP;
} else if (pointerCoords[0].y >= orientedHeight) {
- motionEventEdgeFlags |= MOTION_EVENT_EDGE_FLAG_BOTTOM;
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_BOTTOM;
}
}
nsecs_t downTime = device->touchScreen.downTime;
- mDispatcher->notifyMotion(when, device->id, INPUT_EVENT_NATURE_TOUCH, policyFlags,
+ mDispatcher->notifyMotion(when, device->id, AINPUT_SOURCE_TOUCHSCREEN, policyFlags,
motionEventAction, globalMetaState(), motionEventEdgeFlags,
pointerCount, pointerIds, pointerCoords,
0, 0, downTime);
@@ -912,9 +976,9 @@
int32_t motionEventAction;
if (downChanged) {
- motionEventAction = down ? MOTION_EVENT_ACTION_DOWN : MOTION_EVENT_ACTION_UP;
+ motionEventAction = down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
} else {
- motionEventAction = MOTION_EVENT_ACTION_MOVE;
+ motionEventAction = AMOTION_EVENT_ACTION_MOVE;
}
int32_t pointerId = 0;
@@ -925,6 +989,11 @@
? device->trackball.accumulator.relY * device->trackball.precalculated.yScale : 0;
pointerCoords.pressure = 1.0f; // XXX Consider making this 1.0f if down, 0 otherwise.
pointerCoords.size = 0;
+ pointerCoords.touchMajor = 0;
+ pointerCoords.touchMinor = 0;
+ pointerCoords.toolMajor = 0;
+ pointerCoords.toolMinor = 0;
+ pointerCoords.orientation = 0;
float temp;
switch (mDisplayOrientation) {
@@ -946,8 +1015,8 @@
break;
}
- mDispatcher->notifyMotion(when, device->id, INPUT_EVENT_NATURE_TRACKBALL, policyFlags,
- motionEventAction, globalMetaState(), MOTION_EVENT_EDGE_FLAG_NONE,
+ mDispatcher->notifyMotion(when, device->id, AINPUT_SOURCE_TRACKBALL, policyFlags,
+ motionEventAction, globalMetaState(), AMOTION_EVENT_EDGE_FLAG_NONE,
1, & pointerId, & pointerCoords,
device->trackball.precalculated.xPrecision,
device->trackball.precalculated.yPrecision,
@@ -1079,6 +1148,8 @@
& device->touchScreen.parameters.pressureAxis);
configureAbsoluteAxisInfo(device, ABS_MT_WIDTH_MAJOR, "Size",
& device->touchScreen.parameters.sizeAxis);
+ configureAbsoluteAxisInfo(device, ABS_MT_ORIENTATION, "Orientation",
+ & device->touchScreen.parameters.orientationAxis);
} else if (device->isSingleTouchScreen()) {
configureAbsoluteAxisInfo(device, ABS_X, "X",
& device->touchScreen.parameters.xAxis);
@@ -1088,6 +1159,7 @@
& device->touchScreen.parameters.pressureAxis);
configureAbsoluteAxisInfo(device, ABS_TOOL_WIDTH, "Size",
& device->touchScreen.parameters.sizeAxis);
+ device->touchScreen.parameters.orientationAxis.valid = false;
}
if (device->isTouchScreen()) {
@@ -1117,6 +1189,14 @@
device->touchScreen.precalculated.sizeOrigin = 0;
device->touchScreen.precalculated.sizeScale = 1.0f;
}
+
+ if (device->touchScreen.parameters.orientationAxis.valid
+ && device->touchScreen.parameters.orientationAxis.maxValue > 0) {
+ device->touchScreen.precalculated.orientationScale =
+ M_PI_4 / device->touchScreen.parameters.orientationAxis.maxValue;
+ } else {
+ device->touchScreen.precalculated.orientationScale = 0.0f;
+ }
}
if (device->isTrackball()) {
@@ -1347,7 +1427,7 @@
AutoMutex _l(mExportedStateLock);
if (mExportedVirtualScanCode == scanCode) {
- return KEY_STATE_VIRTUAL;
+ return AKEY_STATE_VIRTUAL;
}
} // release exported state lock
@@ -1360,7 +1440,7 @@
AutoMutex _l(mExportedStateLock);
if (mExportedVirtualKeyCode == keyCode) {
- return KEY_STATE_VIRTUAL;
+ return AKEY_STATE_VIRTUAL;
}
} // release exported state lock
diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp
index fc83e31..cf0f63e 100644
--- a/libs/ui/InputTransport.cpp
+++ b/libs/ui/InputTransport.cpp
@@ -270,7 +270,7 @@
status_t InputPublisher::publishInputEvent(
int32_t type,
int32_t deviceId,
- int32_t nature) {
+ int32_t source) {
if (mPinned) {
LOGE("channel '%s' publisher ~ Attempted to publish a new event but publisher has "
"not yet been reset.", mChannel->getName().string());
@@ -302,13 +302,13 @@
mSharedMessage->consumed = false;
mSharedMessage->type = type;
mSharedMessage->deviceId = deviceId;
- mSharedMessage->nature = nature;
+ mSharedMessage->source = source;
return OK;
}
status_t InputPublisher::publishKeyEvent(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@@ -318,15 +318,15 @@
nsecs_t downTime,
nsecs_t eventTime) {
#if DEBUG_TRANSPORT_ACTIONS
- LOGD("channel '%s' publisher ~ publishKeyEvent: deviceId=%d, nature=%d, "
+ LOGD("channel '%s' publisher ~ publishKeyEvent: deviceId=%d, source=%d, "
"action=%d, flags=%d, keyCode=%d, scanCode=%d, metaState=%d, repeatCount=%d,"
"downTime=%lld, eventTime=%lld",
mChannel->getName().string(),
- deviceId, nature, action, flags, keyCode, scanCode, metaState, repeatCount,
+ deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount,
downTime, eventTime);
#endif
- status_t result = publishInputEvent(INPUT_EVENT_TYPE_KEY, deviceId, nature);
+ status_t result = publishInputEvent(AINPUT_EVENT_TYPE_KEY, deviceId, source);
if (result < 0) {
return result;
}
@@ -344,7 +344,7 @@
status_t InputPublisher::publishMotionEvent(
int32_t deviceId,
- int32_t nature,
+ int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
@@ -358,12 +358,12 @@
const int32_t* pointerIds,
const PointerCoords* pointerCoords) {
#if DEBUG_TRANSPORT_ACTIONS
- LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, nature=%d, "
+ LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, source=%d, "
"action=%d, edgeFlags=%d, metaState=%d, xOffset=%f, yOffset=%f, "
"xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, "
"pointerCount=%d",
mChannel->getName().string(),
- deviceId, nature, action, edgeFlags, metaState, xOffset, yOffset,
+ deviceId, source, action, edgeFlags, metaState, xOffset, yOffset,
xPrecision, yPrecision, downTime, eventTime, pointerCount);
#endif
@@ -373,7 +373,7 @@
return BAD_VALUE;
}
- status_t result = publishInputEvent(INPUT_EVENT_TYPE_MOTION, deviceId, nature);
+ status_t result = publishInputEvent(AINPUT_EVENT_TYPE_MOTION, deviceId, source);
if (result < 0) {
return result;
}
@@ -399,7 +399,7 @@
// Cache essential information about the motion event to ensure that a malicious consumer
// cannot confuse the publisher by modifying the contents of the shared memory buffer while
// it is being updated.
- if (action == MOTION_EVENT_ACTION_MOVE) {
+ if (action == AMOTION_EVENT_ACTION_MOVE) {
mMotionEventPointerCount = pointerCount;
mMotionEventSampleDataStride = InputMessage::sampleDataStride(pointerCount);
mMotionEventSampleDataTail = InputMessage::sampleDataPtrIncrement(
@@ -420,7 +420,7 @@
if (! mPinned || ! mMotionEventSampleDataTail) {
LOGE("channel '%s' publisher ~ Cannot append motion sample because there is no current "
- "MOTION_EVENT_ACTION_MOVE event.", mChannel->getName().string());
+ "AMOTION_EVENT_ACTION_MOVE event.", mChannel->getName().string());
return INVALID_OPERATION;
}
@@ -588,7 +588,7 @@
mSharedMessage->consumed = true;
switch (mSharedMessage->type) {
- case INPUT_EVENT_TYPE_KEY: {
+ case AINPUT_EVENT_TYPE_KEY: {
KeyEvent* keyEvent = factory->createKeyEvent();
if (! keyEvent) return NO_MEMORY;
@@ -598,7 +598,7 @@
break;
}
- case INPUT_EVENT_TYPE_MOTION: {
+ case AINPUT_EVENT_TYPE_MOTION: {
MotionEvent* motionEvent = factory->createMotionEvent();
if (! motionEvent) return NO_MEMORY;
@@ -648,7 +648,7 @@
void InputConsumer::populateKeyEvent(KeyEvent* keyEvent) const {
keyEvent->initialize(
mSharedMessage->deviceId,
- mSharedMessage->nature,
+ mSharedMessage->source,
mSharedMessage->key.action,
mSharedMessage->key.flags,
mSharedMessage->key.keyCode,
@@ -662,7 +662,7 @@
void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const {
motionEvent->initialize(
mSharedMessage->deviceId,
- mSharedMessage->nature,
+ mSharedMessage->source,
mSharedMessage->motion.action,
mSharedMessage->motion.edgeFlags,
mSharedMessage->motion.metaState,
diff --git a/libs/ui/tests/InputPublisherAndConsumer_test.cpp b/libs/ui/tests/InputPublisherAndConsumer_test.cpp
index 55504f2..3bc21fa 100644
--- a/libs/ui/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/ui/tests/InputPublisherAndConsumer_test.cpp
@@ -73,17 +73,17 @@
status_t status;
const int32_t deviceId = 1;
- const int32_t nature = INPUT_EVENT_NATURE_KEY;
- const int32_t action = KEY_EVENT_ACTION_DOWN;
- const int32_t flags = KEY_EVENT_FLAG_FROM_SYSTEM;
+ const int32_t source = AINPUT_SOURCE_KEYBOARD;
+ const int32_t action = AKEY_EVENT_ACTION_DOWN;
+ const int32_t flags = AKEY_EVENT_FLAG_FROM_SYSTEM;
const int32_t keyCode = AKEYCODE_ENTER;
const int32_t scanCode = 13;
- const int32_t metaState = META_ALT_LEFT_ON | META_ALT_ON;
+ const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const int32_t repeatCount = 1;
const nsecs_t downTime = 3;
const nsecs_t eventTime = 4;
- status = mPublisher->publishKeyEvent(deviceId, nature, action, flags,
+ status = mPublisher->publishKeyEvent(deviceId, source, action, flags,
keyCode, scanCode, metaState, repeatCount, downTime, eventTime);
ASSERT_EQ(OK, status)
<< "publisher publishKeyEvent should return OK";
@@ -103,12 +103,12 @@
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
- ASSERT_EQ(INPUT_EVENT_TYPE_KEY, event->getType())
+ ASSERT_EQ(AINPUT_EVENT_TYPE_KEY, event->getType())
<< "consumer should have returned a key event";
KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
EXPECT_EQ(deviceId, keyEvent->getDeviceId());
- EXPECT_EQ(nature, keyEvent->getNature());
+ EXPECT_EQ(source, keyEvent->getSource());
EXPECT_EQ(action, keyEvent->getAction());
EXPECT_EQ(flags, keyEvent->getFlags());
EXPECT_EQ(keyCode, keyEvent->getKeyCode());
@@ -136,10 +136,10 @@
status_t status;
const int32_t deviceId = 1;
- const int32_t nature = INPUT_EVENT_NATURE_TOUCH;
- const int32_t action = MOTION_EVENT_ACTION_MOVE;
- const int32_t edgeFlags = MOTION_EVENT_EDGE_FLAG_TOP;
- const int32_t metaState = META_ALT_LEFT_ON | META_ALT_ON;
+ const int32_t source = AINPUT_SOURCE_TOUCHSCREEN;
+ const int32_t action = AMOTION_EVENT_ACTION_MOVE;
+ const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
+ const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
const float xOffset = -10;
const float yOffset = -20;
const float xPrecision = 0.25;
@@ -159,10 +159,15 @@
samplePointerCoords.editTop().y = 200 * i + j;
samplePointerCoords.editTop().pressure = 0.5 * i + j;
samplePointerCoords.editTop().size = 0.7 * i + j;
+ samplePointerCoords.editTop().touchMajor = 1.5 * i + j;
+ samplePointerCoords.editTop().touchMinor = 1.7 * i + j;
+ samplePointerCoords.editTop().toolMajor = 2.5 * i + j;
+ samplePointerCoords.editTop().toolMinor = 2.7 * i + j;
+ samplePointerCoords.editTop().orientation = 3.5 * i + j;
}
}
- status = mPublisher->publishMotionEvent(deviceId, nature, action, edgeFlags,
+ status = mPublisher->publishMotionEvent(deviceId, source, action, edgeFlags,
metaState, xOffset, yOffset, xPrecision, yPrecision,
downTime, sampleEventTimes[0], pointerCount, pointerIds, samplePointerCoords.array());
ASSERT_EQ(OK, status)
@@ -199,14 +204,14 @@
ASSERT_TRUE(event != NULL)
<< "consumer should have returned non-NULL event";
- ASSERT_EQ(INPUT_EVENT_TYPE_MOTION, event->getType())
+ ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, event->getType())
<< "consumer should have returned a motion event";
size_t lastSampleIndex = samplesToAppendBeforeDispatch + samplesToAppendAfterDispatch;
MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
EXPECT_EQ(deviceId, motionEvent->getDeviceId());
- EXPECT_EQ(nature, motionEvent->getNature());
+ EXPECT_EQ(source, motionEvent->getSource());
EXPECT_EQ(action, motionEvent->getAction());
EXPECT_EQ(edgeFlags, motionEvent->getEdgeFlags());
EXPECT_EQ(metaState, motionEvent->getMetaState());
@@ -241,6 +246,16 @@
motionEvent->getHistoricalPressure(i, sampleIndex));
EXPECT_EQ(samplePointerCoords[offset].size,
motionEvent->getHistoricalSize(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].touchMajor,
+ motionEvent->getHistoricalTouchMajor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].touchMinor,
+ motionEvent->getHistoricalTouchMinor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].toolMajor,
+ motionEvent->getHistoricalToolMajor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].toolMinor,
+ motionEvent->getHistoricalToolMinor(i, sampleIndex));
+ EXPECT_EQ(samplePointerCoords[offset].orientation,
+ motionEvent->getHistoricalOrientation(i, sampleIndex));
}
}
@@ -255,6 +270,11 @@
EXPECT_EQ(samplePointerCoords[offset].y + yOffset, motionEvent->getY(i));
EXPECT_EQ(samplePointerCoords[offset].pressure, motionEvent->getPressure(i));
EXPECT_EQ(samplePointerCoords[offset].size, motionEvent->getSize(i));
+ EXPECT_EQ(samplePointerCoords[offset].touchMajor, motionEvent->getTouchMajor(i));
+ EXPECT_EQ(samplePointerCoords[offset].touchMinor, motionEvent->getTouchMinor(i));
+ EXPECT_EQ(samplePointerCoords[offset].toolMajor, motionEvent->getToolMajor(i));
+ EXPECT_EQ(samplePointerCoords[offset].toolMinor, motionEvent->getToolMinor(i));
+ EXPECT_EQ(samplePointerCoords[offset].orientation, motionEvent->getOrientation(i));
}
status = mConsumer->sendFinishedSignal();
@@ -300,7 +320,7 @@
const size_t pointerCount = 1;
int32_t pointerIds[pointerCount] = { 0 };
- PointerCoords pointerCoords[pointerCount] = { { 0, 0, 0, 0 } };
+ PointerCoords pointerCoords[pointerCount] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
pointerCount, pointerIds, pointerCoords);
@@ -381,7 +401,7 @@
int32_t pointerIds[pointerCount];
PointerCoords pointerCoords[pointerCount];
- status = mPublisher->publishMotionEvent(0, 0, MOTION_EVENT_ACTION_DOWN,
+ status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_DOWN,
0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords);
ASSERT_EQ(OK, status);
@@ -398,7 +418,7 @@
int32_t pointerIds[pointerCount];
PointerCoords pointerCoords[pointerCount];
- status = mPublisher->publishMotionEvent(0, 0, MOTION_EVENT_ACTION_MOVE,
+ status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_MOVE,
0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords);
ASSERT_EQ(OK, status);
@@ -425,7 +445,7 @@
int32_t pointerIds[pointerCount];
PointerCoords pointerCoords[pointerCount];
- status = mPublisher->publishMotionEvent(0, 0, MOTION_EVENT_ACTION_MOVE,
+ status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_MOVE,
0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords);
ASSERT_EQ(OK, status);