Skip to content
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

Added new method HidController::send_feature_report #3051

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
43349a2
Added new method HidController::send_feature_report
JoergAtGithub Aug 30, 2020
6cffd7e
Removed out commented code line
JoergAtGithub Aug 30, 2020
d0b12ad
Clang format fix
JoergAtGithub Aug 30, 2020
ffbe673
Clang fix next iteration
JoergAtGithub Aug 30, 2020
5bf1c18
Clang format fix again
JoergAtGithub Aug 30, 2020
004fc03
Renamed function from send_feature_report to sendFeatureReport
JoergAtGithub Aug 30, 2020
7e1bc5b
Merge branch 'master' into HidController.send_feature_report
JoergAtGithub Aug 30, 2020
8676365
Fixed incorrect merge
JoergAtGithub Aug 30, 2020
f817802
Made sendFeatureReport working with master
JoergAtGithub Aug 30, 2020
bf0478e
Changed number of spaces
JoergAtGithub Aug 30, 2020
f850111
Use spaces instead of tabulator
JoergAtGithub Aug 30, 2020
bcbcf17
Added newline at end of file
JoergAtGithub Aug 30, 2020
26a45d7
Clang format
JoergAtGithub Aug 30, 2020
52ecf40
Changed type cast
JoergAtGithub Aug 30, 2020
a0c2b74
Clang syntax warnings fixed
JoergAtGithub Aug 30, 2020
895cae2
Added missing argument name in declaration
JoergAtGithub Aug 31, 2020
ba1ab39
Replaced prepend by append
JoergAtGithub Aug 31, 2020
7b00ecf
Fixed clang syntax error
JoergAtGithub Aug 31, 2020
ec19a1c
Added constexpr sizeOfReportID in anonymous namespace
JoergAtGithub Sep 9, 2020
28f9132
clang-format
JoergAtGithub Sep 9, 2020
9a2c4cc
clang-format
JoergAtGithub Sep 9, 2020
46a73ba
clang-format
JoergAtGithub Sep 9, 2020
e069659
Merge branch 'HidController.send_feature_report' of https://github.co…
JoergAtGithub Sep 9, 2020
9c8f242
clang-format
JoergAtGithub Sep 9, 2020
0577b25
Put this at the top of the file (below includes/forward declarations)
JoergAtGithub Sep 9, 2020
01551aa
Replaced the 512 by a constexpr in the anonymous namespace too
JoergAtGithub Sep 10, 2020
136464c
clang-format
JoergAtGithub Sep 10, 2020
eb079c6
Removed the redundant comments for the constexpr statements
JoergAtGithub Oct 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,34 @@ void HidController::sendBytesReport(QByteArray data, unsigned int reportID) {
data.prepend(reportID);

int result = hid_write(m_pHidDevice, (unsigned char*)data.constData(), data.size());
if (result == -1) {
JoergAtGithub marked this conversation as resolved.
Show resolved Hide resolved
if (ControllerDebug::enabled()) {
qWarning() << "Unable to send data to" << getName()
<< "serial #" << hid_serial << ":"
<< safeDecodeWideString(hid_error(m_pHidDevice), 512);
} else {
qWarning() << "Unable to send data to" << getName() << ":"
<< safeDecodeWideString(hid_error(m_pHidDevice), 512);
}
} else {
controllerDebug(result << "bytes sent to" << getName()
<< "serial #" << hid_serial
<< "(including report ID of" << reportID << ")");
}
}

void HidController::sendFeatureReport(
QList<int> dataList, unsigned int reportID) {
QByteArray dataArray;
JoergAtGithub marked this conversation as resolved.
Show resolved Hide resolved
foreach (int datum, dataList) {
dataArray.append(datum);
}

// Append the Report ID to the beginning of dataArray[] per the API..
dataArray.prepend(reportID);
JoergAtGithub marked this conversation as resolved.
Show resolved Hide resolved
JoergAtGithub marked this conversation as resolved.
Show resolved Hide resolved

int result = hid_send_feature_report(
m_pHidDevice, (unsigned char*)dataArray.constData(), dataArray.size());
if (result == -1) {
if (ControllerDebug::enabled()) {
qWarning() << "Unable to send data to" << getName()
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/hid/hidcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class HidController final : public Controller {
static QString safeDecodeWideString(const wchar_t* pStr, size_t max_length);

protected:
void sendReport(QList<int> data, unsigned int length, unsigned int reportID);
void sendReport(
QList<int> data, unsigned int length, unsigned int reportID);
Q_INVOKABLE void sendFeatureReport(
QList<int> data, unsigned int reportID = 0);

private slots:
int open() override;
Expand Down