resolved conflicts for merge of aca672ba to master

Change-Id: I7ae11fca0acdbf513a4870226d0d3e3cafbe9a08
This commit is contained in:
Jeff Brown 2010-07-15 23:47:29 -07:00
commit 1a15c6eaff
12 changed files with 349 additions and 163 deletions

View File

@ -59,6 +59,32 @@ namespace android {
class KeyLayoutMap;
/*
* Input device classes.
*/
enum {
/* The input device is a keyboard. */
INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
/* The input device is an alpha-numeric keyboard (not just a dial pad). */
INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
/* The input device is a touchscreen (either single-touch or multi-touch). */
INPUT_DEVICE_CLASS_TOUCHSCREEN = 0x00000004,
/* The input device is a trackball. */
INPUT_DEVICE_CLASS_TRACKBALL = 0x00000008,
/* The input device is a multi-touch touchscreen. */
INPUT_DEVICE_CLASS_TOUCHSCREEN_MT= 0x00000010,
/* The input device is a directional pad. */
INPUT_DEVICE_CLASS_DPAD = 0x00000020,
/* The input device is a gamepad (implies keyboard). */
INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040
};
/*
* Grand Central Station for events.
*

View File

@ -32,7 +32,7 @@ enum {
/*
* Private control to determine when an app is tracking a key sequence.
*/
KEY_EVENT_FLAG_START_TRACKING = 0x40000000
AKEY_EVENT_FLAG_START_TRACKING = 0x40000000
};
/*
@ -130,6 +130,11 @@ struct PointerCoords {
float y;
float pressure;
float size;
float touchMajor;
float touchMinor;
float toolMajor;
float toolMinor;
float orientation;
};
/*
@ -143,14 +148,14 @@ public:
inline int32_t getDeviceId() const { return mDeviceId; }
inline int32_t getNature() const { return mNature; }
inline int32_t getSource() const { return mSource; }
protected:
void initialize(int32_t deviceId, int32_t nature);
void initialize(int32_t deviceId, int32_t source);
private:
int32_t mDeviceId;
int32_t mNature;
int32_t mSource;
};
/*
@ -160,7 +165,7 @@ class KeyEvent : public InputEvent {
public:
virtual ~KeyEvent() { }
virtual int32_t getType() const { return INPUT_EVENT_TYPE_KEY; }
virtual int32_t getType() const { return AINPUT_EVENT_TYPE_KEY; }
inline int32_t getAction() const { return mAction; }
@ -188,7 +193,7 @@ public:
void initialize(
int32_t deviceId,
int32_t nature,
int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@ -216,7 +221,7 @@ class MotionEvent : public InputEvent {
public:
virtual ~MotionEvent() { }
virtual int32_t getType() const { return INPUT_EVENT_TYPE_MOTION; }
virtual int32_t getType() const { return AINPUT_EVENT_TYPE_MOTION; }
inline int32_t getAction() const { return mAction; }
@ -264,6 +269,26 @@ public:
return getCurrentPointerCoords(pointerIndex).size;
}
inline float getTouchMajor(size_t pointerIndex) const {
return getCurrentPointerCoords(pointerIndex).touchMajor;
}
inline float getTouchMinor(size_t pointerIndex) const {
return getCurrentPointerCoords(pointerIndex).touchMinor;
}
inline float getToolMajor(size_t pointerIndex) const {
return getCurrentPointerCoords(pointerIndex).toolMajor;
}
inline float getToolMinor(size_t pointerIndex) const {
return getCurrentPointerCoords(pointerIndex).toolMinor;
}
inline float getOrientation(size_t pointerIndex) const {
return getCurrentPointerCoords(pointerIndex).orientation;
}
inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; }
inline nsecs_t getHistoricalEventTime(size_t historicalIndex) const {
@ -294,9 +319,29 @@ public:
return getHistoricalPointerCoords(pointerIndex, historicalIndex).size;
}
inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).touchMajor;
}
inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).touchMinor;
}
inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).toolMajor;
}
inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).toolMinor;
}
inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalPointerCoords(pointerIndex, historicalIndex).orientation;
}
void initialize(
int32_t deviceId,
int32_t nature,
int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,

View File

@ -42,6 +42,7 @@ namespace android {
extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
extern int32_t rotateKeyCode(int32_t keyCode, int32_t orientation);
/*
* An input device structure tracks the state of a single input device.
*
@ -168,8 +169,11 @@ struct InputDevice {
FIELD_ABS_MT_POSITION_X = 1,
FIELD_ABS_MT_POSITION_Y = 2,
FIELD_ABS_MT_TOUCH_MAJOR = 4,
FIELD_ABS_MT_WIDTH_MAJOR = 8,
FIELD_ABS_MT_TRACKING_ID = 16
FIELD_ABS_MT_TOUCH_MINOR = 8,
FIELD_ABS_MT_WIDTH_MAJOR = 16,
FIELD_ABS_MT_WIDTH_MINOR = 32,
FIELD_ABS_MT_ORIENTATION = 64,
FIELD_ABS_MT_TRACKING_ID = 128
};
uint32_t pointerCount;
@ -179,7 +183,10 @@ struct InputDevice {
int32_t absMTPositionX;
int32_t absMTPositionY;
int32_t absMTTouchMajor;
int32_t absMTTouchMinor;
int32_t absMTWidthMajor;
int32_t absMTWidthMinor;
int32_t absMTOrientation;
int32_t absMTTrackingId;
inline void clear() {
@ -206,6 +213,11 @@ struct InputDevice {
int32_t y;
int32_t pressure;
int32_t size;
int32_t touchMajor;
int32_t touchMinor;
int32_t toolMajor;
int32_t toolMinor;
int32_t orientation;
};
struct TouchData {
@ -236,6 +248,7 @@ struct InputDevice {
AbsoluteAxisInfo yAxis;
AbsoluteAxisInfo pressureAxis;
AbsoluteAxisInfo sizeAxis;
AbsoluteAxisInfo orientationAxis;
} parameters;
// The touch data of the current sample being processed.
@ -290,6 +303,8 @@ struct InputDevice {
int32_t sizeOrigin;
float sizeScale;
float orientationScale;
} precalculated;
void reset();

View File

@ -167,10 +167,10 @@ public:
*/
virtual void notifyConfigurationChanged(nsecs_t eventTime) = 0;
virtual void notifyAppSwitchComing(nsecs_t eventTime) = 0;
virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nature,
virtual void 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) = 0;
virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t nature,
virtual void 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) = 0;
@ -232,10 +232,10 @@ public:
virtual void notifyConfigurationChanged(nsecs_t eventTime);
virtual void notifyAppSwitchComing(nsecs_t eventTime);
virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nature,
virtual void 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);
virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t nature,
virtual void 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);
@ -281,7 +281,7 @@ private:
struct KeyEntry : EventEntry {
int32_t deviceId;
int32_t nature;
int32_t source;
uint32_t policyFlags;
int32_t action;
int32_t flags;
@ -301,7 +301,7 @@ private:
struct MotionEntry : EventEntry {
int32_t deviceId;
int32_t nature;
int32_t source;
uint32_t policyFlags;
int32_t action;
int32_t metaState;
@ -424,11 +424,11 @@ private:
ConfigurationChangedEntry* obtainConfigurationChangedEntry(nsecs_t eventTime);
KeyEntry* 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);
MotionEntry* 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);

View File

@ -119,7 +119,7 @@ struct InputMessage {
};
int32_t deviceId;
int32_t nature;
int32_t source;
union {
struct {
@ -198,7 +198,7 @@ public:
*/
status_t publishKeyEvent(
int32_t deviceId,
int32_t nature,
int32_t source,
int32_t action,
int32_t flags,
int32_t keyCode,
@ -216,7 +216,7 @@ public:
*/
status_t publishMotionEvent(
int32_t deviceId,
int32_t nature,
int32_t source,
int32_t action,
int32_t edgeFlags,
int32_t metaState,
@ -233,7 +233,7 @@ public:
/* Appends a motion sample to a motion event unless already consumed.
*
* Returns OK on success.
* Returns INVALID_OPERATION if the current event is not a MOTION_EVENT_ACTION_MOVE event.
* Returns INVALID_OPERATION if the current event is not a AMOTION_EVENT_ACTION_MOVE event.
* Returns FAILED_TRANSACTION if the current event has already been consumed.
* Returns NO_MEMORY if the buffer is full and no additional samples can be added.
*/
@ -272,7 +272,7 @@ private:
status_t publishInputEvent(
int32_t type,
int32_t deviceId,
int32_t nature);
int32_t source);
};
/*

View File

@ -168,12 +168,12 @@ int32_t EventHub::getScanCodeState(int32_t deviceId, int32_t deviceClasses,
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 @@ int32_t EventHub::getScanCodeState(int32_t deviceId, int32_t deviceClasses,
}
}
}
return KEY_STATE_UNKNOWN;
return AKEY_STATE_UNKNOWN;
}
int32_t EventHub::getScanCodeStateLocked(device_t* device, int32_t scanCode) const {
@ -189,9 +189,9 @@ int32_t EventHub::getScanCodeStateLocked(device_t* device, int32_t scanCode) con
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 @@ int32_t EventHub::getKeyCodeState(int32_t deviceId, int32_t deviceClasses,
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 EventHub::getKeyCodeStateLocked(device_t* device, int32_t keyCode) const
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 @@ int32_t EventHub::getSwitchState(int32_t deviceId, int32_t deviceClasses, int32_
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 @@ int32_t EventHub::getSwitchStateLocked(device_t* device, int32_t sw) const {
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,

View File

@ -13,9 +13,9 @@ namespace android {
// 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 @@ bool KeyEvent::isSystemKey() const {
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 @@ void KeyEvent::initialize(
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 KeyEvent::initialize(
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 @@ void MotionEvent::initialize(
size_t pointerCount,
const int32_t* pointerIds,
const PointerCoords* pointerCoords) {
InputEvent::initialize(deviceId, nature);
InputEvent::initialize(deviceId, source);
mAction = action;
mEdgeFlags = edgeFlags;
mMetaState = metaState;

View File

@ -108,7 +108,7 @@ void InputDevice::TouchData::copyFrom(const TouchData& other) {
// --- InputDevice::KeyboardState ---
void InputDevice::KeyboardState::reset() {
current.metaState = META_NONE;
current.metaState = AMETA_NONE;
current.downTime = 0;
}

View File

@ -245,14 +245,14 @@ void InputDispatcher::processConfigurationChangedLockedInterruptible(
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 @@ void InputDispatcher::processKeyRepeatLockedInterruptible(
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 @@ void InputDispatcher::processKeyRepeatLockedInterruptible(
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 @@ void InputDispatcher::processKeyRepeatLockedInterruptible(
}
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::processKeyRepeatLockedInterruptible(
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 @@ void InputDispatcher::processMotionLockedInterruptible(
// 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 @@ void InputDispatcher::identifyInputTargetsAndDispatchKeyLockedInterruptible(
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 @@ void InputDispatcher::identifyInputTargetsAndDispatchMotionLockedInterruptible(
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 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
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 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
// 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 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
// 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 @@ void InputDispatcher::notifyAppSwitchComing(nsecs_t eventTime) {
} // 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 @@ void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nat
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::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t nat
}
}
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 @@ void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t
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 @@ void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t
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 @@ void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t
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 @@ NoBatchingOrStreaming:;
// 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 @@ bool InputDispatcher::isFullySynchronizedLocked() {
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 @@ InputDispatcher::EventEntry* InputDispatcher::createEntryFromInputEventLocked(
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::Allocator::obtainConfigurationChangedEntry(nsecs_t eventTime) {
}
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::KeyEntry* InputDispatcher::Allocator::obtainKeyEntry(nsecs_t ev
}
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 @@ InputDispatcher::MotionEntry* InputDispatcher::Allocator::obtainMotionEntry(nsec
entry->eventTime = eventTime;
entry->deviceId = deviceId;
entry->nature = nature;
entry->source = source;
entry->policyFlags = policyFlags;
entry->action = action;
entry->metaState = metaState;

View File

@ -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 updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState) {
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 @@ void InputReader::handleAbsoluteMotion(const RawEvent* rawEvent) {
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 @@ void InputReader::onKey(nsecs_t when, InputDevice* device,
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 @@ void InputReader::onMultiTouchScreenStateChanged(nsecs_t when,
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 @@ void InputReader::onSingleTouchScreenStateChanged(nsecs_t when,
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 @@ bool InputReader::consumeVirtualKeyTouches(nsecs_t when,
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 @@ bool InputReader::consumeVirtualKeyTouches(nsecs_t when,
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 @@ bool InputReader::consumeVirtualKeyTouches(nsecs_t when,
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 @@ void InputReader::dispatchVirtualKey(nsecs_t when,
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 @@ void InputReader::dispatchTouches(nsecs_t when,
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 @@ void InputReader::dispatchTouches(nsecs_t when,
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 @@ void InputReader::dispatchTouches(nsecs_t when,
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 @@ void InputReader::dispatchTouch(nsecs_t when, InputDevice* device, uint32_t poli
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 @@ void InputReader::dispatchTouch(nsecs_t when, InputDevice* device, uint32_t poli
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 @@ void InputReader::dispatchTouch(nsecs_t when, InputDevice* device, uint32_t poli
// 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 @@ void InputReader::onTrackballStateChanged(nsecs_t when,
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 @@ void InputReader::onTrackballStateChanged(nsecs_t when,
? 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 @@ void InputReader::onTrackballStateChanged(nsecs_t when,
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 @@ void InputReader::configureDevice(InputDevice* device) {
& 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 @@ void InputReader::configureDevice(InputDevice* device) {
& 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 @@ void InputReader::configureDevice(InputDevice* device) {
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 @@ int32_t InputReader::getCurrentScanCodeState(int32_t deviceId, int32_t deviceCla
AutoMutex _l(mExportedStateLock);
if (mExportedVirtualScanCode == scanCode) {
return KEY_STATE_VIRTUAL;
return AKEY_STATE_VIRTUAL;
}
} // release exported state lock
@ -1360,7 +1440,7 @@ int32_t InputReader::getCurrentKeyCodeState(int32_t deviceId, int32_t deviceClas
AutoMutex _l(mExportedStateLock);
if (mExportedVirtualKeyCode == keyCode) {
return KEY_STATE_VIRTUAL;
return AKEY_STATE_VIRTUAL;
}
} // release exported state lock

View File

@ -270,7 +270,7 @@ status_t InputPublisher::reset() {
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 @@ status_t InputPublisher::publishInputEvent(
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 @@ status_t InputPublisher::publishKeyEvent(
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::publishKeyEvent(
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 @@ status_t InputPublisher::publishMotionEvent(
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 @@ status_t InputPublisher::publishMotionEvent(
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 @@ status_t InputPublisher::publishMotionEvent(
// 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 @@ status_t InputPublisher::appendMotionSample(
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 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, InputEvent*
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 @@ status_t InputConsumer::consume(InputEventFactoryInterface* factory, InputEvent*
break;
}
case INPUT_EVENT_TYPE_MOTION: {
case AINPUT_EVENT_TYPE_MOTION: {
MotionEvent* motionEvent = factory->createMotionEvent();
if (! motionEvent) return NO_MEMORY;
@ -648,7 +648,7 @@ status_t InputConsumer::receiveDispatchSignal() {
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::populateKeyEvent(KeyEvent* keyEvent) const {
void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const {
motionEvent->initialize(
mSharedMessage->deviceId,
mSharedMessage->nature,
mSharedMessage->source,
mSharedMessage->motion.action,
mSharedMessage->motion.edgeFlags,
mSharedMessage->motion.metaState,

View File

@ -73,17 +73,17 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
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 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
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 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent(
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 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent(
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 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent(
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 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent(
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 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent(
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 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenNotReset_ReturnsErr
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 @@ TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenPublishedMotionEven
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 @@ TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenAlreadyConsumed_Ret
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 @@ TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenBufferFull_ReturnsE
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);