From 799ebb9fa057580b3ab05367607bb3228797d777 Mon Sep 17 00:00:00 2001 From: Violet-Scarelli <33497956+Violet-Scarelli@users.noreply.github.com> Date: Fri, 27 May 2022 16:14:45 -0700 Subject: [PATCH] Fixed the mouse button problems with the linked controller. (#3069) * Fixed the mouse button problems with the linked controller. (Closes #2807) * Now with added elegance * I'm here I might as well tie up some loose ends * Compacting out some spaces * This was probably the way it was for a good reason --- src/main/java/com/simibubi/create/AllKeys.java | 6 ++++++ .../logistics/item/LinkedControllerClientHandler.java | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllKeys.java b/src/main/java/com/simibubi/create/AllKeys.java index 58ad25fdf..8010fe460 100644 --- a/src/main/java/com/simibubi/create/AllKeys.java +++ b/src/main/java/com/simibubi/create/AllKeys.java @@ -63,6 +63,12 @@ public enum AllKeys { .getWindow(), key) != 0; } + public static boolean isMouseButtonDown(int button){ + return GLFW.glfwGetMouseButton(Minecraft.getInstance() + .getWindow() + .getWindow(), button) != 0; + } + public static boolean ctrlDown() { return Screen.hasControlDown(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java index 1c3452d7f..1671bda41 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java @@ -6,6 +6,8 @@ import java.util.HashSet; import java.util.List; import java.util.Vector; +import com.simibubi.create.AllKeys; + import org.lwjgl.glfw.GLFW; import com.mojang.blaze3d.platform.InputConstants; @@ -116,11 +118,10 @@ public class LinkedControllerClientHandler { } protected static boolean isActuallyPressed(KeyMapping kb) { - return InputConstants.isKeyDown(Minecraft.getInstance() - .getWindow() - .getWindow(), - kb.getKey() - .getValue()); + if(kb.matchesMouse(kb.getKey().getValue())) + return AllKeys.isMouseButtonDown(kb.getKey().getValue()); + else + return AllKeys.isKeyDown(kb.getKey().getValue()); } public static void tick() {