Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit f402897

Browse files
committed
(1.8.9) "fix" raw mouse input option
- by delegating to glfw since we now depend on it anyway
1 parent 6ed63c2 commit f402897

File tree

5 files changed

+85
-30
lines changed

5 files changed

+85
-30
lines changed

1.8.9/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ dependencies {
5858
implementation(include("org.slf4j:slf4j-api:1.7.36")!!)
5959
localRuntime("org.slf4j:slf4j-jdk14:1.7.36")
6060

61+
compileOnly("org.lwjgl:lwjgl-glfw:${lwjglVersion}")
62+
6163
modCompileOnly("io.github.moehreag:legacy-lwjgl3:${project.property("legacy_lwgjl3")}") {
6264
exclude(group = "org.lwjgl", module = "lwjgl-glfw")
6365
exclude(group = "org.lwjgl", module = "lwjgl-openal")
@@ -105,7 +107,10 @@ tasks.processResources {
105107
}
106108

107109
tasks.runClient {
108-
jvmArgs("-Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient")
110+
if (project.property("native_glfw") == "true") {
111+
val glfwPath = project.properties.getOrDefault("native_glfw_path", "/usr/lib/libglfw.so")
112+
jvmArgs("-Dorg.lwjgl.glfw.libname=$glfwPath")
113+
}
109114
classpath(sourceSets.getByName("test").runtimeClasspath)
110115
}
111116

1.8.9/src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@
3434
import io.github.axolotlclient.AxolotlClientConfig.impl.options.*;
3535
import io.github.axolotlclient.CommonOptions;
3636
import io.github.axolotlclient.config.screen.CreditsScreen;
37+
import io.github.axolotlclient.modules.Module;
38+
import io.github.axolotlclient.util.GLFWUtil;
3739
import io.github.axolotlclient.util.options.ForceableBooleanOption;
3840
import io.github.axolotlclient.util.options.GenericOption;
3941
import lombok.Getter;
4042
import net.minecraft.client.Minecraft;
43+
import org.lwjgl.glfw.GLFW;
4144

4245
public class AxolotlClientConfig {
4346

@@ -65,7 +68,8 @@ public class AxolotlClientConfig {
6568

6669
public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(-1));
6770
public final BooleanOption nightMode = new BooleanOption("nightMode", false);
68-
public final BooleanOption rawMouseInput = new BooleanOption("rawMouseInput", false);
71+
public final BooleanOption rawMouseInput = new BooleanOption("rawMouseInput", false, v ->
72+
GLFWUtil.runUsingGlfwHandle(h -> GLFW.glfwSetInputMode(h, GLFW.GLFW_RAW_MOUSE_MOTION, v ? 1 : 0)));
6973

7074
public final BooleanOption enableCustomOutlines = new BooleanOption("enabled", false);
7175
public final ColorOption outlineColor = new ColorOption("color", Color.parse("#DD000000"));
@@ -116,6 +120,12 @@ public void init() {
116120
general.add(nightMode);
117121
general.add(customWindowTitle);
118122
general.add(rawMouseInput);
123+
AxolotlClient.modules.add(new Module() {
124+
@Override
125+
public void lateInit() {
126+
GLFWUtil.runUsingGlfwHandle(h -> GLFW.glfwSetInputMode(h, GLFW.GLFW_RAW_MOUSE_MOTION, rawMouseInput.get() ? 1 : 0));
127+
}
128+
});
119129
general.add(openCredits);
120130
general.add(debugLogOutput);
121131
general.add(CommonOptions.datetimeFormat);

1.8.9/src/main/java/io/github/axolotlclient/mixin/GameRendererMixin.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import net.minecraft.block.material.Material;
4444
import net.minecraft.client.Minecraft;
4545
import net.minecraft.client.entity.living.player.LocalClientPlayerEntity;
46-
import net.minecraft.client.input.MouseInput;
4746
import net.minecraft.client.options.GameOptions;
4847
import net.minecraft.client.render.Camera;
4948
import net.minecraft.client.render.GameRenderer;
@@ -58,7 +57,6 @@
5857
import org.objectweb.asm.Opcodes;
5958
import org.spongepowered.asm.mixin.Mixin;
6059
import org.spongepowered.asm.mixin.Shadow;
61-
import org.spongepowered.asm.mixin.Unique;
6260
import org.spongepowered.asm.mixin.injection.At;
6361
import org.spongepowered.asm.mixin.injection.At.Shift;
6462
import org.spongepowered.asm.mixin.injection.Inject;
@@ -82,37 +80,12 @@ public abstract class GameRendererMixin {
8280
private float fogBlue;
8381
@Shadow
8482
private boolean thiccFog;
85-
@Unique
86-
private float cachedMouseFactor;
8783
@Shadow
8884
private boolean debugCamera;
8985

9086
@Shadow
9187
protected abstract FloatBuffer setFogColor(float par1, float par2, float par3, float par4);
9288

93-
@Inject(method = "render(FJ)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/MouseInput;dx:I"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
94-
public void axolotlclient$rawMouseInput(float tickDelta, long nanoTime, CallbackInfo ci, boolean displayActive, float f,
95-
float g) {
96-
if (AxolotlClient.CONFIG.rawMouseInput.get()) {
97-
cachedMouseFactor = g;
98-
}
99-
}
100-
101-
@Redirect(method = "render(FJ)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/MouseInput;dx:I"))
102-
public int axolotlclient$rawMouseX(MouseInput instance) {
103-
if (AxolotlClient.CONFIG.rawMouseInput.get()) {
104-
return (int) (instance.dx / cachedMouseFactor * minecraft.options.mouseSensitivity);
105-
}
106-
return instance.dx;
107-
}
108-
109-
@Redirect(method = "render(FJ)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/MouseInput;dy:I"))
110-
public int axolotlclient$rawMouseY(MouseInput instance) {
111-
if (AxolotlClient.CONFIG.rawMouseInput.get()) {
112-
return (int) (instance.dy / cachedMouseFactor * minecraft.options.mouseSensitivity);
113-
}
114-
return instance.dy;
115-
}
11689

11790
@Inject(method = "renderFog", at = @At("HEAD"), cancellable = true)
11891
public void axolotlclient$noFog(int i, float tickDelta, CallbackInfo ci) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright © 2025 moehreag <[email protected]> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.util;
24+
25+
import java.lang.invoke.MethodHandle;
26+
import java.lang.invoke.MethodHandles;
27+
import java.lang.invoke.MethodType;
28+
import java.util.function.Consumer;
29+
30+
import org.lwjgl.opengl.Display;
31+
32+
public class GLFWUtil {
33+
34+
private static MethodHandle getHandle;
35+
36+
static {
37+
try {
38+
getHandle = MethodHandles.lookup().findVirtual(Display.class, "getHandle", MethodType.methodType(Long.class));
39+
} catch (Throwable ignored) {
40+
}
41+
}
42+
43+
private static long windowHandle = -1;
44+
45+
public static long getWindowHandle(){
46+
if (windowHandle == -1){
47+
48+
try {
49+
windowHandle = (long) getHandle.invoke();
50+
} catch (Throwable ignored) {
51+
}
52+
}
53+
return windowHandle;
54+
}
55+
56+
// Since the reflection used for this only works with legacy-lwjgl3 it's possible for us not being able to access the window handle.
57+
// This however should not lead to a crash despite compiling against glfw.
58+
public static boolean isHandleAvailable() {
59+
return getWindowHandle() != -1;
60+
}
61+
62+
public static void runUsingGlfwHandle(Consumer<Long> action) {
63+
if (isHandleAvailable()) {
64+
action.accept(getWindowHandle());
65+
}
66+
}
67+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=true
66
axolotlclient.modules.all=true
77

88
# Mod Properties
9-
version=3.1.1-rc.9
9+
version=3.1.1-rc.10
1010

1111
maven_group=io.github.axolotlclient
1212

0 commit comments

Comments
 (0)