Skip to content

Commit

Permalink
Fix for horizontal scrolling (#96)
Browse files Browse the repository at this point in the history
* Account for horizontal mouse wheel scrolling

Display$Window#scrollCallback: when the vertical scrolling offset (yoffset) is 0, pass the horizontal scrolling offset (xoffset) to Mouse#addWheelEvent instead

Fixes #90

Signed-off-by: unilock <[email protected]>

* Allow inverting horizontal scrolling via config

Respects "invertScrollWheel", in that horizontal scrolling will be double-inverted if both config options are enabled. (thus: not inverted)

Disabled by default.

(Technically, when horizontal scrolling was fixed in Minecraft 1.20.2, it was made to be inverted by default.)

(However, all mods that implemented the same fix before Mojang did (EmuNO, MacOS Input Fixes, McMouser, etc.) do *not* invert horizontal scrolling by default - LWJGL3ify follows this standard.)

Signed-off-by: unilock <[email protected]>

* SPOTLESS...

Signed-off-by: unilock <[email protected]>

---------

Signed-off-by: unilock <[email protected]>
  • Loading branch information
unilock authored Nov 26, 2023
1 parent c218cb0 commit ecdd15f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/java/me/eigenraven/lwjgl3ify/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class Config {
public static boolean OPENGL_CONTEXT_NO_ERROR = false;

public static boolean INPUT_INVERT_WHEEL = false;
public static boolean INPUT_INVERT_X_WHEEL = false;
public static double INPUT_SCROLL_SPEED = 1.0;

public static String X11_CLASS_NAME = "minecraft";
Expand Down Expand Up @@ -182,6 +183,11 @@ public static void reloadConfigObject() {

INPUT_INVERT_WHEEL = config
.getBoolean("invertScrollWheel", CATEGORY_INPUT, INPUT_INVERT_WHEEL, "Invert scrolling direction");
INPUT_INVERT_X_WHEEL = config.getBoolean(
"invertHorizontalScroll",
CATEGORY_INPUT,
INPUT_INVERT_X_WHEEL,
"Invert horizontal scrolling direction (respects invertScrollWheel)");
INPUT_SCROLL_SPEED = (double) config.getFloat(
"scrollSpeedMultiplier",
CATEGORY_INPUT,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/lwjglx/opengl/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void invoke(long window, double xoffset, double yoffset) {
if (Config.DEBUG_PRINT_MOUSE_EVENTS) {
Lwjgl3ify.LOG.info("[DEBUG-MOUSE] wheel window:{} xoffset:{} yoffset:{}", window, xoffset, yoffset);
}
Mouse.addWheelEvent(yoffset);
Mouse.addWheelEvent(yoffset == 0 ? (Config.INPUT_INVERT_X_WHEEL ? -xoffset : xoffset) : yoffset);
}
};

Expand Down

0 comments on commit ecdd15f

Please sign in to comment.