forked from Clones/Controlify
fix vibration category not appearing if screen is opened via keyboard
This commit is contained in:
@ -216,9 +216,7 @@ public class YACLHelper {
|
|||||||
.build());
|
.build());
|
||||||
category.group(basicGroup.build());
|
category.group(basicGroup.build());
|
||||||
|
|
||||||
if (controller.canRumble()) {
|
category.group(makeVibrationGroup(globalVibrationOption, controller));
|
||||||
category.group(makeVibrationGroup(globalVibrationOption, config, def));
|
|
||||||
}
|
|
||||||
|
|
||||||
category.group(makeGyroGroup(controller));
|
category.group(makeGyroGroup(controller));
|
||||||
|
|
||||||
@ -241,24 +239,6 @@ public class YACLHelper {
|
|||||||
.tooltip(Component.translatable("controlify.gui.button_activation_threshold.tooltip"))
|
.tooltip(Component.translatable("controlify.gui.button_activation_threshold.tooltip"))
|
||||||
.binding(def.buttonActivationThreshold, () -> config.buttonActivationThreshold, v -> config.buttonActivationThreshold = v)
|
.binding(def.buttonActivationThreshold, () -> config.buttonActivationThreshold, v -> config.buttonActivationThreshold = v)
|
||||||
.controller(opt -> new FloatSliderController(opt, 0, 1, 0.05f, v -> Component.literal(String.format("%.0f%%", v*100))))
|
.controller(opt -> new FloatSliderController(opt, 0, 1, 0.05f, v -> Component.literal(String.format("%.0f%%", v*100))))
|
||||||
.build())
|
|
||||||
.option(ButtonOption.createBuilder()
|
|
||||||
.name(Component.translatable("controlify.gui.test_vibration"))
|
|
||||||
.tooltip(Component.translatable("controlify.gui.test_vibration.tooltip"))
|
|
||||||
.controller(ActionController::new)
|
|
||||||
.action((screen, btn) -> {
|
|
||||||
controller.rumbleManager().play(
|
|
||||||
RumbleSource.MASTER,
|
|
||||||
BasicRumbleEffect.byTime(t -> new RumbleState(0f, t), 20)
|
|
||||||
.join(BasicRumbleEffect.byTime(t -> new RumbleState(0f, 1 - t), 20))
|
|
||||||
.repeat(3)
|
|
||||||
.join(BasicRumbleEffect.constant(1f, 0f, 5)
|
|
||||||
.join(BasicRumbleEffect.constant(0f, 1f, 5))
|
|
||||||
.repeat(10)
|
|
||||||
)
|
|
||||||
.earlyFinish(BasicRumbleEffect.finishOnScreenChange())
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
category.group(advancedGroup.build());
|
category.group(advancedGroup.build());
|
||||||
@ -275,17 +255,23 @@ public class YACLHelper {
|
|||||||
return category.build();
|
return category.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OptionGroup makeVibrationGroup(Option<Boolean> globalVibrationOption, ControllerConfig config, ControllerConfig def) {
|
private static OptionGroup makeVibrationGroup(Option<Boolean> globalVibrationOption, Controller<?, ?> controller) {
|
||||||
|
boolean canRumble = controller.canRumble();
|
||||||
|
var config = controller.config();
|
||||||
|
var def = controller.defaultConfig();
|
||||||
|
|
||||||
var vibrationGroup = OptionGroup.createBuilder()
|
var vibrationGroup = OptionGroup.createBuilder()
|
||||||
.name(Component.translatable("controlify.gui.group.vibration"))
|
.name(Component.translatable("controlify.gui.group.vibration"))
|
||||||
.tooltip(Component.translatable("controlify.gui.group.vibration.tooltip"));
|
.tooltip(Component.translatable("controlify.gui.group.vibration.tooltip"))
|
||||||
|
.collapsed(!canRumble);
|
||||||
List<Option<Float>> strengthOptions = new ArrayList<>();
|
List<Option<Float>> strengthOptions = new ArrayList<>();
|
||||||
Option<Boolean> allowVibrationOption;
|
Option<Boolean> allowVibrationOption;
|
||||||
vibrationGroup.option(allowVibrationOption = Option.createBuilder(boolean.class)
|
vibrationGroup.option(allowVibrationOption = Option.createBuilder(boolean.class)
|
||||||
.name(Component.translatable("controlify.gui.allow_vibrations"))
|
.name(Component.translatable("controlify.gui.allow_vibrations"))
|
||||||
.tooltip(Component.translatable("controlify.gui.allow_vibrations.tooltip"))
|
.tooltip(Component.translatable("controlify.gui.allow_vibrations.tooltip"))
|
||||||
|
.tooltip(canRumble ? Component.empty() : Component.translatable("controlify.gui.allow_vibrations.not_available").withStyle(ChatFormatting.RED))
|
||||||
.binding(globalVibrationOption.pendingValue(), () -> config.allowVibrations && globalVibrationOption.pendingValue(), v -> config.allowVibrations = v)
|
.binding(globalVibrationOption.pendingValue(), () -> config.allowVibrations && globalVibrationOption.pendingValue(), v -> config.allowVibrations = v)
|
||||||
.available(globalVibrationOption.pendingValue())
|
.available(globalVibrationOption.pendingValue() && canRumble)
|
||||||
.listener((opt, allowVibration) -> strengthOptions.forEach(so -> so.setAvailable(allowVibration)))
|
.listener((opt, allowVibration) -> strengthOptions.forEach(so -> so.setAvailable(allowVibration)))
|
||||||
.controller(TickBoxController::new)
|
.controller(TickBoxController::new)
|
||||||
.build());
|
.build());
|
||||||
@ -293,17 +279,37 @@ public class YACLHelper {
|
|||||||
var option = Option.createBuilder(float.class)
|
var option = Option.createBuilder(float.class)
|
||||||
.name(Component.translatable("controlify.vibration_strength." + source.id().getNamespace() + "." + source.id().getPath()))
|
.name(Component.translatable("controlify.vibration_strength." + source.id().getNamespace() + "." + source.id().getPath()))
|
||||||
.tooltip(Component.translatable("controlify.vibration_strength." + source.id().getNamespace() + "." + source.id().getPath() + ".tooltip"))
|
.tooltip(Component.translatable("controlify.vibration_strength." + source.id().getNamespace() + "." + source.id().getPath() + ".tooltip"))
|
||||||
|
.tooltip(canRumble ? Component.empty() : Component.translatable("controlify.gui.allow_vibrations.not_available").withStyle(ChatFormatting.RED))
|
||||||
.binding(
|
.binding(
|
||||||
def.getRumbleStrength(source),
|
def.getRumbleStrength(source),
|
||||||
() -> config.getRumbleStrength(source),
|
() -> config.getRumbleStrength(source),
|
||||||
v -> config.setRumbleStrength(source, v)
|
v -> config.setRumbleStrength(source, v)
|
||||||
)
|
)
|
||||||
.controller(opt -> new FloatSliderController(opt, 0f, 1f, 0.05f, percentOrOffFormatter))
|
.controller(opt -> new FloatSliderController(opt, 0f, 2f, 0.05f, percentOrOffFormatter))
|
||||||
.available(allowVibrationOption.pendingValue())
|
.available(allowVibrationOption.pendingValue() && canRumble)
|
||||||
.build();
|
.build();
|
||||||
strengthOptions.add(option);
|
strengthOptions.add(option);
|
||||||
vibrationGroup.option(option);
|
vibrationGroup.option(option);
|
||||||
}
|
}
|
||||||
|
vibrationGroup.option(ButtonOption.createBuilder()
|
||||||
|
.name(Component.translatable("controlify.gui.test_vibration"))
|
||||||
|
.tooltip(Component.translatable("controlify.gui.test_vibration.tooltip"))
|
||||||
|
.controller(ActionController::new)
|
||||||
|
.action((screen, btn) -> {
|
||||||
|
controller.rumbleManager().play(
|
||||||
|
RumbleSource.MASTER,
|
||||||
|
BasicRumbleEffect.byTime(t -> new RumbleState(0f, t), 20)
|
||||||
|
.join(BasicRumbleEffect.byTime(t -> new RumbleState(0f, 1 - t), 20))
|
||||||
|
.repeat(3)
|
||||||
|
.join(BasicRumbleEffect.constant(1f, 0f, 5)
|
||||||
|
.join(BasicRumbleEffect.constant(0f, 1f, 5))
|
||||||
|
.repeat(10)
|
||||||
|
)
|
||||||
|
.earlyFinish(BasicRumbleEffect.finishOnScreenChange())
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.build());
|
||||||
|
|
||||||
return vibrationGroup.build();
|
return vibrationGroup.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,6 +327,7 @@ public class YACLHelper {
|
|||||||
var gyroGroup = OptionGroup.createBuilder()
|
var gyroGroup = OptionGroup.createBuilder()
|
||||||
.name(Component.translatable("controlify.gui.group.gyro"))
|
.name(Component.translatable("controlify.gui.group.gyro"))
|
||||||
.tooltip(Component.translatable("controlify.gui.group.gyro.tooltip"))
|
.tooltip(Component.translatable("controlify.gui.group.gyro.tooltip"))
|
||||||
|
.tooltip(hasGyro ? Component.empty() : noGyroTooltip)
|
||||||
.collapsed(!hasGyro)
|
.collapsed(!hasGyro)
|
||||||
.option(gyroSensitivity = Option.createBuilder(float.class)
|
.option(gyroSensitivity = Option.createBuilder(float.class)
|
||||||
.name(Component.translatable("controlify.gui.gyro_look_sensitivity"))
|
.name(Component.translatable("controlify.gui.gyro_look_sensitivity"))
|
||||||
|
@ -92,14 +92,13 @@ public class GamepadController extends AbstractController<GamepadState, GamepadC
|
|||||||
strongMagnitude *= strengthMod;
|
strongMagnitude *= strengthMod;
|
||||||
weakMagnitude *= strengthMod;
|
weakMagnitude *= strengthMod;
|
||||||
|
|
||||||
return drivers.rumbleDriver().rumble(strongMagnitude, weakMagnitude);
|
return drivers.rumbleDriver().rumble(Math.min(strongMagnitude, 1), Math.min(weakMagnitude, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRumble() {
|
public boolean canRumble() {
|
||||||
return drivers.rumbleDriver().isRumbleSupported()
|
return drivers.rumbleDriver().isRumbleSupported()
|
||||||
&& config().allowVibrations
|
&& config().allowVibrations;
|
||||||
&& ControlifyApi.get().currentInputMode() == InputMode.CONTROLLER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"controlify.gui.auto_jump.tooltip": "If the player should automatically jump when you reach a block.",
|
"controlify.gui.auto_jump.tooltip": "If the player should automatically jump when you reach a block.",
|
||||||
"controlify.gui.allow_vibrations": "Allow Vibration",
|
"controlify.gui.allow_vibrations": "Allow Vibration",
|
||||||
"controlify.gui.allow_vibrations.tooltip": "If the controller should vibrate when you do certain actions.",
|
"controlify.gui.allow_vibrations.tooltip": "If the controller should vibrate when you do certain actions.",
|
||||||
|
"controlify.gui.allow_vibrations.not_available": "You controller does not support vibration or the vibration natives are not loaded.",
|
||||||
"controlify.gui.show_ingame_guide": "Show Ingame Button Guide",
|
"controlify.gui.show_ingame_guide": "Show Ingame Button Guide",
|
||||||
"controlify.gui.show_ingame_guide.tooltip": "Show a HUD in-game displaying actions you can do with controller buttons.",
|
"controlify.gui.show_ingame_guide.tooltip": "Show a HUD in-game displaying actions you can do with controller buttons.",
|
||||||
"controlify.gui.show_screen_guide": "Show Screen Button Guide",
|
"controlify.gui.show_screen_guide": "Show Screen Button Guide",
|
||||||
@ -53,7 +54,7 @@
|
|||||||
"controlify.gui.group.vibration.tooltip": "Adjust how your controller vibrates.",
|
"controlify.gui.group.vibration.tooltip": "Adjust how your controller vibrates.",
|
||||||
"controlify.gui.group.gyro": "Gyro",
|
"controlify.gui.group.gyro": "Gyro",
|
||||||
"controlify.gui.group.gyro.tooltip": "Adjust how Controlify treats your controller's built in gyroscope.\nA gyroscope determines how the controller is rotated.",
|
"controlify.gui.group.gyro.tooltip": "Adjust how Controlify treats your controller's built in gyroscope.\nA gyroscope determines how the controller is rotated.",
|
||||||
"controlify.gui.group.gyro.no_gyro.tooltip": "This controller does not support Gyro. You must have a Dualsense™ controller or other compatible controller to use this feature.",
|
"controlify.gui.group.gyro.no_gyro.tooltip": "This controller does not support Gyro. You must have a DualSense™ controller or other compatible controller to use this feature.",
|
||||||
"controlify.gui.gyro_look_sensitivity": "Look Sensitivity",
|
"controlify.gui.gyro_look_sensitivity": "Look Sensitivity",
|
||||||
"controlify.gui.gyro_look_sensitivity.tooltip": "How much the camera moves based on gyroscope rotation.",
|
"controlify.gui.gyro_look_sensitivity.tooltip": "How much the camera moves based on gyroscope rotation.",
|
||||||
"controlify.gui.gyro_requires_button": "Require Button",
|
"controlify.gui.gyro_requires_button": "Require Button",
|
||||||
|
Reference in New Issue
Block a user