forked from Clones/Controlify
swap hands and shift click binds
This commit is contained in:
@ -23,10 +23,11 @@ public class ControllerBindings {
|
|||||||
PAUSE,
|
PAUSE,
|
||||||
INVENTORY,
|
INVENTORY,
|
||||||
CHANGE_PERSPECTIVE,
|
CHANGE_PERSPECTIVE,
|
||||||
|
SWAP_HANDS,
|
||||||
OPEN_CHAT,
|
OPEN_CHAT,
|
||||||
GUI_PRESS, GUI_BACK,
|
GUI_PRESS, GUI_BACK,
|
||||||
GUI_NEXT_TAB, GUI_PREV_TAB,
|
GUI_NEXT_TAB, GUI_PREV_TAB,
|
||||||
VMOUSE_LCLICK, VMOUSE_RCLICK, VMOUSE_MCLICK, VMOUSE_SCROLL_UP, VMOUSE_SCROLL_DOWN, VMOUSE_ESCAPE, VMOUSE_SHIFT, VMOUSE_TOGGLE,
|
VMOUSE_LCLICK, VMOUSE_RCLICK, VMOUSE_SHIFT_CLICK, VMOUSE_SCROLL_UP, VMOUSE_SCROLL_DOWN, VMOUSE_ESCAPE, VMOUSE_SHIFT, VMOUSE_TOGGLE,
|
||||||
PICK_BLOCK,
|
PICK_BLOCK,
|
||||||
TOGGLE_HUD_VISIBILITY,
|
TOGGLE_HUD_VISIBILITY,
|
||||||
SHOW_PLAYER_LIST;
|
SHOW_PLAYER_LIST;
|
||||||
@ -54,6 +55,7 @@ public class ControllerBindings {
|
|||||||
register(PAUSE = new ControllerBinding(controller, Bind.START, new ResourceLocation("controlify", "pause")));
|
register(PAUSE = new ControllerBinding(controller, Bind.START, new ResourceLocation("controlify", "pause")));
|
||||||
register(INVENTORY = new ControllerBinding(controller, Bind.Y_BUTTON, new ResourceLocation("controlify", "inventory"), options.keyInventory, () -> false));
|
register(INVENTORY = new ControllerBinding(controller, Bind.Y_BUTTON, new ResourceLocation("controlify", "inventory"), options.keyInventory, () -> false));
|
||||||
register(CHANGE_PERSPECTIVE = new ControllerBinding(controller, Bind.BACK, new ResourceLocation("controlify", "change_perspective"), options.keyTogglePerspective, () -> false));
|
register(CHANGE_PERSPECTIVE = new ControllerBinding(controller, Bind.BACK, new ResourceLocation("controlify", "change_perspective"), options.keyTogglePerspective, () -> false));
|
||||||
|
register(SWAP_HANDS = new ControllerBinding(controller, Bind.X_BUTTON, new ResourceLocation("controlify", "swap_hands"), options.keySwapOffhand, () -> false));
|
||||||
register(OPEN_CHAT = new ControllerBinding(controller, Bind.DPAD_UP, new ResourceLocation("controlify", "open_chat"), options.keyChat, () -> false));
|
register(OPEN_CHAT = new ControllerBinding(controller, Bind.DPAD_UP, new ResourceLocation("controlify", "open_chat"), options.keyChat, () -> false));
|
||||||
register(GUI_PRESS = new ControllerBinding(controller, Bind.A_BUTTON, new ResourceLocation("controlify", "gui_press")));
|
register(GUI_PRESS = new ControllerBinding(controller, Bind.A_BUTTON, new ResourceLocation("controlify", "gui_press")));
|
||||||
register(GUI_BACK = new ControllerBinding(controller, Bind.B_BUTTON, new ResourceLocation("controlify", "gui_back")));
|
register(GUI_BACK = new ControllerBinding(controller, Bind.B_BUTTON, new ResourceLocation("controlify", "gui_back")));
|
||||||
@ -64,7 +66,7 @@ public class ControllerBindings {
|
|||||||
register(SHOW_PLAYER_LIST = new ControllerBinding(controller, Bind.DPAD_RIGHT, new ResourceLocation("controlify", "show_player_list"), options.keyPlayerList, () -> false));
|
register(SHOW_PLAYER_LIST = new ControllerBinding(controller, Bind.DPAD_RIGHT, new ResourceLocation("controlify", "show_player_list"), options.keyPlayerList, () -> false));
|
||||||
register(VMOUSE_LCLICK = new ControllerBinding(controller, Bind.A_BUTTON, new ResourceLocation("controlify", "vmouse_lclick")));
|
register(VMOUSE_LCLICK = new ControllerBinding(controller, Bind.A_BUTTON, new ResourceLocation("controlify", "vmouse_lclick")));
|
||||||
register(VMOUSE_RCLICK = new ControllerBinding(controller, Bind.X_BUTTON, new ResourceLocation("controlify", "vmouse_rclick")));
|
register(VMOUSE_RCLICK = new ControllerBinding(controller, Bind.X_BUTTON, new ResourceLocation("controlify", "vmouse_rclick")));
|
||||||
register(VMOUSE_MCLICK = new ControllerBinding(controller, Bind.Y_BUTTON, new ResourceLocation("controlify", "vmouse_mclick")));
|
register(VMOUSE_SHIFT_CLICK = new ControllerBinding(controller, Bind.Y_BUTTON, new ResourceLocation("controlify", "vmouse_shift_click")));
|
||||||
register(VMOUSE_SCROLL_UP = new ControllerBinding(controller, Bind.RIGHT_STICK_FORWARD, new ResourceLocation("controlify", "vmouse_scroll_up")));
|
register(VMOUSE_SCROLL_UP = new ControllerBinding(controller, Bind.RIGHT_STICK_FORWARD, new ResourceLocation("controlify", "vmouse_scroll_up")));
|
||||||
register(VMOUSE_SCROLL_DOWN = new ControllerBinding(controller, Bind.RIGHT_STICK_BACKWARD, new ResourceLocation("controlify", "vmouse_scroll_down")));
|
register(VMOUSE_SCROLL_DOWN = new ControllerBinding(controller, Bind.RIGHT_STICK_BACKWARD, new ResourceLocation("controlify", "vmouse_scroll_down")));
|
||||||
register(VMOUSE_ESCAPE = new ControllerBinding(controller, Bind.B_BUTTON, new ResourceLocation("controlify", "vmouse_escape")));
|
register(VMOUSE_ESCAPE = new ControllerBinding(controller, Bind.B_BUTTON, new ResourceLocation("controlify", "vmouse_escape")));
|
||||||
|
@ -3,6 +3,7 @@ package dev.isxander.controlify.mixins.feature.virtualmouse;
|
|||||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
import com.mojang.blaze3d.platform.InputConstants;
|
import com.mojang.blaze3d.platform.InputConstants;
|
||||||
import dev.isxander.controlify.Controlify;
|
import dev.isxander.controlify.Controlify;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -12,8 +13,10 @@ public class InputConstantsMixin {
|
|||||||
// must modify isKeyDown here because Screen.hasShiftDown has some instances that ask for this directly.
|
// must modify isKeyDown here because Screen.hasShiftDown has some instances that ask for this directly.
|
||||||
@ModifyReturnValue(method = "isKeyDown", at = @At("RETURN"))
|
@ModifyReturnValue(method = "isKeyDown", at = @At("RETURN"))
|
||||||
private static boolean modifyIsKeyDown(boolean keyDown, long window, int key) {
|
private static boolean modifyIsKeyDown(boolean keyDown, long window, int key) {
|
||||||
if (key == GLFW.GLFW_KEY_LEFT_SHIFT) {
|
if (key == GLFW.GLFW_KEY_LEFT_SHIFT && window == Minecraft.getInstance().getWindow().getWindow()) {
|
||||||
return keyDown || Controlify.instance().currentController().bindings().VMOUSE_SHIFT.held();
|
return keyDown
|
||||||
|
|| Controlify.instance().currentController().bindings().VMOUSE_SHIFT_CLICK.held()
|
||||||
|
|| Controlify.instance().currentController().bindings().VMOUSE_SHIFT.held();
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyDown;
|
return keyDown;
|
||||||
|
@ -106,10 +106,10 @@ public class VirtualMouseHandler {
|
|||||||
mouseHandler.invokeOnPress(minecraft.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT, GLFW.GLFW_RELEASE, 0);
|
mouseHandler.invokeOnPress(minecraft.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT, GLFW.GLFW_RELEASE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.bindings().VMOUSE_MCLICK.justPressed()) {
|
if (controller.bindings().VMOUSE_SHIFT_CLICK.justPressed()) {
|
||||||
mouseHandler.invokeOnPress(minecraft.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_MIDDLE, GLFW.GLFW_PRESS, 0);
|
mouseHandler.invokeOnPress(minecraft.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT, GLFW.GLFW_PRESS, 0);
|
||||||
} else if (controller.bindings().VMOUSE_MCLICK.justReleased()) {
|
} else if (controller.bindings().VMOUSE_SHIFT_CLICK.justReleased()) {
|
||||||
mouseHandler.invokeOnPress(minecraft.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_MIDDLE, GLFW.GLFW_RELEASE, 0);
|
mouseHandler.invokeOnPress(minecraft.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT, GLFW.GLFW_RELEASE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.bindings().VMOUSE_ESCAPE.justPressed()) {
|
if (controller.bindings().VMOUSE_ESCAPE.justPressed()) {
|
||||||
|
Reference in New Issue
Block a user