-
-
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
HidController: change getInputReport to automatically call script #4520
Conversation
This way, scripts don't need to wrap calls to controller.getInputReport with another call to their incomingData function.
I have successfully used this with #4056 and libusb/hidapi#351 to initialize the state of my Kontrol S4 Mk3 when Mixxx starts. |
@JoergAtGithub what do you think about this change? |
Oops, there was a good reason we did it this way. |
Since I couldn't get #4521 to work, I tried calling |
Why you removed the return value? How to access bits that are not linked to Mixxx controls now? |
That is up to the incomingData callback.
Yeah, that's ugly, but unless you know how to get #4521 to work, I think we'll have to live with that... :/ |
I don't get the point why you want to change the type of the return value. It is working for getInputReport and getFeatureReport now. Why shouldn't it work anymore if you add a call of processInputReport. This way it was implemented in my original code, before code review: https://github.com/JoergAtGithub/mixxx/blob/79e139285282701aeb66431a92162f3e3bdb6d94/src/controllers/hid/hidcontroller.cpp#L163 |
|
I use it this way in the Z2 mapping:
|
Right, but your mixxx/res/controllers/Traktor-Kontrol-S4-MK3.js Line 1974 in ab636db
|
I need the raw report data for the initialization of the Z2 in the Init section, before polling starts. This is why I implemented this function. |
I don't understand what you're proposing. Isn't that what getInputReport already does? |
I propose to leave getInputReport as it is (returns the bytes of the specified input report and isn't calling processInputReport). This ensures that there are no unintended side effects during initialization of the device. And implement a second API function that calls processInputReport but doesn't return anything. |
I don't think it's a good idea to have almost identical functions in the API that only work slightly differently. |
I don't think this is a good idea. IMO we should favor getting #4521 to work. My suggested workaround would be calling I prefer hiding the uglyness in the methods on the edge between JS and C++ and not expose the uglyness into our Controller API. |
This is not trivial because there is no QJSEngine in HidController. If we go that route we may as well use the existing code path with processInputReport. |
Mhmm, then I'll favor keeping as is and waiting until the Qt issue has been fixed? |
The current API requires two layers of boilerplate:
instead of simply:
|
Why do we need to pass the data to |
This is one ofthe use cases for getInputReport: The other use case is to determine controller internal status bits like the internal/external mixing mode in the Init section of the mapping. |
Ah, so |
I think |
Right, but that was not my point. I was trying to send that I might want to call Do you understand my concerns that the proposed change will lead to a less consistent, more convoluted API? |
What about renaming the function? Maybe |
that will only obscure the questionable design. |
not having to write 36 extra chars does not legitimize this change. |
I need a functionality to get the raw data of any InputReport in the Init procedure of the mapping, otherwise I can no longer initialize the mapping to the state of the controller. This is why I implemented this API function. If there would be only a function requestInputReport, that only calls processInputReport this would be impossible. Because the incomingData function wouldn't be executed until the Init procedure is finished. |
The problem with this is that we need to decide on an API before a release is made with this feature. |
I don't understand this. |
That problem is exactly what I tried to point out earlier. When you call To demonstrate, a quick sketch: const DummyController = {};
DummyController.incomingData = function (bytes) {
}
DummyController.init = function () {
// need to query controller for some internal state so we can properly initialize the controller
const buffer = getInputReport(0);
if (buffer[1] == 0) {/* etc */}
// ....
} A usecase like this (which is what @JoergAtGithub described) would result in much more complex and difficult to maintain code. |
I agree. Passing a buffer as a |
I'm sorry if I sound condescending. I don't intend to insult your efforts here but I'm a bit frustrated because of the drama on the other PRs and the fact that I can't seem to convey the consequences of your proposal. |
I agree with @Swiftb0y that adding hidden side-effects to functions like I didn't study the details, but keeping the code separated in two different functions |
By the way, what is the reason for that ( |
Nothing you've said here comes across as condescending. |
Consensus seems to be against this, so let's reconsider #4521 instead. |
This way, scripts don't need to wrap calls to
controller.getInputReport with another call to their incomingData
function.