diff --git a/src/net/ash/HIDToVPADNetworkClient/controller/DS4NewController.java b/src/net/ash/HIDToVPADNetworkClient/controller/DS4NewController.java index b9e2a78..e4aa4c4 100644 --- a/src/net/ash/HIDToVPADNetworkClient/controller/DS4NewController.java +++ b/src/net/ash/HIDToVPADNetworkClient/controller/DS4NewController.java @@ -20,8 +20,9 @@ public class DS4NewController extends HidController { @Override public byte[] pollLatestData() { - byte[] currentData = super.getLatestData(); - if (Settings.isMacOSX()) { // for some reason the controller has one extra byte at the beginning under OSX + byte[] currentData = super.pollLatestData(); + if (Settings.isMacOSX() && currentData != null && currentData.length > 6) { // for some reason the controller has one extra byte at the beginning under + // OSX currentData = Arrays.copyOfRange(currentData, 1, 7); } return currentData; diff --git a/src/net/ash/HIDToVPADNetworkClient/controller/HidController.java b/src/net/ash/HIDToVPADNetworkClient/controller/HidController.java index fb0f481..c753d18 100644 --- a/src/net/ash/HIDToVPADNetworkClient/controller/HidController.java +++ b/src/net/ash/HIDToVPADNetworkClient/controller/HidController.java @@ -30,7 +30,6 @@ import lombok.extern.java.Log; import net.ash.HIDToVPADNetworkClient.exeption.ControllerInitializationFailedException; import net.ash.HIDToVPADNetworkClient.hid.HidDevice; import net.ash.HIDToVPADNetworkClient.hid.HidManager; -import net.ash.HIDToVPADNetworkClient.util.Utilities; @Log public class HidController extends Controller { @@ -69,6 +68,7 @@ public class HidController extends Controller { if (device == null || !device.open()) { return false; } + log.info("HidDevice opened!"); setHidDevice(device); return true; diff --git a/src/net/ash/HIDToVPADNetworkClient/gui/GuiInputControls.java b/src/net/ash/HIDToVPADNetworkClient/gui/GuiInputControls.java index e8b2067..dccbfdc 100644 --- a/src/net/ash/HIDToVPADNetworkClient/gui/GuiInputControls.java +++ b/src/net/ash/HIDToVPADNetworkClient/gui/GuiInputControls.java @@ -61,11 +61,7 @@ public final class GuiInputControls extends JPanel { connectButton.setAlignmentX(Component.CENTER_ALIGNMENT); final JCheckBox cbautoScanForController = new JCheckBox(); - if (Settings.isMacOSX()) { - cbautoScanForController.setEnabled(false); - } else { - cbautoScanForController.setSelected(Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS); - } + cbautoScanForController.setSelected(Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS); cbautoScanForController.addActionListener(new ActionListener() { diff --git a/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java b/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java index a9f63a6..246f963 100644 --- a/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java +++ b/src/net/ash/HIDToVPADNetworkClient/manager/ControllerManager.java @@ -89,6 +89,7 @@ public final class ControllerManager { synchronized (attachedControllers) { attachedControllers.get(remove).destroyAll(); attachedControllers.remove(remove); + log.info("Device removed: " + toRemove); } } @@ -139,10 +140,11 @@ public final class ControllerManager { if (Settings.AUTO_ACTIVATE_CONTROLLER) { c.setActive(true); } - new Thread(c, "Controller Thread " + deviceIdentifier.substring(0, 50)).start(); + new Thread(c, "Controller Thread " + deviceIdentifier).start(); synchronized (attachedControllers) { attachedControllers.put(deviceIdentifier, c); } + log.info("Device added: " + deviceIdentifier); } } } diff --git a/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java b/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java index 595d674..a26c0c8 100644 --- a/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java +++ b/src/net/ash/HIDToVPADNetworkClient/network/NetworkManager.java @@ -157,17 +157,17 @@ public final class NetworkManager implements Runnable { } } - // TODO: PONG from WiiU? Hey Quark ;) private void sendPing(PingCommand command) { if (sendTCP(Protocol.getRawPingDataToSend(command))) { - log.info("PING"); byte pong; try { pong = tcpClient.recvByte(); - if (pong != Protocol.TCP_CMD_PONG) { + if (pong == Protocol.TCP_CMD_PONG) { + log.info("Ping...Pong!"); + } else { + log.info("Got no valid response to a Ping. Disconnecting."); disconnect(); } - log.info("got PONG!"); } catch (IOException e) { log.info("Failed to get PONG. Disconnecting."); tcpClient.checkShouldRetry(); diff --git a/src/net/ash/HIDToVPADNetworkClient/util/Settings.java b/src/net/ash/HIDToVPADNetworkClient/util/Settings.java index 8e741d7..fec12c0 100644 --- a/src/net/ash/HIDToVPADNetworkClient/util/Settings.java +++ b/src/net/ash/HIDToVPADNetworkClient/util/Settings.java @@ -46,7 +46,7 @@ public final class Settings { public static final int DETECT_CONTROLLER_ACTIVE_INTERVAL = 100; - public static boolean SCAN_AUTOMATICALLY_FOR_CONTROLLERS = !isMacOSX(); // It doesn't work on OSX + public static boolean SCAN_AUTOMATICALLY_FOR_CONTROLLERS = true; public static boolean DEBUG_UDP_OUTPUT = false; public static boolean SEND_DATA_ONLY_ON_CHANGE = false;