Split rotationspeed option to allow for separate horizontal and vertical speed configurations (controller)

This commit is contained in:
ronniedude
2022-06-29 16:55:15 -04:00
parent d2e21f8723
commit b15766dfdb
10 changed files with 39 additions and 17 deletions

View File

@@ -52,7 +52,8 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry(name = "midnightcontrols.menu.invert_right_y_axis") public static boolean invertRightYAxis = false;
@Entry(name = "midnightcontrols.menu.invert_right_x_axis") public static boolean invertRightXAxis = false;
public static double DEFAULT_MAX_VALUE = 1;
@Entry(name = "midnightcontrols.menu.right_dead_zone") public static double rotationSpeed = 40.0;
@Entry(name = "midnightcontrols.menu.rotation_speed") public static double rotationSpeed = 40.0; //used for x axis, name kept for compatability
@Entry(name = "midnightcontrols.menu.y_axis_rotation_speed") public static double yAxisRotationSpeed = 40.0;
@Entry(name = "midnightcontrols.menu.mouse_speed") public static double mouseSpeed = 25.0;
@Entry(name = "midnightcontrols.menu.unfocused_input") public static boolean unfocusedInput = false;
@Entry(name = "midnightcontrols.menu.virtual_mouse") public static boolean virtualMouse = false;
@@ -274,6 +275,7 @@ public class MidnightControlsConfig extends MidnightConfig {
invertRightXAxis = false;
DEFAULT_MAX_VALUE = 1;
rotationSpeed = 40.0;
yAxisRotationSpeed = 40.0;
mouseSpeed = 25.0;
unfocusedInput = false;
virtualMouse = false;

View File

@@ -637,9 +637,9 @@ public class MidnightInput {
double powValue = Math.pow(value, 2.0);
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_Y) {
if (state == 2) {
this.targetPitch = -MidnightControlsConfig.getRightYAxisSign() * (MidnightControlsConfig.rotationSpeed * powValue) * 0.11D;
this.targetPitch = -MidnightControlsConfig.getRightYAxisSign() * (MidnightControlsConfig.yAxisRotationSpeed * powValue) * 0.11D;
} else if (state == 1) {
this.targetPitch = MidnightControlsConfig.getRightYAxisSign() * (MidnightControlsConfig.rotationSpeed * powValue) * 0.11D;
this.targetPitch = MidnightControlsConfig.getRightYAxisSign() * (MidnightControlsConfig.yAxisRotationSpeed * powValue) * 0.11D;
}
}
if (axis == GLFW_GAMEPAD_AXIS_RIGHT_X) {

View File

@@ -55,6 +55,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
private final SpruceOption inputModeOption;
private final SpruceOption autoSwitchModeOption;
private final SpruceOption rotationSpeedOption;
private final SpruceOption yAxisRotationSpeedOption;
private final SpruceOption mouseSpeedOption;
private final SpruceOption virtualMouseOption;
private final SpruceOption resetOption;
@@ -172,6 +173,10 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
() -> MidnightControlsConfig.rotationSpeed,
value -> MidnightControlsConfig.rotationSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
Text.translatable("midnightcontrols.tooltip.rotation_speed"));
this.yAxisRotationSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.y_axis_rotation_speed", 0.0, 100.0, .5f,
() -> MidnightControlsConfig.yAxisRotationSpeed,
value -> MidnightControlsConfig.yAxisRotationSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
Text.translatable("midnightcontrols.tooltip.y_axis_rotation_speed"));
this.mouseSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.mouse_speed", 0.0, 150.0, .5f,
() -> MidnightControlsConfig.mouseSpeed,
value -> MidnightControlsConfig.mouseSpeed = value, option -> option.getDisplayText(Text.literal(String.valueOf(option.get()))),
@@ -300,6 +305,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
list.addSingleOptionEntry(this.inputModeOption);
list.addSingleOptionEntry(this.autoSwitchModeOption);
list.addSingleOptionEntry(this.rotationSpeedOption);
list.addSingleOptionEntry(this.yAxisRotationSpeedOption);
list.addSingleOptionEntry(this.mouseSpeedOption);
list.addSingleOptionEntry(this.virtualMouseOption);
return list;