abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Pointers.java
diff options
context:
space:
mode:
authorJules Aguillon2022-05-08 01:18:53 +0200
committerJules Aguillon2022-05-08 16:55:03 +0200
commit9a48acfe3e5ab8e7cf6b748a0764b96fbf4ff484 (patch)
tree3c3da04df3dfdd0322ec7855e1b689c1b25d6751 /srcs/juloo.keyboard2/Pointers.java
parentbce0a98f623e79968a912894684009926f041b2d (diff)
downloadunexpected-keyboard-9a48acfe3e5ab8e7cf6b748a0764b96fbf4ff484.tar.gz
unexpected-keyboard-9a48acfe3e5ab8e7cf6b748a0764b96fbf4ff484.zip
Improve nearest key computation
getAtDirection was too hard to maintain and might contain bugs. Change slightly the meaning of directions and implement a the nearest key calculation as a loop.
Diffstat (limited to 'srcs/juloo.keyboard2/Pointers.java')
-rw-r--r--srcs/juloo.keyboard2/Pointers.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java
index ac5ef84..1328d62 100644
--- a/srcs/juloo.keyboard2/Pointers.java
+++ b/srcs/juloo.keyboard2/Pointers.java
@@ -167,12 +167,12 @@ public final class Pointers implements Handler.Callback
// |\2|3/|
// |1\|/4|
// |-----|
- // |5/|\8|
- // |/6|7\|
+ // |8/|\5|
+ // |/7|6\|
direction = 1;
- if (dy > 0) direction += 4;
if (dx > 0) direction += 2;
if (dx > Math.abs(dy) || (dx < 0 && dx > -Math.abs(dy))) direction += 1;
+ if (dy > 0) direction = 9 - direction;
}
KeyValue newSelectedValue = ptr.key.getAtDirection(direction);