diff --git a/src/main/java/net/silentclient/client/mixin/mixins/lwjgl/WindowsDisplayMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/lwjgl/WindowsDisplayMixin.java new file mode 100644 index 0000000..8fe3e59 --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/mixins/lwjgl/WindowsDisplayMixin.java @@ -0,0 +1,26 @@ +package net.silentclient.client.mixin.mixins.lwjgl; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(targets = "org.lwjgl.opengl.WindowsDisplay") +public abstract class WindowsDisplayMixin { + @Inject(method = "doHandleMessage", at = @At("HEAD"), cancellable = true, remap = false) + private void doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis, + CallbackInfoReturnable callback) { + if (msg == 0x020B) { + if ((wParam >> 16) == 1L) { + handleMouseButton(3, 1, millis); + } else { + handleMouseButton(4, 1, millis); + } + callback.setReturnValue(1L); + } + } + + @Shadow + protected abstract void handleMouseButton(int button, int state, long millis); +} diff --git a/src/main/resources/mixins.SilentClient.json b/src/main/resources/mixins.SilentClient.json index fe44662..7daedea 100644 --- a/src/main/resources/mixins.SilentClient.json +++ b/src/main/resources/mixins.SilentClient.json @@ -119,6 +119,7 @@ "mixins.WorldClientMixin", "mixins.WorldInfoMixin", "mixins.WorldMixin", - "mixins.WorldRendererMixin" + "mixins.WorldRendererMixin", + "mixins.lwjgl.WindowsDisplayMixin" ] } \ No newline at end of file