Compare commits

..

15 Commits

Author SHA1 Message Date
Motschen
ce9495c79c Fix vanilla mouseScreens not working in production 2022-05-08 19:42:41 +02:00
Motschen
ff8270d18a MidnightControls 1.0.0 - Bedrock icon resourcepack
- Bring back Lambda-style XBox icons and add optional resourcepack for Bedrock-style icons (Closes #16)
- Make screens on which the controller behaves like a mouse configurable in the advanced config.
2022-05-08 18:46:46 +02:00
Martin Prokoph
3f33549760 Merge pull request #18 from akemin-dayo/1.18
MidnightControlsSettingsScreen: Fix midnightcontrols.tooltip.controls_mode localisation key, which somehow got clobbered in commit SHA1 0226bfc62f.
2022-05-03 20:59:43 +02:00
Karen/あけみ
d034607032 Merge branch '1.18' of https://github.com/TeamMidnightDust/MidnightControls into 1.18
* '1.18' of https://github.com/TeamMidnightDust/MidnightControls:
  Fix crash on resizing options screen
  MidnightControls 0.3.0 - Automatic mapping downloading
2022-05-03 11:54:22 -07:00
Karen/あけみ
e9a11c0ab9 MidnightControlsSettingsScreen: Fix midnightcontrols.tooltip.controls_mode localisation key, which somehow got clobbered in commit SHA1 0226bfc62f. 2022-05-03 11:50:00 -07:00
Motschen
e0d90fc56a Fix crash on resizing options screen 2022-05-03 20:41:24 +02:00
Motschen
cac23d12a1 MidnightControls 0.3.0 - Automatic mapping downloading
- Automatic downloading of mappings from https://github.com/gabomdq/SDL_GameControllerDB
- Change some default settings
- Fix OkZoomer compat by @akemin-dayo
- German translations (by myself)
- Add contributors to fabric.mod.json
- Fix some issues
2022-05-03 20:29:29 +02:00
Martin Prokoph
b982772d31 Merge pull request #17 from akemin-dayo/akemi-ok-zoomer-compat
OkZoomerCompat, MidnightControlsCompat: Major rewrite that now adds compatibility with both 5.0.0-beta Ok Zoomer API versions via Reflection.
2022-05-03 17:23:59 +02:00
Martin Prokoph
e4ca0db2a2 Merge pull request #15 from akemin-dayo/1.18
Added an option to always show the HUD while in Controller Mode, matching the legacy behaviour of LambdaControls. Also changed some default settings to be "safe" in the sense that the features that can be considered "cheating" in multiplayer servers are now disabled by default.
2022-05-03 17:23:45 +02:00
Karen/あけみ
f0cd2a51d1 build.gradle, gradle.properties: Temporarily comment out Ok Zoomer and LibZoomer dependencies, since we don't use them right now as OkZoomerCompat uses Reflection at runtime instead to deal with the current API incompatibility situation. 2022-05-03 07:50:08 -07:00
Karen/あけみ
9d37862144 OkZoomerCompat, MidnightControlsCompat: Major rewrite that now adds compatibility with both 5.0.0-beta Ok Zoomer API versions via Reflection. This fully fixes all current Ok Zoomer-related crashing issues, such as those encountered in #3. Tested with Minecraft 1.18.2 (5.0.0-beta.6) and Minecraft 1.18.1 (5.0.0-beta.3). 2022-05-03 07:43:06 -07:00
Karen/あけみ
c31fb76215 MidnightControlsConfig: Changed some default settings to be "safe" in the sense that the features that can be considered "cheating" in multiplayer servers are now disabled by default. 2022-05-03 05:02:23 -07:00
Karen/あけみ
b6563af2b1 hud_always_show: Add untranslated strings to es_mx, fr_ca, fr_ft, tr_tr, and zh_cn. 2022-05-03 04:54:07 -07:00
Karen/あけみ
1a0030a680 Added an option to always show the HUD while in Controller Mode, matching the legacy behaviour of LambdaControls. This option is enabled by default so that users migrating from LambdaControls will have a consistent experience. 2022-05-03 04:53:45 -07:00
Motschen
78c858b753 Refresh MidnightControlsFeature state on config change 2022-05-03 12:59:08 +02:00
24 changed files with 403 additions and 67 deletions

View File

@@ -5,8 +5,8 @@
[![GitHub license](https://img.shields.io/github/license/TeamMidnightDust/MidnightControls?style=flat-square)](https://raw.githubusercontent.com/TeamMidnightDust/MidnightControls/master/LICENSE)
![Environment: Client](https://img.shields.io/badge/environment-client-1976d2?style=flat-square)
[![Mod loader: Quilt/Fabric]][quilt] <!-- modrinth_exclude.start -->
![Version](https://img.shields.io/github/v/tag/TeamMidnightDust/MidnightControls?label=version&style=flat-square)
[![CurseForge](http://cf.way2muchnoise.eu/title/354231.svg)](https://www.curseforge.com/minecraft/mc-mods/midnightcontrols)
[![Version](https://img.shields.io/github/v/tag/TeamMidnightDust/MidnightControls?label=version&style=flat-square)](https://github.com/TeamMidnightDust/MidnightControls/releases)
[![CurseForge](http://cf.way2muchnoise.eu/title/621768.svg)](https://www.curseforge.com/minecraft/mc-mods/midnightcontrols)
<!-- modrinth_exclude.end -->
A Fabric Minecraft mod which adds better controls, reach-around and controller support.

View File

@@ -104,9 +104,13 @@ dependencies {
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
// Compatibility mods
modImplementation("maven.modrinth:ok-zoomer:${project.ok_zoomer_version}")
modImplementation "io.github.ennuil:LibZoomer:${project.libzoomer_version}"
// Ok Zoomer and LibZoomer are temporarily disabled for the time being, as we are currently using Reflection at runtime instead in OkZoomerCompat due to there being two major, completely incompatible API versions.
// modImplementation("maven.modrinth:ok-zoomer:${project.ok_zoomer_version}")
// modImplementation "io.github.ennuil:LibZoomer:${project.libzoomer_version}"
modImplementation "org.quiltmc:quilt-json5:1.0.0"
//modImplementation "maven.modrinth:sodium:${project.sodium_version}"
modImplementation("me.shedaniel:RoughlyEnoughItems-runtime-fabric:${project.rei_version}")
modImplementation "maven.modrinth:emotecraft:${project.emotecraft_version}"
modImplementation "io.github.kosmx:bendy-lib:${project.bendylib_version}"

View File

@@ -8,19 +8,22 @@ yarn_mappings=1.18.1+build.22
loader_version=0.13.3
# Mod Properties
mod_version = 0.2.0
mod_version = 1.0.0
maven_group = eu.midnightdust
archives_base_name = midnightcontrols
modrinth_id=W1D3UXEc
modrinth_id=bXX9h73M
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.46.6+1.18
sodium_version=mc1.18.2-0.4.1
spruceui_version=3.3.2+1.17
midnightlib_version=0.4.0
modmenu_version=2.0.2
emotecraft_version=2.1-MC1.18.1-fabric
bendylib_version=2.0.+
rei_version=7.4.456
ok_zoomer_version=5.0.0-beta.3+1.17.1
libzoomer_version = 0.3.0+1.17.1
# Ok Zoomer and LibZoomer are temporarily disabled for the time being, as we are currently using Reflection at runtime instead in OkZoomerCompat due to there being two major, completely incompatible API versions.
# ok_zoomer_version=5.0.0-beta.3+1.17.1
# libzoomer_version=0.3.0+1.17.1

View File

@@ -23,5 +23,5 @@ public class MidnightControlsConstants {
public static final String NAMESPACE = "midnightcontrols";
public static final Identifier CONTROLS_MODE_CHANNEL = new Identifier(NAMESPACE, "controls_mode");
public static final Identifier FEATURE_CHANNEL = new Identifier(NAMESPACE, "feature");
public static final Identifier HELLO_CHANNEL = new Identifier(NAMESPACE, "hello");
public static final Identifier HELLO_CHANNEL = new Identifier("lambdacontrols", "hello");
}

View File

@@ -98,6 +98,15 @@ public class MidnightControlsFeature implements Nameable {
this.enabled = enabled;
}
/**
* Refreshes the enabled values from the config.
*/
public static void refreshEnabled() {
MidnightControlsFeature.VERTICAL_REACHAROUND.setEnabled(MidnightControlsConfig.verticalReacharound);
MidnightControlsFeature.FAST_BLOCK_PLACING.setEnabled(MidnightControlsConfig.fastBlockPlacing);
MidnightControlsFeature.HORIZONTAL_REACHAROUND.setEnabled(MidnightControlsConfig.horizontalReacharound);
}
/**
* Returns whether this feature is available or not.
*

View File

@@ -28,6 +28,9 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.option.KeyBinding;
@@ -64,7 +67,7 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
public static final Identifier CONTROLLER_EXPANDED = new Identifier(MidnightControlsConstants.NAMESPACE, "textures/gui/controller_expanded.png");
public static final Identifier CONTROLLER_AXIS = new Identifier(MidnightControlsConstants.NAMESPACE, "textures/gui/controller_axis.png");
public static final Identifier CURSOR_TEXTURE = new Identifier(MidnightControlsConstants.NAMESPACE, "textures/gui/cursor.png");
public final static File MAPPINGS_FILE = new File("config/gamecontrollerdb.txt");
public final static File MAPPINGS_FILE = new File("config/gamecontrollercustommappings.txt");
public final MidnightInput input = new MidnightInput();
public final MidnightRing ring = new MidnightRing(this);
public final MidnightReacharound reacharound = new MidnightReacharound();
@@ -114,6 +117,9 @@ public class MidnightControlsClient extends MidnightControls implements ClientMo
});
HudManager.register(this.hud = new MidnightControlsHud(this));
FabricLoader.getInstance().getModContainer("midnightcontrols").ifPresent(modContainer -> {
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("midnightcontrols","bedrock"), modContainer, ResourcePackActivationType.NORMAL);
});
}
/**

View File

@@ -11,6 +11,7 @@ package eu.midnightdust.midnightcontrols.client;
import eu.midnightdust.lib.config.MidnightConfig;
import eu.midnightdust.midnightcontrols.ControlsMode;
import eu.midnightdust.midnightcontrols.MidnightControlsFeature;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import eu.midnightdust.midnightcontrols.client.controller.Controller;
import eu.midnightdust.midnightcontrols.client.controller.InputManager;
@@ -30,18 +31,18 @@ import static org.lwjgl.glfw.GLFW.GLFW_GAMEPAD_AXIS_LEFT_Y;
public class MidnightControlsConfig extends MidnightConfig {
// General
@Entry public static ControlsMode controlsMode = ControlsMode.DEFAULT;
@Entry public static boolean autoSwitchMode = false;
@Entry public static boolean autoSwitchMode = true;
@Entry public static boolean debug = false;
// HUD
@Entry public static boolean hudEnable = true;
@Entry public static HudSide hudSide = HudSide.LEFT;
// Gameplay
@Entry public static boolean analogMovement = true;
@Entry public static boolean fastBlockPlacing = true;
@Entry public static boolean flyDrifting = false;
@Entry public static boolean verticalFlyDrifting = true;
@Entry public static boolean horizontalReacharound = false;
@Entry public static boolean verticalReacharound = false;
@Entry public static boolean fastBlockPlacing = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Entry public static boolean flyDrifting = true; // Enabled by default as disabling this behaviour can be considered cheating on multiplayer servers. It can also conflict with some other mods.
@Entry public static boolean verticalFlyDrifting = true; // Enabled by default as disabling this behaviour can be considered cheating on multiplayer servers.
@Entry public static boolean horizontalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Entry public static boolean verticalReacharound = false; // Disabled by default as this behaviour can be considered cheating on multiplayer servers.
@Entry public static boolean shouldRenderReacharoundOutline = true;
@Entry public static int[] reacharoundOutlineColor = new int[]{255, 255, 255, 102};
// Controller
@@ -56,18 +57,12 @@ public class MidnightControlsConfig extends MidnightConfig {
@Entry public static boolean unfocusedInput = false;
@Entry public static boolean virtualMouse = false;
@Entry public static VirtualMouseSkin virtualMouseSkin = VirtualMouseSkin.DEFAULT_LIGHT;
// @Entry public static List<Pages> ringPages = new ArrayList<String>();
// @Entry public static double maxAnalog1 = 1;
// @Entry public static double maxAnalog2 = 1;
// @Entry public static double maxAnalog3 = 1;
// @Entry public static double maxAnalog4 = 1;
@Entry public static Object controllerID = 0;
@Entry public static Object secondControllerID = -1;
@Entry public static List<String> mouseScreens = List.of("me.jellysquid.mods.sodium.client.gui","net.coderbot.iris.gui","net.minecraft.client.gui.screen.advancement", "net.minecraft.client.gui.screen.pack.PackScreen", "net.minecraft.class_5375", "net.minecraft.class_457", "net.minecraft.class_408");
@Entry public static Map<String, String> BINDINGS = Map.of();
private static final Pattern BUTTON_BINDING_PATTERN = Pattern.compile("(-?\\d+)\\+?");
// Gameplay.
// Controller settings
@Entry public static double[] maxAnalogValues = new double[]{DEFAULT_MAX_VALUE, DEFAULT_MAX_VALUE, DEFAULT_MAX_VALUE, DEFAULT_MAX_VALUE};
/**
@@ -87,6 +82,7 @@ public class MidnightControlsConfig extends MidnightConfig {
public static void save() {
MidnightControlsConfig.write("midnightcontrols");
MidnightControlsClient.get().log("Configuration saved.");
MidnightControlsFeature.refreshEnabled();
}
/**
* Gets the used controller.

View File

@@ -31,13 +31,13 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.ParentElement;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.advancement.AdvancementTab;
import net.minecraft.client.gui.screen.advancement.AdvancementsScreen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
import net.minecraft.client.gui.screen.pack.PackScreen;
import net.minecraft.client.gui.screen.world.WorldListWidget;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.gui.widget.EntryListWidget;
@@ -312,7 +312,7 @@ public class MidnightInput {
}
if (button == GLFW.GLFW_GAMEPAD_BUTTON_B) {
if (client.currentScreen != null) {
if (client.currentScreen != null && client.currentScreen.getClass() != TitleScreen.class) {
if (!MidnightControlsCompat.handleMenuBack(client, client.currentScreen))
if (!this.tryGoBack(client.currentScreen))
client.currentScreen.onClose();
@@ -703,7 +703,7 @@ public class MidnightInput {
}
public static boolean isScreenInteractive(@NotNull Screen screen) {
return !(screen instanceof AdvancementsScreen || screen instanceof HandledScreen || screen instanceof PackScreen
return !(screen instanceof HandledScreen || MidnightControlsConfig.mouseScreens.stream().anyMatch(a -> screen.getClass().toString().contains(a))
|| (screen instanceof SpruceScreen && ((SpruceScreen) screen).requiresCursor())
|| MidnightControlsCompat.requireMouseOnScreen(screen));
}

View File

@@ -40,7 +40,7 @@ public class MidnightControlsCompat {
*/
public static void init(@NotNull MidnightControlsClient mod) {
if (FabricLoader.getInstance().isModLoaded("okzoomer")) {
mod.log("Adding okzoomer compatibility...");
mod.log("Adding Ok Zoomer compatibility...");
HANDLERS.add(new OkZoomerCompat());
}
/*if (isReiPresent()) {

View File

@@ -1,7 +1,7 @@
/*
* Copyright © 2021 LambdAurora <aurora42lambda@gmail.com>
* Copyright © 2021-2022 Karen/あけみ <karen@akemi.ai>, LambdAurora <aurora42lambda@gmail.com>
*
* This file is part of midnightcontrols.
* This file is part of MidnightControls.
*
* Licensed under the MIT license. For more information,
* see the LICENSE file.
@@ -11,49 +11,173 @@ package eu.midnightdust.midnightcontrols.client.compat;
import eu.midnightdust.midnightcontrols.client.MidnightControlsClient;
import eu.midnightdust.midnightcontrols.client.controller.ButtonBinding;
import io.github.ennuil.okzoomer.keybinds.ZoomKeybinds;
import net.minecraft.client.option.KeyBinding;
import org.jetbrains.annotations.NotNull;
import org.aperlambda.lambdacommon.utils.LambdaReflection;
import org.lwjgl.glfw.GLFW;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Represents a compatibility handler for Ok Zoomer.
*
* @author LambdAurora
* @author Karen/あけみ, LambdAurora
* @version 1.4.3
* @since 1.1.0
*/
public class OkZoomerCompat implements CompatHandler {
private boolean didAllReflectionCallsSucceed = false;
private KeyBinding okZoomerZoomKey;
private KeyBinding okZoomerIncreaseZoomKey;
private KeyBinding okZoomerDecreaseZoomKey;
private KeyBinding okZoomerResetZoomKey;
private Method okZoomerAreExtraKeyBindsEnabledMethod;
public OkZoomerCompat() {
// These strings represent the names of the classes, fields, and methods we use from the Ok Zoomer API
String okZoomerZoomKeybindsClassString;
String okZoomerZoomKeyFieldString;
String okZoomerIncreaseZoomKeyFieldString;
String okZoomerDecreaseZoomKeyFieldString;
String okZoomerResetZoomKeyFieldString;
String okZoomerAreExtraKeyBindsEnabledMethodNameString;
// These variables represent the actual objects that we reflect to
Class<?> okZoomerZoomKeybindsClass;
Field okZoomerZoomKeyField;
Field okZoomerIncreaseZoomKeyField;
Field okZoomerDecreaseZoomKeyField;
Field okZoomerResetZoomKeyField;
// First, we need to determine which version of the Ok Zoomer API we're dealing with here.
if (LambdaReflection.doesClassExist("io.github.ennuil.okzoomer.keybinds.ZoomKeybinds")) {
// https://github.com/EnnuiL/OkZoomer/blob/5.0.0-beta.3+1.17.1/src/main/java/io/github/ennuil/okzoomer/keybinds/ZoomKeybinds.java
MidnightControlsClient.get().log("Ok Zoomer version 5.0.0-beta.3 or below detected!");
okZoomerZoomKeybindsClassString = "io.github.ennuil.okzoomer.keybinds.ZoomKeybinds";
okZoomerZoomKeyFieldString = "zoomKey";
okZoomerIncreaseZoomKeyFieldString = "increaseZoomKey";
okZoomerDecreaseZoomKeyFieldString = "decreaseZoomKey";
okZoomerResetZoomKeyFieldString = "resetZoomKey";
okZoomerAreExtraKeyBindsEnabledMethodNameString = "areExtraKeybindsEnabled";
} else if (LambdaReflection.doesClassExist("io.github.ennuil.okzoomer.key_binds.ZoomKeyBinds")) {
// https://github.com/EnnuiL/OkZoomer/blob/5.0.0-beta.6+1.18.2/src/main/java/io/github/ennuil/okzoomer/key_binds/ZoomKeyBinds.java
MidnightControlsClient.get().log("Ok Zoomer version 5.0.0-beta.4 or above detected!");
okZoomerZoomKeybindsClassString = "io.github.ennuil.okzoomer.key_binds.ZoomKeyBinds";
okZoomerZoomKeyFieldString = "ZOOM_KEY";
okZoomerIncreaseZoomKeyFieldString = "INCREASE_ZOOM_KEY";
okZoomerDecreaseZoomKeyFieldString = "DECREASE_ZOOM_KEY";
okZoomerResetZoomKeyFieldString = "RESET_ZOOM_KEY";
okZoomerAreExtraKeyBindsEnabledMethodNameString = "areExtraKeyBindsEnabled";
} else {
// If both of the above checks fail, then the version of the Ok Zoomer API that the user is trying to use is too new.
MidnightControlsClient.get().warn("The version of Ok Zoomer that you are currently using is too new, and is not yet supported by MidnightControls!");
return;
}
// Reflect to the ZoomKeyBinds (>= 5.0.0-beta.4) / ZoomKeybinds (<= 5.0.0-beta.3) class.
try {
okZoomerZoomKeybindsClass = Class.forName(okZoomerZoomKeybindsClassString);
} catch (ClassNotFoundException exception) {
// This theoretically should never happen.
MidnightControlsClient.get().warn("MidnightControls failed to reflect to the Ok Zoomer keybinds class!");
exception.printStackTrace();
return;
}
// Reflect to all of the keybind fields.
try {
okZoomerZoomKeyField = okZoomerZoomKeybindsClass.getField(okZoomerZoomKeyFieldString);
okZoomerIncreaseZoomKeyField = okZoomerZoomKeybindsClass.getField(okZoomerIncreaseZoomKeyFieldString);
okZoomerDecreaseZoomKeyField = okZoomerZoomKeybindsClass.getField(okZoomerDecreaseZoomKeyFieldString);
okZoomerResetZoomKeyField = okZoomerZoomKeybindsClass.getField(okZoomerResetZoomKeyFieldString);
} catch (NoSuchFieldException exception) {
MidnightControlsClient.get().warn("MidnightControls failed to reflect to the Ok Zoomer keybind fields!");
exception.printStackTrace();
return;
}
// Initialise KeyBinding objects
try {
okZoomerZoomKey = (KeyBinding) okZoomerZoomKeyField.get(null);
okZoomerIncreaseZoomKey = (KeyBinding) okZoomerIncreaseZoomKeyField.get(null);
okZoomerDecreaseZoomKey = (KeyBinding) okZoomerDecreaseZoomKeyField.get(null);
okZoomerResetZoomKey = (KeyBinding) okZoomerResetZoomKeyField.get(null);
} catch (IllegalAccessException exception) {
MidnightControlsClient.get().warn("MidnightControls failed to reflect to the Ok Zoomer keybind objects!");
exception.printStackTrace();
return;
}
// Reflect to the areExtraKeyBindsEnabled (>= 5.0.0-beta.4) / areExtraKeybindsEnabled (<= 5.0.0-beta.3) method.
// TODO: Consider replacing this entirely with getExtraKeyBind (>= 5.0.0-beta.4) / getExtraKeybind (<= 5.0.0-beta.3) in the future.
try {
okZoomerAreExtraKeyBindsEnabledMethod = okZoomerZoomKeybindsClass.getDeclaredMethod(okZoomerAreExtraKeyBindsEnabledMethodNameString);
} catch (NoSuchMethodException exception) {
MidnightControlsClient.get().warn("MidnightControls failed to reflect to an Ok Zoomer method (areExtraKeyBindsEnabled / areExtraKeybindsEnabled)!");
exception.printStackTrace();
return;
}
didAllReflectionCallsSucceed = true;
}
@Override
public void handle(@NotNull MidnightControlsClient mod) {
if (didAllReflectionCallsSucceed) {
new ButtonBinding.Builder("zoom")
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, GLFW.GLFW_GAMEPAD_BUTTON_X)
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(ZoomKeybinds.zoomKey)
.linkKeybind(okZoomerZoomKey)
.register();
if (ZoomKeybinds.areExtraKeybindsEnabled()) {
boolean okZoomerAreExtraKeyBindsEnabled = false;
try {
okZoomerAreExtraKeyBindsEnabled = (boolean) okZoomerAreExtraKeyBindsEnabledMethod.invoke(null);
} catch (IllegalAccessException exception) {
MidnightControlsClient.get().warn("MidnightControls encountered an IllegalAccessException while attempting to invoke a reflected Ok Zoomer method (areExtraKeyBindsEnabled / areExtraKeybindsEnabled)!");
exception.printStackTrace();
} catch (InvocationTargetException exception) {
MidnightControlsClient.get().warn("MidnightControls encountered an InvocationTargetException while attempting to invoke a reflected Ok Zoomer method (areExtraKeyBindsEnabled / areExtraKeybindsEnabled)!");
exception.printStackTrace();
}
if (okZoomerAreExtraKeyBindsEnabled) {
new ButtonBinding.Builder("zoom_in")
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true))
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(ZoomKeybinds.increaseZoomKey)
.linkKeybind(okZoomerIncreaseZoomKey)
.register();
new ButtonBinding.Builder("zoom_out")
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true))
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(ZoomKeybinds.decreaseZoomKey)
.linkKeybind(okZoomerDecreaseZoomKey)
.register();
new ButtonBinding.Builder("zoom_reset")
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(ZoomKeybinds.resetZoomKey)
.linkKeybind(okZoomerResetZoomKey)
.register();
}
}
}
}

View File

@@ -23,7 +23,8 @@ import org.lwjgl.glfw.GLFWGamepadState;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import java.io.IOException;
import java.io.*;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -145,9 +146,23 @@ public record Controller(int id) implements Nameable {
*/
public static void updateMappings() {
try {
MidnightControlsClient.get().log("Updating controller mappings...");
File databaseFile = new File("config/gamecontrollerdatabase.txt");
try {
BufferedInputStream in = new BufferedInputStream(new URL("https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt").openStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(databaseFile));
byte[] dataBuffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
out.write(dataBuffer, 0, bytesRead);
}
out.close();
} catch (Exception ignored) {/* Just continue when internet connection is not available */}
var database = ioResourceToBuffer(databaseFile.getPath(), 1024);
GLFW.glfwUpdateGamepadMappings(database);
if (!MidnightControlsClient.MAPPINGS_FILE.exists())
return;
MidnightControlsClient.get().log("Updating controller mappings...");
var buffer = ioResourceToBuffer(MidnightControlsClient.MAPPINGS_FILE.getPath(), 1024);
GLFW.glfwUpdateGamepadMappings(buffer);
} catch (IOException e) {

View File

@@ -78,7 +78,7 @@ public class MidnightControlsHud extends Hud {
*/
@Override
public void render(MatrixStack matrices, float tickDelta) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.currentScreen == null && MidnightControlsConfig.getController().isConnected() && MidnightControlsConfig.getController().isGamepad()) {
if (MidnightControlsConfig.controlsMode == ControlsMode.CONTROLLER && this.client.currentScreen == null) {
int y = bottom(2);
this.renderFirstIcons(matrices, MidnightControlsConfig.hudSide == HudSide.LEFT ? 2 : client.getWindow().getScaledWidth() - 2, y);
this.renderSecondIcons(matrices, MidnightControlsConfig.hudSide == HudSide.RIGHT ? 2 : client.getWindow().getScaledWidth() - 2, y);

View File

@@ -166,7 +166,7 @@ public class MidnightControlsSettingsScreen extends SpruceScreen {
ClientPlayNetworking.getSender().sendPacket(MidnightControls.CONTROLS_MODE_CHANNEL, this.mod.makeControlsModeBuffer(next));
}
}, option -> option.getDisplayText(new TranslatableText(MidnightControlsConfig.controlsMode.getTranslationKey())),
new TranslatableText("midnightcontrols.tooltip.controlsMidnightColorUtil.radialRainbow(1f,1f);_mode"));
new TranslatableText("midnightcontrols.tooltip.controls_mode"));
this.autoSwitchModeOption = new SpruceToggleBooleanOption("midnightcontrols.menu.auto_switch_mode", () -> MidnightControlsConfig.autoSwitchMode,
value -> MidnightControlsConfig.autoSwitchMode = value, new TranslatableText("midnightcontrols.tooltip.auto_switch_mode"));
this.rotationSpeedOption = new SpruceDoubleOption("midnightcontrols.menu.rotation_speed", 0.0, 100.0, .5f,

View File

@@ -0,0 +1,159 @@
{
"midnightcontrols.midnightconfig.title": "MidnightControls Erweiterte Konfiguration",
"key.midnightcontrols.look_down": "Nach unten schauen",
"key.midnightcontrols.look_left": "Nach links schauen",
"key.midnightcontrols.look_right": "Nach rechts schauen",
"key.midnightcontrols.look_up": "Nach oben schauen",
"key.midnightcontrols.ring": "Zeige Steuerungsring",
"midnightcontrols.action.attack": "Angreifen",
"midnightcontrols.action.back": "Zurück",
"midnightcontrols.action.chat": "Chat öffnen",
"midnightcontrols.action.drop_item": "Item droppen",
"midnightcontrols.action.exit": "Schließen",
"midnightcontrols.action.forward": "Vorwärts",
"midnightcontrols.action.hit": "Schlagen",
"midnightcontrols.action.hotbar_left": "Hotbar nach links",
"midnightcontrols.action.hotbar_right": "Hotbar nach rechts",
"midnightcontrols.action.inventory": "Inventar",
"midnightcontrols.action.jump": "Springen",
"midnightcontrols.action.left": "Links",
"midnightcontrols.action.pause_game": "Spiel pausieren",
"midnightcontrols.action.pick_block": "Block auswählen",
"midnightcontrols.action.pickup": "Aufheben",
"midnightcontrols.action.pickup_all": "Alles aufheben",
"midnightcontrols.action.place": "Platzieren",
"midnightcontrols.action.player_list": "Spielerliste",
"midnightcontrols.action.quick_move": "Schnell bewegen",
"midnightcontrols.action.right": "Rechts",
"midnightcontrols.action.screenshot": "Screenshot aufnehmen",
"midnightcontrols.action.sneak": "Schleichen",
"midnightcontrols.action.sprint": "Sprinten",
"midnightcontrols.action.swap_hands": "Hände wechseln",
"midnightcontrols.action.toggle_perspective": "Perspektive wechseln",
"midnightcontrols.action.toggle_smooth_camera": "Cinematische Kamera",
"midnightcontrols.action.use": "Benutzen",
"midnightcontrols.action.zoom": "Zoom",
"midnightcontrols.action.zoom_in": "Zoom erhöhen",
"midnightcontrols.action.zoom_out": "Zoom verringern",
"midnightcontrols.action.zoom_reset": "Zoom zurücksetzen",
"midnightcontrols.action.key.emotecraft.fastchoose": "Emote Schnellauswahl",
"midnightcontrols.action.key.emotecraft.stop": "Emote stoppen",
"midnightcontrols.button.left_bumper": "Linke Schultertaste",
"midnightcontrols.button.right_bumper": "Rechte Schultertaste",
"midnightcontrols.button.back": "Zurück",
"midnightcontrols.button.start": "Start",
"midnightcontrols.button.guide": "Guide",
"midnightcontrols.button.left_thumb": "Linker Stick",
"midnightcontrols.button.right_thumb": "Rechter Stick",
"midnightcontrols.button.dpad_up": "Steuerkreuz hoch",
"midnightcontrols.button.dpad_right": "Steuerkreuz rechts",
"midnightcontrols.button.dpad_down": "Steuerkreuz runter",
"midnightcontrols.button.dpad_left": "Steuerkreuz links",
"midnightcontrols.button.l4": "L4",
"midnightcontrols.button.l5": "L5",
"midnightcontrols.button.r4": "R4",
"midnightcontrols.button.r5": "L5",
"midnightcontrols.axis.left_x+": "Links X+",
"midnightcontrols.axis.left_y+": "Links Y+",
"midnightcontrols.axis.right_x+": "Rechts X+",
"midnightcontrols.axis.right_y+": "Rechts Y+",
"midnightcontrols.axis.left_trigger": "Linker Trigger",
"midnightcontrols.axis.right_trigger": "Rechter Trigger",
"midnightcontrols.axis.left_x-": "Links X-",
"midnightcontrols.axis.left_y-": "Links Y-",
"midnightcontrols.axis.right_x-": "Rechts X-",
"midnightcontrols.axis.right_y-": "Rechts Y-",
"midnightcontrols.button.unknown": "Unbekannt (%d)",
"midnightcontrols.controller.connected": "Controller %d verbunden.",
"midnightcontrols.controller.disconnected": "Controller %d getrennt.",
"midnightcontrols.controller.mappings.1": "Um die Controller-Mappings anzupassen, benutze %s",
"midnightcontrols.controller.mappings.3": "und füge die Controller-Mappings in den Mapping-Editor ein.",
"midnightcontrols.controller.mappings.error": "Fehler beim Laden der Controller-Mappings.",
"midnightcontrols.controller.mappings.error.write": "Fehler beim Schreiben der Controller Mappings.",
"midnightcontrols.controller.mappings.updated": "Mappings aktualisiert!",
"midnightcontrols.controller_type.default": "Standard",
"midnightcontrols.controller_type.dualshock": "DualShock",
"midnightcontrols.controller_type.switch": "Switch",
"midnightcontrols.controller_type.xbox": "Xbox",
"midnightcontrols.controller_type.steam": "Steam",
"midnightcontrols.controller_type.ouya": "OUYA",
"midnightcontrols.controls_mode.default": "Tastatur/Maus",
"midnightcontrols.controls_mode.controller": "Controller",
"midnightcontrols.controls_mode.touchscreen": "Touchscreen",
"midnightcontrols.hud_side.left": "links",
"midnightcontrols.hud_side.right": "rechts",
"midnightcontrols.menu.analog_movement": "Analoge Bewegung",
"midnightcontrols.menu.auto_switch_mode": "Automatischer Wechsel",
"midnightcontrols.menu.controller": "Controller",
"midnightcontrols.menu.controller2": "Zweiter Controller",
"midnightcontrols.menu.controller_type": "Controller-Typ",
"midnightcontrols.menu.controls_mode": "Modus",
"midnightcontrols.menu.fast_block_placing": "Schnelles Bauen",
"midnightcontrols.menu.fly_drifting": "Flug-Drifting",
"midnightcontrols.menu.fly_drifting_vertical": "Vertikales Flug-Drifting",
"midnightcontrols.menu.hud_enable": "HUD aktivieren",
"midnightcontrols.menu.hud_side": "HUD-Seite",
"midnightcontrols.menu.invert_right_x_axis": "X rechts umkehren",
"midnightcontrols.menu.invert_right_y_axis": "Y rechts umkehren",
"midnightcontrols.menu.keyboard_controls": "Tastatureinstellungen...",
"midnightcontrols.menu.left_dead_zone": "Linke tote Zone",
"midnightcontrols.menu.mappings.open_input_str": "Öffne den Controller-Mapping Editor",
"midnightcontrols.menu.max_left_x_value": "Maximalwert Linke X-Achse",
"midnightcontrols.menu.max_left_y_value": "Maximalwert Linke Y-Achse",
"midnightcontrols.menu.max_right_x_value": "Maximalwert Rechte X-Achse",
"midnightcontrols.menu.max_right_y_value": "Maximalwert Rechte Y-Achse",
"midnightcontrols.menu.mouse_speed": "Mausgeschwindigkeit",
"midnightcontrols.menu.reacharound.horizontal": "Vorderes Blockplatzieren",
"midnightcontrols.menu.reacharound.vertical": "Vertikales Umgreifen",
"midnightcontrols.menu.reload_controller_mappings": "Controller-Mappings neuladen",
"midnightcontrols.menu.right_dead_zone": "Rechte tote Zone",
"midnightcontrols.menu.rotation_speed": "Rotationsgeschwindigkeit",
"midnightcontrols.menu.separator.controller": "Controller",
"midnightcontrols.menu.separator.general": "Generell",
"midnightcontrols.menu.title": "MidnightControls - Einstellungen",
"midnightcontrols.menu.title.controller": "Controlleroptionen",
"midnightcontrols.menu.title.controller_controls": "Controller Steuerung",
"midnightcontrols.menu.title.gameplay": "Gameplay Optionen",
"midnightcontrols.menu.title.general": "Generelle Optionen",
"midnightcontrols.menu.title.hud": "HUD Optionen",
"midnightcontrols.menu.title.mappings.string": "Mapping-Datei Editor",
"midnightcontrols.menu.title.visual": "Visuelle Optionen",
"midnightcontrols.menu.unfocused_input": "Unfokussierte Eingabe",
"midnightcontrols.menu.virtual_mouse": "Virtuelle Maus",
"midnightcontrols.menu.virtual_mouse.skin": "Aussehen der Virtuellen Maus",
"midnightcontrols.narrator.unbound": "%s entbunden",
"midnightcontrols.not_bound": "Nicht zugewiesen",
"midnightcontrols.tooltip.analog_movement": "Aktiviert analoge Bewegung, wenn möglich.",
"midnightcontrols.tooltip.auto_switch_mode": "Ob der Eingabemodus automatisch auf Controller eingestellt werden soll, wenn einer verbunden wird.",
"midnightcontrols.tooltip.controller2": "Zweiter Controller, zum Beispiel für Joy-Cons.",
"midnightcontrols.tooltip.controller_type": "Der Controllertyp für den die Knöpfe angezeigt werden sollen.",
"midnightcontrols.tooltip.controls_mode": "Der Steuerungsmodus.",
"midnightcontrols.tooltip.fast_block_placing": "Während des Fliegens im Kreativmodus das schnelle Platzieren von Knöpfen aktivieren. §cWird von manchen Servern als cheaten eingestuft.",
"midnightcontrols.tooltip.fly_drifting": "Aktiviert das Flug-Drifting von Vanilla Minecraft.",
"midnightcontrols.tooltip.fly_drifting_vertical": "Aktiviert das vertikale Flug-Drifting von Vanilla Minecraft",
"midnightcontrols.tooltip.hud_enable": "(De-)Aktiviert die Knopfanzeige im Spiel",
"midnightcontrols.tooltip.hud_side": "Die Position der Knopfanzeige.",
"midnightcontrols.tooltip.left_dead_zone": "Die tote Zone für den linken Analogstick.",
"midnightcontrols.tooltip.max_left_x_value": "Ändert den maximalen Wert der linken X-Achse. Nützlich, wenn deine Achse nicht bis zum Maximum geht.",
"midnightcontrols.tooltip.max_left_y_value": "Ändert den maximalen Wert der linken Y-Achse. Nützlich, wenn deine Achse nicht bis zum Maximum geht.",
"midnightcontrols.tooltip.max_right_x_value": "Ändert den maximalen Wert der rechten X-Achse. Nützlich, wenn deine Achse nicht bis zum Maximum geht.",
"midnightcontrols.tooltip.max_right_y_value": "Ändert den maximalen Wert der rechten Y-Achse. Nützlich, wenn deine Achse nicht bis zum Maximum geht.",
"midnightcontrols.tooltip.mouse_speed": "Die emulierte Mausgeschwindigkeit des Controllers.",
"midnightcontrols.tooltip.reacharound.horizontal": "Aktiviert vorderes Platzieren von Blöcken, §cwird von manchen Servern als cheaten eingestuft§r.",
"midnightcontrols.tooltip.reacharound.vertical": "Aktiviert vertikales Platzieren von Blöcken, §cwird von manchen Servern als cheaten eingestuft§r.",
"midnightcontrols.tooltip.reload_controller_mappings": "Lädt die Controller-Mappings neu.",
"midnightcontrols.tooltip.right_dead_zone": "Die tote Zone für den rechten Analogstick.",
"midnightcontrols.tooltip.rotation_speed": "Die Kamerarotationsgeschwindigkeit im Controllermodus.",
"midnightcontrols.tooltip.unfocused_input": "Erlaube Controllereingabe auch wenn das Fenster nicht fokussiert ist.",
"midnightcontrols.tooltip.virtual_mouse": "Aktiviere die virtuelle Maus.",
"midnightcontrols.virtual_mouse.skin.default_light": "Standard Hell",
"midnightcontrols.virtual_mouse.skin.default_dark": "Standard Dunkel",
"midnightcontrols.virtual_mouse.skin.second_light": "Alternativ Hell",
"midnightcontrols.virtual_mouse.skin.second_dark": "Alternativ Dunkel",
"midnightcontrols.button.a": "A",
"midnightcontrols.button.b": "B",
"midnightcontrols.button.x": "X",
"midnightcontrols.button.y": "Y",
"modmenu.descriptionTranslation.midnightcontrols": "Fügt Controller-Unterstützung hinzu und verbessert allgemein die Steuerung.\nBasiert auf der LambdaControls mod, deren Entwicklung leider eingestellt wurde.",
"modmenu.summaryTranslation.midnightcontrols": "Fügt Controller-Unterstützung hinzu und verbessert allgemein die Steuerung."
}

View File

@@ -153,5 +153,6 @@
"midnightcontrols.virtual_mouse.skin.default_light": "Default Light",
"midnightcontrols.virtual_mouse.skin.default_dark": "Default Dark",
"midnightcontrols.virtual_mouse.skin.second_light": "Second Light",
"midnightcontrols.virtual_mouse.skin.second_dark": "Second Dark"
"midnightcontrols.virtual_mouse.skin.second_dark": "Second Dark",
"modmenu.descriptionTranslation.midnightcontrols": "Adds controller support and enhanced controls overall.\nForked from LambdaControls, which sadly got discontinued."
}

View File

@@ -115,7 +115,6 @@
"midnightcontrols.tooltip.controller2": "Kullanılacak ikinci oyun kolu, örnek olarak Joy-Con desteği de mümkün.",
"midnightcontrols.tooltip.controller_type": "Doğru tuşları göstermesi için oyun kolu türü.",
"midnightcontrols.tooltip.controls_mode": "Kontrol Modu",
"midnightcontrols.tooltip.dead_zone": "Oyun kolunun analog çubukları için ayarlanan ölü bölge/dead zone",
"midnightcontrols.tooltip.fast_block_placing": "Yaratıcı modda uçarken, hızına bağlı olarak hızlı blok koymayı etkinleştirir. §cBazı sunucular bunun hile olduğunu düşünebilir.",
"midnightcontrols.tooltip.fly_drifting": "Uçarken, Vanilla'daki gibi ani duruşlarda kayma efektini etkinleştirir.",
"midnightcontrols.tooltip.fly_drifting_vertical": "Yukarı/aşağı uçarken, Vanilla'daki gibi ani duruşlarda kayma efektini etkinleştirir.",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -3,11 +3,21 @@
"id": "midnightcontrols",
"name": "MidnightControls",
"version": "${version}",
"description": "Adds better controls, and controller support.",
"description": "Adds controller support and enhanced controls overall.",
"authors": [
"LambdAurora",
"Motschen"
],
"contributors": [
"akemin-dayo",
"DioEgizio",
"Ivanoks",
"FlashyReese",
"Hambaka",
"joaoh1",
"EnnuiL",
"egeesin"
],
"contact": {
"homepage": "https://modrinth.com/mod/midnightcontrols",
"sources": "https://github.com/TeamMidnightDust/MidnightControls",

View File

@@ -0,0 +1,4 @@
Some of the textures in this Resourcepack are directly taken from the Bedrock assets and are therefore © Mojang Studios.
Credits go to Ivanoks for redrawing the Bedrock XBox controller icons in 15x15,
Motschen for creating the assets for the other controllers
and LambdAurora for the original assets, part of which are also included.

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 8,
"description": "Makes the controller buttons look like from Bedrock Edition"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB