mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-24 23:16:52 +01:00
Basic functionality for Info tab
This commit is contained in:
parent
a73873e96d
commit
fdf74a0f55
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,10 @@ public class HidManager {
|
||||
return connectedGamepads;
|
||||
}
|
||||
|
||||
public static List<HidDevice> getAllAttachedControllers() {
|
||||
return backend.enumerateDevices();
|
||||
}
|
||||
|
||||
public static boolean isGamepad(HidDevice info) {
|
||||
if (info == null) return false;
|
||||
short usage = info.getUsage();
|
||||
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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) + "]";
|
||||
}
|
||||
}
|
||||
|
39
src/net/ash/HIDToVPADNetworkClient/util/StatusReport.java
Normal file
39
src/net/ash/HIDToVPADNetworkClient/util/StatusReport.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user