1
0
forked from Clones/Controlify

binding api full javadoc

This commit is contained in:
isXander
2023-04-05 10:00:45 +01:00
parent 4940b04f09
commit f7fe7d8ec0
2 changed files with 70 additions and 0 deletions

View File

@ -16,6 +16,12 @@ import java.util.function.UnaryOperator;
* Should be called within {@link dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint#onControlifyPreInit(ControlifyApi)} * Should be called within {@link dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint#onControlifyPreInit(ControlifyApi)}
*/ */
public interface ControlifyBindingsApi { public interface ControlifyBindingsApi {
/**
* Registers a custom binding for all controllers.
* @param id the identifier for the binding, the namespace should be your modid.
* @param builder the binding builder function
* @return the binding supplier to fetch the binding for a specific controller.
*/
BindingSupplier registerBind(ResourceLocation id, UnaryOperator<ControllerBindingBuilder<?>> builder); BindingSupplier registerBind(ResourceLocation id, UnaryOperator<ControllerBindingBuilder<?>> builder);
/** /**
@ -42,6 +48,12 @@ public interface ControlifyBindingsApi {
@Deprecated @Deprecated
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride); BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride);
/**
* By default, all modded keybindings are registered as controller binds.
* If you are explicitly depending on Controlify, you should exclude all your
* keybindings and register them explicitly.
* @param keyMapping the mappings to exclude
*/
void excludeVanillaBind(KeyMapping... keyMapping); void excludeVanillaBind(KeyMapping... keyMapping);
static ControlifyBindingsApi get() { static ControlifyBindingsApi get() {

View File

@ -16,22 +16,80 @@ public interface ControllerBindingBuilder<T extends ControllerState> {
return new ControllerBinding.ControllerBindingBuilderImpl<>(controller); return new ControllerBinding.ControllerBindingBuilderImpl<>(controller);
} }
/**
* Sets the identifier for the binding.
* @param id the identifier for the binding, the namespace should be your modid.
*/
ControllerBindingBuilder<T> identifier(ResourceLocation id); ControllerBindingBuilder<T> identifier(ResourceLocation id);
/**
* Sets the identifier for the binding.
* @param namespace the namespace for the binding, should be your modid.
* @param path the path for the binding.
*/
ControllerBindingBuilder<T> identifier(String namespace, String path); ControllerBindingBuilder<T> identifier(String namespace, String path);
/**
* The default bind for the binding. This is usually inaccessible due to unknown
* generics and {@link ControllerBindingBuilder#defaultBind(GamepadBinds)} should be used instead.
* @param bind the default bind
*/
ControllerBindingBuilder<T> defaultBind(IBind<T> bind); ControllerBindingBuilder<T> defaultBind(IBind<T> bind);
/**
* Sets the default gamepad bind for the binding.
* If the controller is not a gamepad, the default is unbound.
* @param gamepadBind the default gamepad bind
*/
ControllerBindingBuilder<T> defaultBind(GamepadBinds gamepadBind); ControllerBindingBuilder<T> defaultBind(GamepadBinds gamepadBind);
/**
* Sets the name of the binding.
* <p>
* If left unset, the default translation location is
* <p>
* {@code controlify.binding.<namespace>.<path>}.
*
* @param name the name of the binding
*/
ControllerBindingBuilder<T> name(Component name); ControllerBindingBuilder<T> name(Component name);
/**
* Sets the description of the binding.
* <p>
* If left unset, the default translation location is
* <p>
* {@code controlify.binding.<namespace>.<path>.desc}.
*
* @param description the description of the binding
*/
ControllerBindingBuilder<T> description(Component description); ControllerBindingBuilder<T> description(Component description);
/**
* Sets the category of the binding.
* Must be set.
*
* @param category the category of the binding
*/
ControllerBindingBuilder<T> category(Component category); ControllerBindingBuilder<T> category(Component category);
/**
* Specifies are vanilla override for the binding.
* Will emulate presses of the vanilla keybind when the controller binding is pressed.
* Though usage of this is discouraged as it can have funny behaviours.
*
* @param keyMapping the vanilla keybind to emulate
* @param toggleable if the binding should be toggleable
*/
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping, BooleanSupplier toggleable); ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping, BooleanSupplier toggleable);
/**
* Specifies are vanilla override for the binding.
* Will emulate presses of the vanilla keybind when the controller binding is pressed.
* Though usage of this is discouraged as it can have funny behaviours.
*
* @param keyMapping the vanilla keybind to emulate
*/
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping); ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping);
ControllerBinding<T> build(); ControllerBinding<T> build();