diff options
| author | 2014-03-29 00:56:00 +0000 | |
|---|---|---|
| committer | 2014-03-29 00:56:00 +0000 | |
| commit | d020fd33d147c88a9cda4976d2fa559e55b4ab03 (patch) | |
| tree | f1efcf211ac61ea9deab18c423185faa1216ec6c /libs/input | |
| parent | 594c73fc57c99a0bceaa84ccd7524e5038a17ad8 (diff) | |
| parent | 1b10869f39978a864cfcc4efc73aefc312d8ed79 (diff) | |
Merge changes Ib18c99b9,I9f42eeb9 into klp-modular-dev
* changes:
Generate and respect ACTION_CANCEL for joystick fallbacks. DO NOT MERGE
Adds API for determining confirm and cancel keys.
Diffstat (limited to 'libs/input')
| -rw-r--r-- | libs/input/InputDispatcher.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/libs/input/InputDispatcher.cpp b/libs/input/InputDispatcher.cpp index 4d447878da4b..70ff0851b1f8 100644 --- a/libs/input/InputDispatcher.cpp +++ b/libs/input/InputDispatcher.cpp @@ -4105,18 +4105,39 @@ bool InputDispatcher::InputState::trackMotion(const MotionEntry* entry, case AMOTION_EVENT_ACTION_POINTER_UP: case AMOTION_EVENT_ACTION_POINTER_DOWN: case AMOTION_EVENT_ACTION_MOVE: { + if (entry->source & AINPUT_SOURCE_CLASS_NAVIGATION) { + // Trackballs can send MOVE events with a corresponding DOWN or UP. There's no need to + // generate cancellation events for these since they're based in relative rather than + // absolute units. + return true; + } + ssize_t index = findMotionMemento(entry, false /*hovering*/); + + if (entry->source & AINPUT_SOURCE_CLASS_JOYSTICK) { + // Joysticks can send MOVE events without a corresponding DOWN or UP. Since all + // joystick axes are normalized to [-1, 1] we can trust that 0 means it's neutral. Any + // other value and we need to track the motion so we can send cancellation events for + // anything generating fallback events (e.g. DPad keys for joystick movements). + if (index >= 0) { + if (entry->pointerCoords[0].isEmpty()) { + mMotionMementos.removeAt(index); + } else { + MotionMemento& memento = mMotionMementos.editItemAt(index); + memento.setPointers(entry); + } + } else if (!entry->pointerCoords[0].isEmpty()) { + addMotionMemento(entry, flags, false /*hovering*/); + } + + // Joysticks and trackballs can send MOVE events without corresponding DOWN or UP. + return true; + } if (index >= 0) { MotionMemento& memento = mMotionMementos.editItemAt(index); memento.setPointers(entry); return true; } - if (actionMasked == AMOTION_EVENT_ACTION_MOVE - && (entry->source & (AINPUT_SOURCE_CLASS_JOYSTICK - | AINPUT_SOURCE_CLASS_NAVIGATION))) { - // Joysticks and trackballs can send MOVE events without corresponding DOWN or UP. - return true; - } #if DEBUG_OUTBOUND_EVENT_DETAILS ALOGD("Dropping inconsistent motion pointer up/down or move event: " "deviceId=%d, source=%08x, actionMasked=%d", |