mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-15 03:15:05 +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
|
@Override
|
||||||
public byte[] pollLatestData() {
|
public byte[] pollLatestData() {
|
||||||
byte[] currentData = super.getLatestData();
|
byte[] currentData = super.pollLatestData();
|
||||||
if (Settings.isMacOSX()) { // for some reason the controller has one extra byte at the beginning under OSX
|
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);
|
currentData = Arrays.copyOfRange(currentData, 1, 7);
|
||||||
}
|
}
|
||||||
return currentData;
|
return currentData;
|
||||||
|
@ -30,7 +30,6 @@ import lombok.extern.java.Log;
|
|||||||
import net.ash.HIDToVPADNetworkClient.exeption.ControllerInitializationFailedException;
|
import net.ash.HIDToVPADNetworkClient.exeption.ControllerInitializationFailedException;
|
||||||
import net.ash.HIDToVPADNetworkClient.hid.HidDevice;
|
import net.ash.HIDToVPADNetworkClient.hid.HidDevice;
|
||||||
import net.ash.HIDToVPADNetworkClient.hid.HidManager;
|
import net.ash.HIDToVPADNetworkClient.hid.HidManager;
|
||||||
import net.ash.HIDToVPADNetworkClient.util.Utilities;
|
|
||||||
|
|
||||||
@Log
|
@Log
|
||||||
public class HidController extends Controller {
|
public class HidController extends Controller {
|
||||||
@ -69,6 +68,7 @@ public class HidController extends Controller {
|
|||||||
if (device == null || !device.open()) {
|
if (device == null || !device.open()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
log.info("HidDevice opened!");
|
||||||
|
|
||||||
setHidDevice(device);
|
setHidDevice(device);
|
||||||
return true;
|
return true;
|
||||||
|
@ -61,11 +61,7 @@ public final class GuiInputControls extends JPanel {
|
|||||||
connectButton.setAlignmentX(Component.CENTER_ALIGNMENT);
|
connectButton.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
|
||||||
final JCheckBox cbautoScanForController = new JCheckBox();
|
final JCheckBox cbautoScanForController = new JCheckBox();
|
||||||
if (Settings.isMacOSX()) {
|
cbautoScanForController.setSelected(Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS);
|
||||||
cbautoScanForController.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
cbautoScanForController.setSelected(Settings.SCAN_AUTOMATICALLY_FOR_CONTROLLERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
cbautoScanForController.addActionListener(new ActionListener() {
|
cbautoScanForController.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ public final class ControllerManager {
|
|||||||
synchronized (attachedControllers) {
|
synchronized (attachedControllers) {
|
||||||
attachedControllers.get(remove).destroyAll();
|
attachedControllers.get(remove).destroyAll();
|
||||||
attachedControllers.remove(remove);
|
attachedControllers.remove(remove);
|
||||||
|
log.info("Device removed: " + toRemove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +140,11 @@ public final class ControllerManager {
|
|||||||
if (Settings.AUTO_ACTIVATE_CONTROLLER) {
|
if (Settings.AUTO_ACTIVATE_CONTROLLER) {
|
||||||
c.setActive(true);
|
c.setActive(true);
|
||||||
}
|
}
|
||||||
new Thread(c, "Controller Thread " + deviceIdentifier.substring(0, 50)).start();
|
new Thread(c, "Controller Thread " + deviceIdentifier).start();
|
||||||
synchronized (attachedControllers) {
|
synchronized (attachedControllers) {
|
||||||
attachedControllers.put(deviceIdentifier, c);
|
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) {
|
private void sendPing(PingCommand command) {
|
||||||
if (sendTCP(Protocol.getRawPingDataToSend(command))) {
|
if (sendTCP(Protocol.getRawPingDataToSend(command))) {
|
||||||
log.info("PING");
|
|
||||||
byte pong;
|
byte pong;
|
||||||
try {
|
try {
|
||||||
pong = tcpClient.recvByte();
|
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();
|
disconnect();
|
||||||
}
|
}
|
||||||
log.info("got PONG!");
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.info("Failed to get PONG. Disconnecting.");
|
log.info("Failed to get PONG. Disconnecting.");
|
||||||
tcpClient.checkShouldRetry();
|
tcpClient.checkShouldRetry();
|
||||||
|
@ -46,7 +46,7 @@ public final class Settings {
|
|||||||
|
|
||||||
public static final int DETECT_CONTROLLER_ACTIVE_INTERVAL = 100;
|
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 DEBUG_UDP_OUTPUT = false;
|
||||||
public static boolean SEND_DATA_ONLY_ON_CHANGE = false;
|
public static boolean SEND_DATA_ONLY_ON_CHANGE = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user