Add support for ecoder buttons

smart-pointers
Phil Taylor 2023-02-07 19:37:33 +00:00
rodzic 1e217bc5b8
commit 5298949f3a
4 zmienionych plików z 61 dodań i 23 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 289 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 321 KiB

Wyświetl plik

@ -304,7 +304,7 @@ void usbController::runTimer()
<< hex << (unsigned char)data[3] << ":"
<< hex << (unsigned char)data[4];
*/
unsigned int tempButtons = (unsigned int)((unsigned char)data[3] | (unsigned char)data[4] << 8);
quint16 tempButtons = (data[4] << 8) | (data[3] & 0xff);
unsigned char tempJogpos = (unsigned char)data[1];
unsigned char tempShutpos = (unsigned char)data[0];
@ -343,7 +343,7 @@ void usbController::runTimer()
// Step through all buttons and emit ones that have been pressed.
for (unsigned char i = 0; i < 16; i++)
{
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
if (but->dev == usbDevice && but->num == i) {
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
@ -475,8 +475,47 @@ void usbController::runTimer()
lastData = data;
}
}
else if (usbDevice == eCoderPlus) {
quint16 buts = (data[2] << 8) | (data[1] & 0xff);
else if (usbDevice == eCoderPlus && data.length() == 16 && data[0]==0xff) {
/* Button matrix:
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
*/
quint16 tempButtons = (data[2] << 8) | (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 (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
if (but->dev == usbDevice && but->num == i) {
if ((tempButtons << i & 1) && !(buttons << i & 1) && but->onCommand->index > 0)
{
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
emit button(but->onCommand);
}
else if ((buttons << i & 1) && !(tempButtons << i & 1) && but->offCommand->index > 0)
{
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
emit button(but->offCommand);
}
}
}
}
}
buttons = tempButtons;
}

Wyświetl plik

@ -126,7 +126,7 @@ private:
hid_device* handle=NULL;
int hidStatus = 1;
bool isOpen=false;
unsigned int buttons=0;
quint16 buttons=0;
unsigned char jogpos=0;
unsigned char shutpos=0;
unsigned char shutMult = 0;
@ -149,9 +149,10 @@ private:
usbDeviceType usbDevice = usbNone;
unsigned short knownUsbDevices[4][3] = {
{shuttleXpress,0x0b33,0x0020},
//{shuttleXpress,0x0b33,0x0020},
{shuttlePro2,0x0b33,0x0030},
{eCoderPlus,0x1fc9,0x0003},
//{eCoderPlus,0x1fc9,0x0003},
{eCoderPlus,0x0b33,0x0020},
{RC28,0x0c26,0x001e} };
protected:

Wyświetl plik

@ -9242,22 +9242,20 @@ void wfmain::resetUsbButtons()
usbButtons.append(BUTTON(xBoxGamepad, "RIGHTY", QRect(453, 233, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
// eCoder
// ShuttlePro2
usbButtons.append(BUTTON(eCoderPlus, 0, QRect(60, 66, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 1, QRect(114, 50, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 2, QRect(169, 47, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 3, QRect(225, 59, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 4, QRect(41, 132, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 5, QRect(91, 105, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 6, QRect(144, 93, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 7, QRect(204, 99, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 8, QRect(253, 124, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 9, QRect(50, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 10, QRect(210, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 11, QRect(50, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 12, QRect(210, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 13, QRect(30, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 14, QRect(280, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 1, QRect(87, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 2, QRect(168, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 3, QRect(249, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 4, QRect(329, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 5, QRect(410, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 6, QRect(87, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 7, QRect(168, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 8, QRect(249, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 9, QRect(329, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 10, QRect(410, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 11, QRect(87, 351, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
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]));
emit sendUsbControllerButtons(&usbButtons);