From 706ea80e7ab91af4e8728eb873564880430fbc2c Mon Sep 17 00:00:00 2001 From: JoergAtGithub Date: Sun, 21 Feb 2021 09:04:58 +0100 Subject: [PATCH] Removed call of incomingData from getInputReport due to the risk of infinite loops in mapping scripts Fixed some comments mentioned in review --- src/controllers/hid/hidcontroller.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/controllers/hid/hidcontroller.cpp b/src/controllers/hid/hidcontroller.cpp index 23ebcf9579c..9126db1bac8 100644 --- a/src/controllers/hid/hidcontroller.cpp +++ b/src/controllers/hid/hidcontroller.cpp @@ -152,11 +152,14 @@ void HidController::processInputReport(int bytesRead) { memcmp(pCurrentBuffer, pPreviousBuffer, bytesRead) == 0) { return; } - // Cycle between buffers so the memcmp below does not require deep copying to another buffer. + // Cycle between buffers so the memcmp above does not require deep copying to another buffer. m_pollingBufferIndex = (m_pollingBufferIndex + 1) % kNumBuffers; m_lastPollSize = bytesRead; auto incomingData = QByteArray::fromRawData( reinterpret_cast(pCurrentBuffer), bytesRead); + + // Execute callback function in JavaScript mapping + // and print to stdout in case of --controllerDebug receive(incomingData, mixxx::Time::elapsed()); } @@ -174,9 +177,9 @@ QList HidController::getInputReport(unsigned int reportID) { << QString::number(static_cast(reportID), 16) .toUpper() .rightJustified(2, QChar('0')) - << ")") + << ")"); - if (bytesRead <= kReportIdSize) { + if (bytesRead <= kReportIdSize) { // -1 is the only error value according to hidapi documentation. // Otherwise minimum possible value is 1, because 1 byte is for the reportID, // the smallest report with data is therefore 2 bytes. @@ -191,11 +194,6 @@ QList HidController::getInputReport(unsigned int reportID) { for (int i = 0; i < bytesRead; i++) { dataList.append(m_pPollData[m_pollingBufferIndex][i]); } - - // Execute callback function in JavaScript mapping - // and print to stdout in case of --controllerDebug - processInputReport(bytesRead); - return dataList; }