-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow controller mapping to discard polling #12558
Allow controller mapping to discard polling #12558
Conversation
c1660ba
to
ff37a30
Compare
Oh, it looks like you have discovered a more serious problem. The busy loop around What could be a solution for this root issue? The solution in this PR looks reasonable, thank you. Just let's verify that it will fit to a possible solution for the root case. |
So on my specific problem - devices not meant to be read/written to - I guess an extension of the mapping manifest to completely set exclusively polling/sending capabilities is the most effective solution I can think about. For the problem you've raised - the spam of
Perhaps it might be best to handle those as two separate issue? Happy to look into that polling refactor, but I'd rather do it in another PR if that okay with you! Btw, is any Windows guru able to tell me what is wrong on Windows? My gut feeling is that a syntax isn't supported or one of my symbol naming would clash with a reserved keyword but cannot clearly tell... |
Yes that's perfect. I just want to make sure both solutions are not conflicting. |
@@ -32,6 +32,12 @@ class LegacyControllerMapping { | |||
bool builtin; | |||
}; | |||
|
|||
enum DeviceDirection { | |||
OUT = 0x1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such issuers normally happen a ; or } is missing in the code before probably in one of the included headers.
ff37a30
to
d8bda87
Compare
The approach with the free-running HidIoThread and 250us sleep proved to be very performant on all platforms, while not consuming too many resources. The main reason why it works so well, is that it is completely asyncronous to the processing cycles of other threads like audio buffer processing, and vsync. It virtually synchronizes with the timing of the HID kernel driver, and therefore utilizes the transport bus efficiently, without unused idle time. |
The keywords |
d8bda87
to
ac692a2
Compare
Thanks for your help! Hopefully my naming doesn't clash with anything anymore.
(Disclaimer: this is my first time ever working on USB communication so please be kind if that's completely wrong 😅) I believe the
This way, bulk communication will keep low latency capabilities (e.g while using the jog wheel, faders or pots) but will also try and reduce the load on the USB stack when unused. Aligned with the ability for controllers to completely turn off polling (this PR), I guess this should allow us to get bulk in a better position. What do you think? |
Yes, that's the already implemented as it should be!
It depends much on the operating systems USB implementation. I know it only for HID but guess that general USB is the same, there Windows is the only OS that allows overlapping IO (sending the next transfer, before receiving acknowlege for the last). This is why the cross-platform wrapper hidapi strictly serializes all reports. It can take several milliseconds until the acknowledgement is received. BTW: I think it's also possible to determine the direction from libusb, by evaluating the endpoint descriptor: https://libusb.sourceforge.io/api-1.0/structlibusb__endpoint__descriptor.html#a111d087a09cbeded8e15eda9127e23d2 |
reviving this because it's necessary for S4MK3 support in general. The basic idea seems good to me, are there any objections to merging it? |
The functionality itself is the right thing to do, for sure. But why let the mapping creator specify the device direction, when it is always available in the USB endpoint descriptor, which can be read by libusb? |
In theory I agree with you @JoergAtGithub - definitely think that should be detected by libusb, but I didn't have the skillset at the time I wrote that. With my recent Windows support work, I gain some so I might give it a go, except if you would know how to implement this easily? |
Can you add a TODO comment, that this should be changed in future - and add it as task to #13004 |
ac692a2
to
9a98695
Compare
9a98695
to
97e87c0
Compare
Done here - let me know if that's good enough. Also added a task via the comment (no edit permission) |
Moved it up to description. PR LGTM! Waiting for CI! Thank you! |
As I'm working on the screen support for S4 MK3, I realized that the
BulkReader
was keeping its thread under a 100% CPU usage. After somelibusb
debugging, it looks like theBulkReader
was constantly initiating a bulk transfer, despite the device returning an empty buffer (the bulk endpoint on S4 Mk3 is write-only).This PR allows mapping to provide information on whether or not a device should be polled or not. It also set the foundations to inhibit writing to a device.