forked from Clones/Controlify
✏️ Modify vmouse so that controls feel "less square" + apply a harsher easing function (quad -> cubic)
This commit is contained in:
@ -6,9 +6,11 @@ import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||
import dev.isxander.controlify.hid.ControllerHIDService;
|
||||
import dev.isxander.controlify.hid.HIDDevice;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.joml.Vector2f;
|
||||
|
||||
import java.util.HexFormat;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ControllerUtils {
|
||||
public static String createControllerString(Controller<?, ?> controller) {
|
||||
@ -38,6 +40,16 @@ public class ControllerUtils {
|
||||
return (float) (y * Math.sqrt(1 - (x * x) / 2));
|
||||
}
|
||||
|
||||
public static Vector2f applyEasingToLength(float x, float y, Function<Float, Float> easing) {
|
||||
float length = Mth.sqrt(x * x + y * y);
|
||||
float easedLength = easing.apply(length);
|
||||
float angle = (float) Mth.atan2(y, x);
|
||||
return new Vector2f(
|
||||
Mth.cos(angle) * easedLength,
|
||||
Mth.sin(angle) * easedLength
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean shouldApplyAntiSnapBack(float x, float y, float px, float py, float threshold) {
|
||||
float dx = x - px;
|
||||
float dy = y - py;
|
||||
|
Reference in New Issue
Block a user