From f4a86ac02e5996d61bdddef0f69b4ce92b19a4de Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 7 Feb 2023 23:05:42 +0000 Subject: [PATCH] Add more buttons --- usbcontroller.cpp | 44 +++++++++++++++++++++++++------------------- usbcontroller.h | 2 +- wfmain.cpp | 6 ++++++ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/usbcontroller.cpp b/usbcontroller.cpp index 27baa04..bc03ad2 100644 --- a/usbcontroller.cpp +++ b/usbcontroller.cpp @@ -304,7 +304,7 @@ void usbController::runTimer() << hex << (unsigned char)data[3] << ":" << hex << (unsigned char)data[4]; */ - quint16 tempButtons = ((quint8)data[4] << 8) | ((quint8)data[3] & 0xff); + quint32 tempButtons = ((quint8)data[4] << 8) | ((quint8)data[3] & 0xff); unsigned char tempJogpos = (unsigned char)data[1]; unsigned char tempShutpos = (unsigned char)data[0]; @@ -477,29 +477,35 @@ void usbController::runTimer() } else if (usbDevice == eCoderPlus && data.length() >= 0x0f && (quint8)data[0] == 0xff) { /* Button matrix: - DATA2 DATA 1 - 7654321076543210 - 0100000000000000 = button14 - 0010000000000000 = button13 - 0001000000000000 = button12 - 0000100000000000 = button11 - 0000010000000000 = button10 - 0000001000000000 = button9 - 0000000100000000 = button8 - 0000000010000000 = button7 - 0000000001000000 = button6 - 0000000000100000 = button5 - 0000000000010000 = button4 - 0000000000001000 = button3 - 0000000000000100 = button2 - 0000000000000010 = button1 + DATA3 DATA2 DATA 1 + 765432107654321076543210 + 001000000000000000000000 = Left CW + 000100000000000000000000 = Right CW + 000010000000000000000000 = PTT + 000001000000000000000000 = Knob 3 Press + 000000100000000000000000 = Knob 2 Press + 000000010000000000000000 = Knob 1 Press + 000000000100000000000000 = button14 + 000000000010000000000000 = button13 + 000000000001000000000000 = button12 + 000000000000100000000000 = button11 + 000000000000010000000000 = button10 + 000000000000001000000000 = button9 + 000000000000000100000000 = button8 + 000000000000000010000000 = button7 + 000000000000000001000000 = button6 + 000000000000000000100000 = button5 + 000000000000000000010000 = button4 + 000000000000000000001000 = button3 + 000000000000000000000100 = button2 + 000000000000000000000010 = button1 */ - quint16 tempButtons = ((quint8)data[2] << 8) | ((quint8)data[1] & 0xff); + quint32 tempButtons = ((quint8)data[3] << 16) | ((quint8)data[2] << 8) | ((quint8)data[1] & 0xff); if (buttons != tempButtons) { // Step through all buttons and emit ones that have been pressed. - for (unsigned char i = 1; i < 15; i++) + for (unsigned char i = 1; i < 23; i++) { for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) { if (but->dev == usbDevice && but->num == i) { diff --git a/usbcontroller.h b/usbcontroller.h index 7cea81c..e01d12a 100644 --- a/usbcontroller.h +++ b/usbcontroller.h @@ -126,7 +126,7 @@ private: hid_device* handle=NULL; int hidStatus = 1; bool isOpen=false; - quint16 buttons=0; + quint32 buttons=0; unsigned char jogpos=0; unsigned char shutpos=0; unsigned char shutMult = 0; diff --git a/wfmain.cpp b/wfmain.cpp index d0e6ed3..dc37048 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -9256,6 +9256,12 @@ void wfmain::resetUsbButtons() usbButtons.append(BUTTON(eCoderPlus, 12, QRect(410, 351, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0])); usbButtons.append(BUTTON(eCoderPlus, 13, QRect(87, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0])); usbButtons.append(BUTTON(eCoderPlus, 14, QRect(410, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0])); + usbButtons.append(BUTTON(eCoderPlus, 16, QRect(121, 102, 68, 73), Qt::red, &usbCommands[0], &usbCommands[0])); + usbButtons.append(BUTTON(eCoderPlus, 17, QRect(242, 102, 68, 73), Qt::red, &usbCommands[0], &usbCommands[0])); + usbButtons.append(BUTTON(eCoderPlus, 18, QRect(362, 102, 68, 73), Qt::red, &usbCommands[0], &usbCommands[0])); + usbButtons.append(BUTTON(eCoderPlus, 19, QRect(124, 2, 55, 30), Qt::red, &usbCommands[1], &usbCommands[2])); + usbButtons.append(BUTTON(eCoderPlus, 20, QRect(290, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0])); + usbButtons.append(BUTTON(eCoderPlus, 21, QRect(404, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0])); emit sendUsbControllerButtons(&usbButtons);