forked from Clones/Controlify
rewrite most of joystick mapping
This commit is contained in:
@ -8,6 +8,7 @@ import dev.isxander.controlify.api.bind.ControllerBindingBuilder;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.ControllerState;
|
||||
import dev.isxander.controlify.api.event.ControlifyEvents;
|
||||
import dev.isxander.controlify.controller.gamepad.GamepadController;
|
||||
import dev.isxander.controlify.mixins.compat.fapi.KeyBindingRegistryImplAccessor;
|
||||
import dev.isxander.controlify.mixins.feature.bind.KeyMappingAccessor;
|
||||
import dev.isxander.controlify.mixins.feature.bind.ToggleKeyMappingAccessor;
|
||||
@ -38,6 +39,7 @@ public class ControllerBindings<T extends ControllerState> {
|
||||
public final ControllerBinding<T>
|
||||
WALK_FORWARD, WALK_BACKWARD, WALK_LEFT, WALK_RIGHT,
|
||||
LOOK_UP, LOOK_DOWN, LOOK_LEFT, LOOK_RIGHT,
|
||||
GAMEPAD_GYRO_BUTTON,
|
||||
JUMP, SNEAK,
|
||||
ATTACK, USE,
|
||||
SPRINT,
|
||||
@ -110,6 +112,15 @@ public class ControllerBindings<T extends ControllerState> {
|
||||
.defaultBind(GamepadBinds.RIGHT_STICK_RIGHT)
|
||||
.category(MOVEMENT_CATEGORY)
|
||||
.build());
|
||||
if (controller instanceof GamepadController gamepad && gamepad.hasGyro()) {
|
||||
register(GAMEPAD_GYRO_BUTTON = ControllerBindingBuilder.create(controller)
|
||||
.identifier("controlify", "gamepad_gyro_button")
|
||||
.defaultBind(new EmptyBind<>())
|
||||
.category(MOVEMENT_CATEGORY)
|
||||
.build());
|
||||
} else {
|
||||
GAMEPAD_GYRO_BUTTON = null;
|
||||
}
|
||||
register(JUMP = ControllerBindingBuilder.create(controller)
|
||||
.identifier("controlify", "jump")
|
||||
.defaultBind(GamepadBinds.A_BUTTON)
|
||||
|
@ -42,8 +42,8 @@ public class JoystickAxisBind implements IBind<JoystickState> {
|
||||
JoystickMapping mapping = joystick.mapping();
|
||||
|
||||
String type = joystick.type().identifier();
|
||||
String axis = mapping.axis(axisIndex).identifier();
|
||||
String direction = mapping.axis(axisIndex).getDirectionIdentifier(axisIndex, this.direction);
|
||||
String axis = mapping.axes()[axisIndex].identifier();
|
||||
String direction = mapping.axes()[axisIndex].getDirectionIdentifier(axisIndex, this.direction);
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/axis_" + axis + "_" + direction + ".png");
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
|
@ -31,7 +31,7 @@ public class JoystickButtonBind implements IBind<JoystickState> {
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
String type = joystick.type().identifier();
|
||||
String button = joystick.mapping().button(buttonIndex).identifier();
|
||||
String button = joystick.mapping().buttons()[buttonIndex].identifier();
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/button_" + button + ".png");
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
|
@ -33,18 +33,18 @@ public class JoystickHatBind implements IBind<JoystickState> {
|
||||
@Override
|
||||
public void draw(PoseStack matrices, int x, int centerY) {
|
||||
String type = joystick.type().identifier();
|
||||
String button = joystick.mapping().button(hatIndex).identifier();
|
||||
String hat = joystick.mapping().hats()[hatIndex].identifier();
|
||||
String direction = "centered";
|
||||
if (hatState.isUp())
|
||||
direction = "up";
|
||||
else if (hatState.isDown())
|
||||
direction = "down";
|
||||
else if (hatState.isLeft())
|
||||
direction = "strong";
|
||||
direction = "left";
|
||||
else if (hatState.isRight())
|
||||
direction = "weak";
|
||||
direction = "right";
|
||||
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/hat" + button + "_" + direction + ".png");
|
||||
var texture = new ResourceLocation("controlify", "textures/gui/joystick/" + type + "/hat" + hat + "_" + direction + ".png");
|
||||
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
Reference in New Issue
Block a user