1
0
forked from Clones/Controlify

controller hid identification + ps4 buttons

This commit is contained in:
isXander
2023-02-03 19:23:08 +00:00
parent 5bd390f2b1
commit c9b0870af3
54 changed files with 302 additions and 44 deletions

View File

@ -28,12 +28,10 @@ public enum Bind {
private final BiFunction<ControllerState, Controller, Boolean> state;
private final String identifier;
private final ResourceLocation textureLocation;
Bind(BiFunction<ControllerState, Controller, Boolean> state, String identifier) {
this.state = state;
this.identifier = identifier;
this.textureLocation = new ResourceLocation("controlify", "textures/gui/buttons/xbox/" + identifier + ".png");
}
Bind(Function<ControllerState, Boolean> state, String identifier) {
@ -48,8 +46,8 @@ public enum Bind {
return identifier;
}
public ResourceLocation textureLocation() {
return textureLocation;
public ResourceLocation textureLocation(Controller controller) {
return new ResourceLocation("controlify", "textures/gui/buttons/" + controller.config().theme.id(controller) + "/" + identifier + ".png");
}
public static Bind fromIdentifier(String identifier) {

View File

@ -0,0 +1,28 @@
package dev.isxander.controlify.bindings;
import dev.isxander.controlify.controller.Controller;
import dev.isxander.yacl.api.NameableEnum;
import net.minecraft.network.chat.Component;
import java.util.function.Function;
public enum ControllerTheme implements NameableEnum {
AUTO(c -> c.type().theme().id(c)),
XBOX_ONE(c -> "xbox"),
DUALSHOCK4(c -> "dualshock4");
private final Function<Controller, String> idGetter;
ControllerTheme(Function<Controller, String> idGetter) {
this.idGetter = idGetter;
}
public String id(Controller controller) {
return idGetter.apply(controller);
}
@Override
public Component getDisplayName() {
return Component.translatable("controlify.controller_theme." + name().toLowerCase());
}
}