Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ public final class ControlifyBindings {
.id("controlify", "radial_axis_right")
.category(RADIAL_CATEGORY)
.allowedContexts(BindContext.RADIAL_MENU));
//? if neoforge {
public static final InputBindingSupplier RADIAL_SEND_KEY = ControlifyBindApi.get().registerBinding(builder -> builder
.id("controlify", "radial_send_key")
.category(RADIAL_CATEGORY)
.allowedContexts(BindContext.RADIAL_MENU));
//?}

public static final InputBindingSupplier VMOUSE_MOVE_UP = ControlifyBindApi.get().registerBinding(builder -> builder
.id("controlify", "vmouse_move_up")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
import net.minecraft.util.Mth;
import org.jetbrains.annotations.Nullable;

//? if neoforge {
/*import net.minecraft.client.KeyMapping;
import org.lwjgl.glfw.GLFW;
import net.neoforged.neoforge.client.event.InputEvent;
import net.neoforged.neoforge.common.NeoForge;

//? if >= 1.21.9 {
//import net.minecraft.client.input.KeyEvent;
//?}

//? if < 1.21.4 {
//import dev.isxander.controlify.mixins.feature.bind.KeyMappingAccessor;
//?}

*///?}

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -109,7 +125,7 @@ protected void init() {
}
animation.play();

if (editMode != null) {
// if (editMode != null) {
// var exitGuide = addRenderableWidget(new PositionedComponent<>(
// new GuideActionRenderer(
// new GuideAction(
Expand All @@ -126,19 +142,54 @@ protected void init() {
//
// exitGuide.getComponent().updateName(null);
// exitGuide.updatePosition(width, height);
}
// }
}

@Override
public void onControllerInput(ControllerEntity controller) {
if (this.controller != controller) return;

if (editMode == null && !openBind.digitalNow()) {
if (selectedButton != -1 && buttons[selectedButton].invoke()) {
playClickSound();
if (editMode == null) {
//? if neoforge {
/*if (ControlifyBindings.RADIAL_SEND_KEY.on(controller).justPressed()) {
onClose();

if (selectedButton != -1) {
@Nullable KeyMapping km =
//? if >= 1.21.4 {
KeyMapping
//?} else {
//KeyMappingAccessor.getAll()
//?}
.get(controller.input().orElseThrow().confObj().radialActions[selectedButton].getPath());

if (km != null) {
NeoForge.EVENT_BUS.post(
new InputEvent.Key(
//? if >= 1.21.9 {
new KeyEvent(km.getKey().getValue(), 0, 0),
GLFW.GLFW_PRESS
//?} else {
//km.getKey().getValue(),
//0,
//GLFW.GLFW_PRESS,
//0
//?}
)
);
playClickSound();
}
}
}
*///?}

onClose();
if (!openBind.digitalNow()) {
if (selectedButton != -1 && buttons[selectedButton].invoke()) {
playClickSound();
}

onClose();
}
}

if (editMode != null && ControlifyBindings.GUI_BACK.on(controller).justPressed()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.isxander.controlify.mixins.feature.bind;

import net.minecraft.client.KeyMapping;
import org.apache.commons.lang3.NotImplementedException;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Map;

@Mixin(KeyMapping.class)
public interface KeyMappingAccessor {
@Accessor("ALL")
static Map<String, KeyMapping> getAll() {
throw new NotImplementedException("Should be overwritten by Accessor");
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/controlify/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
"controlify.binding.controlify.radial_axis_down": "Radial Menu Down",
"controlify.binding.controlify.radial_axis_left": "Radial Menu Left",
"controlify.binding.controlify.radial_axis_right": "Radial Menu Right",
"controlify.binding.controlify.radial_send_key": "Radial Menu Send Key",
"controlify.binding.controlify.game_mode_switcher": "Game Mode Switcher",
"controlify.binding.controlify.vmouse_move_up": "VMouse Move Up",
"controlify.binding.controlify.vmouse_move_down": "VMouse Move Down",
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/controlify.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"core.MouseHandlerMixin",
"feature.accessibility.LocalPlayerMixin",
"feature.bind.GuiMixin",
"feature.bind.KeyMappingAccessor",
"feature.bind.KeyMappingMixin",
"feature.bind.MinecraftMixin",
"feature.bind.ToggleKeyMappingMixin",
Expand Down Expand Up @@ -86,10 +87,10 @@
"feature.screenop.impl.elements.EditBoxMixin",
"feature.screenop.impl.outofgame.CreateWorldScreenMixin",
"feature.screenop.impl.outofgame.DirectJoinServerScreenMixin",
"feature.screenop.impl.outofgame.ManageServerScreenMixin",
"feature.screenop.impl.outofgame.JoinMultiplayerScreenAccessor",
"feature.screenop.impl.outofgame.JoinMultiplayerScreenMixin",
"feature.screenop.impl.outofgame.LanguageSelectionListEntryMixin",
"feature.screenop.impl.outofgame.ManageServerScreenMixin",
"feature.screenop.impl.outofgame.OptionsSubScreenAccessor",
"feature.screenop.impl.outofgame.PauseScreenAccessor",
"feature.screenop.impl.outofgame.PauseScreenMixin",
Expand Down