From 26065e4077b847d3b86056159858822c6bd87e34 Mon Sep 17 00:00:00 2001 From: UknownPerson <1785618795@qq.com> Date: Thu, 9 Apr 2026 21:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E5=AF=BC=E8=87=B4=E7=9A=84=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E5=8F=AA=E8=83=BD=E8=8E=B7=E5=8F=96=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=BC=A0=E6=A0=87=E7=A7=BB=E5=8A=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/input/raw/RawInputMod.java | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/main/java/top/fpsmaster/utils/input/raw/RawInputMod.java b/src/main/java/top/fpsmaster/utils/input/raw/RawInputMod.java index c3e6aeb3..040a4556 100644 --- a/src/main/java/top/fpsmaster/utils/input/raw/RawInputMod.java +++ b/src/main/java/top/fpsmaster/utils/input/raw/RawInputMod.java @@ -8,12 +8,13 @@ import top.fpsmaster.modules.logger.ClientLogger; import java.io.File; +import java.util.ArrayList; import java.util.concurrent.atomic.AtomicInteger; public class RawInputMod { private Thread inputThread; - public static Mouse mouse = null; + public static ArrayList mouses = new ArrayList<>(); public static Controller[] controllers; public static final AtomicInteger dx = new AtomicInteger(0); public static final AtomicInteger dy = new AtomicInteger(0); @@ -25,34 +26,44 @@ public void start() { } Minecraft.getMinecraft().mouseHelper = new RawMouseHelper(); String environment; - if (checkLibrary("jinput-dx8")){ + if (checkLibrary("jinput-dx8")) { environment = "DirectInputEnvironmentPlugin"; - }else if (checkLibrary("jinput-raw")){ + } else if (checkLibrary("jinput-raw")) { environment = "DirectAndRawInputEnvironmentPlugin"; - }else{ + } else { return; } - Class aClass = Class.forName("net.java.games.input." + environment); aClass.getDeclaredConstructor().setAccessible(true); ControllerEnvironment env = (ControllerEnvironment) aClass.newInstance(); controllers = env.getControllers(); inputThread = new Thread(() -> { while (!Thread.currentThread().isInterrupted()) { - int i = 0; - while (controllers != null && i < controllers.length && mouse == null) { - if (controllers[i].getType() == Controller.Type.MOUSE) { - controllers[i].poll(); - if (((Mouse) controllers[i]).getX().getPollData() != 0.0 || ((Mouse) controllers[i]).getY().getPollData() != 0.0) { - mouse = (Mouse) controllers[i]; + if(environment.equals("DirectInputEnvironmentPlugin")){ + int i = 0; + while (controllers != null && i < controllers.length && mouses.isEmpty()) { + if (controllers[i].getType() == Controller.Type.MOUSE) { + controllers[i].poll(); + if (((Mouse) controllers[i]).getX().getPollData() != 0.0 || ((Mouse) controllers[i]).getY().getPollData() != 0.0) { + mouses.add((Mouse) controllers[i]); + } + } + i++; + } + }else { + for (Controller controller : controllers) { + if (controller.getType() == Controller.Type.MOUSE) { + mouses.add((Mouse) controller); } } - i++; } - if (mouse != null) { - mouse.poll(); - dx.addAndGet((int) mouse.getX().getPollData()); - dy.addAndGet((int) mouse.getY().getPollData()); + + if (!mouses.isEmpty()) { + for (Mouse mouse : mouses) { + mouse.poll(); + dx.addAndGet((int) mouse.getX().getPollData()); + dy.addAndGet((int) mouse.getY().getPollData()); + } if (Minecraft.getMinecraft().currentScreen != null) { dx.set(0); dy.set(0); @@ -80,7 +91,7 @@ public void stop() { inputThread.join(200L); } inputThread = null; - mouse = null; + mouses = new ArrayList<>(); controllers = null; dx.set(0); dy.set(0);