diff --git a/README.md b/README.md index d26f0cd..f8602c3 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,8 @@ Using this client, you can use unsuported devices such as XInput and Bluetooth c Please check the releases page for the latest feature list. Configuration files for HID to VPAD can be found [here](https://github.com/Maschell/controller_patcher_configs). + +## Used Libraries +Lombok - https://projectlombok.org/index.html +purejavahidapi - https://github.com/nyholku/purejavahidapi +JXInput - https://github.com/StrikerX3/JXInput diff --git a/pom.xml b/pom.xml index d33e9ba..785487b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 net.ash HIDToVPADNetworkClient - 0.0.1-SNAPSHOT + 0.2 UTF-8 diff --git a/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java b/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java index 9af0b94..f32b9d4 100644 --- a/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java +++ b/src/net/ash/HIDToVPADNetworkClient/network/NetworkHIDDevice.java @@ -35,6 +35,7 @@ import net.ash.HIDToVPADNetworkClient.network.commands.DetachCommand; import net.ash.HIDToVPADNetworkClient.network.commands.DeviceCommand; import net.ash.HIDToVPADNetworkClient.network.commands.ReadCommand; import net.ash.HIDToVPADNetworkClient.util.HandleFoundry; +import net.ash.HIDToVPADNetworkClient.util.Settings; public class NetworkHIDDevice { @Getter private final short vid; @@ -76,7 +77,7 @@ public class NetworkHIDDevice { private byte[] lastdata = null; public void sendRead(byte[] data) { - if (!Arrays.equals(lastdata, data) || isNeedFirstData()) { + if (!Settings.SEND_DATA_ONLY_ON_CHANGE || !Arrays.equals(lastdata, data) && Settings.SEND_DATA_ONLY_ON_CHANGE || isNeedFirstData()) { synchronized (readCommandLock) { setLatestRead(new ReadCommand(getHidHandle(), data, this)); // Only get the latest Value. } diff --git a/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java b/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java index 0c8bfd6..7df3b1a 100644 --- a/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java +++ b/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java @@ -284,7 +284,7 @@ public class NetworkManager implements Runnable { byte[] rawCommand; try { rawCommand = Protocol.getRawReadDataToSend(readCommands); - if (sendUDP(rawCommand) == true) { + if (sendUDP(rawCommand) == true && Settings.DEBUG_UDP_OUTPUT) { System.out.println("UDP Packet sent: " + Utilities.ByteArrayToString(rawCommand)); } } catch (IOException e) { diff --git a/src/net/ash/HIDToVPADNetworkClient/util/Settings.java b/src/net/ash/HIDToVPADNetworkClient/util/Settings.java index 2d18c12..edd2cbd 100644 --- a/src/net/ash/HIDToVPADNetworkClient/util/Settings.java +++ b/src/net/ash/HIDToVPADNetworkClient/util/Settings.java @@ -44,6 +44,8 @@ public class Settings { public static final int PING_INTERVAL = 1000; public static final int PROCESS_CMD_INTERVAL = 10; + public static boolean DEBUG_UDP_OUTPUT = false; + public static boolean SEND_DATA_ONLY_ON_CHANGE = false; public static boolean AUTO_ACTIVATE_CONTROLLER = true; @Getter @Setter private static String ipAddr = "192.168.0.35"; // @Maschell, you're welcome @@ -85,6 +87,7 @@ public class Settings { Settings.ipAddr = prop.getProperty("ipAddr"); String autoActivatingControllerString = prop.getProperty("autoActivatingController"); + String sendDataOnlyOnChanges = prop.getProperty("sendDataOnlyOnChanges"); if (autoActivatingControllerString != null) { // We don't combine the if statements to keep the default value. if (autoActivatingControllerString.equals("true")) { @@ -93,6 +96,13 @@ public class Settings { Settings.AUTO_ACTIVATE_CONTROLLER = false; } } + if (sendDataOnlyOnChanges != null) { // We don't combine the if statements to keep the default value. + if (sendDataOnlyOnChanges.equals("true")) { + Settings.SEND_DATA_ONLY_ON_CHANGE = true; + } else { + Settings.SEND_DATA_ONLY_ON_CHANGE = false; + } + } log.info("Loaded config successfully!"); } @@ -114,6 +124,7 @@ public class Settings { prop.setProperty("ipAddr", Settings.ipAddr); prop.setProperty("autoActivatingController", Boolean.toString(Settings.AUTO_ACTIVATE_CONTROLLER)); + prop.setProperty("sendDataOnlyOnChanges", Boolean.toString(Settings.SEND_DATA_ONLY_ON_CHANGE)); try { FileOutputStream outStream = new FileOutputStream(configFile);