From ed6ff40abb5636b7cc322bf4d88d2e87e10fb273 Mon Sep 17 00:00:00 2001 From: Tungstend Date: Wed, 21 Feb 2024 22:36:57 +0800 Subject: [PATCH] Update ControlDirection.java --- .../com/tungsten/fcl/control/view/ControlDirection.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FCL/src/main/java/com/tungsten/fcl/control/view/ControlDirection.java b/FCL/src/main/java/com/tungsten/fcl/control/view/ControlDirection.java index afc732e8..eb68813a 100644 --- a/FCL/src/main/java/com/tungsten/fcl/control/view/ControlDirection.java +++ b/FCL/src/main/java/com/tungsten/fcl/control/view/ControlDirection.java @@ -655,7 +655,7 @@ public class ControlDirection extends RelativeLayout implements CustomView { xDist = left - buttonLeft; selfX = left - xDist; } - if (Math.abs(left - buttonRight) < xDist) { + if (left - buttonRight >= 0 && left - buttonRight < xDist) { xPref = true; prefX = buttonRight; xDist = left - buttonRight - dist; @@ -667,7 +667,7 @@ public class ControlDirection extends RelativeLayout implements CustomView { xDist = right - buttonRight; selfX = right - xDist; } - if (Math.abs(right - buttonLeft) < xDist) { + if (buttonLeft - right >= 0 && buttonLeft - right < xDist) { xPref = true; prefX = buttonLeft; xDist = right - buttonLeft + dist; @@ -679,7 +679,7 @@ public class ControlDirection extends RelativeLayout implements CustomView { yDist = up - buttonUp; selfY = up - yDist; } - if (Math.abs(up - buttonDown) < yDist) { + if (up - buttonDown >= 0 && up - buttonDown < yDist) { yPref = true; prefY = buttonDown; yDist = up - buttonDown - dist; @@ -691,7 +691,7 @@ public class ControlDirection extends RelativeLayout implements CustomView { yDist = down - buttonDown; selfY = down - yDist; } - if (Math.abs(down - buttonUp) < yDist) { + if (buttonUp - down >= 0 && buttonUp - down < yDist) { yPref = true; prefY = buttonUp; yDist = down - buttonUp + dist;