mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-22 05:59:16 +01:00
Added Auto-Scanning for OSX and changed some debug messages
This commit is contained in:
parent
2a5dcddd69
commit
92baf6ebeb
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.addActionListener(new ActionListener() {
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user