mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-27 20:36:31 -08:00
update hid4java to 0.8 (#992)
Co-authored-by: sctanf <[email protected]>
This commit is contained in:
1 parent
ae4391bff1
commit
827e2ceef8
3 files changed
+10
-4
No files matched your search
@@ -96,6 +96,7 @@
|
||||
expat
|
||||
libayatana-appindicator
|
||||
libusb1
|
||||
libudev-zero
|
||||
])
|
||||
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.darwin.apple_sdk.frameworks.Security
|
||||
|
||||
@@ -59,7 +59,7 @@ dependencies {
|
||||
implementation("net.java.dev.jna:jna:5.+")
|
||||
implementation("net.java.dev.jna:jna-platform:5.+")
|
||||
implementation("com.fazecast:jSerialComm:2.10.2")
|
||||
implementation("org.hid4java:hid4java:0.7.0")
|
||||
implementation("org.hid4java:hid4java:0.8.0")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
|
||||
+8
-3
@@ -32,7 +32,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
private val hidServices: HidServices
|
||||
|
||||
init {
|
||||
hidServicesSpecification.isAutoStart = false
|
||||
hidServicesSpecification.setAutoStart(false)
|
||||
hidServices = HidManager.getHidServices(hidServicesSpecification)
|
||||
hidServices.addHidServicesListener(this)
|
||||
val dataReadThread = Thread(dataReadRunnable)
|
||||
@@ -43,7 +43,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
|
||||
private fun checkConfigureDevice(hidDevice: HidDevice) {
|
||||
if (hidDevice.vendorId == 0x2FE3 && hidDevice.productId == 0x5652) { // TODO: Use correct ids
|
||||
if (!hidDevice.isOpen) {
|
||||
if (hidDevice.isClosed) {
|
||||
check(hidDevice.open()) { "Unable to open device" }
|
||||
}
|
||||
// TODO: Configure the device here
|
||||
@@ -164,7 +164,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
var devicesPresent = false
|
||||
for ((hidDevice, deviceList) in devicesByHID) {
|
||||
val dataReceived: Array<Byte> = try {
|
||||
hidDevice.read(80, 1) // Read up to 80 bytes, timeout 1ms
|
||||
hidDevice.read(80, 0) // Read up to 80 bytes
|
||||
} catch (e: NegativeArraySizeException) {
|
||||
continue // Skip devices with read error (Maybe disconnected)
|
||||
}
|
||||
@@ -174,6 +174,7 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
// TODO: make this less bad
|
||||
if (dataReceived.size % 20 != 0) {
|
||||
LogManager.info("[TrackerServer] Malformed HID packet, ignoring")
|
||||
continue // Don't continue with this data
|
||||
}
|
||||
val packetCount = dataReceived.size / 20
|
||||
var i = 0
|
||||
@@ -243,6 +244,10 @@ class TrackersHID(name: String, private val trackersConsumer: Consumer<Tracker>)
|
||||
// TODO:
|
||||
}
|
||||
|
||||
override fun hidDataReceived(p0: HidServicesEvent?) {
|
||||
// Seems to have issues with the size of data returned
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Change between IMU axes and OpenGL/SteamVR axes
|
||||
|
||||
Reference in new issue
Block a user