From 9a48acfe3e5ab8e7cf6b748a0764b96fbf4ff484 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 8 May 2022 01:18:53 +0200 Subject: 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. --- srcs/juloo.keyboard2/Pointers.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'srcs/juloo.keyboard2/Pointers.java') 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); -- cgit v1.2.3