am 7a17c1fc: Tuning gesture detection parameters

* commit '7a17c1fcb52f0249108cfcbd789928320706718a':
  Tuning gesture detection parameters
main
Tadashi G. Takaoka 2012-10-09 07:43:37 -07:00 committed by Android Git Automerger
commit f5c10d00a9
3 changed files with 31 additions and 37 deletions

View File

@ -81,7 +81,7 @@
<integer name="config_gesture_dynamic_time_threshold_to">20</integer> <integer name="config_gesture_dynamic_time_threshold_to">20</integer>
<!-- Distance based threshold values for gesture detection (keyWidth%/sec) --> <!-- Distance based threshold values for gesture detection (keyWidth%/sec) -->
<fraction name="config_gesture_dynamic_distance_threshold_from">600%</fraction> <fraction name="config_gesture_dynamic_distance_threshold_from">600%</fraction>
<fraction name="config_gesture_dynamic_distance_threshold_to">35%</fraction> <fraction name="config_gesture_dynamic_distance_threshold_to">50%</fraction>
<!-- Parameter for gesture sampling (keyWidth%/sec) --> <!-- Parameter for gesture sampling (keyWidth%/sec) -->
<fraction name="config_gesture_sampling_minimum_distance">16.6666%</fraction> <fraction name="config_gesture_sampling_minimum_distance">16.6666%</fraction>
<!-- Parameters for gesture recognition (msec) and (keyWidth%/sec) --> <!-- Parameters for gesture recognition (msec) and (keyWidth%/sec) -->

View File

@ -192,47 +192,32 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
gestureStrokeParams.mStaticTimeThresholdAfterFastTyping; gestureStrokeParams.mStaticTimeThresholdAfterFastTyping;
} }
private void recordTyping(final long eventTime) { private boolean wasLastInputTyping() {
mLastTypingTime = eventTime; return mLastTypingTime >= mLastBatchInputTime;
}
private void recordLetterTyping(final long eventTime) {
mLastLetterTypingTime = eventTime;
// Reset gesture typing time
mLastBatchInputTime = 0;
}
private void recordGestureTyping(final long eventTime) {
mLastBatchInputTime = eventTime;
// Reset typing time.
mLastTypingTime = 0;
}
private boolean isInTyping() {
return mLastTypingTime != 0;
}
private boolean isInBatchInput() {
return mLastBatchInputTime != 0;
} }
public void onCodeInput(final int code, final long eventTime) { public void onCodeInput(final int code, final long eventTime) {
if (Keyboard.isLetterCode(code) && code != Keyboard.CODE_SPACE) { // Record the letter typing time when
if (isInTyping() // 1. Letter keys are typed successively without any batch input in between.
&& eventTime - mLastTypingTime < mStaticTimeThresholdAfterFastTyping) { // 2. A letter key is typed within the threshold time since the last any key typing.
recordLetterTyping(eventTime); // 3. A non-letter key is typed within the threshold time since the last letter key
// typing.
if (Character.isLetter(code)) {
if (wasLastInputTyping()
|| eventTime - mLastTypingTime < mStaticTimeThresholdAfterFastTyping) {
mLastLetterTypingTime = eventTime;
} }
} else { } else {
if (eventTime - mLastLetterTypingTime < mStaticTimeThresholdAfterFastTyping) { if (eventTime - mLastLetterTypingTime < mStaticTimeThresholdAfterFastTyping) {
// This non-letter typing should be treated as a part of fast typing. // This non-letter typing should be treated as a part of fast typing.
recordLetterTyping(eventTime); mLastLetterTypingTime = eventTime;
} }
} }
recordTyping(eventTime); mLastTypingTime = eventTime;
} }
public void onEndBatchInput(final long eventTime) { public void onEndBatchInput(final long eventTime) {
recordGestureTyping(eventTime); mLastBatchInputTime = eventTime;
} }
public long getLastLetterTypingTime() { public long getLastLetterTypingTime() {
@ -240,7 +225,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
} }
public boolean needsToSuppressKeyPreviewPopup(final long eventTime) { public boolean needsToSuppressKeyPreviewPopup(final long eventTime) {
return !isInTyping() && isInBatchInput() return !wasLastInputTyping()
&& eventTime - mLastBatchInputTime < mSuppressKeyPreviewAfterBatchInputDuration; && eventTime - mLastBatchInputTime < mSuppressKeyPreviewAfterBatchInputDuration;
} }
} }
@ -851,11 +836,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
// Register move event on gesture tracker. // Register move event on gesture tracker.
onGestureMoveEvent(x, y, eventTime, true /* isMajorEvent */, key); onGestureMoveEvent(x, y, eventTime, true /* isMajorEvent */, key);
if (sInGesture) { if (sInGesture) {
mTimerProxy.cancelLongPressTimer();
mCurrentKey = null; mCurrentKey = null;
setReleasedKeyGraphics(oldKey); setReleasedKeyGraphics(oldKey);
return; return;
} }
if (mGestureStrokeWithPreviewPoints.hasDetectedFastMove()) {
mTimerProxy.cancelLongPressTimer();
}
} }
if (key != null) { if (key != null) {

View File

@ -190,8 +190,8 @@ public class GestureStroke {
return mParams.mDynamicTimeThresholdFrom - decayedThreshold; return mParams.mDynamicTimeThresholdFrom - decayedThreshold;
} }
public boolean isStartOfAGesture() { public final boolean isStartOfAGesture() {
if (mDetectFastMoveTime == 0) { if (!hasDetectedFastMove()) {
return false; return false;
} }
final int size = mEventTimes.getLength(); final int size = mEventTimes.getLength();
@ -200,6 +200,9 @@ public class GestureStroke {
} }
final int lastIndex = size - 1; final int lastIndex = size - 1;
final int deltaTime = mEventTimes.get(lastIndex) - mDetectFastMoveTime; final int deltaTime = mEventTimes.get(lastIndex) - mDetectFastMoveTime;
if (deltaTime < 0) {
return false;
}
final int deltaDistance = getDistance( final int deltaDistance = getDistance(
mXCoordinates.get(lastIndex), mYCoordinates.get(lastIndex), mXCoordinates.get(lastIndex), mYCoordinates.get(lastIndex),
mDetectFastMoveX, mDetectFastMoveY); mDetectFastMoveX, mDetectFastMoveY);
@ -240,6 +243,10 @@ public class GestureStroke {
mLastMajorEventY = y; mLastMajorEventY = y;
} }
public final boolean hasDetectedFastMove() {
return mDetectFastMoveTime > 0;
}
private int detectFastMove(final int x, final int y, final int time) { private int detectFastMove(final int x, final int y, final int time) {
final int size = mEventTimes.getLength(); final int size = mEventTimes.getLength();
final int lastIndex = size - 1; final int lastIndex = size - 1;
@ -255,7 +262,7 @@ public class GestureStroke {
Log.d(TAG, String.format("[%d] detectFastMove: speed=%5.2f", mPointerId, speed)); Log.d(TAG, String.format("[%d] detectFastMove: speed=%5.2f", mPointerId, speed));
} }
// Equivalent to (pixels / msecs < mStartSpeedThreshold / MSEC_PER_SEC) // Equivalent to (pixels / msecs < mStartSpeedThreshold / MSEC_PER_SEC)
if (mDetectFastMoveTime == 0 && pixelsPerSec > mDetectFastMoveSpeedThreshold * msecs) { if (!hasDetectedFastMove() && pixelsPerSec > mDetectFastMoveSpeedThreshold * msecs) {
if (DEBUG) { if (DEBUG) {
final float speed = (float)pixelsPerSec / msecs / mKeyWidth; final float speed = (float)pixelsPerSec / msecs / mKeyWidth;
Log.d(TAG, String.format( Log.d(TAG, String.format(
@ -306,11 +313,11 @@ public class GestureStroke {
return currentTime > lastRecognitionTime + mParams.mRecognitionMinimumTime; return currentTime > lastRecognitionTime + mParams.mRecognitionMinimumTime;
} }
public void appendAllBatchPoints(final InputPointers out) { public final void appendAllBatchPoints(final InputPointers out) {
appendBatchPoints(out, mEventTimes.getLength()); appendBatchPoints(out, mEventTimes.getLength());
} }
public void appendIncrementalBatchPoints(final InputPointers out) { public final void appendIncrementalBatchPoints(final InputPointers out) {
appendBatchPoints(out, mIncrementalRecognitionSize); appendBatchPoints(out, mIncrementalRecognitionSize);
} }