1
0
forked from Clones/Controlify

Add 'PRINT_VID_PID' debug property

This commit is contained in:
isXander
2023-08-04 23:39:58 +01:00
parent d74b7d3724
commit 34f729484b
2 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,8 @@ public class DebugProperties {
private static final List<DebugProperty> properties = new ArrayList<>(); private static final List<DebugProperty> properties = new ArrayList<>();
public static final boolean DEBUG_LOGGING = boolProp("controlify.debug.logging", false, true); public static final boolean DEBUG_LOGGING = boolProp("controlify.debug.logging", false, true);
/* Print the VID and PID of every controller connected. */
public static final boolean PRINT_VID_PID = boolProp("controlify.debug.print_vid_pid", false, true);
/* Renders debug overlay for vmouse snapping */ /* Renders debug overlay for vmouse snapping */
public static final boolean DEBUG_SNAPPING = boolProp("controlify.debug.snapping", false, false); public static final boolean DEBUG_SNAPPING = boolProp("controlify.debug.snapping", false, false);
/* Forces all gamepads to be treated as a regular joystick */ /* Forces all gamepads to be treated as a regular joystick */

View File

@ -4,6 +4,7 @@ import com.mojang.datafixers.util.Pair;
import dev.isxander.controlify.Controlify; import dev.isxander.controlify.Controlify;
import dev.isxander.controlify.controller.ControllerType; import dev.isxander.controlify.controller.ControllerType;
import dev.isxander.controlify.controller.sdl2.SDL2NativesManager; import dev.isxander.controlify.controller.sdl2.SDL2NativesManager;
import dev.isxander.controlify.debug.DebugProperties;
import dev.isxander.controlify.utils.Log; import dev.isxander.controlify.utils.Log;
import dev.isxander.controlify.utils.ToastUtils; import dev.isxander.controlify.utils.ToastUtils;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -47,6 +48,17 @@ public class ControllerHIDService {
} }
public ControllerHIDInfo fetchType(int jid) { public ControllerHIDInfo fetchType(int jid) {
ControllerHIDInfo info = fetchType0(jid);
if (DebugProperties.PRINT_VID_PID) {
info.hidDevice.ifPresent(hid -> {
var hex = HexFormat.of().withPrefix("0x");
Log.LOGGER.info("VID: {}, PID: {}", hex.toHexDigits(hid.vendorID()), hex.toHexDigits(hid.productID()));
});
}
return info;
}
private ControllerHIDInfo fetchType0(int jid) {
if (firstFetch) { if (firstFetch) {
firstFetch = false; firstFetch = false;
if (isDisabled() && !SDL2NativesManager.isLoaded()) { if (isDisabled() && !SDL2NativesManager.isLoaded()) {