Skip to content

Commit

Permalink
Revert "Tried to use IOUSBDeviceInterface, but I think that is too lo…
Browse files Browse the repository at this point in the history
…w level and won't work for Bluetooth devices"

So I looked into this more:

- When you connect a device via BT, there is no related object of type IOUSBDevice in the registry (I think so at least) (If this is true then then razer-macos driver should not work with Bluetooth mice, since it uses the bluetooth specific kernel interface IOUSBDeviceInterface)
- IOHIDDevice internally uses plugin interfaces to communicate with the kernel space device driver. You can also use these interfaces manually. See IOHIDDeviceCreate in IOHIDDevice.c for examples.
- Here are the interfaces for HIDDevices that I found:

IOHIDDeviceInterface
IOHIDDeviceInterface121
IOHIDDeviceInterface122
IOHIDDeviceDeviceInterface
IOHIDDeviceTimeStampedDeviceInterface
IOHIDDeviceQueueInterface
IOHIDDeviceTransactionInterface
IOHIDQueueInterface

- The IOHIDQueueInterface seems like it might be able to do what we want it to. (We want to read with a timeout and interrupt reading asynchronously) It has a getNextEvent() function with a timeout and there are functions to stop the queue (I think in IOHIDDeviceInterface?). But the problem is that the queue doesn't seem to deliver raw reports, but instead only parsed input elements or something. Also the docs say that the `timeoutMS` parameter is "UNSUPPORTED" and also the docs don't say what stopping the queue while waiting for an event actually does exactly. None of the other interfaces do what we need them to either. Well IOHIDDeviceInterface122 (and possibly others) can read reports with a timeout, but there's no way to interrupt reading anywhere.

Based on this I think there is no elegant way to interrupt reading. I think you'd need create multiple threads when using them, to be able to interrupt reading. None of these interfaces provide any sigificant benefits over our current approach.

The IOUSBDeviceInterface allows for elegant read interrupts, but I think it won't work for Bluetooth mice.

So our current solution is the best we have.

This reverts commit 4318472.
  • Loading branch information
noah-nuebling committed Jan 12, 2022
1 parent 4318472 commit 0236614
Show file tree
Hide file tree
Showing 2 changed files with 304 additions and 142 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,5 @@
"memory_resource": "cpp",
"stop_token": "cpp",
"__availability": "cpp"
},
"files.autoSave": "afterDelay"
}
}
Loading

0 comments on commit 0236614

Please sign in to comment.