From 358375be8a8537d75bc2d9678dd4fe3ba8eb55f7 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sat, 22 Oct 2022 20:55:08 +0100 Subject: [PATCH] Add gamepad detection --- shuttlesetup.cpp => controllersetup.cpp | 28 +++++---- shuttlesetup.h => controllersetup.h | 18 +++--- shuttlesetup.ui => controllersetup.ui | 10 +-- resources/xbox.png | Bin 0 -> 245564 bytes usbcontroller.cpp | 78 ++++++++++++++++++++++++ usbcontroller.h | 4 +- wfmain.cpp | 6 +- wfmain.h | 6 +- wfview.pro | 8 +-- wfview.vcxproj | 73 +++++++++++++--------- wfview.vcxproj.filters | 36 +++++++---- 11 files changed, 190 insertions(+), 77 deletions(-) rename shuttlesetup.cpp => controllersetup.cpp (87%) rename shuttlesetup.h => controllersetup.h (81%) rename shuttlesetup.ui => controllersetup.ui (91%) create mode 100644 resources/xbox.png diff --git a/shuttlesetup.cpp b/controllersetup.cpp similarity index 87% rename from shuttlesetup.cpp rename to controllersetup.cpp index 4617cdb..d90e309 100644 --- a/shuttlesetup.cpp +++ b/controllersetup.cpp @@ -1,13 +1,13 @@ -#include "shuttlesetup.h" -#include "ui_shuttlesetup.h" +#include "controllersetup.h" +#include "ui_controllersetup.h" #include "logcategories.h" -shuttleSetup::shuttleSetup(QWidget* parent) : +controllerSetup::controllerSetup(QWidget* parent) : QDialog(parent), - ui(new Ui::shuttleSetup) + ui(new Ui::controllerSetup) { ui->setupUi(this); - scene = new shuttleScene(); + scene = new controllerScene(); connect(scene, SIGNAL(mousePressed(QPoint)), this, SLOT(mousePressed(QPoint))); ui->graphicsView->setScene(scene); textItem = scene->addText("No USB controller found"); @@ -18,7 +18,7 @@ shuttleSetup::shuttleSetup(QWidget* parent) : connect(&offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int))); } -shuttleSetup::~shuttleSetup() +controllerSetup::~controllerSetup() { delete textItem; delete scene; @@ -29,7 +29,7 @@ shuttleSetup::~shuttleSetup() } } -void shuttleSetup::mousePressed(QPoint p) +void controllerSetup::mousePressed(QPoint p) { // Receive mouse event from the scene qDebug() << "Looking for button Point x=" << p.x() << " y=" << p.y(); @@ -71,7 +71,7 @@ void shuttleSetup::mousePressed(QPoint p) } -void shuttleSetup::onEventIndexChanged(int index) { +void controllerSetup::onEventIndexChanged(int index) { qDebug() << "On Event for button" << currentButton->num << "Event" << index; if (currentButton != Q_NULLPTR && index < commands->size()) { currentButton->onCommand = &commands->at(index); @@ -80,7 +80,7 @@ void shuttleSetup::onEventIndexChanged(int index) { } -void shuttleSetup::offEventIndexChanged(int index) { +void controllerSetup::offEventIndexChanged(int index) { qDebug() << "Off Event for button" << currentButton->num << "Event" << index; if (currentButton != Q_NULLPTR && index < commands->size()) { currentButton->offCommand = &commands->at(index); @@ -89,7 +89,7 @@ void shuttleSetup::offEventIndexChanged(int index) { } -void shuttleSetup::newDevice(unsigned char devType, QVector