mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-26 07:44:15 +01:00
Added support for the new DS4
- send only udp packets if there is a TCP connection - added .jar creation
This commit is contained in:
parent
845cdcb8f2
commit
4a590b9a20
1
buildJar.bat
Normal file
1
buildJar.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
mvn clean compile assembly:single
|
15
pom.xml
15
pom.xml
@ -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>
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -40,7 +40,10 @@ 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{
|
}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);
|
return new PureJavaHidController(deviceIdentifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user