Merge pull request #3 from Maschell/dev-maschell

Added support for the new DS4
This commit is contained in:
Maschell 2017-03-19 23:56:27 +01:00 committed by GitHub
commit e98f4294e1
8 changed files with 50 additions and 6 deletions

1
buildJar.bat Normal file
View File

@ -0,0 +1 @@
mvn clean compile assembly:single

15
pom.xml
View File

@ -14,6 +14,21 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>net.ash.HIDToVPADNetworkClient.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<repositories>

View File

@ -0,0 +1,24 @@
package net.ash.HIDToVPADNetworkClient.controller;
import net.ash.HIDToVPADNetworkClient.exeption.ControllerInitializationFailedException;
public class DS4NewController extends PureJavaHidController {
public static final short DS4_NEW_CONTROLLER_VID = 0x54C;
public static final short DS4_NEW_CONTROLLER_PID = 0x09CC;
public DS4NewController(String identifier) throws ControllerInitializationFailedException {
super(identifier);
//truncate package to 6;
this.PACKET_LENGTH = 6;
}
@Override
public byte[] pollLatestData() {
return currentData.clone();
}
@Override
public String getInfoText(){
return "DS4 on " + getIdentifier();
}
}

View File

@ -40,7 +40,10 @@ public class PureJavaHidController extends Controller implements InputReportList
if(device.getHidDeviceInfo().getVendorId() == SwitchProController.SWITCH_PRO_CONTROLLER_VID &&
device.getHidDeviceInfo().getProductId() == SwitchProController.SWITCH_PRO_CONTROLLER_PID){
return new SwitchProController(deviceIdentifier);
}else{
}else if(device.getHidDeviceInfo().getVendorId() == DS4NewController.DS4_NEW_CONTROLLER_VID &&
device.getHidDeviceInfo().getProductId() == DS4NewController.DS4_NEW_CONTROLLER_PID){
return new DS4NewController(deviceIdentifier);
}else {
return new PureJavaHidController(deviceIdentifier);
}
}

View File

@ -27,7 +27,6 @@ public class SwitchProController extends PureJavaHidController {
public static final short SWITCH_PRO_CONTROLLER_VID = 0x57e;
public static final short SWITCH_PRO_CONTROLLER_PID = 0x2009;
public SwitchProController(String identifier) throws ControllerInitializationFailedException {
super(identifier);
//truncate package to 11;

View File

@ -142,7 +142,7 @@ public class ControllerManager{
Map<String,ControllerType> connectedDevices = new HashMap<>();
for (HidDeviceInfo info : PureJavaHidApi.enumerateDevices()) {
if(info.getUsagePage() == 0x05 || info.getUsagePage() == 0x04 || (info.getVendorId() == 0x57e)){
if(info.getUsagePage() == 0x05 || info.getUsagePage() == 0x04 || (info.getVendorId() == 0x57e) || (info.getVendorId() == 0x054c) ){
connectedDevices.put(info.getPath(),ControllerType.PureJAVAHid);
}
}

View File

@ -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.Utilities;
public class NetworkHIDDevice {
@Getter private final short vid;

View File

@ -270,8 +270,9 @@ public class NetworkManager implements Runnable{
byte[] rawCommand;
try {
rawCommand = Protocol.getRawReadDataToSend(readCommands);
System.out.println("UDP Packet: "+ Utilities.ByteArrayToString(rawCommand));
sendUDP(rawCommand);
if(sendUDP(rawCommand) == true){
System.out.println("UDP Packet sent: "+ Utilities.ByteArrayToString(rawCommand));
}
} catch (IOException e) {
System.out.println("Sending read data failed.");
}
@ -279,7 +280,7 @@ public class NetworkManager implements Runnable{
private boolean sendUDP(byte[] rawCommand) {
boolean result = false;
if(udpClient != null){
if(udpClient != null && isConnected()){
try {
udpClient.send(rawCommand);
result = true;