Legacy4J

Legacy4J

192k Downloads

Deadzone Implementation Issues

CrazyCritic89 opened this issue ยท 2 comments

commented

Hi there!

I recently found out about this mod and have been loving it, but there's one small problem which I surprisingly don't see brought up.

Small analog movements, especially when moving up and trying to go slightly to the left or right.

To explain more, this is a (bad) visual of what a normal deadzone looks like:
deadzonegood
A red area where no movements are picked up to accommodate for the inaccuracies of potentiometers.

Now this is how it's like in legacy4j (exaggerated a bit):
deadzonebad
Because of how it's implemented, the x and y axis get separate deadzones, causing them to stretch out.

This especially causes an issue when the stick is like this:
deadzonemove
The small movement to the left ends up not getting picked up, and, to me, this feels really jarring when moving around.

I can confirm too that the legacy editions don't have this issue! It's just the way this mod does it that causes problems.

I've taken the liberty of tracking down the code responsible.

In BindingState.java with getSmoothX() and getSmoothY() (deadzones the axes separately).

In KeyboardControllerInputMixin.java. This is a weird one because it contributes even more to the problem. On lines 18 and 23, it first checks if the left stick is being pressed in the corresponding direction. This has a deadzone of it's own of 0.5 (which can be found in ControllerBinding.java). This means that the deadzone for movement is always 0.5!
I'm not entirely too sure why this is done though. It's a conditional operator meaning if that check fails, it passes "value" instead. Maybe this is done so normal WASD movement doesn't get affected? This is my first time doing something with Minecraft so if I could get an answer to this that'd help.

I'm currently trying to fix this myself, but I'm not too sure what I should or shouldn't change. I don't wanna make a pull request for some shitty code lol. So if I could get a little help to where to point myself towards, I'd be grateful.

commented

Okay, I did some testing, and my theory was right. "value" is used for the standard WASD movement, so it needs to be passed if not using the stick.

Currently I changed it so that instead of checking using the pressed function, it just checks if getSmooth() returns greater than 0. Seems to work fine.

commented

Fixed in version 1.6.4, thanks for reporting.