summaryrefslogtreecommitdiff
path: root/java/src/com/android/inputmethod/keyboard/KeyDetector.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-07-04 19:59:57 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-07-04 22:32:21 +0900
commita19b84dcf65bd70caa0fc72089cfe043b023a898 (patch)
tree22000ca2fda581e07c03c827a27f55e84009dc1f /java/src/com/android/inputmethod/keyboard/KeyDetector.java
parent5f6816fa8bf259f0340a3d12c551d1532f647d66 (diff)
Move key hysteresis distance parameter to KeyDetector class
Bug: 4768084 Change-Id: Ib8771afd7363a4a5590b2b4a586e3014c026be34
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/KeyDetector.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 7add43a6d..85418a61d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -28,6 +28,8 @@ public class KeyDetector {
public static final int NOT_A_CODE = -1;
public static final int NOT_A_KEY = -1;
+ private final int mKeyHysteresisDistanceSquared;
+
private Keyboard mKeyboard;
private int mCorrectionX;
private int mCorrectionY;
@@ -39,12 +41,28 @@ public class KeyDetector {
private final int[] mDistances = new int[MAX_NEARBY_KEYS];
private final int[] mIndices = new int[MAX_NEARBY_KEYS];
+ /**
+ * This class handles key detection.
+ *
+ * @param keyHysteresisDistance if the pointer movement distance is smaller than this, the
+ * movement will not been handled as meaningful movement. The unit is pixel.
+ */
+ public KeyDetector(float keyHysteresisDistance) {
+ mKeyHysteresisDistanceSquared = (int)(keyHysteresisDistance * keyHysteresisDistance);
+ }
+
public void setKeyboard(Keyboard keyboard, float correctionX, float correctionY) {
if (keyboard == null)
throw new NullPointerException();
mCorrectionX = (int)correctionX;
mCorrectionY = (int)correctionY;
mKeyboard = keyboard;
+ final int threshold = keyboard.getMostCommonKeyWidth();
+ mProximityThresholdSquare = threshold * threshold;
+ }
+
+ public int getKeyHysteresisDistanceSquared() {
+ return mKeyHysteresisDistanceSquared;
}
protected int getTouchX(int x) {