diff --git a/src/net/ash/HIDToVPADNetworkClient/gui/GuiOptionsWindow.java b/src/net/ash/HIDToVPADNetworkClient/gui/GuiOptionsWindow.java index cb5195e..cddbff5 100644 --- a/src/net/ash/HIDToVPADNetworkClient/gui/GuiOptionsWindow.java +++ b/src/net/ash/HIDToVPADNetworkClient/gui/GuiOptionsWindow.java @@ -48,6 +48,7 @@ import javax.swing.border.EtchedBorder; import lombok.extern.java.Log; import net.ash.HIDToVPADNetworkClient.util.Settings; +import net.ash.HIDToVPADNetworkClient.util.StatusReport; @Log public class GuiOptionsWindow extends JPanel { @@ -217,21 +218,21 @@ public class GuiOptionsWindow extends JPanel { private static final long serialVersionUID = 1L; private final JTextArea infoText; + private final JScrollPane infoTextWrap; private InfoTab() { super(); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5)); infoText = new JTextArea(); - infoText.setBorder(BorderFactory.createLoweredBevelBorder()); infoText.setEditable(false); - infoText.setText("WIP"); - JPanel infoTextWrap = new JPanel(new GridLayout(1, 1)); - infoTextWrap.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5)); - infoTextWrap.add(infoText); + infoTextWrap = new JScrollPane(infoText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); infoTextWrap.setAlignmentX(Component.CENTER_ALIGNMENT); add(infoTextWrap); + add(Box.createVerticalStrut(10)); + JButton copyButton = new JButton("Copy"); copyButton.addActionListener(new ActionListener() { @Override @@ -242,12 +243,13 @@ public class GuiOptionsWindow extends JPanel { }); copyButton.setAlignmentX(Component.CENTER_ALIGNMENT); add(copyButton); - add(Box.createVerticalStrut(10)); } @Override public void updateTab() { - //TODO update info text + infoText.setCaretPosition(0); + infoText.setText(StatusReport.generateStatusReport()); + infoText.setCaretPosition(0); } } diff --git a/src/net/ash/HIDToVPADNetworkClient/hid/HidManager.java b/src/net/ash/HIDToVPADNetworkClient/hid/HidManager.java index 7eaaab6..6291b2d 100644 --- a/src/net/ash/HIDToVPADNetworkClient/hid/HidManager.java +++ b/src/net/ash/HIDToVPADNetworkClient/hid/HidManager.java @@ -37,7 +37,7 @@ public class HidManager { public static HidDevice getDeviceByPath(String path) throws IOException { return backend.getDeviceByPath(path); } - + public static List getAttachedControllers() { List connectedGamepads = new ArrayList(); @@ -64,6 +64,10 @@ public class HidManager { } return connectedGamepads; } + + public static List getAllAttachedControllers() { + return backend.enumerateDevices(); + } public static boolean isGamepad(HidDevice info) { if (info == null) return false; @@ -98,6 +102,10 @@ public class HidManager { return (info.getVendorId() == (short) 0x045e) && ((info.getProductId() == (short) 0x02ff) || (info.getProductId() == (short) 0x02a1)); } + public static String getBackendType() { + return backend.getClass().getSimpleName(); + } + static { if (Settings.isMacOSX()) { backend = new Hid4JavaHidManagerBackend(); diff --git a/src/net/ash/HIDToVPADNetworkClient/hid/hid4java/Hid4JavaHidDevice.java b/src/net/ash/HIDToVPADNetworkClient/hid/hid4java/Hid4JavaHidDevice.java index ad6104f..b959153 100644 --- a/src/net/ash/HIDToVPADNetworkClient/hid/hid4java/Hid4JavaHidDevice.java +++ b/src/net/ash/HIDToVPADNetworkClient/hid/hid4java/Hid4JavaHidDevice.java @@ -68,7 +68,7 @@ class Hid4JavaHidDevice implements HidDevice { @Override public String toString() { - return "Hid4JavaHidDevice [vid= " + getVendorId() + ", pid= " + getProductId() + ", data=" + Arrays.toString(data) + "]"; + return "Hid4JavaHidDevice [vid= " + getVendorId() + ", pid= " + getProductId() + ", usage= " + String.format("%04X", getUsage()) + ", data=" + Arrays.toString(data) + "]"; } @Override diff --git a/src/net/ash/HIDToVPADNetworkClient/hid/purejavahid/PureJavaHidDevice.java b/src/net/ash/HIDToVPADNetworkClient/hid/purejavahid/PureJavaHidDevice.java index d4b822d..73bab45 100644 --- a/src/net/ash/HIDToVPADNetworkClient/hid/purejavahid/PureJavaHidDevice.java +++ b/src/net/ash/HIDToVPADNetworkClient/hid/purejavahid/PureJavaHidDevice.java @@ -93,6 +93,6 @@ class PureJavaHidDevice implements HidDevice, InputReportListener { @Override public String toString() { return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath() - + ", data=" + Arrays.toString(currentData) + "]"; + + ", usage= " + String.format("%04X", getUsage()) + ", data=" + Arrays.toString(currentData) + "]"; } } diff --git a/src/net/ash/HIDToVPADNetworkClient/util/StatusReport.java b/src/net/ash/HIDToVPADNetworkClient/util/StatusReport.java new file mode 100644 index 0000000..b6ab09f --- /dev/null +++ b/src/net/ash/HIDToVPADNetworkClient/util/StatusReport.java @@ -0,0 +1,39 @@ +package net.ash.HIDToVPADNetworkClient.util; + +import net.ash.HIDToVPADNetworkClient.controller.Controller; +import net.ash.HIDToVPADNetworkClient.hid.HidDevice; +import net.ash.HIDToVPADNetworkClient.hid.HidManager; +import net.ash.HIDToVPADNetworkClient.manager.ControllerManager; +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(); + + report += "\nHID Backend: "; + report += HidManager.getBackendType(); + + report += "\nCurrently "; + report += (NetworkManager.getInstance().isConnected()) ? "Connected.\n" : "Disconnected.\n"; + report += (NetworkManager.getInstance().isReconnecting()) ? "" : "Not "; + report += "Reconnecting."; + + report += "\n\nCurrently attached controllers:"; + for (Controller c : ControllerManager.getAttachedControllers()) { + report += "\n"; + report += c.toString(); + } + + report += "\n\nFiltering settings:\n"; + report += Settings.ControllerFiltering.getFilterStates(); + + report += "\n\nAll HIDs:"; + for (HidDevice d : HidManager.getAllAttachedControllers()) { + report += "\n"; + report += d.toString(); + } + + return report; + } +}