mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-22 05:59:16 +01:00
Differentiate usagePage and usageID, fix whitespace bugs
This commit is contained in:
parent
fdf74a0f55
commit
725d23de72
2
pom.xml
2
pom.xml
@ -140,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.QuarkTheAwesome</groupId>
|
||||
<artifactId>purejavahidapi</artifactId>
|
||||
<version>847db72</version>
|
||||
<version>f877704</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hid4java</groupId>
|
||||
|
@ -170,7 +170,7 @@ public abstract class Controller implements Runnable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getType() + " " + getIdentifier();
|
||||
return getType() + " " + getIdentifier().trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,11 +57,18 @@ public interface HidDevice {
|
||||
byte[] getLatestData();
|
||||
|
||||
/**
|
||||
* Retuns the Usage of this HID-Device
|
||||
* Retuns the Usage Page of this HID-Device
|
||||
*
|
||||
* @return usage
|
||||
* @return usage page
|
||||
*/
|
||||
short getUsage();
|
||||
short getUsagePage();
|
||||
|
||||
/**
|
||||
* Retuns the Usage ID of this HID-Device
|
||||
*
|
||||
* @return usage id
|
||||
*/
|
||||
short getUsageID();
|
||||
|
||||
/**
|
||||
* Returns the path of this HidDevice
|
||||
|
@ -71,19 +71,19 @@ public class HidManager {
|
||||
|
||||
public static boolean isGamepad(HidDevice info) {
|
||||
if (info == null) return false;
|
||||
short usage = info.getUsage();
|
||||
short usage = info.getUsageID();
|
||||
return (usage == 0x05 || usage == 0x04 || isNintendoController(info) || isPlaystationController(info));
|
||||
}
|
||||
|
||||
public static boolean isKeyboard(HidDevice info) {
|
||||
if (info == null) return false;
|
||||
short usage = info.getUsage();
|
||||
short usage = info.getUsageID();
|
||||
return (usage == 0x06);
|
||||
}
|
||||
|
||||
public static boolean isMouse(HidDevice info) {
|
||||
if (info == null) return false;
|
||||
short usage = info.getUsage();
|
||||
short usage = info.getUsageID();
|
||||
return (usage == 0x02);
|
||||
}
|
||||
|
||||
|
@ -68,11 +68,16 @@ class Hid4JavaHidDevice implements HidDevice {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Hid4JavaHidDevice [vid= " + getVendorId() + ", pid= " + getProductId() + ", usage= " + String.format("%04X", getUsage()) + ", data=" + Arrays.toString(data) + "]";
|
||||
return "Hid4JavaHidDevice [vid= " + getVendorId() + ", pid= " + getProductId() + ", usage= " + String.format("%04X:%04X", getUsagePage(), getUsageID()) + ", data=" + Arrays.toString(data) + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getUsage() {
|
||||
public short getUsageID() {
|
||||
return (short) myDevice.getUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getUsagePage() {
|
||||
return (short) myDevice.getUsagePage();
|
||||
}
|
||||
}
|
||||
|
@ -81,9 +81,14 @@ class PureJavaHidDevice implements HidDevice, InputReportListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getUsage() {
|
||||
public short getUsagePage() {
|
||||
return myDeviceInfo.getUsagePage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getUsageID() {
|
||||
return myDeviceInfo.getUsageID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
@ -92,7 +97,7 @@ class PureJavaHidDevice implements HidDevice, InputReportListener {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath()
|
||||
+ ", usage= " + String.format("%04X", getUsage()) + ", data=" + Arrays.toString(currentData) + "]";
|
||||
return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath().trim()
|
||||
+ ", usage= " + String.format("%04X:%04X", getUsagePage(), getUsageID()) + ", data=" + Arrays.toString(currentData) + "]";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user