forked from Clones/Controlify
improve bindings
This commit is contained in:
@ -68,6 +68,7 @@ dependencies {
|
|||||||
listOf(
|
listOf(
|
||||||
"fabric-resource-loader-v0",
|
"fabric-resource-loader-v0",
|
||||||
"fabric-lifecycle-events-v1",
|
"fabric-lifecycle-events-v1",
|
||||||
|
"fabric-key-binding-api-v1",
|
||||||
|
|
||||||
// sodium requirements
|
// sodium requirements
|
||||||
"fabric-rendering-data-attachment-v1",
|
"fabric-rendering-data-attachment-v1",
|
||||||
|
@ -12,7 +12,7 @@ quilt_mappings = "1"
|
|||||||
fabric_loader = "0.14.17"
|
fabric_loader = "0.14.17"
|
||||||
fabric_api = "0.76.0+1.19.4"
|
fabric_api = "0.76.0+1.19.4"
|
||||||
mixin_extras = "0.2.0-beta.1"
|
mixin_extras = "0.2.0-beta.1"
|
||||||
yet_another_config_lib = "2.3.0"
|
yet_another_config_lib = "2.3.1"
|
||||||
mod_menu = "6.1.0-rc.1"
|
mod_menu = "6.1.0-rc.1"
|
||||||
hid4java = "0.7.0"
|
hid4java = "0.7.0"
|
||||||
quilt_json5 = "1.0.3"
|
quilt_json5 = "1.0.3"
|
||||||
|
@ -8,6 +8,7 @@ import net.minecraft.client.KeyMapping;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles registering new bindings for controllers.
|
* Handles registering new bindings for controllers.
|
||||||
@ -15,6 +16,8 @@ import java.util.function.BooleanSupplier;
|
|||||||
* 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 {
|
||||||
|
BindingSupplier registerBind(ResourceLocation id, UnaryOperator<ControllerBindingBuilder<?>> builder);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a custom binding for all available controllers.
|
* Registers a custom binding for all available controllers.
|
||||||
* If the controller is not a gamepad, the binding with be empty by default.
|
* If the controller is not a gamepad, the binding with be empty by default.
|
||||||
@ -23,6 +26,7 @@ public interface ControlifyBindingsApi {
|
|||||||
* @param id the identifier for the binding, the namespace should be your modid.
|
* @param id the identifier for the binding, the namespace should be your modid.
|
||||||
* @return the binding supplier to fetch the binding for a specific controller.
|
* @return the binding supplier to fetch the binding for a specific controller.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id);
|
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,8 +39,11 @@ public interface ControlifyBindingsApi {
|
|||||||
* @param toggleOverride a supplier that returns true if the vanilla keybind should be treated as a {@link net.minecraft.client.ToggleKeyMapping}
|
* @param toggleOverride a supplier that returns true if the vanilla keybind should be treated as a {@link net.minecraft.client.ToggleKeyMapping}
|
||||||
* @return the binding supplier to fetch the binding for a specific controller.
|
* @return the binding supplier to fetch the binding for a specific controller.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride);
|
BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride);
|
||||||
|
|
||||||
|
void excludeVanillaBind(KeyMapping... keyMapping);
|
||||||
|
|
||||||
static ControlifyBindingsApi get() {
|
static ControlifyBindingsApi get() {
|
||||||
return ControllerBindings.Api.INSTANCE;
|
return ControllerBindings.Api.INSTANCE;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package dev.isxander.controlify.api.bind;
|
||||||
|
|
||||||
|
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||||
|
import dev.isxander.controlify.bindings.GamepadBinds;
|
||||||
|
import dev.isxander.controlify.bindings.IBind;
|
||||||
|
import dev.isxander.controlify.controller.Controller;
|
||||||
|
import dev.isxander.controlify.controller.ControllerState;
|
||||||
|
import net.minecraft.client.KeyMapping;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
public interface ControllerBindingBuilder<T extends ControllerState> {
|
||||||
|
static <T extends ControllerState> ControllerBindingBuilder<T> create(Controller<T, ?> controller) {
|
||||||
|
return new ControllerBinding.ControllerBindingBuilderImpl<>(controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> identifier(ResourceLocation id);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> identifier(String namespace, String path);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> defaultBind(IBind<T> bind);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> defaultBind(GamepadBinds gamepadBind);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> name(Component name);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> description(Component description);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> category(Component category);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping, BooleanSupplier toggleable);
|
||||||
|
|
||||||
|
ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping);
|
||||||
|
|
||||||
|
ControllerBinding<T> build();
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package dev.isxander.controlify.bindings;
|
package dev.isxander.controlify.bindings;
|
||||||
|
|
||||||
|
import dev.isxander.controlify.api.bind.ControllerBindingBuilder;
|
||||||
import dev.isxander.controlify.controller.Controller;
|
import dev.isxander.controlify.controller.Controller;
|
||||||
import dev.isxander.controlify.controller.ControllerState;
|
import dev.isxander.controlify.controller.ControllerState;
|
||||||
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||||
@ -7,6 +8,8 @@ import net.minecraft.client.KeyMapping;
|
|||||||
import net.minecraft.locale.Language;
|
import net.minecraft.locale.Language;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -19,11 +22,22 @@ public class ControllerBinding<T extends ControllerState> {
|
|||||||
private IBind<T> bind;
|
private IBind<T> bind;
|
||||||
private final IBind<T> defaultBind;
|
private final IBind<T> defaultBind;
|
||||||
private final ResourceLocation id;
|
private final ResourceLocation id;
|
||||||
private final Component name, description;
|
private final Component name, description, category;
|
||||||
private final KeyMappingOverride override;
|
private final KeyMappingOverride override;
|
||||||
|
|
||||||
private static final Map<Controller<?, ?>, Set<IBind<?>>> pressedBinds = new HashMap<>();
|
private static final Map<Controller<?, ?>, Set<IBind<?>>> pressedBinds = new HashMap<>();
|
||||||
|
|
||||||
|
private ControllerBinding(Controller<T, ?> controller, IBind<T> defaultBind, ResourceLocation id, KeyMappingOverride vanillaOverride, Component name, Component description, Component category) {
|
||||||
|
this.controller = controller;
|
||||||
|
this.bind = this.defaultBind = defaultBind;
|
||||||
|
this.id = id;
|
||||||
|
this.override = vanillaOverride;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ControllerBinding(Controller<T, ?> controller, IBind<T> defaultBind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
public ControllerBinding(Controller<T, ?> controller, IBind<T> defaultBind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
this.bind = this.defaultBind = defaultBind;
|
this.bind = this.defaultBind = defaultBind;
|
||||||
@ -32,17 +46,21 @@ public class ControllerBinding<T extends ControllerState> {
|
|||||||
var descKey = "controlify.binding." + id.getNamespace() + "." + id.getPath() + ".desc";
|
var descKey = "controlify.binding." + id.getNamespace() + "." + id.getPath() + ".desc";
|
||||||
this.description = Language.getInstance().has(descKey) ? Component.translatable(descKey) : Component.empty();
|
this.description = Language.getInstance().has(descKey) ? Component.translatable(descKey) : Component.empty();
|
||||||
this.override = override != null ? new KeyMappingOverride(override, toggleOverride) : null;
|
this.override = override != null ? new KeyMappingOverride(override, toggleOverride) : null;
|
||||||
|
this.category = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ControllerBinding(Controller<T, ?> controller, IBind<T> defaultBind, ResourceLocation id) {
|
public ControllerBinding(Controller<T, ?> controller, IBind<T> defaultBind, ResourceLocation id) {
|
||||||
this(controller, defaultBind, id, null, () -> false);
|
this(controller, defaultBind, id, null, () -> false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ControllerBinding(Controller<T, ?> controller, GamepadBinds defaultBind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
public ControllerBinding(Controller<T, ?> controller, GamepadBinds defaultBind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
||||||
this(controller, controller instanceof GamepadController gamepad ? (IBind<T>) defaultBind.forGamepad(gamepad) : new EmptyBind<>(), id, override, toggleOverride);
|
this(controller, controller instanceof GamepadController gamepad ? (IBind<T>) defaultBind.forGamepad(gamepad) : new EmptyBind<>(), id, override, toggleOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ControllerBinding(Controller<T, ?> controller, GamepadBinds defaultBind, ResourceLocation id) {
|
public ControllerBinding(Controller<T, ?> controller, GamepadBinds defaultBind, ResourceLocation id) {
|
||||||
this(controller, defaultBind, id, null, () -> false);
|
this(controller, defaultBind, id, null, () -> false);
|
||||||
}
|
}
|
||||||
@ -109,6 +127,10 @@ public class ControllerBinding<T extends ControllerState> {
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Component category() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean unbound() {
|
public boolean unbound() {
|
||||||
return bind instanceof EmptyBind;
|
return bind instanceof EmptyBind;
|
||||||
}
|
}
|
||||||
@ -140,4 +162,94 @@ public class ControllerBinding<T extends ControllerState> {
|
|||||||
|
|
||||||
public record KeyMappingOverride(KeyMapping keyMapping, BooleanSupplier toggleable) {
|
public record KeyMappingOverride(KeyMapping keyMapping, BooleanSupplier toggleable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static final class ControllerBindingBuilderImpl<T extends ControllerState> implements ControllerBindingBuilder<T> {
|
||||||
|
private final Controller<T, ?> controller;
|
||||||
|
private IBind<T> bind;
|
||||||
|
private ResourceLocation id;
|
||||||
|
private Component name = null, description = null, category = null;
|
||||||
|
private KeyMappingOverride override = null;
|
||||||
|
|
||||||
|
public ControllerBindingBuilderImpl(Controller<T, ?> controller) {
|
||||||
|
this.controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> identifier(ResourceLocation id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> identifier(String namespace, String path) {
|
||||||
|
return identifier(new ResourceLocation(namespace, path));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> defaultBind(IBind<T> bind) {
|
||||||
|
this.bind = bind;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public ControllerBindingBuilder<T> defaultBind(GamepadBinds gamepadBind) {
|
||||||
|
if (controller instanceof GamepadController gamepad) {
|
||||||
|
this.bind = (IBind<T>) gamepadBind.forGamepad(gamepad);
|
||||||
|
} else {
|
||||||
|
this.bind = new EmptyBind<>();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> name(Component name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> description(Component description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> category(Component category) {
|
||||||
|
this.category = category;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping, BooleanSupplier toggleable) {
|
||||||
|
this.override = new KeyMappingOverride(keyMapping, toggleable);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBindingBuilder<T> vanillaOverride(KeyMapping keyMapping) {
|
||||||
|
return vanillaOverride(keyMapping, () -> false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ControllerBinding<T> build() {
|
||||||
|
Validate.notNull(id, "Identifier must be set");
|
||||||
|
Validate.notNull(bind, "Default bind must be set");
|
||||||
|
Validate.notNull(category, "Category must be set");
|
||||||
|
|
||||||
|
if (name == null)
|
||||||
|
name = Component.translatable("controlify.binding." + id.getNamespace() + "." + id.getPath());
|
||||||
|
if (description == null) {
|
||||||
|
var descKey = "controlify.binding." + id.getNamespace() + "." + id.getPath() + ".desc";
|
||||||
|
if (Language.getInstance().has(descKey)) {
|
||||||
|
description = Component.translatable(descKey);
|
||||||
|
} else {
|
||||||
|
description = Component.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ControllerBinding<>(controller, bind, id, override, name, description, category);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,36 @@ import com.google.gson.JsonObject;
|
|||||||
import dev.isxander.controlify.Controlify;
|
import dev.isxander.controlify.Controlify;
|
||||||
import dev.isxander.controlify.InputMode;
|
import dev.isxander.controlify.InputMode;
|
||||||
import dev.isxander.controlify.api.bind.ControlifyBindingsApi;
|
import dev.isxander.controlify.api.bind.ControlifyBindingsApi;
|
||||||
|
import dev.isxander.controlify.api.bind.ControllerBindingBuilder;
|
||||||
import dev.isxander.controlify.controller.Controller;
|
import dev.isxander.controlify.controller.Controller;
|
||||||
import dev.isxander.controlify.controller.ControllerState;
|
import dev.isxander.controlify.controller.ControllerState;
|
||||||
import dev.isxander.controlify.api.event.ControlifyEvents;
|
import dev.isxander.controlify.api.event.ControlifyEvents;
|
||||||
|
import dev.isxander.controlify.mixins.compat.fapi.KeyBindingRegistryImplAccessor;
|
||||||
import dev.isxander.controlify.mixins.feature.bind.KeyMappingAccessor;
|
import dev.isxander.controlify.mixins.feature.bind.KeyMappingAccessor;
|
||||||
|
import dev.isxander.controlify.mixins.feature.bind.ToggleKeyMappingAccessor;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.ToggleKeyMapping;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
public class ControllerBindings<T extends ControllerState> {
|
public class ControllerBindings<T extends ControllerState> {
|
||||||
private static final Map<ResourceLocation, Function<ControllerBindings<?>, ControllerBinding<?>>> CUSTOM_BINDS = new LinkedHashMap<>();
|
private static final Map<ResourceLocation, Function<ControllerBindings<?>, ControllerBinding<?>>> CUSTOM_BINDS = new LinkedHashMap<>();
|
||||||
|
private static final Set<KeyMapping> EXCLUDED_VANILLA_BINDS = new HashSet<>();
|
||||||
|
|
||||||
|
public static final Component MOVEMENT_CATEGORY = Component.translatable("key.categories.movement");
|
||||||
|
public static final Component GAMEPLAY_CATEGORY = Component.translatable("key.categories.gameplay");
|
||||||
|
public static final Component INVENTORY_CATEGORY = Component.translatable("key.categories.inventory");
|
||||||
|
public static final Component CREATIVE_CATEGORY = Component.translatable("key.categories.creative");
|
||||||
|
public static final Component VMOUSE_CATEGORY = Component.translatable("controlify.binding_category.vmouse");
|
||||||
|
public static final Component GUI_CATEGORY = Component.translatable("controlify.binding_category.gui");
|
||||||
|
public static final Component MISC_CATEGORY = Component.translatable("key.categories.misc");
|
||||||
|
|
||||||
public final ControllerBinding<T>
|
public final ControllerBinding<T>
|
||||||
WALK_FORWARD, WALK_BACKWARD, WALK_LEFT, WALK_RIGHT,
|
WALK_FORWARD, WALK_BACKWARD, WALK_LEFT, WALK_RIGHT,
|
||||||
@ -47,65 +63,271 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
CYCLE_OPT_FORWARD, CYCLE_OPT_BACKWARD;
|
CYCLE_OPT_FORWARD, CYCLE_OPT_BACKWARD;
|
||||||
|
|
||||||
private final Map<ResourceLocation, ControllerBinding<T>> registry = new LinkedHashMap<>();
|
private final Map<ResourceLocation, ControllerBinding<T>> registry = new LinkedHashMap<>();
|
||||||
|
|
||||||
private final Controller<T, ?> controller;
|
private final Controller<T, ?> controller;
|
||||||
|
|
||||||
public ControllerBindings(Controller<T, ?> controller) {
|
public ControllerBindings(Controller<T, ?> controller) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
var options = Minecraft.getInstance().options;
|
var options = Minecraft.getInstance().options;
|
||||||
|
|
||||||
register(WALK_FORWARD = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_FORWARD, new ResourceLocation("controlify", "walk_forward")));
|
register(WALK_FORWARD = ControllerBindingBuilder.create(controller)
|
||||||
register(WALK_BACKWARD = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_BACKWARD, new ResourceLocation("controlify", "walk_backward")));
|
.identifier("controlify", "walk_forward")
|
||||||
register(WALK_LEFT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_LEFT, new ResourceLocation("controlify", "strafe_left")));
|
.defaultBind(GamepadBinds.LEFT_STICK_FORWARD)
|
||||||
register(WALK_RIGHT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_RIGHT, new ResourceLocation("controlify", "strafe_right")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(LOOK_UP = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_FORWARD, new ResourceLocation("controlify", "look_up")));
|
.build());
|
||||||
register(LOOK_DOWN = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_BACKWARD, new ResourceLocation("controlify", "look_down")));
|
register(WALK_BACKWARD = ControllerBindingBuilder.create(controller)
|
||||||
register(LOOK_LEFT = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_LEFT, new ResourceLocation("controlify", "look_left")));
|
.identifier("controlify", "walk_backward")
|
||||||
register(LOOK_RIGHT = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_RIGHT, new ResourceLocation("controlify", "look_right")));
|
.defaultBind(GamepadBinds.LEFT_STICK_BACKWARD)
|
||||||
register(JUMP = new ControllerBinding<>(controller, GamepadBinds.A_BUTTON, new ResourceLocation("controlify", "jump"), options.keyJump, () -> false));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(SNEAK = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_PRESS, new ResourceLocation("controlify", "sneak"), options.keyShift, () -> controller.config().toggleSneak));
|
.build());
|
||||||
register(ATTACK = new ControllerBinding<>(controller, GamepadBinds.RIGHT_TRIGGER, new ResourceLocation("controlify", "attack"), options.keyAttack, () -> false));
|
register(WALK_LEFT = ControllerBindingBuilder.create(controller)
|
||||||
register(USE = new ControllerBinding<>(controller, GamepadBinds.LEFT_TRIGGER, new ResourceLocation("controlify", "use"), options.keyUse, () -> false));
|
.identifier("controlify", "strafe_left")
|
||||||
register(SPRINT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_PRESS, new ResourceLocation("controlify", "sprint"), options.keySprint, () -> controller.config().toggleSprint));
|
.defaultBind(GamepadBinds.LEFT_STICK_LEFT)
|
||||||
register(DROP = new ControllerBinding<>(controller, GamepadBinds.DPAD_DOWN, new ResourceLocation("controlify", "drop")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(NEXT_SLOT = new ControllerBinding<>(controller, GamepadBinds.RIGHT_BUMPER, new ResourceLocation("controlify", "next_slot")));
|
.build());
|
||||||
register(PREV_SLOT = new ControllerBinding<>(controller, GamepadBinds.LEFT_BUMPER, new ResourceLocation("controlify", "prev_slot")));
|
register(WALK_RIGHT = ControllerBindingBuilder.create(controller)
|
||||||
register(PAUSE = new ControllerBinding<>(controller, GamepadBinds.START, new ResourceLocation("controlify", "pause")));
|
.identifier("controlify", "strafe_right")
|
||||||
register(INVENTORY = new ControllerBinding<>(controller, GamepadBinds.Y_BUTTON, new ResourceLocation("controlify", "inventory"), options.keyInventory, () -> false));
|
.defaultBind(GamepadBinds.LEFT_STICK_RIGHT)
|
||||||
register(CHANGE_PERSPECTIVE = new ControllerBinding<>(controller, GamepadBinds.BACK, new ResourceLocation("controlify", "change_perspective"), options.keyTogglePerspective, () -> false));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(SWAP_HANDS = new ControllerBinding<>(controller, GamepadBinds.X_BUTTON, new ResourceLocation("controlify", "swap_hands"), options.keySwapOffhand, () -> false));
|
.build());
|
||||||
register(OPEN_CHAT = new ControllerBinding<>(controller, GamepadBinds.DPAD_UP, new ResourceLocation("controlify", "open_chat"), options.keyChat, () -> false));
|
register(LOOK_UP = ControllerBindingBuilder.create(controller)
|
||||||
register(GUI_PRESS = new ControllerBinding<>(controller, GamepadBinds.A_BUTTON, new ResourceLocation("controlify", "gui_press")));
|
.identifier("controlify", "look_up")
|
||||||
register(GUI_BACK = new ControllerBinding<>(controller, GamepadBinds.B_BUTTON, new ResourceLocation("controlify", "gui_back")));
|
.defaultBind(GamepadBinds.RIGHT_STICK_FORWARD)
|
||||||
register(GUI_NEXT_TAB = new ControllerBinding<>(controller, GamepadBinds.RIGHT_BUMPER, new ResourceLocation("controlify", "gui_next_tab")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(GUI_PREV_TAB = new ControllerBinding<>(controller, GamepadBinds.LEFT_BUMPER, new ResourceLocation("controlify", "gui_prev_tab")));
|
.build());
|
||||||
register(GUI_ABSTRACT_ACTION_1 = new ControllerBinding<>(controller, GamepadBinds.X_BUTTON, new ResourceLocation("controlify", "gui_abstract_action_1")));
|
register(LOOK_DOWN = ControllerBindingBuilder.create(controller)
|
||||||
register(GUI_ABSTRACT_ACTION_2 = new ControllerBinding<>(controller, GamepadBinds.Y_BUTTON, new ResourceLocation("controlify", "gui_abstract_action_2")));
|
.identifier("controlify", "look_down")
|
||||||
register(PICK_BLOCK = new ControllerBinding<>(controller, GamepadBinds.DPAD_LEFT, new ResourceLocation("controlify", "pick_block"), options.keyPickItem, () -> false));
|
.defaultBind(GamepadBinds.RIGHT_STICK_BACKWARD)
|
||||||
register(TOGGLE_HUD_VISIBILITY = new ControllerBinding<>(controller, new EmptyBind<>(), new ResourceLocation("controlify", "toggle_hud_visibility")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(SHOW_PLAYER_LIST = new ControllerBinding<>(controller, GamepadBinds.DPAD_RIGHT, new ResourceLocation("controlify", "show_player_list"), options.keyPlayerList, () -> false));
|
.build());
|
||||||
register(VMOUSE_MOVE_UP = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_FORWARD, new ResourceLocation("controlify", "vmouse_move_up")));
|
register(LOOK_LEFT = ControllerBindingBuilder.create(controller)
|
||||||
register(VMOUSE_MOVE_DOWN = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_BACKWARD, new ResourceLocation("controlify", "vmouse_move_down")));
|
.identifier("controlify", "look_left")
|
||||||
register(VMOUSE_MOVE_LEFT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_LEFT, new ResourceLocation("controlify", "vmouse_move_left")));
|
.defaultBind(GamepadBinds.RIGHT_STICK_LEFT)
|
||||||
register(VMOUSE_MOVE_RIGHT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_RIGHT, new ResourceLocation("controlify", "vmouse_move_right")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(VMOUSE_LCLICK = new ControllerBinding<>(controller, GamepadBinds.A_BUTTON, new ResourceLocation("controlify", "vmouse_lclick")));
|
.build());
|
||||||
register(VMOUSE_RCLICK = new ControllerBinding<>(controller, GamepadBinds.X_BUTTON, new ResourceLocation("controlify", "vmouse_rclick")));
|
register(LOOK_RIGHT = ControllerBindingBuilder.create(controller)
|
||||||
register(VMOUSE_SHIFT_CLICK = new ControllerBinding<>(controller, GamepadBinds.Y_BUTTON, new ResourceLocation("controlify", "vmouse_shift_click")));
|
.identifier("controlify", "look_right")
|
||||||
register(VMOUSE_SCROLL_UP = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_FORWARD, new ResourceLocation("controlify", "vmouse_scroll_up")));
|
.defaultBind(GamepadBinds.RIGHT_STICK_RIGHT)
|
||||||
register(VMOUSE_SCROLL_DOWN = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_BACKWARD, new ResourceLocation("controlify", "vmouse_scroll_down")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(VMOUSE_ESCAPE = new ControllerBinding<>(controller, GamepadBinds.B_BUTTON, new ResourceLocation("controlify", "vmouse_escape")));
|
.build());
|
||||||
register(VMOUSE_SHIFT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_PRESS, new ResourceLocation("controlify", "vmouse_shift")));
|
register(JUMP = ControllerBindingBuilder.create(controller)
|
||||||
register(VMOUSE_TOGGLE = new ControllerBinding<>(controller, GamepadBinds.BACK, new ResourceLocation("controlify", "vmouse_toggle")));
|
.identifier("controlify", "jump")
|
||||||
register(GUI_NAVI_UP = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_FORWARD, new ResourceLocation("controlify", "gui_navi_up")));
|
.defaultBind(GamepadBinds.A_BUTTON)
|
||||||
register(GUI_NAVI_DOWN = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_BACKWARD, new ResourceLocation("controlify", "gui_navi_down")));
|
.category(MOVEMENT_CATEGORY)
|
||||||
register(GUI_NAVI_LEFT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_LEFT, new ResourceLocation("controlify", "gui_navi_left")));
|
.vanillaOverride(options.keyJump, () -> false)
|
||||||
register(GUI_NAVI_RIGHT = new ControllerBinding<>(controller, GamepadBinds.LEFT_STICK_RIGHT, new ResourceLocation("controlify", "gui_navi_right")));
|
.build());
|
||||||
register(CYCLE_OPT_FORWARD = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_RIGHT, new ResourceLocation("controlify", "cycle_opt_forward")));
|
register(SPRINT = ControllerBindingBuilder.create(controller)
|
||||||
register(CYCLE_OPT_BACKWARD = new ControllerBinding<>(controller, GamepadBinds.RIGHT_STICK_LEFT, new ResourceLocation("controlify", "cycle_opt_backward")));
|
.identifier("controlify", "sprint")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_PRESS)
|
||||||
|
.category(MOVEMENT_CATEGORY)
|
||||||
|
.vanillaOverride(options.keySprint, () -> controller.config().toggleSprint)
|
||||||
|
.build());
|
||||||
|
register(SNEAK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "sneak")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_STICK_PRESS)
|
||||||
|
.category(MOVEMENT_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyShift, () -> controller.config().toggleSneak)
|
||||||
|
.build());
|
||||||
|
register(ATTACK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "attack")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_TRIGGER)
|
||||||
|
.category(GAMEPLAY_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyAttack, () -> false)
|
||||||
|
.build());
|
||||||
|
register(USE = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "use")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_TRIGGER)
|
||||||
|
.category(GAMEPLAY_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyUse, () -> false)
|
||||||
|
.build());
|
||||||
|
register(DROP = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "drop")
|
||||||
|
.defaultBind(GamepadBinds.DPAD_DOWN)
|
||||||
|
.category(GAMEPLAY_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(NEXT_SLOT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "next_slot")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_BUMPER)
|
||||||
|
.category(INVENTORY_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(PREV_SLOT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "prev_slot")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_BUMPER)
|
||||||
|
.category(INVENTORY_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(PAUSE = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "pause")
|
||||||
|
.defaultBind(GamepadBinds.START)
|
||||||
|
.category(GAMEPLAY_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(INVENTORY = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "inventory")
|
||||||
|
.defaultBind(GamepadBinds.Y_BUTTON)
|
||||||
|
.category(INVENTORY_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyInventory, () -> false)
|
||||||
|
.build());
|
||||||
|
register(CHANGE_PERSPECTIVE = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "change_perspective")
|
||||||
|
.defaultBind(GamepadBinds.BACK)
|
||||||
|
.category(GAMEPLAY_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyTogglePerspective, () -> false)
|
||||||
|
.build());
|
||||||
|
register(SWAP_HANDS = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "swap_hands")
|
||||||
|
.defaultBind(GamepadBinds.X_BUTTON)
|
||||||
|
.category(INVENTORY_CATEGORY)
|
||||||
|
.vanillaOverride(options.keySwapOffhand, () -> false)
|
||||||
|
.build());
|
||||||
|
register(OPEN_CHAT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "open_chat")
|
||||||
|
.defaultBind(GamepadBinds.DPAD_UP)
|
||||||
|
.category(MISC_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyChat, () -> false)
|
||||||
|
.build());
|
||||||
|
register(GUI_PRESS = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_press")
|
||||||
|
.defaultBind(GamepadBinds.A_BUTTON)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_BACK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_back")
|
||||||
|
.defaultBind(GamepadBinds.B_BUTTON)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_NEXT_TAB = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_next_tab")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_BUMPER)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_PREV_TAB = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_prev_tab")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_BUMPER)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_ABSTRACT_ACTION_1 = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_abstract_action_1")
|
||||||
|
.defaultBind(GamepadBinds.X_BUTTON)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_ABSTRACT_ACTION_2 = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_abstract_action_1")
|
||||||
|
.defaultBind(GamepadBinds.Y_BUTTON)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(PICK_BLOCK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "pick_block")
|
||||||
|
.defaultBind(GamepadBinds.DPAD_LEFT)
|
||||||
|
.category(GAMEPLAY_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyPickItem, () -> false)
|
||||||
|
.build());
|
||||||
|
register(TOGGLE_HUD_VISIBILITY = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "toggle_hud_visibility")
|
||||||
|
.defaultBind(new EmptyBind<>())
|
||||||
|
.category(MISC_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(SHOW_PLAYER_LIST = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "show_player_list")
|
||||||
|
.defaultBind(GamepadBinds.DPAD_RIGHT)
|
||||||
|
.category(MISC_CATEGORY)
|
||||||
|
.vanillaOverride(options.keyPlayerList, () -> false)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_MOVE_UP = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_move_up")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_FORWARD)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_MOVE_DOWN = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_move_down")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_BACKWARD)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_MOVE_LEFT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_move_left")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_LEFT)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_MOVE_RIGHT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_move_right")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_RIGHT)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_LCLICK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_lclick")
|
||||||
|
.defaultBind(GamepadBinds.A_BUTTON)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_RCLICK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_rclick")
|
||||||
|
.defaultBind(GamepadBinds.X_BUTTON)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_SHIFT_CLICK = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_shift_click")
|
||||||
|
.defaultBind(GamepadBinds.Y_BUTTON)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_SCROLL_UP = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_scroll_up")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_STICK_FORWARD)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_SCROLL_DOWN = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_scroll_down")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_STICK_BACKWARD)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_ESCAPE = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_escape")
|
||||||
|
.defaultBind(GamepadBinds.B_BUTTON)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_SHIFT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_shift")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_PRESS)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(VMOUSE_TOGGLE = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "vmouse_toggle")
|
||||||
|
.defaultBind(GamepadBinds.BACK)
|
||||||
|
.category(VMOUSE_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_NAVI_UP = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_navi_up")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_FORWARD)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_NAVI_DOWN = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_navi_down")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_BACKWARD)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_NAVI_LEFT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_navi_left")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_LEFT)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(GUI_NAVI_RIGHT = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "gui_navi_right")
|
||||||
|
.defaultBind(GamepadBinds.LEFT_STICK_RIGHT)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(CYCLE_OPT_FORWARD = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "cycle_opt_forward")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_STICK_RIGHT)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
register(CYCLE_OPT_BACKWARD = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier("controlify", "cycle_opt_backward")
|
||||||
|
.defaultBind(GamepadBinds.RIGHT_STICK_LEFT)
|
||||||
|
.category(GUI_CATEGORY)
|
||||||
|
.build());
|
||||||
|
|
||||||
for (var constructor : CUSTOM_BINDS.values()) {
|
for (var constructor : CUSTOM_BINDS.values()) {
|
||||||
register((ControllerBinding<T>) constructor.apply(this));
|
register((ControllerBinding<T>) constructor.apply(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerModdedKeybinds();
|
||||||
|
|
||||||
ControlifyEvents.CONTROLLER_STATE_UPDATED.register(this::onControllerUpdate);
|
ControlifyEvents.CONTROLLER_STATE_UPDATED.register(this::onControllerUpdate);
|
||||||
ControlifyEvents.INPUT_MODE_CHANGED.register(mode -> KeyMapping.releaseAll());
|
ControlifyEvents.INPUT_MODE_CHANGED.register(mode -> KeyMapping.releaseAll());
|
||||||
}
|
}
|
||||||
@ -115,10 +337,16 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ControllerBinding<?> create(UnaryOperator<ControllerBindingBuilder<?>> builder) {
|
||||||
|
return builder.apply(ControllerBindingBuilder.create(controller)).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private ControllerBinding<?> create(GamepadBinds bind, ResourceLocation id) {
|
private ControllerBinding<?> create(GamepadBinds bind, ResourceLocation id) {
|
||||||
return new ControllerBinding<>(controller, bind, id);
|
return new ControllerBinding<>(controller, bind, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private ControllerBinding<?> create(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
private ControllerBinding<?> create(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
||||||
return new ControllerBinding<>(controller, bind, id, override, toggleOverride);
|
return new ControllerBinding<>(controller, bind, id, override, toggleOverride);
|
||||||
}
|
}
|
||||||
@ -139,20 +367,25 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fromJson(JsonObject json) {
|
public boolean fromJson(JsonObject json) {
|
||||||
|
boolean clean = true;
|
||||||
for (var binding : registry().values()) {
|
for (var binding : registry().values()) {
|
||||||
if (!json.has(binding.id().toString())) {
|
if (!json.has(binding.id().toString())) {
|
||||||
Controlify.LOGGER.warn("Missing control: " + binding.id() + " in config file. Skipping!");
|
Controlify.LOGGER.warn("Missing binding: " + binding.id() + " in config file. Skipping!");
|
||||||
|
clean = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bind = json.get(binding.id().toString()).getAsJsonObject();
|
var bind = json.get(binding.id().toString()).getAsJsonObject();
|
||||||
if (bind == null) {
|
if (bind == null) {
|
||||||
Controlify.LOGGER.warn("Unknown control: " + binding.id() + " in config file. Skipping!");
|
Controlify.LOGGER.warn("Unknown binding: " + binding.id() + " in config file. Skipping!");
|
||||||
|
clean = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
binding.setCurrentBind(IBind.fromJson(bind, controller));
|
binding.setCurrentBind(IBind.fromJson(bind, controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onControllerUpdate(Controller<?, ?> controller) {
|
public void onControllerUpdate(Controller<?, ?> controller) {
|
||||||
@ -161,6 +394,34 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
imitateVanillaClick();
|
imitateVanillaClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerModdedKeybinds() {
|
||||||
|
for (KeyMapping keyMapping : KeyBindingRegistryImplAccessor.getCustomKeys()) {
|
||||||
|
if (EXCLUDED_VANILLA_BINDS.contains(keyMapping))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var identifier = new ResourceLocation("fabric-key-binding-api-v1", keyMapping.getName());
|
||||||
|
BooleanSupplier toggleOverride = () -> false;
|
||||||
|
if (keyMapping instanceof ToggleKeyMapping toggleKeyMapping) {
|
||||||
|
toggleOverride = ((ToggleKeyMappingAccessor) toggleKeyMapping).getNeedsToggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
ControllerBinding<T> binding = ControllerBindingBuilder.create(controller)
|
||||||
|
.identifier(identifier)
|
||||||
|
.defaultBind(new EmptyBind<>())
|
||||||
|
.name(Component.translatable(keyMapping.getName()))
|
||||||
|
.description(Component.translatable("controlify.custom_binding.vanilla_description").withStyle(ChatFormatting.GRAY))
|
||||||
|
.category(Component.translatable(keyMapping.getCategory()))
|
||||||
|
.vanillaOverride(keyMapping, toggleOverride)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
register(binding);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Controlify.LOGGER.error("Failed to automatically register modded keybind: " + keyMapping.getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void imitateVanillaClick() {
|
private void imitateVanillaClick() {
|
||||||
ControllerBinding.clearPressedBinds(controller);
|
ControllerBinding.clearPressedBinds(controller);
|
||||||
|
|
||||||
@ -191,14 +452,29 @@ public class ControllerBindings<T extends ControllerState> {
|
|||||||
public static final class Api implements ControlifyBindingsApi {
|
public static final class Api implements ControlifyBindingsApi {
|
||||||
public static final Api INSTANCE = new Api();
|
public static final Api INSTANCE = new Api();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BindingSupplier registerBind(ResourceLocation id, UnaryOperator<ControllerBindingBuilder<?>> builder) {
|
||||||
|
CUSTOM_BINDS.put(id, bindings -> bindings.create(b -> builder.apply(b).identifier(id)));
|
||||||
|
return controller -> controller.bindings().get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
public BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id) {
|
public BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id) {
|
||||||
CUSTOM_BINDS.put(id, bindings -> bindings.create(bind, id));
|
CUSTOM_BINDS.put(id, bindings -> bindings.create(bind, id));
|
||||||
return controller -> controller.bindings().get(id);
|
return controller -> controller.bindings().get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
public BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
public BindingSupplier registerBind(GamepadBinds bind, ResourceLocation id, KeyMapping override, BooleanSupplier toggleOverride) {
|
||||||
CUSTOM_BINDS.put(id, bindings -> bindings.create(bind, id, override, toggleOverride));
|
CUSTOM_BINDS.put(id, bindings -> bindings.create(bind, id, override, toggleOverride));
|
||||||
return controller -> controller.bindings().get(id);
|
return controller -> controller.bindings().get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void excludeVanillaBind(KeyMapping... keyMappings) {
|
||||||
|
EXCLUDED_VANILLA_BINDS.addAll(Arrays.asList(keyMappings));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public class ControlifyConfig {
|
|||||||
private Map<String, CompoundJoystickInfo> compoundJoysticks = Map.of();
|
private Map<String, CompoundJoystickInfo> compoundJoysticks = Map.of();
|
||||||
private GlobalSettings globalSettings = new GlobalSettings();
|
private GlobalSettings globalSettings = new GlobalSettings();
|
||||||
private boolean firstLaunch;
|
private boolean firstLaunch;
|
||||||
|
private boolean dirty;
|
||||||
|
|
||||||
public ControlifyConfig(Controlify controlify) {
|
public ControlifyConfig(Controlify controlify) {
|
||||||
this.controlify = controlify;
|
this.controlify = controlify;
|
||||||
@ -43,6 +44,7 @@ public class ControlifyConfig {
|
|||||||
try {
|
try {
|
||||||
Files.deleteIfExists(CONFIG_PATH);
|
Files.deleteIfExists(CONFIG_PATH);
|
||||||
Files.writeString(CONFIG_PATH, GSON.toJson(generateConfig()), StandardOpenOption.CREATE_NEW, StandardOpenOption.TRUNCATE_EXISTING);
|
Files.writeString(CONFIG_PATH, GSON.toJson(generateConfig()), StandardOpenOption.CREATE_NEW, StandardOpenOption.TRUNCATE_EXISTING);
|
||||||
|
dirty = false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to save config!", e);
|
throw new IllegalStateException("Failed to save config!", e);
|
||||||
}
|
}
|
||||||
@ -62,6 +64,11 @@ public class ControlifyConfig {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Controlify.LOGGER.error("Failed to load Controlify config!", e);
|
Controlify.LOGGER.error("Failed to load Controlify config!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dirty) {
|
||||||
|
Controlify.LOGGER.info("Config was dirty after load, saving...");
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonObject generateConfig() {
|
private JsonObject generateConfig() {
|
||||||
@ -100,7 +107,7 @@ public class ControlifyConfig {
|
|||||||
if (controllers != null) {
|
if (controllers != null) {
|
||||||
this.controllerData = controllers;
|
this.controllerData = controllers;
|
||||||
for (var controller : Controller.CONTROLLERS.values()) {
|
for (var controller : Controller.CONTROLLERS.values()) {
|
||||||
loadOrCreateControllerData(controller);
|
_loadOrCreateControllerData(controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +126,12 @@ public class ControlifyConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadOrCreateControllerData(Controller<?, ?> controller) {
|
public boolean loadOrCreateControllerData(Controller<?, ?> controller) {
|
||||||
|
boolean result = _loadOrCreateControllerData(controller);
|
||||||
|
saveIfDirty();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean _loadOrCreateControllerData(Controller<?, ?> controller) {
|
||||||
var uid = controller.uid();
|
var uid = controller.uid();
|
||||||
if (controllerData.has(uid)) {
|
if (controllerData.has(uid)) {
|
||||||
Controlify.LOGGER.info("Loading controller data for " + uid);
|
Controlify.LOGGER.info("Loading controller data for " + uid);
|
||||||
@ -134,7 +147,7 @@ public class ControlifyConfig {
|
|||||||
private void applyControllerConfig(Controller<?, ?> controller, JsonObject object) {
|
private void applyControllerConfig(Controller<?, ?> controller, JsonObject object) {
|
||||||
try {
|
try {
|
||||||
controller.setConfig(GSON, object.getAsJsonObject("config"));
|
controller.setConfig(GSON, object.getAsJsonObject("config"));
|
||||||
controller.bindings().fromJson(object.getAsJsonObject("bindings"));
|
dirty |= !controller.bindings().fromJson(object.getAsJsonObject("bindings"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Controlify.LOGGER.error("Failed to load controller data for " + controller.uid() + ". Resetting to default!", e);
|
Controlify.LOGGER.error("Failed to load controller data for " + controller.uid() + ". Resetting to default!", e);
|
||||||
controller.resetConfig();
|
controller.resetConfig();
|
||||||
@ -142,6 +155,13 @@ public class ControlifyConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveIfDirty() {
|
||||||
|
if (dirty) {
|
||||||
|
Controlify.LOGGER.info("Config is dirty. Saving...");
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<JsonObject> getLoadedControllerConfig(String uid) {
|
public Optional<JsonObject> getLoadedControllerConfig(String uid) {
|
||||||
return Optional.ofNullable(controllerData.getAsJsonObject(uid));
|
return Optional.ofNullable(controllerData.getAsJsonObject(uid));
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@ package dev.isxander.controlify.config.gui;
|
|||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import dev.isxander.controlify.Controlify;
|
import dev.isxander.controlify.Controlify;
|
||||||
|
import dev.isxander.controlify.bindings.ControllerBinding;
|
||||||
import dev.isxander.controlify.bindings.IBind;
|
import dev.isxander.controlify.bindings.IBind;
|
||||||
import dev.isxander.controlify.config.GlobalSettings;
|
import dev.isxander.controlify.config.GlobalSettings;
|
||||||
import dev.isxander.controlify.controller.Controller;
|
import dev.isxander.controlify.controller.Controller;
|
||||||
|
import dev.isxander.controlify.controller.ControllerState;
|
||||||
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||||
import dev.isxander.controlify.controller.gamepad.GamepadState;
|
import dev.isxander.controlify.controller.gamepad.GamepadState;
|
||||||
import dev.isxander.controlify.controller.gamepad.BuiltinGamepadTheme;
|
import dev.isxander.controlify.controller.gamepad.BuiltinGamepadTheme;
|
||||||
@ -30,6 +32,7 @@ import net.minecraft.network.chat.Component;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
@ -263,7 +266,9 @@ public class YACLHelper {
|
|||||||
var controlsGroup = OptionGroup.createBuilder()
|
var controlsGroup = OptionGroup.createBuilder()
|
||||||
.name(Component.translatable("controlify.gui.group.controls"));
|
.name(Component.translatable("controlify.gui.group.controls"));
|
||||||
if (controller instanceof GamepadController gamepad) {
|
if (controller instanceof GamepadController gamepad) {
|
||||||
for (var binding : gamepad.bindings().registry().values()) {
|
groupBindings(gamepad.bindings().registry().values()).forEach((categoryName, bindGroup) -> {
|
||||||
|
controlsGroup.option(LabelOption.create(categoryName));
|
||||||
|
for (var binding : bindGroup) {
|
||||||
controlsGroup.option(Option.createBuilder((Class<IBind<GamepadState>>) (Class<?>) IBind.class)
|
controlsGroup.option(Option.createBuilder((Class<IBind<GamepadState>>) (Class<?>) IBind.class)
|
||||||
.name(binding.name())
|
.name(binding.name())
|
||||||
.binding(binding.defaultBind(), binding::currentBind, binding::setCurrentBind)
|
.binding(binding.defaultBind(), binding::currentBind, binding::setCurrentBind)
|
||||||
@ -271,8 +276,11 @@ public class YACLHelper {
|
|||||||
.tooltip(binding.description())
|
.tooltip(binding.description())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} else if (controller instanceof JoystickController<?> joystick) {
|
} else if (controller instanceof JoystickController<?> joystick) {
|
||||||
for (var binding : joystick.bindings().registry().values()) {
|
groupBindings(joystick.bindings().registry().values()).forEach((categoryName, bindGroup) -> {
|
||||||
|
controlsGroup.option(LabelOption.create(categoryName));
|
||||||
|
for (var binding : bindGroup) {
|
||||||
controlsGroup.option(Option.createBuilder((Class<IBind<JoystickState>>) (Class<?>) IBind.class)
|
controlsGroup.option(Option.createBuilder((Class<IBind<JoystickState>>) (Class<?>) IBind.class)
|
||||||
.name(binding.name())
|
.name(binding.name())
|
||||||
.binding(binding.defaultBind(), binding::currentBind, binding::setCurrentBind)
|
.binding(binding.defaultBind(), binding::currentBind, binding::setCurrentBind)
|
||||||
@ -280,10 +288,16 @@ public class YACLHelper {
|
|||||||
.tooltip(binding.description())
|
.tooltip(binding.description())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
category.group(controlsGroup.build());
|
category.group(controlsGroup.build());
|
||||||
|
|
||||||
return category.build();
|
return category.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T extends ControllerState> Map<Component, List<ControllerBinding<T>>> groupBindings(Collection<ControllerBinding<T>> bindings) {
|
||||||
|
return bindings.stream()
|
||||||
|
.collect(Collectors.groupingBy(ControllerBinding::category, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package dev.isxander.controlify.mixins.compat.fapi;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.impl.client.keybinding.KeyBindingRegistryImpl;
|
||||||
|
import net.minecraft.client.KeyMapping;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(KeyBindingRegistryImpl.class)
|
||||||
|
public interface KeyBindingRegistryImplAccessor {
|
||||||
|
@Accessor("MODDED_KEY_BINDINGS")
|
||||||
|
static List<KeyMapping> getCustomKeys() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package dev.isxander.controlify.mixins.feature.bind;
|
||||||
|
|
||||||
|
import net.minecraft.client.ToggleKeyMapping;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
@Mixin(ToggleKeyMapping.class)
|
||||||
|
public interface ToggleKeyMappingAccessor {
|
||||||
|
@Accessor
|
||||||
|
BooleanSupplier getNeedsToggle();
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package dev.isxander.controlify.mixins.feature.screenop;
|
||||||
|
|
||||||
|
import dev.isxander.controlify.screenop.ComponentProcessorProvider;
|
||||||
|
import dev.isxander.controlify.screenop.ScreenProcessorProvider;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public class MinecraftMixin {
|
||||||
|
@Inject(method = "setScreen", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/BufferUploader;reset()V"))
|
||||||
|
private void changeScreen(Screen screen, CallbackInfo ci) {
|
||||||
|
ScreenProcessorProvider.REGISTRY.clearCache();
|
||||||
|
ComponentProcessorProvider.REGISTRY.clearCache();
|
||||||
|
}
|
||||||
|
}
|
@ -26,10 +26,4 @@ public class ScreenMixin implements ScreenProcessorProvider {
|
|||||||
// cannot use screenProcessor() because it may be overriden by registry
|
// cannot use screenProcessor() because it may be overriden by registry
|
||||||
ScreenProcessorProvider.provide((Screen) (Object) this).onWidgetRebuild();
|
ScreenProcessorProvider.provide((Screen) (Object) this).onWidgetRebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "init(Lnet/minecraft/client/Minecraft;II)V", at = @At("HEAD"))
|
|
||||||
private void clearRegistryCaches(Minecraft client, int width, int height, CallbackInfo ci) {
|
|
||||||
ScreenProcessorProvider.REGISTRY.clearCache();
|
|
||||||
ComponentProcessorProvider.REGISTRY.clearCache();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@ import org.spongepowered.asm.mixin.gen.Invoker;
|
|||||||
@Mixin(CreativeModeInventoryScreen.class)
|
@Mixin(CreativeModeInventoryScreen.class)
|
||||||
public interface CreativeModeInventoryScreenAccessor {
|
public interface CreativeModeInventoryScreenAccessor {
|
||||||
@Accessor
|
@Accessor
|
||||||
CreativeModeTab getSelectedTab();
|
static CreativeModeTab getSelectedTab() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
@Invoker
|
@Invoker
|
||||||
void invokeSelectTab(CreativeModeTab tab);
|
void invokeSelectTab(CreativeModeTab tab);
|
||||||
|
@ -20,13 +20,13 @@ public class CreativeModeInventoryScreenProcessor extends AbstractContainerScree
|
|||||||
|
|
||||||
if (controller.bindings().GUI_NEXT_TAB.justPressed()) {
|
if (controller.bindings().GUI_NEXT_TAB.justPressed()) {
|
||||||
var tabs = CreativeModeTabs.tabs();
|
var tabs = CreativeModeTabs.tabs();
|
||||||
int newIndex = tabs.indexOf(accessor.getSelectedTab()) + 1;
|
int newIndex = tabs.indexOf(CreativeModeInventoryScreenAccessor.getSelectedTab()) + 1;
|
||||||
if (newIndex >= tabs.size()) newIndex = 0;
|
if (newIndex >= tabs.size()) newIndex = 0;
|
||||||
accessor.invokeSelectTab(tabs.get(newIndex));
|
accessor.invokeSelectTab(tabs.get(newIndex));
|
||||||
}
|
}
|
||||||
if (controller.bindings().GUI_PREV_TAB.justPressed()) {
|
if (controller.bindings().GUI_PREV_TAB.justPressed()) {
|
||||||
var tabs = CreativeModeTabs.tabs();
|
var tabs = CreativeModeTabs.tabs();
|
||||||
int newIndex = tabs.indexOf(accessor.getSelectedTab()) - 1;
|
int newIndex = tabs.indexOf(CreativeModeInventoryScreenAccessor.getSelectedTab()) - 1;
|
||||||
if (newIndex < 0) newIndex = tabs.size() - 1;
|
if (newIndex < 0) newIndex = tabs.size() - 1;
|
||||||
accessor.invokeSelectTab(tabs.get(newIndex));
|
accessor.invokeSelectTab(tabs.get(newIndex));
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,11 @@
|
|||||||
"controlify.binding.controlify.cycle_opt_forward": "Cycle Option Forward",
|
"controlify.binding.controlify.cycle_opt_forward": "Cycle Option Forward",
|
||||||
"controlify.binding.controlify.cycle_opt_backward": "Cycle Option Backward",
|
"controlify.binding.controlify.cycle_opt_backward": "Cycle Option Backward",
|
||||||
|
|
||||||
|
"controlify.binding_category.gui": "GUI",
|
||||||
|
"controlify.binding_category.vmouse": "Virtual Mouse",
|
||||||
|
|
||||||
|
"controlify.custom_binding.vanilla_description": "Automatically generated key binding from Fabric API.",
|
||||||
|
|
||||||
"controlify.guide.inventory": "Open Inventory",
|
"controlify.guide.inventory": "Open Inventory",
|
||||||
"controlify.guide.swim_up": "Swim Up",
|
"controlify.guide.swim_up": "Swim Up",
|
||||||
"controlify.guide.start_elytra": "Open Elytra Wings",
|
"controlify.guide.start_elytra": "Open Elytra Wings",
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"core.GLXMixin"
|
"core.GLXMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
|
"compat.fapi.KeyBindingRegistryImplAccessor",
|
||||||
"compat.sodium.SodiumOptionsGUIAccessor",
|
"compat.sodium.SodiumOptionsGUIAccessor",
|
||||||
"compat.sodium.SodiumOptionsGUIMixin",
|
"compat.sodium.SodiumOptionsGUIMixin",
|
||||||
"compat.yacl.CyclingControllerElementMixin",
|
"compat.yacl.CyclingControllerElementMixin",
|
||||||
@ -23,6 +24,7 @@
|
|||||||
"feature.accessibility.LocalPlayerMixin",
|
"feature.accessibility.LocalPlayerMixin",
|
||||||
"feature.autoswitch.ToastComponentAccessor",
|
"feature.autoswitch.ToastComponentAccessor",
|
||||||
"feature.bind.KeyMappingAccessor",
|
"feature.bind.KeyMappingAccessor",
|
||||||
|
"feature.bind.ToggleKeyMappingAccessor",
|
||||||
"feature.chatkbheight.ChatComponentMixin",
|
"feature.chatkbheight.ChatComponentMixin",
|
||||||
"feature.chatkbheight.ChatScreenMixin",
|
"feature.chatkbheight.ChatScreenMixin",
|
||||||
"feature.guide.ingame.ClientPacketListenerMixin",
|
"feature.guide.ingame.ClientPacketListenerMixin",
|
||||||
@ -30,6 +32,7 @@
|
|||||||
"feature.guide.screen.AbstractButtonMixin",
|
"feature.guide.screen.AbstractButtonMixin",
|
||||||
"feature.guide.screen.AbstractWidgetMixin",
|
"feature.guide.screen.AbstractWidgetMixin",
|
||||||
"feature.guide.screen.TabNavigationBarMixin",
|
"feature.guide.screen.TabNavigationBarMixin",
|
||||||
|
"feature.screenop.MinecraftMixin",
|
||||||
"feature.screenop.ScreenMixin",
|
"feature.screenop.ScreenMixin",
|
||||||
"feature.screenop.vanilla.AbstractButtonMixin",
|
"feature.screenop.vanilla.AbstractButtonMixin",
|
||||||
"feature.screenop.vanilla.AbstractContainerEventHandlerMixin",
|
"feature.screenop.vanilla.AbstractContainerEventHandlerMixin",
|
||||||
|
@ -5,6 +5,7 @@ import dev.isxander.controlify.api.ControlifyApi;
|
|||||||
import dev.isxander.controlify.api.bind.ControlifyBindingsApi;
|
import dev.isxander.controlify.api.bind.ControlifyBindingsApi;
|
||||||
import dev.isxander.controlify.api.event.ControlifyEvents;
|
import dev.isxander.controlify.api.event.ControlifyEvents;
|
||||||
import dev.isxander.controlify.bindings.BindingSupplier;
|
import dev.isxander.controlify.bindings.BindingSupplier;
|
||||||
|
import dev.isxander.controlify.bindings.EmptyBind;
|
||||||
import dev.isxander.controlify.bindings.GamepadBinds;
|
import dev.isxander.controlify.bindings.GamepadBinds;
|
||||||
import dev.isxander.controlify.screenop.ScreenProcessor;
|
import dev.isxander.controlify.screenop.ScreenProcessor;
|
||||||
import dev.isxander.controlify.screenop.ScreenProcessorProvider;
|
import dev.isxander.controlify.screenop.ScreenProcessorProvider;
|
||||||
@ -25,7 +26,10 @@ public class ControlifyTests {
|
|||||||
void bindingRegistryTest() {
|
void bindingRegistryTest() {
|
||||||
var registry = ControlifyBindingsApi.get();
|
var registry = ControlifyBindingsApi.get();
|
||||||
assertNotNull(registry, "Binding registry is null");
|
assertNotNull(registry, "Binding registry is null");
|
||||||
binding = registry.registerBind(GamepadBinds.A_BUTTON, new ResourceLocation("controlify", "test_bind"));
|
binding = registry.registerBind(
|
||||||
|
new ResourceLocation("controlify", "test_bind"),
|
||||||
|
builder -> builder.defaultBind(new EmptyBind<>())
|
||||||
|
);
|
||||||
assertNotNull(binding, "Bind registry failed - BindingSupplier is null");
|
assertNotNull(binding, "Bind registry failed - BindingSupplier is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user