1
0
forked from Clones/Controlify

✏️ Modify vmouse so that controls feel "less square" + apply a harsher easing function (quad -> cubic)

This commit is contained in:
isXander
2023-10-30 19:33:38 +00:00
parent 675bceff18
commit 8529fa8a08
4 changed files with 40 additions and 19 deletions

View File

@ -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;