mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-22 05:59:16 +01:00
Minor code clean up
This commit is contained in:
parent
b94ed1cc9a
commit
f5f1d42d1b
@ -113,13 +113,13 @@ public class HidController extends Controller {
|
||||
// TODO: own class for joycons
|
||||
if (getVID() == 0x57e) {
|
||||
if (getPID() == 0x2006) {
|
||||
return "Joy-Con (L) (57e:2006) on " + getIdentifier();
|
||||
return "Joy-Con (L) (0x057e:0x2006) on " + getIdentifier();
|
||||
} else if (getPID() == 0x2007) {
|
||||
return "Joy-Con (R) (57e:2007) on " + getIdentifier();
|
||||
return "Joy-Con (R) (0x057e:0x2007) on " + getIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
String name = getHidDevice().getProductString();
|
||||
return ((name != null) ? name : "USB HID") + " (" + Integer.toHexString((int)getVID() & 0xFFFF) + ":" + Integer.toHexString((int)getPID() & 0xFFFF) + ") on " + getIdentifier();
|
||||
return String.format("%s (0x%04X:0x%04X) on %s",(name != null) ? name: "USB HID", getVID(),getPID(),getIdentifier());
|
||||
}
|
||||
}
|
@ -81,7 +81,7 @@ public class LinuxDevInputController extends Controller implements Runnable {
|
||||
return true;
|
||||
}
|
||||
|
||||
//This could probably do with some cleanup
|
||||
// This could probably do with some cleanup
|
||||
public void doSysFs(String identifier) throws Exception {
|
||||
Process querySysFs = Runtime.getRuntime().exec("udevadm info -q path " + identifier);
|
||||
querySysFs.waitFor();
|
||||
@ -125,7 +125,7 @@ public class LinuxDevInputController extends Controller implements Runnable {
|
||||
type = inputStream.readByte();
|
||||
number = inputStream.readByte();
|
||||
} catch (IOException e) {
|
||||
if (!isActive()) return null; //"Stream closed" when removing
|
||||
if (!isActive()) return null; // "Stream closed" when removing
|
||||
System.err.println("[LinuxDevInputController] Couldn't read from controller!");
|
||||
e.printStackTrace();
|
||||
System.out.println("[LinuxDevInputController] Detaching...");
|
||||
@ -175,8 +175,7 @@ public class LinuxDevInputController extends Controller implements Runnable {
|
||||
|
||||
@Override
|
||||
protected void doSleepAfterPollingData() {
|
||||
// This is event driven (aka pollLatestData() is blocking anyway until
|
||||
// we have data), we don't need to sleep it all.
|
||||
// This is event driven (aka pollLatestData() is blocking anyway until we have data), we don't need to sleep it all.
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -195,6 +194,6 @@ public class LinuxDevInputController extends Controller implements Runnable {
|
||||
|
||||
@Override
|
||||
public String getInfoText() {
|
||||
return ((name != null) ? name : "Linux controller") + " (" + Integer.toHexString((int)getVID() & 0xFFFF) + ":" + Integer.toHexString((int)getPID() & 0xFFFF) + ") on " + getIdentifier();
|
||||
return String.format("%s (0x%04X:0x%04X) on %s", (name != null) ? name : "Linux Controller", getVID(), getPID(), getIdentifier());
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ public class XInput13Controller extends XInputController {
|
||||
|
||||
@Override
|
||||
public String getInfoText() {
|
||||
return "XInput 1.3 (" + Integer.toHexString((int)getVID() & 0xFFFF) + ":" + Integer.toHexString((int)getPID() & 0xFFFF) + ") on " + getIdentifier();
|
||||
return String.format("XInput 1.3 (0x%04X:0x%04X) on ", getVID(),getPID()) + getIdentifier();
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ public class XInput14Controller extends XInputController {
|
||||
|
||||
@Override
|
||||
public String getInfoText() {
|
||||
return "XInput 1.4 (" + Integer.toHexString((int)getVID() & 0xFFFF) + ":" + Integer.toHexString((int)getPID() & 0xFFFF) + ") on " + getIdentifier();
|
||||
return String.format("XInput 1.4 (0x%04X:0x%04X) on ", getVID(),getPID()) + getIdentifier();
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +139,6 @@ public class XInputController extends Controller {
|
||||
|
||||
@Override
|
||||
public String getInfoText() {
|
||||
return "XInput (" + Integer.toHexString((int)getVID() & 0xFFFF) + ":" + Integer.toHexString((int)getPID() & 0xFFFF) + ") on " + getIdentifier();
|
||||
return String.format("XInput (0x%04X:%0x04X) on ", getVID(),getPID()) + getIdentifier();
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class HidManager {
|
||||
public static boolean isGamepad(HidDevice info) {
|
||||
if (info == null) return false;
|
||||
short usage = info.getUsageID();
|
||||
return (usage == 0x05 || usage == 0x04 || isNintendoController(info) || isPlaystationController(info));
|
||||
return (info.getProductString().toLowerCase().contains("gamepad") || usage == 0x05 || usage == 0x04 || isNintendoController(info) || isPlaystationController(info));
|
||||
}
|
||||
|
||||
public static boolean isKeyboard(HidDevice info) {
|
||||
|
@ -113,7 +113,7 @@ class PureJavaHidDevice implements HidDevice, InputReportListener {
|
||||
|
||||
@Override
|
||||
public String getProductString() {
|
||||
return myDeviceInfo.getProductString();
|
||||
return myDeviceInfo.getProductString().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,11 +209,12 @@ public final class Settings {
|
||||
public static class ControllerFiltering {
|
||||
public static enum Type {
|
||||
HIDGAMEPAD (0, "HID Gamepads", Platform.LINUX.mask | Platform.WINDOWS.mask | Platform.MAC_OS_X.mask),
|
||||
XINPUT (5, "XInput controllers", Platform.WINDOWS.mask),
|
||||
HIDKEYBOARD (1, "HID Keyboards", Platform.LINUX.mask | Platform.MAC_OS_X.mask),
|
||||
HIDMOUSE (2, "HID Mice", Platform.LINUX.mask),
|
||||
HIDOTHER (3, "Other HIDs", Platform.LINUX.mask | Platform.WINDOWS.mask | Platform.MAC_OS_X.mask),
|
||||
LINUX (4, "Linux controllers", Platform.LINUX.mask),
|
||||
XINPUT (5, "XInput controllers", Platform.WINDOWS.mask);
|
||||
;
|
||||
|
||||
private int index;
|
||||
@Getter private String name;
|
||||
|
@ -8,32 +8,33 @@ import net.ash.HIDToVPADNetworkClient.network.NetworkManager;
|
||||
|
||||
public class StatusReport {
|
||||
public static String generateStatusReport() {
|
||||
String report = "HID to VPAD Network Client\n\nRunning on ";
|
||||
report += Settings.getPlattform();
|
||||
StringBuilder report = new StringBuilder();
|
||||
report.append("HID to VPAD Network Client\n\nRunning on ");
|
||||
report.append(Settings.getPlattform());
|
||||
|
||||
report += "\nHID Backend: ";
|
||||
report += HidManager.getBackendType();
|
||||
report.append(System.lineSeparator()).append("HID Backend: ");
|
||||
report.append(HidManager.getBackendType());
|
||||
|
||||
report += "\nCurrently ";
|
||||
report += (NetworkManager.getInstance().isConnected()) ? "Connected.\n" : "Disconnected.\n";
|
||||
report += (NetworkManager.getInstance().isReconnecting()) ? "" : "Not ";
|
||||
report += "Reconnecting.";
|
||||
report.append(System.lineSeparator()).append("Currently ");
|
||||
report.append((NetworkManager.getInstance().isConnected()) ? "Connected.\n" : "Disconnected.").append(System.lineSeparator());
|
||||
report.append((NetworkManager.getInstance().isReconnecting()) ? "" : "Not ");
|
||||
report.append("Reconnecting.");
|
||||
|
||||
report += "\n\nCurrently attached controllers:";
|
||||
report.append(System.lineSeparator()).append(System.lineSeparator()).append("Currently attached controllers:");
|
||||
for (Controller c : ControllerManager.getAttachedControllers()) {
|
||||
report += "\n";
|
||||
report += c.toString();
|
||||
report.append(System.lineSeparator());
|
||||
report.append(c.toString());
|
||||
}
|
||||
|
||||
report += "\n\nFiltering settings:\n";
|
||||
report += Settings.ControllerFiltering.getFilterStates();
|
||||
report.append(System.lineSeparator()).append(System.lineSeparator()).append("Filtering settings:").append(System.lineSeparator());
|
||||
report.append(Settings.ControllerFiltering.getFilterStates());
|
||||
|
||||
report += "\n\nAll HIDs:";
|
||||
report.append(System.lineSeparator()).append(System.lineSeparator()).append("All HIDs:");
|
||||
for (HidDevice d : HidManager.getAllAttachedControllers()) {
|
||||
report += "\n";
|
||||
report += d.toString();
|
||||
report.append(System.lineSeparator());
|
||||
report.append(d.toString());
|
||||
}
|
||||
|
||||
return report;
|
||||
return report.toString();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user