Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't scroll while holding SHIFT on macOS #90

Closed
unilock opened this issue Nov 8, 2023 · 3 comments
Closed

Can't scroll while holding SHIFT on macOS #90

unilock opened this issue Nov 8, 2023 · 3 comments

Comments

@unilock
Copy link
Contributor

unilock commented Nov 8, 2023

On macOS, while holding the SHIFT key, scrolling using the mouse wheel does not work anywhere in-game. This is most notable when attempting to scroll through hotbar slots.

This does not affect 1.7.10 without LWJGL3ify.
See MC-121772.

(as a side note, lwjgl3ify is surprisingly not affected by MC-59810)

Versions:

  • Minecraft 1.7.10
  • Forge 10.13.4.1614
  • LWJGL 3.3.2
  • LWJGL3ify 1.5.2
@bombcar
Copy link
Member

bombcar commented Nov 8, 2023

Confirmed that the shift key issue occurs on 2.4.1

@unilock
Copy link
Contributor Author

unilock commented Nov 17, 2023

I suspect the issue is here:

Window.scrollCallback = new GLFWScrollCallback() {
@Override
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);
}
};

Holding SHIFT while scrolling on macOS usually enables "horizontal scrolling", which I assume would mean here that the xoffset parameter would be set instead of the yoffset parameter. However, it seems the former is completely ignored by LWJGL3ify.

Minecraft itself had this issue until 1.20.2; I wonder what their fix was?

@unilock
Copy link
Contributor Author

unilock commented Nov 19, 2023

Minecraft itself had this issue until 1.20.2; I wonder what their fix was?

net.minecraft.client.MouseHandler

(Yarn mappings)

private void onScroll(long l, double d, double e) {
    if (l == Minecraft.getInstance().getWindow().getWindow()) {
        boolean bl = this.minecraft.options.discreteMouseScroll().get();
        double f = this.minecraft.options.mouseWheelSensitivity().get();
        double g = (bl ? Math.signum(d) : d) * f;
        double h = (bl ? Math.signum(e) : e) * f;
        if (this.minecraft.getOverlay() == null) {
            if (this.minecraft.screen != null) {
                double i = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth();
                double j = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getScreenHeight();
                this.minecraft.screen.mouseScrolled(i, j, g, h);
                this.minecraft.screen.afterMouseAction();
            } else if (this.minecraft.player != null) {
                if (this.accumulatedScrollX != 0.0 && Math.signum(g) != Math.signum(this.accumulatedScrollX)) {
                    this.accumulatedScrollX = 0.0;
                }

                if (this.accumulatedScrollY != 0.0 && Math.signum(h) != Math.signum(this.accumulatedScrollY)) {
                    this.accumulatedScrollY = 0.0;
                }

                this.accumulatedScrollX += g;
                this.accumulatedScrollY += h;
                int k = (int)this.accumulatedScrollX;
                int m = (int)this.accumulatedScrollY;
                if (k == 0 && m == 0) {
                    return;
                }

                this.accumulatedScrollX -= (double)k;
                this.accumulatedScrollY -= (double)m;
                int n = m == 0 ? -k : m;
                if (this.minecraft.player.isSpectator()) {
                    if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
                        this.minecraft.gui.getSpectatorGui().onMouseScrolled(-n);
                    } else {
                        float o = Mth.clamp(this.minecraft.player.getAbilities().getFlyingSpeed() + (float)m * 0.005F, 0.0F, 0.2F);
                        this.minecraft.player.getAbilities().setFlyingSpeed(o);
                    }
                } else {
                    this.minecraft.player.getInventory().swapPaint((double)n);
                }
            }
        }
    }
}

I guess that would translate to simply Mouse.addWheelEvent(yoffset == 0 ? -xoffset : yoffset); in this case.

Note that this would reverse hotbar scrolling while holding SHIFT (instead of breaking it completely), which is what vanilla Minecraft 1.20.2 does as well.
Unless there were an option to toggle this behavior (a la MacOS Input Fixes), I personally would prefer leaving out the inversion of xoffset, making scrolling work in the same direction regardless of SHIFT being held.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants