mirror of
https://github.com/Maschell/HIDtoVPADNetworkClient.git
synced 2024-11-25 15:26:53 +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>
|
<dependency>
|
||||||
<groupId>com.github.QuarkTheAwesome</groupId>
|
<groupId>com.github.QuarkTheAwesome</groupId>
|
||||||
<artifactId>purejavahidapi</artifactId>
|
<artifactId>purejavahidapi</artifactId>
|
||||||
<version>847db72</version>
|
<version>f877704</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hid4java</groupId>
|
<groupId>org.hid4java</groupId>
|
||||||
|
@ -170,7 +170,7 @@ public abstract class Controller implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getType() + " " + getIdentifier();
|
return getType() + " " + getIdentifier().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,11 +57,18 @@ public interface HidDevice {
|
|||||||
byte[] getLatestData();
|
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
|
* Returns the path of this HidDevice
|
||||||
|
@ -71,19 +71,19 @@ public class HidManager {
|
|||||||
|
|
||||||
public static boolean isGamepad(HidDevice info) {
|
public static boolean isGamepad(HidDevice info) {
|
||||||
if (info == null) return false;
|
if (info == null) return false;
|
||||||
short usage = info.getUsage();
|
short usage = info.getUsageID();
|
||||||
return (usage == 0x05 || usage == 0x04 || isNintendoController(info) || isPlaystationController(info));
|
return (usage == 0x05 || usage == 0x04 || isNintendoController(info) || isPlaystationController(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isKeyboard(HidDevice info) {
|
public static boolean isKeyboard(HidDevice info) {
|
||||||
if (info == null) return false;
|
if (info == null) return false;
|
||||||
short usage = info.getUsage();
|
short usage = info.getUsageID();
|
||||||
return (usage == 0x06);
|
return (usage == 0x06);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMouse(HidDevice info) {
|
public static boolean isMouse(HidDevice info) {
|
||||||
if (info == null) return false;
|
if (info == null) return false;
|
||||||
short usage = info.getUsage();
|
short usage = info.getUsageID();
|
||||||
return (usage == 0x02);
|
return (usage == 0x02);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,16 @@ class Hid4JavaHidDevice implements HidDevice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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
|
@Override
|
||||||
public short getUsage() {
|
public short getUsageID() {
|
||||||
return (short) myDevice.getUsage();
|
return (short) myDevice.getUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public short getUsagePage() {
|
||||||
|
return (short) myDevice.getUsagePage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,10 +81,15 @@ class PureJavaHidDevice implements HidDevice, InputReportListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getUsage() {
|
public short getUsagePage() {
|
||||||
return myDeviceInfo.getUsagePage();
|
return myDeviceInfo.getUsagePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public short getUsageID() {
|
||||||
|
return myDeviceInfo.getUsageID();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return myDeviceInfo.getPath();
|
return myDeviceInfo.getPath();
|
||||||
@ -92,7 +97,7 @@ class PureJavaHidDevice implements HidDevice, InputReportListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath()
|
return "PureJavaHidDevice [vid= " + String.format("%04X", getVendorId()) + ", pid= " + String.format("%04X", getProductId()) + ", path= " + getPath().trim()
|
||||||
+ ", usage= " + String.format("%04X", getUsage()) + ", data=" + Arrays.toString(currentData) + "]";
|
+ ", usage= " + String.format("%04X:%04X", getUsagePage(), getUsageID()) + ", data=" + Arrays.toString(currentData) + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user