Try to show the name of a HID (if possible)

This commit is contained in:
Ash 2017-04-12 21:50:32 +10:00
parent 3917dbbb0c
commit 63815a3fdd
4 changed files with 19 additions and 1 deletions

View File

@ -119,6 +119,7 @@ public class HidController extends Controller {
} }
} }
return "USB HID on " + getIdentifier(); String name = getHidDevice().getProductString();
return ((name != null) ? name : "USB HID") + " on " + getIdentifier();
} }
} }

View File

@ -76,4 +76,11 @@ public interface HidDevice {
* @return path * @return path
*/ */
String getPath(); String getPath();
/**
* Returns the name of the HID device
*
* @return product string (name)
*/
String getProductString();
} }

View File

@ -66,6 +66,11 @@ class Hid4JavaHidDevice implements HidDevice {
return myDevice.getPath(); return myDevice.getPath();
} }
@Override
public String getProductString() {
return myDevice.getProduct();
}
@Override @Override
public String toString() { public String toString() {
return "Hid4JavaHidDevice [vid= " + getVendorId() + ", pid= " + getProductId() + ", usage= " + String.format("%04X:%04X", getUsagePage(), getUsageID()) + ", data=" + Arrays.toString(data) + "]"; return "Hid4JavaHidDevice [vid= " + getVendorId() + ", pid= " + getProductId() + ", usage= " + String.format("%04X:%04X", getUsagePage(), getUsageID()) + ", data=" + Arrays.toString(data) + "]";

View File

@ -95,6 +95,11 @@ class PureJavaHidDevice implements HidDevice, InputReportListener {
return myDeviceInfo.getPath(); return myDeviceInfo.getPath();
} }
@Override
public String getProductString() {
return myDeviceInfo.getProductString();
}
@Override @Override
public String toString() { public String toString() {
return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath().trim() return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath().trim()