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> <target>1.8</target>
</configuration> </configuration>
</plugin> </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> </plugins>
</build> </build>
<repositories> <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,6 +40,9 @@ public class PureJavaHidController extends Controller implements InputReportList
if(device.getHidDeviceInfo().getVendorId() == SwitchProController.SWITCH_PRO_CONTROLLER_VID && if(device.getHidDeviceInfo().getVendorId() == SwitchProController.SWITCH_PRO_CONTROLLER_VID &&
device.getHidDeviceInfo().getProductId() == SwitchProController.SWITCH_PRO_CONTROLLER_PID){ device.getHidDeviceInfo().getProductId() == SwitchProController.SWITCH_PRO_CONTROLLER_PID){
return new SwitchProController(deviceIdentifier); return new SwitchProController(deviceIdentifier);
}else if(device.getHidDeviceInfo().getVendorId() == DS4NewController.DS4_NEW_CONTROLLER_VID &&
device.getHidDeviceInfo().getProductId() == DS4NewController.DS4_NEW_CONTROLLER_PID){
return new DS4NewController(deviceIdentifier);
}else { }else {
return new PureJavaHidController(deviceIdentifier); 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_VID = 0x57e;
public static final short SWITCH_PRO_CONTROLLER_PID = 0x2009; public static final short SWITCH_PRO_CONTROLLER_PID = 0x2009;
public SwitchProController(String identifier) throws ControllerInitializationFailedException { public SwitchProController(String identifier) throws ControllerInitializationFailedException {
super(identifier); super(identifier);
//truncate package to 11; //truncate package to 11;

View File

@ -142,7 +142,7 @@ public class ControllerManager{
Map<String,ControllerType> connectedDevices = new HashMap<>(); Map<String,ControllerType> connectedDevices = new HashMap<>();
for (HidDeviceInfo info : PureJavaHidApi.enumerateDevices()) { 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); 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.DeviceCommand;
import net.ash.HIDToVPADNetworkClient.network.commands.ReadCommand; import net.ash.HIDToVPADNetworkClient.network.commands.ReadCommand;
import net.ash.HIDToVPADNetworkClient.util.HandleFoundry; import net.ash.HIDToVPADNetworkClient.util.HandleFoundry;
import net.ash.HIDToVPADNetworkClient.util.Utilities;
public class NetworkHIDDevice { public class NetworkHIDDevice {
@Getter private final short vid; @Getter private final short vid;

View File

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