Skip to content

Commit

Permalink
Changed member variables to camelCase
Browse files Browse the repository at this point in the history
Removed class name before private method call
  • Loading branch information
JoergAtGithub committed Feb 18, 2021
1 parent ba53b75 commit 79e1392
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ HidController::HidController(
mixxx::hid::DeviceInfo&& deviceInfo)
: m_deviceInfo(std::move(deviceInfo)),
m_pHidDevice(nullptr),
m_PollingBufferIndex(0) {
m_pollingBufferIndex(0) {
setDeviceCategory(mixxx::hid::DeviceCategory::guessFromDeviceInfo(m_deviceInfo));
setDeviceName(m_deviceInfo.formatName());

Expand Down Expand Up @@ -109,7 +109,7 @@ int HidController::open() {
for (int i = 0; i < kNumBuffers; i++) {
memset(m_pPollData[i], 0, kBufferSize);
}
m_LastPollSize = 0;
m_lastPollSize = 0;

setOpen(true);
startEngine();
Expand Down Expand Up @@ -138,23 +138,23 @@ int HidController::close() {

void HidController::processInputReport(int bytesRead) {
Trace process("HidController processInputReport");
unsigned char* pPreviousBuffer = m_pPollData[(m_PollingBufferIndex + 1) % kNumBuffers];
unsigned char* pCurrentBuffer = m_pPollData[m_PollingBufferIndex];
unsigned char* pPreviousBuffer = m_pPollData[(m_pollingBufferIndex + 1) % kNumBuffers];
unsigned char* pCurrentBuffer = m_pPollData[m_pollingBufferIndex];
// Some controllers such as the Gemini GMX continuously send input reports even if it
// is identical to the previous input report. If this loop processed all those redundant
// input reports, it would be a big performance problem to run JS code for every input report
// plus it would be unnecessary.
// This assumes that the redundant input reports all use the same report ID. In practice we
// have not encountered any controllers that send redundant input reports with different report
// is identical to the previous send input report. If this loop processed all those redundant
// input report, it would be a big performance problem to run JS code for every input report and
// would be unnecessary.
// This assumes that the redundant input report all use the same report ID. In practice we
// have not encountered any controllers that send redundant input report with different report
// IDs. If any such devices exist, this may be changed to use a separate buffer to store
// the last input report for each report ID.
if (bytesRead == m_LastPollSize &&
if (bytesRead == m_lastPollSize &&
memcmp(pCurrentBuffer, pPreviousBuffer, bytesRead) == 0) {
return;
}
// Cycle between buffers so the memcmp below does not require deep copying to another buffer.
m_PollingBufferIndex = (m_PollingBufferIndex + 1) % kNumBuffers;
m_LastPollSize = bytesRead;
m_pollingBufferIndex = (m_pollingBufferIndex + 1) % kNumBuffers;
m_lastPollSize = bytesRead;
auto incomingData = QByteArray::fromRawData(
reinterpret_cast<char*>(pCurrentBuffer), bytesRead);
receive(incomingData, mixxx::Time::elapsed());
Expand All @@ -164,8 +164,8 @@ QList<int> HidController::getInputReport(unsigned int reportID) {
Trace hidRead("HidController getInputReport");
int bytesRead;

m_pPollData[m_PollingBufferIndex][0] = reportID;
bytesRead = hid_get_input_report(m_pHidDevice, m_pPollData[m_PollingBufferIndex], kBufferSize);
m_pPollData[m_pollingBufferIndex][0] = reportID;
bytesRead = hid_get_input_report(m_pHidDevice, m_pPollData[m_pollingBufferIndex], kBufferSize);

controllerDebug(bytesRead
<< "bytes received by hid_get_input_report" << getName()
Expand All @@ -189,12 +189,12 @@ QList<int> HidController::getInputReport(unsigned int reportID) {
QList<int> dataList;
dataList.reserve(bytesRead);
for (int i = 0; i < bytesRead; i++) {
dataList.append(m_pPollData[m_PollingBufferIndex][i]);
dataList.append(m_pPollData[m_pollingBufferIndex][i]);
}

// Execute callback function in JavaScript mapping
// and print to stdout in case of --controllerDebug
HidController::processInputReport(bytesRead);
processInputReport(bytesRead);

return dataList;
}
Expand All @@ -208,7 +208,7 @@ bool HidController::poll() {
// There is no safety net for this because it has not been demonstrated to be
// a problem in practice.
while (true) {
int bytesRead = hid_read(m_pHidDevice, m_pPollData[m_PollingBufferIndex], kBufferSize);
int bytesRead = hid_read(m_pHidDevice, m_pPollData[m_pollingBufferIndex], kBufferSize);
if (bytesRead < 0) {
// -1 is the only error value according to hidapi documentation.
DEBUG_ASSERT(bytesRead == -1);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/hid/hidcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HidController final : public Controller {

QList<int> getInputReport(unsigned int reportID);
QList<int> getFeatureReport(unsigned int reportID);

const mixxx::hid::DeviceInfo m_deviceInfo;

hid_device* m_pHidDevice;
Expand Down

0 comments on commit 79e1392

Please sign in to comment.