-
-
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
HID Switch to force sending of duplicate data and cleanup of JS API functions #4692
Conversation
-With data as QList or QByteArray -Without the unused length argument -With a new argument to disable skipping of OutputReports with redundant data
Removed not working overloaded sendOutputReport with argument type QList
Added missing sentence in comment
@JoergAtGithub could you take care of @uklotzde's review comments above? I would prefer to not add yet another function to the API for this one niche use case. |
…e logical meaning of the flag
5741ce6
to
2804b01
Compare
… (both are introduced after 2.3). ReportId is now first argument, as in all other HID APIs I know.
6643381
to
45a4510
Compare
Passed by reference now
…unctions Passed by reference now
-Now the arguments are identical with the similar function getFeatureReport -This array is no longer compatible with incomingData anyway, because the type changed in mixxxdj#4521 -And even before, it was only compatible, under the assumption, that the HID device uses ReportIds Note, that getInputReport is new for 2.4 and can be changed without breaking backward compatibility
cf9d059
to
2c3b119
Compare
Does it make sense to adjust res/controllers/common-hid-packet-parser.js to the new API? |
In fact, this is what I had done for testing this PR. There is only one single line to change:
this needs to be changed to: controller.sendOutputReport(this.reportId, Uint8Array.from(data).buffer);
|
For my understanding this saves some CPU cycles due to the QByteArray, right? Would you mind to add this commit? This PR looks good to me. @uklotzde: Can we merge? |
I don't know, what's the more efficient implementation. I would prefer to do it in a follow-up PR for common-hid-packet-parser.js |
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.
Thank you for this follow-up PR. Reordering the parameters to reflect the order within the actual data make sense. Not touching the Q_INVOKABLE functions goes without saying.
The data is copied twice into QByteArray? I didn't check if this behavior is unchanged from before.
LGTM
…m HidIoOutputReport
…m HidIoOutputReport
…m HidIoOutputReport
I added a switch to force the sending of HID OutputReports with identical data, as needed by @Be-ing to support the S4 MK3 mapping: #4585 (comment)
After looking at the JavaScript API, I found out, that
Q_INVOKABLE void send(const QList<int>& data, unsigned int length = 0) override
is only there to comply with the inheritance of controller.c. But this function is practically useless. It doesn't send raw bytes as the siblings for MIDI and BULK, because this is a functionality, which the HID protocoll doesn't support. Instead it sends a OutputReport with hardcoded ReportID 0. I wonder, if this function was ever used anywhere.
Than there is
Q_INVOKABLE void send(const QList<int>& data, unsigned int length, unsigned int reportID)
which has already one unused argument (length).
Both send functions use QLIST as argument, while since #4521, the other functions of the JavaScript API use QByteArray.
I added a new API function with QByteArray
Q_INVOKABLE void sendOutputReport(unsigned int reportID, const QByteArray& dataArray, resendUnchangedReport = false)
and extended the old send function backward compatibility:
Q_INVOKABLE void send(const QList<int>& dataList, unsigned int length, unsigned int reportID, resendUnchangedReport = false)
Note: I found no way to make an overloaded function work, which support both QList or QByteArray. Independend of the type in JavaScript, always the same function was called.
Furthermore I noticed, that the comments describing these JavaScript API functions are no longer apply since #4521, I rewrote them (in Doxygen syntax). Especially the returned array of getInputReport became incompatible to the incommingdata function. And this compatibility was the only reason to prepend the reportId to the data array.
Now the HID API functions are:
Unchanged since 2.3:
Q_INVOKABLE void send(const QList<int>& dataList, unsigned int length = 0) override
IMHO this function makes no sense, but I kept it for backward compatibility
Extended since 2.3:
Q_INVOKABLE void send(const QList<int>& dataList, unsigned int length, quint8 reportID, bool resendUnchangedReport = false)
Added optional argument resendUnchangedReport - Note that the Length argument is unused and it uses QList
New in 2.4 and now unified in content and type of the data array:
Q_INVOKABLE void sendOutputReport(quint8 reportID, const QByteArray& dataArray, bool resendUnchangedReport = false)
Q_INVOKABLE QByteArray getInputReport(quint8 reportID)
Q_INVOKABLE void sendFeatureReport(quint8 reportID, const QByteArray& reportData)
Q_INVOKABLE QByteArray getFeatureReport(quint8 reportID)
This is now similar to the basic IO functions in all other HID APIs I know - as well in naming as in order of arguments