mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-29 13:22:50 -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
+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