mirror of
https://github.com/TeamMidnightDust/MidnightControls.git
synced 2025-12-13 07:15:10 +01:00
First Beta for 1.10.0!
- Separate movement and camera joysticks to fix boat movement (again) - Fixed crashes with various mods - Compatibility for Sodium 0.6.0 - Updated MidnightLib to 1.6.1
This commit is contained in:
@@ -37,7 +37,7 @@ dependencies {
|
||||
// Compatibility mods
|
||||
modCompileOnlyApi "io.github.cottonmc:LibGui:${project.libgui_version}"
|
||||
modCompileOnlyApi "org.quiltmc:quilt-json5:1.0.0"
|
||||
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}"
|
||||
modImplementation "maven.modrinth:sodium:${project.sodium_version}-fabric"
|
||||
modCompileOnlyApi "maven.modrinth:emi:${project.emi_version}"
|
||||
modCompileOnlyApi "maven.modrinth:emotecraft:${project.emotecraft_version}"
|
||||
modCompileOnlyApi "io.github.kosmx:bendy-lib:${project.bendylib_version}"
|
||||
|
||||
@@ -88,7 +88,7 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
public void run() { // TODO: Add a try/catch here after the alpha testing period
|
||||
if (lateInitDone && client.isRunning()) {
|
||||
input.tickJoysticks();
|
||||
input.tickCameraStick();
|
||||
input.updateCamera();
|
||||
}
|
||||
}
|
||||
@@ -145,11 +145,11 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
if (!keyBinding.getTranslationKey().contains(MidnightControlsConstants.NAMESPACE)) {
|
||||
AtomicReference<ButtonCategory> category = new AtomicReference<>();
|
||||
InputManager.streamCategories().forEach(buttonCategory -> {
|
||||
if (buttonCategory.getIdentifier().equals(Identifier.ofVanilla(keyBinding.getCategory())))
|
||||
if (buttonCategory.getIdentifier().equals(validVanillaId(keyBinding.getCategory())))
|
||||
category.set(buttonCategory);
|
||||
});
|
||||
if (category.get() == null) {
|
||||
category.set(new ButtonCategory(Identifier.ofVanilla(keyBinding.getCategory())));
|
||||
category.set(new ButtonCategory(validVanillaId(keyBinding.getCategory())));
|
||||
InputManager.registerCategory(category.get());
|
||||
}
|
||||
ButtonBinding buttonBinding = new ButtonBinding.Builder(keyBinding.getTranslationKey()).category(category.get()).linkKeybind(keyBinding).register();
|
||||
@@ -163,6 +163,14 @@ public class MidnightControlsClient extends MidnightControls {
|
||||
InputManager.loadButtonBindings();
|
||||
lateInitDone = true;
|
||||
}
|
||||
private static Identifier validVanillaId(String path) {
|
||||
for(int i = 0; i < path.length(); ++i) {
|
||||
if (!Identifier.isPathCharacterValid(path.charAt(i))) {
|
||||
path = path.replace(path.charAt(i), '_');
|
||||
}
|
||||
}
|
||||
return Identifier.ofVanilla(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called every Minecraft tick.
|
||||
|
||||
@@ -112,11 +112,10 @@ public class MidnightControlsConfig extends MidnightConfig {
|
||||
@Entry @Hidden public static Map<String, String> BINDING = new HashMap<>();
|
||||
|
||||
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
|
||||
@Deprecated @Hidden @Entry public static double[] maxAnalogValues = new double[]{1, 1, 1, 1};
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = maxAnalogValues[0];
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = maxAnalogValues[1];
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = maxAnalogValues[2];
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = maxAnalogValues[3];
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Left X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftX = 1;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Left Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueLeftY = 1;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Right X", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightX = 1;
|
||||
@Entry(category = CONTROLLER, name = "Max analog value: Right Y", isSlider = true, min = .25f, max = 1.f) public static double maxAnalogValueRightY = 1;
|
||||
@Entry(category = CONTROLLER, name = "Trigger button fix") public static boolean triggerFix = true;
|
||||
@Entry(category = CONTROLLER, name = "Excluded Controllers (Name Regex)") public static List<String> excludedControllers = Lists.newArrayList(".*(Keyboard)$", ".*(Touchpad)$", ".*(Pen)$", ".*(Finger)$");
|
||||
@Entry(category = MISC, name = "Excluded Keybindings") public static List<String> excludedKeybindings = Lists.newArrayList("key.forward", "key.left", "key.back", "key.right", "key.jump", "key.sneak", "key.sprint", "key.inventory",
|
||||
|
||||
@@ -144,12 +144,14 @@ public class MidnightInput {
|
||||
var state = controller.getState();
|
||||
this.fetchButtonInput(state, false);
|
||||
this.fetchTriggerInput(state, false);
|
||||
this.fetchJoystickInput(state, false, false);
|
||||
}
|
||||
MidnightControlsConfig.getSecondController().filter(Controller::isConnected)
|
||||
.ifPresent(joycon -> {
|
||||
var state = joycon.getState();
|
||||
this.fetchButtonInput(state, true);
|
||||
this.fetchTriggerInput(state, true);
|
||||
this.fetchJoystickInput(state, true, false);
|
||||
});
|
||||
|
||||
boolean allowInput = this.controlsInput == null || this.controlsInput.focusedBinding == null;
|
||||
@@ -177,18 +179,16 @@ public class MidnightInput {
|
||||
this.inventoryInteractionCooldown--;
|
||||
}
|
||||
/**
|
||||
* This method is called 1000 times a second for smooth joystick input
|
||||
* This method is called 1000 times a second for smooth camera input
|
||||
*/
|
||||
public void tickJoysticks() {
|
||||
public void tickCameraStick() {
|
||||
var controller = MidnightControlsConfig.getController();
|
||||
|
||||
if (controller.isConnected()) {
|
||||
this.fetchJoystickInput(controller.getState(), false);
|
||||
this.fetchJoystickInput(controller.getState(), false, true);
|
||||
}
|
||||
MidnightControlsConfig.getSecondController().filter(Controller::isConnected)
|
||||
.ifPresent(joycon -> {
|
||||
this.fetchJoystickInput(joycon.getState(), true);
|
||||
});
|
||||
.ifPresent(joycon -> this.fetchJoystickInput(joycon.getState(), true, true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +278,7 @@ public class MidnightInput {
|
||||
}
|
||||
final MathUtil.PolarUtil polarUtil = new MathUtil.PolarUtil();
|
||||
|
||||
private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean leftJoycon) {
|
||||
private void fetchJoystickInput(@NotNull GLFWGamepadState gamepadState, boolean leftJoycon, boolean cameraTick) {
|
||||
var buffer = gamepadState.axes();
|
||||
|
||||
polarUtil.calculate(buffer.get(GLFW_GAMEPAD_AXIS_LEFT_X), buffer.get(GLFW_GAMEPAD_AXIS_LEFT_Y), 1, MidnightControlsConfig.leftDeadZone);
|
||||
@@ -291,7 +291,7 @@ public class MidnightInput {
|
||||
boolean isRadialMenu = client.currentScreen instanceof RingScreen || (PlatformFunctions.isModLoaded("emotecraft") && EmotecraftCompat.isEmotecraftScreen(client.currentScreen));
|
||||
|
||||
if (!isRadialMenu) {
|
||||
for (int i = 0; i < GLFW_GAMEPAD_AXIS_LEFT_TRIGGER; i++) {
|
||||
for (int i = cameraTick ? GLFW_GAMEPAD_AXIS_RIGHT_X : 0; i < (cameraTick ? GLFW_GAMEPAD_AXIS_LEFT_TRIGGER : GLFW_GAMEPAD_AXIS_RIGHT_X); i++) {
|
||||
int axis = leftJoycon ? ButtonBinding.controller2Button(i) : i;
|
||||
float value = buffer.get(i);
|
||||
|
||||
@@ -503,21 +503,22 @@ public class MidnightInput {
|
||||
axisValue /= (float) (1.0 - storage.deadZone);
|
||||
axisValue *= (float) storage.deadZone;
|
||||
}
|
||||
|
||||
axisValue = (float) Math.min(axisValue / MidnightControlsConfig.getAxisMaxValue(storage.axis), 1);
|
||||
if (AxisStorage.isLeftAxis(storage.axis)) MidnightControlsCompat.handleMovement(storage, axisValue);
|
||||
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
|
||||
InputManager.BUTTON_VALUES.put(ButtonBinding.axisAsButton(storage.axis, false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
|
||||
InputManager.BUTTON_VALUES.put(storage.getButtonId(true), storage.polarity == AxisStorage.Polarity.PLUS ? axisValue : 0.f);
|
||||
InputManager.BUTTON_VALUES.put(storage.getButtonId(false), storage.polarity == AxisStorage.Polarity.MINUS ? axisValue : 0.f);
|
||||
storage.absValue = axisValue;
|
||||
}
|
||||
|
||||
private boolean handleScreenScrolling(Screen screen, AxisStorage storage) {
|
||||
if (screen == null) return false;
|
||||
// @TODO allow rebinding to left stick
|
||||
int preferredAxis = true ? GLFW_GAMEPAD_AXIS_RIGHT_Y : GLFW_GAMEPAD_AXIS_LEFT_Y;
|
||||
|
||||
if (this.controlsInput != null && this.controlsInput.focusedBinding != null) {
|
||||
if (storage.buttonState != ButtonState.NONE && !this.controlsInput.currentButtons.contains(ButtonBinding.axisAsButton(storage.axis, storage.buttonState == ButtonState.PRESS))) {
|
||||
if (storage.buttonState != ButtonState.NONE && !this.controlsInput.currentButtons.contains(storage.getButtonId(storage.buttonState == ButtonState.PRESS))) {
|
||||
|
||||
this.controlsInput.currentButtons.add(ButtonBinding.axisAsButton(storage.axis, storage.buttonState == ButtonState.PRESS));
|
||||
this.controlsInput.currentButtons.add(storage.getButtonId(storage.buttonState == ButtonState.PRESS));
|
||||
|
||||
int[] buttons = new int[this.controlsInput.currentButtons.size()];
|
||||
for (int i = 0; i < this.controlsInput.currentButtons.size(); i++)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package eu.midnightdust.midnightcontrols.client.compat;
|
||||
|
||||
import eu.midnightdust.midnightcontrols.client.compat.mixin.sodium.SodiumOptionsGUIAccessor;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
public class SodiumCompat implements CompatHandler {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package eu.midnightdust.midnightcontrols.client.compat.mixin.sodium;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
|
||||
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionPage;
|
||||
import net.caffeinemc.mods.sodium.client.gui.options.control.ControlElement;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
|
||||
@@ -58,10 +58,19 @@ public class AxisStorage {
|
||||
}
|
||||
this.polarity = currentPlusState ? AxisStorage.Polarity.PLUS : currentMinusState ? AxisStorage.Polarity.MINUS : AxisStorage.Polarity.ZERO;
|
||||
}
|
||||
/**
|
||||
* Returns the specified axis as a button.
|
||||
*
|
||||
* @param positive true if the axis part is positive, else false
|
||||
* @return the axis as a button
|
||||
*/
|
||||
public int getButtonId(boolean positive) {
|
||||
return ButtonBinding.axisAsButton(axis, positive);
|
||||
}
|
||||
|
||||
public void setupButtonStates() {
|
||||
var posButton = ButtonBinding.axisAsButton(axis, true);
|
||||
var negButton = ButtonBinding.axisAsButton(axis, false);
|
||||
var posButton = getButtonId(true);
|
||||
var negButton = getButtonId(false);
|
||||
var previousPlusState = STATES.getOrDefault(posButton, ButtonState.NONE);
|
||||
var previousMinusState = STATES.getOrDefault(negButton, ButtonState.NONE);
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
},
|
||||
"breaks": {
|
||||
"lambdacontrols": "*",
|
||||
"modmenu": "<1.12.2"
|
||||
"modmenu": "<1.12.2",
|
||||
"sodium": "<0.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ yarn_mappings=1.21+build.2
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
||||
archives_base_name=midnightcontrols
|
||||
mod_version=1.10.0-alpha.1
|
||||
mod_version=1.10.0-beta.1
|
||||
maven_group=eu.midnightdust
|
||||
release_type=release
|
||||
modrinth_id = bXX9h73M
|
||||
curseforge_id = 621768
|
||||
# Configure the IDs here after creating the projects on the websites
|
||||
|
||||
midnightlib_version=1.5.7
|
||||
midnightlib_version=1.6.1
|
||||
|
||||
fabric_loader_version=0.15.11
|
||||
fabric_api_version=0.100.1+1.21
|
||||
@@ -25,7 +25,7 @@ yarn_mappings_patch_neoforge_version = 1.21+build.4
|
||||
quilt_loader_version=0.19.0-beta.18
|
||||
quilt_fabric_api_version=7.0.1+0.83.0-1.20
|
||||
|
||||
sodium_version=mc1.21-0.5.11
|
||||
sodium_version=mc1.21-0.6.0-beta.1
|
||||
obsidianui_version=0.2.7+mc1.21
|
||||
modmenu_version=10.0.0-beta.1
|
||||
emotecraft_version=2.1.3-SNAPSHOT-build.29-MC1.19-fabric
|
||||
|
||||
Reference in New Issue
Block a user