|
1 | 1 | package net.notcoded.wayfix.mixin; |
2 | 2 |
|
| 3 | +import io.netty.util.internal.PlatformDependent; |
3 | 4 | import net.minecraft.client.Keyboard; |
4 | | - |
5 | | -//? if >=1.21.9 { |
6 | | -/*import net.minecraft.client.input.CharInput; |
7 | | -import net.minecraft.client.input.SystemKeycodes; |
8 | | -*///?} else if <1.21.9 { |
9 | | -import net.minecraft.client.gui.screen.Screen; |
10 | | -import net.minecraft.client.util.InputUtil; |
11 | | -//?} |
| 5 | +import net.minecraft.client.MinecraftClient; |
12 | 6 | import org.lwjgl.glfw.GLFW; |
13 | 7 | import net.notcoded.wayfix.WayFix; |
14 | 8 |
|
| 9 | +import org.spongepowered.asm.mixin.Dynamic; |
15 | 10 | import org.spongepowered.asm.mixin.Mixin; |
| 11 | +import org.spongepowered.asm.mixin.Unique; |
16 | 12 | import org.spongepowered.asm.mixin.injection.At; |
17 | 13 | import org.spongepowered.asm.mixin.injection.Inject; |
18 | 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
|
26 | 22 | @Mixin(Keyboard.class) |
27 | 23 | public class KeyboardMixin { |
28 | 24 |
|
29 | | - @Inject(method = "onChar", at = @At("HEAD"), cancellable = true) |
30 | | - //? if <1.21.9 { |
31 | | - private void charTyped(long window, int codePoint, int modifiers, CallbackInfo ci) { |
32 | | - //?} |
33 | | - //? if >=1.21.9 { |
34 | | - /*private void charTyped(long window, CharInput input, CallbackInfo ci) { |
35 | | - *///?} |
| 25 | + @Unique |
| 26 | + private static final int LEFT_CTRL = PlatformDependent.isOsx() ? GLFW.GLFW_KEY_LEFT_SUPER : GLFW.GLFW_KEY_LEFT_CONTROL; |
| 27 | + @Unique |
| 28 | + private static final int RIGHT_CTRL = PlatformDependent.isOsx() ? GLFW.GLFW_KEY_RIGHT_SUPER : GLFW.GLFW_KEY_RIGHT_CONTROL; |
| 29 | + |
| 30 | + @Dynamic |
| 31 | + @Inject(method = {"onChar", "method_1457"}, at = @At("HEAD"), cancellable = true, require = 1) |
| 32 | + private void charTyped(CallbackInfo ci) { |
36 | 33 | if(!WayFix.config.keyModifiersFix || !WayFix.isWayland()) return; |
37 | 34 |
|
38 | | - //? if >=1.21.9 { |
39 | | - /*if(GLFW.glfwGetKey(window, SystemKeycodes.LEFT_CTRL) == GLFW.GLFW_PRESS || |
40 | | - GLFW.glfwGetKey(window, SystemKeycodes.RIGHT_CTRL) == GLFW.GLFW_PRESS || |
| 35 | + long window = MinecraftClient.getInstance().getWindow().getHandle(); |
| 36 | + if(GLFW.glfwGetKey(window, LEFT_CTRL) == GLFW.GLFW_PRESS || |
| 37 | + GLFW.glfwGetKey(window, RIGHT_CTRL) == GLFW.GLFW_PRESS || |
41 | 38 | GLFW.glfwGetKey(window, GLFW.GLFW_KEY_LEFT_ALT) == GLFW.GLFW_PRESS |
42 | | - *///?} |
43 | | - //? if <1.21.9 { |
44 | | - if( |
45 | | - Screen.hasControlDown() || |
46 | | - InputUtil.isKeyPressed(window, GLFW.GLFW_KEY_LEFT_ALT) |
47 | | - //?} |
48 | 39 | ) { |
49 | 40 | ci.cancel(); |
50 | 41 | } |
|
0 commit comments