mirror of
https://github.com/AntiMicroX/antimicrox.git
synced 2025-12-23 23:29:25 -05:00
chore: ensure Consistent formatting of code across entire project
* Create basic config for clang-format * Format source files using clang-format * Add Github Action checking proper code formatting after every Pull request
This commit is contained in:
14
.clang-format
Normal file
14
.clang-format
Normal file
@@ -0,0 +1,14 @@
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
|
||||
BreakBeforeBraces: Custom
|
||||
ColumnLimit: 125
|
||||
IndentPPDirectives: BeforeHash
|
||||
BraceWrapping:
|
||||
AfterEnum: true
|
||||
AfterStruct: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterFunction: true
|
||||
AfterUnion: true
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
20
.github/workflows/code_formatting.yml
vendored
Normal file
20
.github/workflows/code_formatting.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Check code formatting
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
test:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download tools
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install clang-format-10
|
||||
echo "Clang-format version"
|
||||
clang-format --version
|
||||
wget https://raw.githubusercontent.com/Sarcasm/run-clang-format/master/run-clang-format.py
|
||||
chmod +x ./run-clang-format.py
|
||||
|
||||
- name: Test
|
||||
run: ./run-clang-format.py -r src
|
||||
@@ -19,24 +19,24 @@
|
||||
#include "aboutdialog.h"
|
||||
#include "ui_aboutdialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "common.h"
|
||||
#include "eventhandlerfactory.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <SDL2/SDL_version.h>
|
||||
#include <SDL2/SDL_gamecontroller.h>
|
||||
#include <SDL2/SDL_version.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QResource>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QFile>
|
||||
#include <QResource>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
#include <QTextStream>
|
||||
#include <QtGlobal>
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AboutDialog)
|
||||
AboutDialog::AboutDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AboutDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -107,7 +107,8 @@ void AboutDialog::changeEvent(QEvent *event)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (event->type() == QEvent::LanguageChange) retranslateUi();
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
retranslateUi();
|
||||
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ABOUTDIALOG_H
|
||||
#define ABOUTDIALOG_H
|
||||
|
||||
@@ -32,14 +31,14 @@ class AboutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit AboutDialog(QWidget *parent = nullptr);
|
||||
~AboutDialog();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::AboutDialog *ui;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void fillInfoTextBrowser();
|
||||
virtual void changeEvent(QEvent *event);
|
||||
void retranslateUi();
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
#include "addeditautoprofiledialog.h"
|
||||
#include "ui_addeditautoprofiledialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "autoprofileinfo.h"
|
||||
#include "inputdevice.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "autoprofileinfo.h"
|
||||
#include "common.h"
|
||||
#include "inputdevice.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#ifdef WITH_X11
|
||||
#include "unixcapturewindowutility.h"
|
||||
#ifdef WITH_X11
|
||||
#include "capturedwindowinfodialog.h"
|
||||
#include "unixcapturewindowutility.h"
|
||||
#include "x11extras.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
@@ -39,13 +39,11 @@
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
|
||||
AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings,
|
||||
QList<InputDevice*> *devices,
|
||||
QList<QString> &reservedUniques, bool edit, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AddEditAutoProfileDialog)
|
||||
QList<InputDevice *> *devices, QList<QString> &reservedUniques, bool edit,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AddEditAutoProfileDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -61,8 +59,10 @@ AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMi
|
||||
this->originalWindowClass = info->getWindowClass();
|
||||
this->originalWindowName = info->getWindowName();
|
||||
|
||||
if (info->isPartialState()) ui->setPartialCheckBox->setChecked(true);
|
||||
else ui->setPartialCheckBox->setChecked(false);
|
||||
if (info->isPartialState())
|
||||
ui->setPartialCheckBox->setChecked(true);
|
||||
else
|
||||
ui->setPartialCheckBox->setChecked(false);
|
||||
|
||||
QListIterator<QString> iterUniques(reservedUniques);
|
||||
|
||||
@@ -70,20 +70,22 @@ AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMi
|
||||
{
|
||||
QString uniqueID = iterUniques.next();
|
||||
|
||||
if (!getReservedUniques().contains(uniqueID)) this->reservedUniques.append(uniqueID);
|
||||
if (!getReservedUniques().contains(uniqueID))
|
||||
this->reservedUniques.append(uniqueID);
|
||||
}
|
||||
|
||||
ui->devicesComboBox->addItem("all");
|
||||
QListIterator<InputDevice*> iter(*devices);
|
||||
QListIterator<InputDevice *> iter(*devices);
|
||||
int found = -1;
|
||||
int numItems = 1;
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
InputDevice *device = iter.next();
|
||||
ui->devicesComboBox->addItem(device->getSDLName(), QVariant::fromValue<InputDevice*>(device));
|
||||
ui->devicesComboBox->addItem(device->getSDLName(), QVariant::fromValue<InputDevice *>(device));
|
||||
|
||||
if (device->getUniqueIDString() == info->getUniqueID()) found = numItems;
|
||||
if (device->getUniqueIDString() == info->getUniqueID())
|
||||
found = numItems;
|
||||
|
||||
numItems++;
|
||||
}
|
||||
@@ -93,11 +95,10 @@ AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMi
|
||||
if (found >= 0)
|
||||
{
|
||||
ui->devicesComboBox->setCurrentIndex(found);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->devicesComboBox->addItem(tr("Current (%1)").arg(info->getDeviceName()));
|
||||
ui->devicesComboBox->setCurrentIndex(ui->devicesComboBox->count()-1);
|
||||
ui->devicesComboBox->setCurrentIndex(ui->devicesComboBox->count() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,29 +111,29 @@ AddEditAutoProfileDialog::AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMi
|
||||
|
||||
connect(ui->profileBrowsePushButton, &QPushButton::clicked, this, &AddEditAutoProfileDialog::openProfileBrowseDialog);
|
||||
connect(ui->applicationPushButton, &QPushButton::clicked, this, &AddEditAutoProfileDialog::openApplicationBrowseDialog);
|
||||
connect(ui->devicesComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AddEditAutoProfileDialog::checkForReservedUniques);
|
||||
connect(ui->devicesComboBox, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged), this, &AddEditAutoProfileDialog::checkDefaultCheckbox);
|
||||
connect(ui->devicesComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AddEditAutoProfileDialog::checkForReservedUniques);
|
||||
connect(ui->devicesComboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged), this,
|
||||
&AddEditAutoProfileDialog::checkDefaultCheckbox);
|
||||
connect(ui->applicationLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
|
||||
connect(ui->winClassLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
|
||||
connect(ui->winNameLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
|
||||
|
||||
connect(ui->detectWinPropsSelectWindowPushButton, &QPushButton::clicked, this, &AddEditAutoProfileDialog::showCaptureHelpWindow);
|
||||
connect(ui->detectWinPropsSelectWindowPushButton, &QPushButton::clicked, this,
|
||||
&AddEditAutoProfileDialog::showCaptureHelpWindow);
|
||||
|
||||
connect(this, &AddEditAutoProfileDialog::accepted, this, &AddEditAutoProfileDialog::saveAutoProfileInformation);
|
||||
|
||||
ui->asDefaultCheckBox->setChecked(info->isCurrentDefault());
|
||||
}
|
||||
|
||||
|
||||
// created for tests
|
||||
AddEditAutoProfileDialog::AddEditAutoProfileDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AddEditAutoProfileDialog)
|
||||
AddEditAutoProfileDialog::AddEditAutoProfileDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AddEditAutoProfileDialog)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
AddEditAutoProfileDialog::~AddEditAutoProfileDialog()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -140,18 +141,18 @@ AddEditAutoProfileDialog::~AddEditAutoProfileDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void AddEditAutoProfileDialog::openProfileBrowseDialog()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QString lookupDir = PadderCommon::preferredProfileDir(settings);
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Config"), lookupDir, QString("Config Files (*.amgp *.xml)"));
|
||||
QString filename =
|
||||
QFileDialog::getOpenFileName(this, tr("Open Config"), lookupDir, QString("Config Files (*.amgp *.xml)"));
|
||||
|
||||
if (!filename.isNull() && !filename.isEmpty()) ui->profileLineEdit->setText(QDir::toNativeSeparators(filename));
|
||||
if (!filename.isNull() && !filename.isEmpty())
|
||||
ui->profileLineEdit->setText(QDir::toNativeSeparators(filename));
|
||||
}
|
||||
|
||||
|
||||
void AddEditAutoProfileDialog::openApplicationBrowseDialog()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -162,19 +163,18 @@ void AddEditAutoProfileDialog::openApplicationBrowseDialog()
|
||||
{
|
||||
QFileInfo exe(filename);
|
||||
|
||||
if (exe.exists() && exe.isExecutable()) ui->applicationLineEdit->setText(filename);
|
||||
if (exe.exists() && exe.isExecutable())
|
||||
ui->applicationLineEdit->setText(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AutoProfileInfo* AddEditAutoProfileDialog::getAutoProfile() const
|
||||
AutoProfileInfo *AddEditAutoProfileDialog::getAutoProfile() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
void AddEditAutoProfileDialog::saveAutoProfileInformation()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -182,7 +182,6 @@ void AddEditAutoProfileDialog::saveAutoProfileInformation()
|
||||
info->setProfileLocation(ui->profileLineEdit->text());
|
||||
int deviceIndex = ui->devicesComboBox->currentIndex();
|
||||
|
||||
|
||||
if (deviceIndex > 0)
|
||||
{
|
||||
|
||||
@@ -190,12 +189,11 @@ void AddEditAutoProfileDialog::saveAutoProfileInformation()
|
||||
// not be changed.
|
||||
if (!ui->devicesComboBox->itemData(deviceIndex, Qt::UserRole).isNull())
|
||||
{
|
||||
InputDevice *device = ui->devicesComboBox->itemData(deviceIndex, Qt::UserRole).value<InputDevice*>();
|
||||
InputDevice *device = ui->devicesComboBox->itemData(deviceIndex, Qt::UserRole).value<InputDevice *>();
|
||||
info->setUniqueID(device->getUniqueIDString());
|
||||
info->setDeviceName(device->getSDLName());
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
info->setUniqueID("all");
|
||||
info->setDeviceName("");
|
||||
@@ -208,7 +206,6 @@ void AddEditAutoProfileDialog::saveAutoProfileInformation()
|
||||
info->setPartialState(ui->setPartialCheckBox->isChecked());
|
||||
}
|
||||
|
||||
|
||||
void AddEditAutoProfileDialog::checkForReservedUniques(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -220,21 +217,20 @@ void AddEditAutoProfileDialog::checkForReservedUniques(int index)
|
||||
ui->asDefaultCheckBox->setChecked(false);
|
||||
ui->asDefaultCheckBox->setEnabled(false);
|
||||
QMessageBox::warning(this, tr("Main Profile"), tr("Please use the main default profile selection."));
|
||||
}
|
||||
else if (!data.isNull() && getReservedUniques().contains(data.value<InputDevice*>()->getUniqueIDString()))
|
||||
} else if (!data.isNull() && getReservedUniques().contains(data.value<InputDevice *>()->getUniqueIDString()))
|
||||
{
|
||||
ui->asDefaultCheckBox->setChecked(false);
|
||||
ui->asDefaultCheckBox->setEnabled(false);
|
||||
QMessageBox::warning(this, tr("Already selected"), tr("A different profile is already selected as the default for this device."));
|
||||
}
|
||||
else
|
||||
QMessageBox::warning(this, tr("Already selected"),
|
||||
tr("A different profile is already selected as the default for this device."));
|
||||
} else
|
||||
{
|
||||
ui->asDefaultCheckBox->setEnabled(true);
|
||||
QMessageBox::information(this, tr("Chosen Profile"), tr("The selection will be used instead\nof the all default profile option."));
|
||||
QMessageBox::information(this, tr("Chosen Profile"),
|
||||
tr("The selection will be used instead\nof the all default profile option."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString AddEditAutoProfileDialog::getOriginalUniqueID() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -242,7 +238,6 @@ QString AddEditAutoProfileDialog::getOriginalUniqueID() const
|
||||
return originalUniqueID;
|
||||
}
|
||||
|
||||
|
||||
QString AddEditAutoProfileDialog::getOriginalExe() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -264,14 +259,13 @@ QString AddEditAutoProfileDialog::getOriginalWindowName() const
|
||||
return originalWindowName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Display a simple message box and attempt to capture a window using the mouse
|
||||
*/
|
||||
void AddEditAutoProfileDialog::showCaptureHelpWindow()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
|
||||
if (QApplication::platformName() == QStringLiteral("xcb"))
|
||||
{
|
||||
@@ -289,27 +283,27 @@ void AddEditAutoProfileDialog::showCaptureHelpWindow()
|
||||
connect(thread, &QThread::started, util, &UnixCaptureWindowUtility::attemptWindowCapture);
|
||||
connect(util, &UnixCaptureWindowUtility::captureFinished, thread, &QThread::quit);
|
||||
connect(util, &UnixCaptureWindowUtility::captureFinished, box, &QMessageBox::hide);
|
||||
connect(util, &UnixCaptureWindowUtility::captureFinished, this, [this, util]() {
|
||||
checkForGrabbedWindow(util);
|
||||
}, Qt::QueuedConnection);
|
||||
connect(
|
||||
util, &UnixCaptureWindowUtility::captureFinished, this, [this, util]() { checkForGrabbedWindow(util); },
|
||||
Qt::QueuedConnection);
|
||||
|
||||
connect(thread, &QThread::finished, box, &QMessageBox::deleteLater);
|
||||
connect(util, &UnixCaptureWindowUtility::destroyed, thread, &QThread::deleteLater);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if there is a program path saved in an UnixCaptureWindowUtility
|
||||
* object
|
||||
*/
|
||||
void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility* util)
|
||||
void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility *util)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
if (QApplication::platformName() == QStringLiteral("xcb"))
|
||||
{
|
||||
long targetWindow = util->getTargetWindow();
|
||||
@@ -323,7 +317,6 @@ void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility* u
|
||||
|
||||
qDebug() << "ORIGINAL: " << QString::number(targetWindow, 16);
|
||||
|
||||
|
||||
long tempWindow = X11Extras::getInstance()->findClientWindow(targetWindow);
|
||||
if (tempWindow > 0)
|
||||
{
|
||||
@@ -331,19 +324,15 @@ void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility* u
|
||||
}
|
||||
|
||||
qDebug() << "ADJUSTED: " << QString::number(targetWindow, 16);
|
||||
|
||||
}
|
||||
|
||||
if (targetWindow != None)
|
||||
{
|
||||
CapturedWindowInfoDialog *dialog = new CapturedWindowInfoDialog(targetWindow, this);
|
||||
connect(dialog, &CapturedWindowInfoDialog::accepted, [this, dialog]() {
|
||||
windowPropAssignment(dialog);
|
||||
});
|
||||
connect(dialog, &CapturedWindowInfoDialog::accepted, [this, dialog]() { windowPropAssignment(dialog); });
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
else if (!escaped)
|
||||
} else if (!escaped)
|
||||
{
|
||||
failed = true;
|
||||
}
|
||||
@@ -362,10 +351,9 @@ void AddEditAutoProfileDialog::checkForGrabbedWindow(UnixCaptureWindowUtility* u
|
||||
util->deleteLater();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void AddEditAutoProfileDialog::windowPropAssignment(CapturedWindowInfoDialog *dialog)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -374,16 +362,14 @@ void AddEditAutoProfileDialog::windowPropAssignment(CapturedWindowInfoDialog *di
|
||||
disconnect(ui->winClassLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
|
||||
disconnect(ui->winNameLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
if (dialog->useFullWindowPath() && dialog->getSelectedOptions() & CapturedWindowInfoDialog::WindowPath)
|
||||
{
|
||||
ui->applicationLineEdit->setText(dialog->getWindowPath());
|
||||
}
|
||||
else if (!dialog->useFullWindowPath() && dialog->getSelectedOptions() & CapturedWindowInfoDialog::WindowPath)
|
||||
} else if (!dialog->useFullWindowPath() && dialog->getSelectedOptions() & CapturedWindowInfoDialog::WindowPath)
|
||||
{
|
||||
ui->applicationLineEdit->setText(QFileInfo(dialog->getWindowPath()).fileName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
#endif
|
||||
ui->applicationLineEdit->clear();
|
||||
@@ -391,27 +377,25 @@ void AddEditAutoProfileDialog::windowPropAssignment(CapturedWindowInfoDialog *di
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
if (dialog->getSelectedOptions() & CapturedWindowInfoDialog::WindowClass)
|
||||
{
|
||||
ui->winClassLineEdit->setText(dialog->getWindowClass());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
#endif
|
||||
#endif
|
||||
ui->winClassLineEdit->clear();
|
||||
#ifdef WITH_X11
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
if (dialog->getSelectedOptions() & CapturedWindowInfoDialog::WindowName)
|
||||
{
|
||||
ui->winNameLineEdit->setText(dialog->getWindowName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
#endif
|
||||
#endif
|
||||
ui->winNameLineEdit->clear();
|
||||
#ifdef WITH_X11
|
||||
}
|
||||
@@ -424,7 +408,6 @@ void AddEditAutoProfileDialog::windowPropAssignment(CapturedWindowInfoDialog *di
|
||||
connect(ui->winNameLineEdit, &QLineEdit::textChanged, this, &AddEditAutoProfileDialog::checkForDefaultStatus);
|
||||
}
|
||||
|
||||
|
||||
void AddEditAutoProfileDialog::checkForDefaultStatus()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -437,8 +420,7 @@ void AddEditAutoProfileDialog::checkForDefaultStatus()
|
||||
{
|
||||
ui->asDefaultCheckBox->setChecked(false);
|
||||
ui->asDefaultCheckBox->setEnabled(false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->asDefaultCheckBox->setEnabled(true);
|
||||
}
|
||||
@@ -466,15 +448,12 @@ void AddEditAutoProfileDialog::accept()
|
||||
}
|
||||
}
|
||||
|
||||
if (validForm &&
|
||||
(ui->applicationLineEdit->text().isEmpty() &&
|
||||
ui->winClassLineEdit->text().isEmpty() &&
|
||||
if (validForm && (ui->applicationLineEdit->text().isEmpty() && ui->winClassLineEdit->text().isEmpty() &&
|
||||
ui->winNameLineEdit->text().isEmpty()))
|
||||
{
|
||||
validForm = false;
|
||||
errorString = tr("No window matching property was specified.");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
propertyFound = true;
|
||||
}
|
||||
@@ -500,8 +479,7 @@ void AddEditAutoProfileDialog::accept()
|
||||
if (validForm)
|
||||
{
|
||||
QDialog::accept();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(errorString);
|
||||
@@ -510,46 +488,31 @@ void AddEditAutoProfileDialog::accept()
|
||||
}
|
||||
}
|
||||
|
||||
QList<InputDevice *> *AddEditAutoProfileDialog::getDevices() const { return devices; }
|
||||
|
||||
QList<InputDevice*> *AddEditAutoProfileDialog::getDevices() const {
|
||||
AntiMicroSettings *AddEditAutoProfileDialog::getSettings() const { return settings; }
|
||||
|
||||
return devices;
|
||||
}
|
||||
bool AddEditAutoProfileDialog::getEditForm() const { return editForm; }
|
||||
|
||||
AntiMicroSettings *AddEditAutoProfileDialog::getSettings() const {
|
||||
bool AddEditAutoProfileDialog::getDefaultInfo() const { return defaultInfo; }
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
bool AddEditAutoProfileDialog::getEditForm() const {
|
||||
|
||||
return editForm;
|
||||
}
|
||||
|
||||
bool AddEditAutoProfileDialog::getDefaultInfo() const {
|
||||
|
||||
return defaultInfo;
|
||||
}
|
||||
|
||||
QList<QString> const& AddEditAutoProfileDialog::getReservedUniques() {
|
||||
|
||||
return reservedUniques;
|
||||
}
|
||||
QList<QString> const &AddEditAutoProfileDialog::getReservedUniques() { return reservedUniques; }
|
||||
|
||||
void AddEditAutoProfileDialog::on_setPartialCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
if (arg1 == 0) ui->winNameLineEdit->setEnabled(false);
|
||||
else ui->winNameLineEdit->setEnabled(true);
|
||||
if (arg1 == 0)
|
||||
ui->winNameLineEdit->setEnabled(false);
|
||||
else
|
||||
ui->winNameLineEdit->setEnabled(true);
|
||||
}
|
||||
|
||||
void AddEditAutoProfileDialog::checkDefaultCheckbox(const QString& text)
|
||||
void AddEditAutoProfileDialog::checkDefaultCheckbox(const QString &text)
|
||||
{
|
||||
if (text == "all")
|
||||
{
|
||||
ui->asDefaultCheckBox->setChecked(false);
|
||||
ui->asDefaultCheckBox->setDisabled(true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->asDefaultCheckBox->setDisabled(false);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ADDEDITAUTOPROFILEDIALOG_H
|
||||
#define ADDEDITAUTOPROFILEDIALOG_H
|
||||
|
||||
@@ -36,35 +35,33 @@ class AddEditAutoProfileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings, QList<InputDevice*> *devices,
|
||||
QList<QString> &reservedUniques,
|
||||
bool edit=false, QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit AddEditAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings, QList<InputDevice *> *devices,
|
||||
QList<QString> &reservedUniques, bool edit = false, QWidget *parent = nullptr);
|
||||
|
||||
AddEditAutoProfileDialog(QWidget *parent = nullptr);
|
||||
|
||||
~AddEditAutoProfileDialog();
|
||||
|
||||
AutoProfileInfo* getAutoProfile() const;
|
||||
AutoProfileInfo *getAutoProfile() const;
|
||||
QString getOriginalUniqueID() const;
|
||||
QString getOriginalExe() const;
|
||||
QString getOriginalWindowClass() const;
|
||||
QString getOriginalWindowName() const;
|
||||
|
||||
QList<InputDevice*> *getDevices() const;
|
||||
QList<InputDevice *> *getDevices() const;
|
||||
AntiMicroSettings *getSettings() const;
|
||||
bool getEditForm() const;
|
||||
bool getDefaultInfo() const;
|
||||
QList<QString> const& getReservedUniques();
|
||||
QList<QString> const &getReservedUniques();
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void accept();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void captureFinished();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void openProfileBrowseDialog();
|
||||
void openApplicationBrowseDialog();
|
||||
void saveAutoProfileInformation();
|
||||
@@ -72,15 +69,15 @@ private slots:
|
||||
void checkForDefaultStatus();
|
||||
void windowPropAssignment(CapturedWindowInfoDialog *dialog);
|
||||
void showCaptureHelpWindow();
|
||||
void checkForGrabbedWindow(UnixCaptureWindowUtility* util);
|
||||
void checkForGrabbedWindow(UnixCaptureWindowUtility *util);
|
||||
void on_setPartialCheckBox_stateChanged(int arg1);
|
||||
void checkDefaultCheckbox(const QString& text);
|
||||
void checkDefaultCheckbox(const QString &text);
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::AddEditAutoProfileDialog *ui;
|
||||
|
||||
AutoProfileInfo *info;
|
||||
QList<InputDevice*> *devices;
|
||||
QList<InputDevice *> *devices;
|
||||
AntiMicroSettings *settings;
|
||||
bool editForm;
|
||||
bool defaultInfo;
|
||||
@@ -89,7 +86,6 @@ private:
|
||||
QString originalExe;
|
||||
QString originalWindowClass;
|
||||
QString originalWindowName;
|
||||
|
||||
};
|
||||
|
||||
#endif // ADDEDITAUTOPROFILEDIALOG_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,11 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ADVANCEBUTTONDIALOG_H
|
||||
#define ADVANCEBUTTONDIALOG_H
|
||||
|
||||
|
||||
#include "uihelpers/advancebuttondialoghelper.h"
|
||||
|
||||
#include <QDialog>
|
||||
@@ -38,16 +36,16 @@ class AdvanceButtonDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AdvanceButtonDialog(JoyButton *button, QWidget *parent=0);
|
||||
AdvanceButtonDialog(QWidget *parent=0);
|
||||
public:
|
||||
explicit AdvanceButtonDialog(JoyButton *button, QWidget *parent = 0);
|
||||
AdvanceButtonDialog(QWidget *parent = 0);
|
||||
~AdvanceButtonDialog();
|
||||
|
||||
int getOldRow() const;
|
||||
JoyButton *getButton() const;
|
||||
AdvanceButtonDialogHelper const& getHelper();
|
||||
AdvanceButtonDialogHelper const &getHelper();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void connectButtonEvents(SimpleKeyGrabberButton *button); // AdvanceBtnDlgAssign class
|
||||
void appendBlankKeyGrabber(); // AdvanceBtnDlgAssign class
|
||||
int actionTimeConvert(); // AdvanceBtnDlgAssign class
|
||||
@@ -62,21 +60,21 @@ protected:
|
||||
void populateSetSelectionComboBox();
|
||||
void populateSlotSetSelectionComboBox();
|
||||
void findTurboModeComboIndex();
|
||||
void showSelectProfileWind(QListWidgetItem* item, QString& firstChoiceProfile);
|
||||
void showSelectProfileWind(QListWidgetItem *item, QString &firstChoiceProfile);
|
||||
bool anySelectedNotKeybSlot();
|
||||
bool selectedNotMixSlot();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void toggleChanged(bool state);
|
||||
void turboChanged(bool state);
|
||||
void slotsChanged(); // AdvanceBtnDlgAssign class
|
||||
void turboButtonEnabledChange(bool state);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void placeNewSlot(JoyButtonSlot *slot); // AdvanceBtnDlgAssign class
|
||||
void clearAllSlots(); // AdvanceBtnDlgAssign class
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void changeTurboText(int value);
|
||||
void updateTurboIntervalValue(int value);
|
||||
void checkTurboSetting(bool state);
|
||||
@@ -87,9 +85,9 @@ private slots:
|
||||
void joinSlot(); // AdvanceBtnDlgAssign class
|
||||
void splitSlot(); // AdvanceBtnDlgAssign class
|
||||
|
||||
void insertCycleSlot(QListWidgetItem* item); // AdvanceBtnDlgAssign class
|
||||
void insertTextEntrySlot(QListWidgetItem* item); // AdvanceBtnDlgAssign class
|
||||
void insertExecuteSlot(QListWidgetItem* item, QStringList& prevExecAndArgs); // AdvanceBtnDlgAssign class
|
||||
void insertCycleSlot(QListWidgetItem *item); // AdvanceBtnDlgAssign class
|
||||
void insertTextEntrySlot(QListWidgetItem *item); // AdvanceBtnDlgAssign class
|
||||
void insertExecuteSlot(QListWidgetItem *item, QStringList &prevExecAndArgs); // AdvanceBtnDlgAssign class
|
||||
|
||||
void updateActionTimeLabel();
|
||||
void updateSetSelection();
|
||||
@@ -111,16 +109,26 @@ private slots:
|
||||
void changeSlotTypeDisplay(int index); // AdvanceBtnDlgAssign class
|
||||
void changeSlotHelpText(int index); // AdvanceBtnDlgAssign class
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
Ui::AdvanceButtonDialog *ui;
|
||||
|
||||
AdvanceButtonDialogHelper& getHelperLocal();
|
||||
AdvanceButtonDialogHelper &getHelperLocal();
|
||||
|
||||
enum SlotTypeComboIndex {
|
||||
KBMouseSlot = 0, CycleSlot, DelaySlot, DistanceSlot, ExecuteSlot,
|
||||
HoldSlot, LoadSlot, MouseModSlot, PauseSlot, PressTimeSlot,
|
||||
ReleaseSlot, SetChangeSlot, TextEntry
|
||||
enum SlotTypeComboIndex
|
||||
{
|
||||
KBMouseSlot = 0,
|
||||
CycleSlot,
|
||||
DelaySlot,
|
||||
DistanceSlot,
|
||||
ExecuteSlot,
|
||||
HoldSlot,
|
||||
LoadSlot,
|
||||
MouseModSlot,
|
||||
PauseSlot,
|
||||
PressTimeSlot,
|
||||
ReleaseSlot,
|
||||
SetChangeSlot,
|
||||
TextEntry
|
||||
};
|
||||
|
||||
int oldRow;
|
||||
@@ -128,8 +136,8 @@ private:
|
||||
AdvanceButtonDialogHelper helper;
|
||||
QReadWriteLock joinLock;
|
||||
|
||||
void insertKindOfSlot(QListWidgetItem* item, int slotProperty, JoyButtonSlot::JoySlotInputAction inputAction); // AdvanceBtnDlgAssign class
|
||||
|
||||
void insertKindOfSlot(QListWidgetItem *item, int slotProperty,
|
||||
JoyButtonSlot::JoySlotInputAction inputAction); // AdvanceBtnDlgAssign class
|
||||
};
|
||||
|
||||
#endif // ADVANCEBUTTONDIALOG_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ADVANCESTICKASSIGNMENTDIALOG_H
|
||||
#define ADVANCESTICKASSIGNMENTDIALOG_H
|
||||
|
||||
@@ -37,24 +36,23 @@ class AdvanceStickAssignmentDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit AdvanceStickAssignmentDialog(Joystick *joystick, QWidget *parent = nullptr);
|
||||
AdvanceStickAssignmentDialog(QWidget *parent = nullptr);
|
||||
~AdvanceStickAssignmentDialog();
|
||||
|
||||
Joystick *getJoystick() const;
|
||||
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void stickConfigurationChanged();
|
||||
void vdpadConfigurationChanged();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void refreshStickConfiguration(JoyControlStick *stick1, JoyControlStick *stick2);
|
||||
void refreshVDPadsConfiguration();
|
||||
|
||||
void checkForAxisAssignmentStickOne(QWidget* comboBox);
|
||||
void checkForAxisAssignmentStickTwo(QWidget* comboBox);
|
||||
void checkForAxisAssignmentStickOne(QWidget *comboBox);
|
||||
void checkForAxisAssignmentStickTwo(QWidget *comboBox);
|
||||
|
||||
void changeStateStickOneWidgets(bool enabled);
|
||||
void changeStateStickTwoWidgets(bool enabled);
|
||||
@@ -78,25 +76,27 @@ private slots:
|
||||
void openAssignVDPadLeft();
|
||||
void openAssignVDPadRight();
|
||||
|
||||
void quickAssignVDPadUp(JoyAxisButton* joyaxisbtn);
|
||||
void quickAssignVDPadUpBtn(JoyButton* joybtn);
|
||||
void quickAssignVDPadDown(JoyAxisButton* axbtn);
|
||||
void quickAssignVDPadDownJbtn(JoyButton* axbtn);
|
||||
void quickAssignVDPadLeft(JoyAxisButton* joyaxisbtn);
|
||||
void quickAssignVDPadLeftJbtn(JoyButton* joybtn);
|
||||
void quickAssignVDPadRight(JoyAxisButton* joyaxisbtn);
|
||||
void quickAssignVDPadRightJbtn(JoyButton* joybtn);
|
||||
void quickAssignVDPadUp(JoyAxisButton *joyaxisbtn);
|
||||
void quickAssignVDPadUpBtn(JoyButton *joybtn);
|
||||
void quickAssignVDPadDown(JoyAxisButton *axbtn);
|
||||
void quickAssignVDPadDownJbtn(JoyButton *axbtn);
|
||||
void quickAssignVDPadLeft(JoyAxisButton *joyaxisbtn);
|
||||
void quickAssignVDPadLeftJbtn(JoyButton *joybtn);
|
||||
void quickAssignVDPadRight(JoyAxisButton *joyaxisbtn);
|
||||
void quickAssignVDPadRightJbtn(JoyButton *joybtn);
|
||||
|
||||
void reenableButtonEvents();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::AdvanceStickAssignmentDialog *ui;
|
||||
|
||||
Joystick *joystick;
|
||||
|
||||
void checkForAxisAssignmentSticks(QWidget* comboBox, QComboBox* xAxisComboBox, QComboBox* yAxisComboBox, int controlStickNumber);
|
||||
void refreshSticksForAxes(bool axesExist, int xAxisComboBoxIndex, int yAxisComboBoxIndex, QComboBox* xAxisComboBox, QComboBox* yAxisComboBox, QCheckBox* enabledSticksCheckbox, QPushButton* quickAssignBtn);
|
||||
void refreshVDPadConf(JoyButton *vdpadButton, QComboBox* vpadComboBox);
|
||||
void checkForAxisAssignmentSticks(QWidget *comboBox, QComboBox *xAxisComboBox, QComboBox *yAxisComboBox,
|
||||
int controlStickNumber);
|
||||
void refreshSticksForAxes(bool axesExist, int xAxisComboBoxIndex, int yAxisComboBoxIndex, QComboBox *xAxisComboBox,
|
||||
QComboBox *yAxisComboBox, QCheckBox *enabledSticksCheckbox, QPushButton *quickAssignBtn);
|
||||
void refreshVDPadConf(JoyButton *vdpadButton, QComboBox *vpadComboBox);
|
||||
};
|
||||
|
||||
#endif // ADVANCESTICKASSIGNMENTDIALOG_H
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
AntiMicroSettings::AntiMicroSettings(const QString &fileName, Format format, QObject *parent) :
|
||||
QSettings(fileName, format, parent)
|
||||
AntiMicroSettings::AntiMicroSettings(const QString &fileName, Format format, QObject *parent)
|
||||
: QSettings(fileName, format, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
@@ -44,8 +43,10 @@ QVariant AntiMicroSettings::runtimeValue(const QString &key, const QVariant &def
|
||||
QString inGroup = group();
|
||||
QString fullKey = QString(inGroup).append("/").append(key);
|
||||
|
||||
if (cmdSettings.contains(fullKey)) settingValue = cmdSettings.value(fullKey, defaultValue);
|
||||
else settingValue = value(key, defaultValue);
|
||||
if (cmdSettings.contains(fullKey))
|
||||
settingValue = cmdSettings.value(fullKey, defaultValue);
|
||||
else
|
||||
settingValue = value(key, defaultValue);
|
||||
|
||||
return settingValue;
|
||||
}
|
||||
@@ -73,14 +74,15 @@ void AntiMicroSettings::importFromCommandLine(CommandLineUtility &cmdutility)
|
||||
}
|
||||
}
|
||||
|
||||
QMutex* AntiMicroSettings::getLock()
|
||||
QMutex *AntiMicroSettings::getLock()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return &lock;
|
||||
}
|
||||
|
||||
QSettings& AntiMicroSettings::getCmdSettings() {
|
||||
QSettings &AntiMicroSettings::getCmdSettings()
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
@@ -16,32 +16,28 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ANTIMICROSETTINGS_H
|
||||
#define ANTIMICROSETTINGS_H
|
||||
|
||||
|
||||
#include "commandlineutility.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
class AntiMicroSettings : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit AntiMicroSettings(const QString &fileName, Format format, QObject *parent = nullptr);
|
||||
|
||||
QVariant runtimeValue(const QString &key, const QVariant &defaultValue = QVariant()) const;
|
||||
void importFromCommandLine(CommandLineUtility &cmdutility);
|
||||
QMutex* getLock();
|
||||
QSettings& getCmdSettings();
|
||||
QMutex *getLock();
|
||||
QSettings &getCmdSettings();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
QSettings cmdSettings;
|
||||
QMutex lock;
|
||||
|
||||
};
|
||||
|
||||
#endif // ANTIMICROSETTINGS_H
|
||||
|
||||
@@ -18,15 +18,14 @@
|
||||
|
||||
#include "antkeymapper.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "eventhandlerfactory.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtGlobal>
|
||||
#include <QStringList>
|
||||
#include <QtGlobal>
|
||||
|
||||
|
||||
AntKeyMapper* AntKeyMapper::_instance = nullptr;
|
||||
AntKeyMapper *AntKeyMapper::_instance = nullptr;
|
||||
|
||||
static QStringList buildEventGeneratorList()
|
||||
{
|
||||
@@ -34,18 +33,18 @@ static QStringList buildEventGeneratorList()
|
||||
|
||||
QStringList temp = QStringList();
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
#ifdef WITH_XTEST
|
||||
temp.append("xtest");
|
||||
#endif
|
||||
#ifdef WITH_UINPUT
|
||||
#endif
|
||||
#ifdef WITH_UINPUT
|
||||
temp.append("uinput");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
AntKeyMapper::AntKeyMapper(QString handler, QObject *parent) :
|
||||
QObject(parent)
|
||||
AntKeyMapper::AntKeyMapper(QString handler, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -64,18 +63,18 @@ AntKeyMapper::AntKeyMapper(QString handler, QObject *parent) :
|
||||
if (handler == "uinput")
|
||||
{
|
||||
internalMapper = &uinputMapper;
|
||||
#ifdef WITH_XTEST
|
||||
#ifdef WITH_XTEST
|
||||
nativeKeyMapper = &x11Mapper;
|
||||
#else
|
||||
#else
|
||||
nativeKeyMapper = nullptr;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
AntKeyMapper* AntKeyMapper::getInstance(QString handler)
|
||||
AntKeyMapper *AntKeyMapper::getInstance(QString handler)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -122,14 +121,14 @@ bool AntKeyMapper::isModifierKey(int qkey)
|
||||
return internalMapper->isModifier(qkey);
|
||||
}
|
||||
|
||||
QtKeyMapperBase* AntKeyMapper::getNativeKeyMapper() const
|
||||
QtKeyMapperBase *AntKeyMapper::getNativeKeyMapper() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return nativeKeyMapper;
|
||||
}
|
||||
|
||||
QtKeyMapperBase* AntKeyMapper::getKeyMapper() const
|
||||
QtKeyMapperBase *AntKeyMapper::getKeyMapper() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
@@ -16,53 +16,50 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ANTKEYMAPPER_H
|
||||
#define ANTKEYMAPPER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#if defined(WITH_XTEST)
|
||||
#if defined(WITH_XTEST)
|
||||
#include "qtx11keymapper.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WITH_UINPUT)
|
||||
#if defined(WITH_UINPUT)
|
||||
#include "qtuinputkeymapper.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
class AntKeyMapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static AntKeyMapper* getInstance(QString handler = "");
|
||||
public:
|
||||
static AntKeyMapper *getInstance(QString handler = "");
|
||||
void deleteInstance();
|
||||
|
||||
int returnVirtualKey(int qkey);
|
||||
int returnQtKey(int key, int scancode=0);
|
||||
int returnQtKey(int key, int scancode = 0);
|
||||
bool isModifierKey(int qkey);
|
||||
QtKeyMapperBase* getNativeKeyMapper() const;
|
||||
QtKeyMapperBase* getKeyMapper() const;
|
||||
QtKeyMapperBase *getNativeKeyMapper() const;
|
||||
QtKeyMapperBase *getKeyMapper() const;
|
||||
bool hasNativeKeyMapper();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
static AntKeyMapper *_instance;
|
||||
|
||||
private:
|
||||
private:
|
||||
explicit AntKeyMapper(QString handler = "", QObject *parent = nullptr);
|
||||
|
||||
QtKeyMapperBase *internalMapper;
|
||||
QtKeyMapperBase *nativeKeyMapper;
|
||||
|
||||
#if defined(WITH_XTEST)
|
||||
#if defined(WITH_XTEST)
|
||||
QtX11KeyMapper x11Mapper;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WITH_UINPUT)
|
||||
#if defined(WITH_UINPUT)
|
||||
QtUInputKeyMapper uinputMapper;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // ANTKEYMAPPER_H
|
||||
|
||||
@@ -18,22 +18,20 @@
|
||||
|
||||
#include "applaunchhelper.h"
|
||||
|
||||
#include "antimicrosettings.h"
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joybutton.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QMapIterator>
|
||||
#include <QDesktopWidget>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QMapIterator>
|
||||
#include <QTextStream>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
AppLaunchHelper::AppLaunchHelper(AntiMicroSettings *settings, bool graphical,
|
||||
QObject *parent) :
|
||||
QObject(parent)
|
||||
AppLaunchHelper::AppLaunchHelper(AntiMicroSettings *settings, bool graphical, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -67,14 +65,18 @@ void AppLaunchHelper::enablePossibleMouseSmoothing()
|
||||
|
||||
if (historySize > 0)
|
||||
{
|
||||
JoyButton::setMouseHistorySize(historySize, GlobalVariables::JoyButton::MAXIMUMMOUSEHISTORYSIZE, GlobalVariables::JoyButton::mouseHistorySize, &GlobalVariables::JoyButton::mouseHistoryX, &GlobalVariables::JoyButton::mouseHistoryY);
|
||||
JoyButton::setMouseHistorySize(historySize, GlobalVariables::JoyButton::MAXIMUMMOUSEHISTORYSIZE,
|
||||
GlobalVariables::JoyButton::mouseHistorySize,
|
||||
&GlobalVariables::JoyButton::mouseHistoryX,
|
||||
&GlobalVariables::JoyButton::mouseHistoryY);
|
||||
}
|
||||
|
||||
double weightModifier = settings->value("Mouse/WeightModifier", 0.0).toDouble();
|
||||
|
||||
if (weightModifier > 0.0)
|
||||
{
|
||||
JoyButton::setWeightModifier(weightModifier, GlobalVariables::JoyButton::MAXIMUMWEIGHTMODIFIER, GlobalVariables::JoyButton::weightModifier);
|
||||
JoyButton::setWeightModifier(weightModifier, GlobalVariables::JoyButton::MAXIMUMWEIGHTMODIFIER,
|
||||
GlobalVariables::JoyButton::weightModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,7 +89,11 @@ void AppLaunchHelper::changeMouseRefreshRate()
|
||||
|
||||
if (refreshRate > 0)
|
||||
{
|
||||
JoyButton::setMouseRefreshRate(refreshRate, GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getMouseHelper(), &GlobalVariables::JoyButton::mouseHistoryX, &GlobalVariables::JoyButton::mouseHistoryY, JoyButton::getTestOldMouseTime(), JoyButton::getStaticMouseEventTimer());
|
||||
JoyButton::setMouseRefreshRate(refreshRate, GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getMouseHelper(),
|
||||
&GlobalVariables::JoyButton::mouseHistoryX,
|
||||
&GlobalVariables::JoyButton::mouseHistoryY, JoyButton::getTestOldMouseTime(),
|
||||
JoyButton::getStaticMouseEventTimer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,11 +101,11 @@ void AppLaunchHelper::changeGamepadPollRate()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
int pollRate = settings->value("GamepadPollRate",
|
||||
GlobalVariables::AntimicroSettings::defaultSDLGamepadPollRate).toInt();
|
||||
int pollRate = settings->value("GamepadPollRate", GlobalVariables::AntimicroSettings::defaultSDLGamepadPollRate).toInt();
|
||||
if (pollRate > 0)
|
||||
{
|
||||
JoyButton::setGamepadRefreshRate(pollRate, GlobalVariables::JoyButton::gamepadRefreshRate, JoyButton::getMouseHelper());
|
||||
JoyButton::setGamepadRefreshRate(pollRate, GlobalVariables::JoyButton::gamepadRefreshRate,
|
||||
JoyButton::getMouseHelper());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +119,7 @@ void AppLaunchHelper::printControllerList(QMap<SDL_JoystickID, InputDevice *> *j
|
||||
outstream << endl;
|
||||
outstream << QObject::tr("List Joysticks:") << endl;
|
||||
outstream << QObject::tr("---------------") << endl;
|
||||
QMapIterator<SDL_JoystickID, InputDevice*> iter(*joysticks);
|
||||
QMapIterator<SDL_JoystickID, InputDevice *> iter(*joysticks);
|
||||
int indexNumber = 1;
|
||||
|
||||
while (iter.hasNext())
|
||||
@@ -121,15 +127,14 @@ void AppLaunchHelper::printControllerList(QMap<SDL_JoystickID, InputDevice *> *j
|
||||
InputDevice *tempdevice = iter.next().value();
|
||||
outstream << QObject::tr("Joystick %1:").arg(indexNumber) << endl;
|
||||
outstream << " " << QObject::tr("Index: %1").arg(tempdevice->getRealJoyNumber()) << endl;
|
||||
//outstream << " " << QObject::tr("GUID: %1").arg(tempdevice->getGUIDString()) << endl;
|
||||
// outstream << " " << QObject::tr("GUID: %1").arg(tempdevice->getGUIDString()) << endl;
|
||||
outstream << " " << QObject::tr("UniqueID: %1").arg(tempdevice->getUniqueIDString()) << endl;
|
||||
outstream << " " << QObject::tr("GUID: %1").arg(tempdevice->getGUIDString()) << endl;
|
||||
outstream << " " << QObject::tr("VendorID: %1").arg(tempdevice->getVendorString()) << endl;
|
||||
outstream << " " << QObject::tr("ProductID: %1").arg(tempdevice->getProductIDString()) << endl;
|
||||
outstream << " " << QObject::tr("Product Version: %1").arg(tempdevice->getProductVersion()) << endl;
|
||||
outstream << " " << QObject::tr("Name: %1").arg(tempdevice->getSDLName()) << endl;
|
||||
QString gameControllerStatus = tempdevice->isGameController() ?
|
||||
QObject::tr("Yes") : QObject::tr("No");
|
||||
QString gameControllerStatus = tempdevice->isGameController() ? QObject::tr("Yes") : QObject::tr("No");
|
||||
outstream << " " << QObject::tr("Game Controller: %1").arg(gameControllerStatus) << endl;
|
||||
|
||||
outstream << " " << QObject::tr("# of Axes: %1").arg(tempdevice->getNumberRawAxes()) << endl;
|
||||
@@ -149,33 +154,33 @@ void AppLaunchHelper::changeSpringModeScreen()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QDesktopWidget deskWid;
|
||||
int springScreen = settings->value("Mouse/SpringScreen",
|
||||
GlobalVariables::AntimicroSettings::defaultSpringScreen).toInt();
|
||||
int springScreen =
|
||||
settings->value("Mouse/SpringScreen", GlobalVariables::AntimicroSettings::defaultSpringScreen).toInt();
|
||||
|
||||
if (springScreen >= deskWid.screenCount())
|
||||
{
|
||||
springScreen = -1;
|
||||
settings->setValue("Mouse/SpringScreen",
|
||||
GlobalVariables::AntimicroSettings::defaultSpringScreen);
|
||||
settings->setValue("Mouse/SpringScreen", GlobalVariables::AntimicroSettings::defaultSpringScreen);
|
||||
settings->sync();
|
||||
}
|
||||
|
||||
JoyButton::setSpringModeScreen(springScreen, GlobalVariables::JoyButton::springModeScreen);
|
||||
}
|
||||
|
||||
|
||||
void AppLaunchHelper::revertMouseThread()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyButton::indirectStaticMouseThread(QThread::currentThread(), JoyButton::getStaticMouseEventTimer(), JoyButton::getMouseHelper());
|
||||
JoyButton::indirectStaticMouseThread(QThread::currentThread(), JoyButton::getStaticMouseEventTimer(),
|
||||
JoyButton::getMouseHelper());
|
||||
}
|
||||
|
||||
void AppLaunchHelper::changeMouseThread(QThread *thread)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyButton::setStaticMouseThread(thread, JoyButton::getStaticMouseEventTimer(), JoyButton::getTestOldMouseTime(), GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getMouseHelper());
|
||||
JoyButton::setStaticMouseThread(thread, JoyButton::getStaticMouseEventTimer(), JoyButton::getTestOldMouseTime(),
|
||||
GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getMouseHelper());
|
||||
}
|
||||
|
||||
void AppLaunchHelper::establishMouseTimerConnections()
|
||||
@@ -185,7 +190,4 @@ void AppLaunchHelper::establishMouseTimerConnections()
|
||||
JoyButton::establishMouseTimerConnections();
|
||||
}
|
||||
|
||||
AntiMicroSettings *AppLaunchHelper::getSettings() const {
|
||||
|
||||
return settings;
|
||||
}
|
||||
AntiMicroSettings *AppLaunchHelper::getSettings() const { return settings; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef APPLAUNCHHELPER_H
|
||||
#define APPLAUNCHHELPER_H
|
||||
|
||||
@@ -32,31 +31,28 @@ class AppLaunchHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AppLaunchHelper(AntiMicroSettings *settings, bool graphical=false,
|
||||
QObject *parent=0);
|
||||
public:
|
||||
explicit AppLaunchHelper(AntiMicroSettings *settings, bool graphical = false, QObject *parent = 0);
|
||||
|
||||
void printControllerList(QMap<SDL_JoystickID, InputDevice *> *joysticks);
|
||||
|
||||
AntiMicroSettings *getSettings() const;
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void enablePossibleMouseSmoothing();
|
||||
void establishMouseTimerConnections();
|
||||
void changeMouseRefreshRate();
|
||||
void changeSpringModeScreen();
|
||||
void changeGamepadPollRate();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void initRunMethods();
|
||||
void revertMouseThread();
|
||||
void changeMouseThread(QThread *thread);
|
||||
|
||||
private:
|
||||
private:
|
||||
AntiMicroSettings *settings;
|
||||
bool graphical;
|
||||
|
||||
};
|
||||
|
||||
#endif // APPLAUNCHHELPER_H
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
|
||||
|
||||
AutoProfileInfo::AutoProfileInfo(QString uniqueID, QString profileLocation,
|
||||
QString exe, bool active, bool partialTitle, QObject *parent) :
|
||||
QObject(parent)
|
||||
AutoProfileInfo::AutoProfileInfo(QString uniqueID, QString profileLocation, QString exe, bool active, bool partialTitle,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -38,9 +37,8 @@ AutoProfileInfo::AutoProfileInfo(QString uniqueID, QString profileLocation,
|
||||
setPartialState(partialTitle);
|
||||
}
|
||||
|
||||
AutoProfileInfo::AutoProfileInfo(QString uniqueID, QString profileLocation,
|
||||
bool active, bool partialTitle, QObject *parent) :
|
||||
QObject(parent)
|
||||
AutoProfileInfo::AutoProfileInfo(QString uniqueID, QString profileLocation, bool active, bool partialTitle, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -51,8 +49,8 @@ AutoProfileInfo::AutoProfileInfo(QString uniqueID, QString profileLocation,
|
||||
setPartialState(partialTitle);
|
||||
}
|
||||
|
||||
AutoProfileInfo::AutoProfileInfo(QObject *parent) :
|
||||
QObject(parent)
|
||||
AutoProfileInfo::AutoProfileInfo(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -61,11 +59,7 @@ AutoProfileInfo::AutoProfileInfo(QObject *parent) :
|
||||
setPartialState(false);
|
||||
}
|
||||
|
||||
AutoProfileInfo::~AutoProfileInfo()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
AutoProfileInfo::~AutoProfileInfo() { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
void AutoProfileInfo::setUniqueID(QString uniqueID)
|
||||
{
|
||||
@@ -74,7 +68,6 @@ void AutoProfileInfo::setUniqueID(QString uniqueID)
|
||||
this->uniqueID = uniqueID;
|
||||
}
|
||||
|
||||
|
||||
QString AutoProfileInfo::getUniqueID() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -82,19 +75,16 @@ QString AutoProfileInfo::getUniqueID() const
|
||||
return uniqueID;
|
||||
}
|
||||
|
||||
|
||||
void AutoProfileInfo::setProfileLocation(QString profileLocation)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QFileInfo info(profileLocation);
|
||||
|
||||
if ((profileLocation != this->profileLocation) &&
|
||||
info.exists() && info.isReadable())
|
||||
if ((profileLocation != this->profileLocation) && info.exists() && info.isReadable())
|
||||
{
|
||||
this->profileLocation = profileLocation;
|
||||
}
|
||||
else if (profileLocation.isEmpty())
|
||||
} else if (profileLocation.isEmpty())
|
||||
{
|
||||
this->profileLocation = "";
|
||||
}
|
||||
@@ -119,8 +109,7 @@ void AutoProfileInfo::setExe(QString exe)
|
||||
{
|
||||
this->exe = exe;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
this->exe = exe;
|
||||
}
|
||||
@@ -200,8 +189,10 @@ QString AutoProfileInfo::getDeviceName() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (deviceName.isNull()) return "";
|
||||
else return deviceName;
|
||||
if (deviceName.isNull())
|
||||
return "";
|
||||
else
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
void AutoProfileInfo::setPartialState(bool value)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AUTOPROFILEINFO_H
|
||||
#define AUTOPROFILEINFO_H
|
||||
|
||||
@@ -27,12 +26,12 @@ class AutoProfileInfo : public QObject
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutoProfileInfo(QString uniqueID, QString profileLocation,
|
||||
bool active, bool partialTitle, QObject *parent = nullptr);
|
||||
explicit AutoProfileInfo(QString uniqueID, QString profileLocation,
|
||||
QString exe, bool active, bool partialTitle, QObject *parent = nullptr);
|
||||
explicit AutoProfileInfo(QObject *parent=0);
|
||||
public:
|
||||
explicit AutoProfileInfo(QString uniqueID, QString profileLocation, bool active, bool partialTitle,
|
||||
QObject *parent = nullptr);
|
||||
explicit AutoProfileInfo(QString uniqueID, QString profileLocation, QString exe, bool active, bool partialTitle,
|
||||
QObject *parent = nullptr);
|
||||
explicit AutoProfileInfo(QObject *parent = 0);
|
||||
~AutoProfileInfo();
|
||||
|
||||
// void setGUID(QString guid);
|
||||
@@ -65,7 +64,7 @@ public:
|
||||
void setPartialState(bool value);
|
||||
bool isPartialState();
|
||||
|
||||
private:
|
||||
private:
|
||||
QString guid;
|
||||
QString uniqueID;
|
||||
QString profileLocation;
|
||||
@@ -76,9 +75,8 @@ private:
|
||||
bool active;
|
||||
bool defaultState;
|
||||
bool partialState;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AutoProfileInfo*)
|
||||
Q_DECLARE_METATYPE(AutoProfileInfo *)
|
||||
|
||||
#endif // AUTOPROFILEINFO_H
|
||||
|
||||
@@ -18,30 +18,28 @@
|
||||
|
||||
#include "autoprofilewatcher.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "autoprofileinfo.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "autoprofileinfo.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QListIterator>
|
||||
#include <QStringListIterator>
|
||||
#include <QSetIterator>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
#include <QListIterator>
|
||||
#include <QSetIterator>
|
||||
#include <QStringListIterator>
|
||||
|
||||
#if defined(WITH_X11)
|
||||
#include "x11extras.h"
|
||||
#endif
|
||||
|
||||
|
||||
AutoProfileWatcher* AutoProfileWatcher::_instance = nullptr;
|
||||
AutoProfileWatcher *AutoProfileWatcher::_instance = nullptr;
|
||||
QTimer AutoProfileWatcher::checkWindowTimer;
|
||||
|
||||
|
||||
AutoProfileWatcher::AutoProfileWatcher(AntiMicroSettings *settings, QObject *parent) :
|
||||
QObject(parent)
|
||||
AutoProfileWatcher::AutoProfileWatcher(AntiMicroSettings *settings, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -57,7 +55,8 @@ AutoProfileWatcher::AutoProfileWatcher(AntiMicroSettings *settings, QObject *par
|
||||
|
||||
AutoProfileWatcher::~AutoProfileWatcher()
|
||||
{
|
||||
if (checkWindowTimer.isActive()) {
|
||||
if (checkWindowTimer.isActive())
|
||||
{
|
||||
|
||||
checkWindowTimer.stop();
|
||||
disconnect(&(checkWindowTimer), &QTimer::timeout, _instance, nullptr);
|
||||
@@ -66,10 +65,7 @@ AutoProfileWatcher::~AutoProfileWatcher()
|
||||
_instance = nullptr;
|
||||
}
|
||||
|
||||
AutoProfileWatcher* AutoProfileWatcher::getAutoProfileWatcherInstance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
AutoProfileWatcher *AutoProfileWatcher::getAutoProfileWatcherInstance() { return _instance; }
|
||||
|
||||
void AutoProfileWatcher::disconnectWindowTimer()
|
||||
{
|
||||
@@ -91,15 +87,12 @@ void AutoProfileWatcher::stopTimer()
|
||||
checkWindowTimer.stop();
|
||||
}
|
||||
|
||||
|
||||
void AutoProfileWatcher::runAppCheck()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
qDebug() << qApp->applicationFilePath();
|
||||
|
||||
|
||||
QString appLocation = QString();
|
||||
QString baseAppFileName = QString();
|
||||
getUniqeIDSetLocal().clear();
|
||||
@@ -115,7 +108,8 @@ void AutoProfileWatcher::runAppCheck()
|
||||
// More portable check for whether antimicrox is the current application
|
||||
// with focus.
|
||||
QWidget *focusedWidget = qApp->activeWindow();
|
||||
if (focusedWidget != nullptr) qDebug() << "get active window of app" << endl;
|
||||
if (focusedWidget != nullptr)
|
||||
qDebug() << "get active window of app" << endl;
|
||||
QString nowWindow = QString();
|
||||
QString nowWindowClass = QString();
|
||||
QString nowWindowName = QString();
|
||||
@@ -128,7 +122,8 @@ void AutoProfileWatcher::runAppCheck()
|
||||
long tempWindow = X11Extras::getInstance()->findParentClient(currentWindow);
|
||||
qDebug() << "findParentClient: " << tempWindow << endl;
|
||||
|
||||
if (tempWindow > 0) currentWindow = tempWindow;
|
||||
if (tempWindow > 0)
|
||||
currentWindow = tempWindow;
|
||||
|
||||
nowWindow = QString::number(currentWindow);
|
||||
qDebug() << "number of window now: " << nowWindow << endl;
|
||||
@@ -158,27 +153,26 @@ void AutoProfileWatcher::runAppCheck()
|
||||
currentAppWindowTitle = nowWindowName;
|
||||
|
||||
Logger::LogDebug(QObject::tr("Active window changed to: Title = \"%1\", "
|
||||
"Class = \"%2\", Program = \"%3\" or \"%4\".").
|
||||
arg(nowWindowName, nowWindowClass, appLocation, baseAppFileName));
|
||||
"Class = \"%2\", Program = \"%3\" or \"%4\".")
|
||||
.arg(nowWindowName, nowWindowClass, appLocation, baseAppFileName));
|
||||
|
||||
QSet<AutoProfileInfo*> fullSet;
|
||||
QSet<AutoProfileInfo *> fullSet;
|
||||
|
||||
if (!appLocation.isEmpty() && getAppProfileAssignments().contains(appLocation))
|
||||
{
|
||||
QSet<AutoProfileInfo*> tempSet;
|
||||
QSet<AutoProfileInfo *> tempSet;
|
||||
tempSet = getAppProfileAssignments().value(appLocation).toSet();
|
||||
fullSet.unite(tempSet);
|
||||
}
|
||||
else if (!baseAppFileName.isEmpty() && getAppProfileAssignments().contains(baseAppFileName))
|
||||
} else if (!baseAppFileName.isEmpty() && getAppProfileAssignments().contains(baseAppFileName))
|
||||
{
|
||||
QSet<AutoProfileInfo*> tempSet;
|
||||
QSet<AutoProfileInfo *> tempSet;
|
||||
tempSet = getAppProfileAssignments().value(baseAppFileName).toSet();
|
||||
fullSet.unite(tempSet);
|
||||
}
|
||||
|
||||
if (!nowWindowClass.isEmpty() && getWindowClassProfileAssignments().contains(nowWindowClass))
|
||||
{
|
||||
QSet<AutoProfileInfo*> tempSet;
|
||||
QSet<AutoProfileInfo *> tempSet;
|
||||
tempSet = getWindowClassProfileAssignments().value(nowWindowClass).toSet();
|
||||
fullSet.unite(tempSet);
|
||||
}
|
||||
@@ -186,55 +180,63 @@ void AutoProfileWatcher::runAppCheck()
|
||||
// part window title
|
||||
if (!nowWindowName.isEmpty())
|
||||
{
|
||||
QHashIterator< QString, QList< AutoProfileInfo *> > iter(getWindowNameProfileAssignments());
|
||||
QHashIterator<QString, QList<AutoProfileInfo *>> iter(getWindowNameProfileAssignments());
|
||||
while (iter.hasNext())
|
||||
{
|
||||
iter.next();
|
||||
|
||||
bool hasOnePartName = false;
|
||||
|
||||
QListIterator< AutoProfileInfo* > iterList(iter.value());
|
||||
while (iterList.hasNext()) {
|
||||
QListIterator<AutoProfileInfo *> iterList(iter.value());
|
||||
while (iterList.hasNext())
|
||||
{
|
||||
|
||||
AutoProfileInfo* autoInfo = iterList.next();
|
||||
AutoProfileInfo *autoInfo = iterList.next();
|
||||
|
||||
if (autoInfo->isPartialState()) {
|
||||
if (autoInfo->isPartialState())
|
||||
{
|
||||
hasOnePartName = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOnePartName) {
|
||||
if (hasOnePartName)
|
||||
{
|
||||
|
||||
qDebug() << "IT HAS A PARTIAL TITLE NAME";
|
||||
|
||||
if (nowWindowName.contains(iter.key())) {
|
||||
if (nowWindowName.contains(iter.key()))
|
||||
{
|
||||
|
||||
qDebug() << "WINDOW: \"" << nowWindowName << "\" includes \"" << iter.key() << "\"";
|
||||
|
||||
QSet< AutoProfileInfo* > tempSet;
|
||||
QList< AutoProfileInfo *> list = iter.value();
|
||||
QSet<AutoProfileInfo *> tempSet;
|
||||
QList<AutoProfileInfo *> list = iter.value();
|
||||
tempSet = list.toSet();
|
||||
fullSet = fullSet.unite(tempSet);
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
qDebug() << "WINDOW: \"" << nowWindowName << "\" doesn't include \"" << iter.key() << "\"";
|
||||
}
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
qDebug() << "IT HAS A FULL TITLE NAME";
|
||||
|
||||
if (iter.key() == nowWindowName) {
|
||||
if (iter.key() == nowWindowName)
|
||||
{
|
||||
|
||||
qDebug() << "WINDOW: \"" << nowWindowName << "\" is equal to hash key: \"" << iter.key() << "\"";
|
||||
|
||||
QSet<AutoProfileInfo*> tempSet;
|
||||
QSet<AutoProfileInfo *> tempSet;
|
||||
tempSet = getWindowNameProfileAssignments().value(nowWindowName).toSet();
|
||||
fullSet = fullSet.unite(tempSet);
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
qDebug() << "WINDOW: \"" << nowWindowName << "\" is not equal to hash key: \"" << iter.key() << "\"";
|
||||
}
|
||||
@@ -243,9 +245,9 @@ void AutoProfileWatcher::runAppCheck()
|
||||
}
|
||||
|
||||
QHash<QString, int> highestMatchCount;
|
||||
QHash<QString, AutoProfileInfo*> highestMatches;
|
||||
QHash<QString, AutoProfileInfo *> highestMatches;
|
||||
|
||||
QSetIterator<AutoProfileInfo*> fullSetIter(fullSet);
|
||||
QSetIterator<AutoProfileInfo *> fullSetIter(fullSet);
|
||||
while (fullSetIter.hasNext())
|
||||
{
|
||||
AutoProfileInfo *info = fullSetIter.next();
|
||||
@@ -257,24 +259,22 @@ void AutoProfileWatcher::runAppCheck()
|
||||
numProps += !info->getWindowName().isEmpty() ? 1 : 0;
|
||||
|
||||
int numMatched = 0;
|
||||
numMatched += (!info->getExe().isEmpty() &&
|
||||
(info->getExe() == appLocation ||
|
||||
info->getExe() == baseAppFileName)) ? 1 : 0;
|
||||
numMatched += (!info->getWindowClass().isEmpty() &&
|
||||
info->getWindowClass() == nowWindowClass) ? 1 : 0;
|
||||
numMatched +=
|
||||
(!info->getExe().isEmpty() && (info->getExe() == appLocation || info->getExe() == baseAppFileName)) ? 1
|
||||
: 0;
|
||||
numMatched += (!info->getWindowClass().isEmpty() && info->getWindowClass() == nowWindowClass) ? 1 : 0;
|
||||
|
||||
if (info->isPartialState())
|
||||
{
|
||||
|
||||
if (info->isPartialState()) {
|
||||
numMatched +=
|
||||
(!info->getWindowName().isEmpty() && nowWindowName.contains(info->getWindowName())) ? 1 : 0;
|
||||
} else
|
||||
{
|
||||
|
||||
numMatched += (!info->getWindowName().isEmpty() &&
|
||||
nowWindowName.contains(info->getWindowName())) ? 1 : 0;
|
||||
} else {
|
||||
|
||||
numMatched += (!info->getWindowName().isEmpty() &&
|
||||
info->getWindowName() == nowWindowName) ? 1 : 0;
|
||||
numMatched += (!info->getWindowName().isEmpty() && info->getWindowName() == nowWindowName) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
if (numProps == numMatched && highestMatchCount.contains(info->getUniqueID()))
|
||||
{
|
||||
int currentHigh = highestMatchCount.value(info->getUniqueID());
|
||||
@@ -283,8 +283,7 @@ void AutoProfileWatcher::runAppCheck()
|
||||
highestMatchCount.insert(info->getUniqueID(), numMatched);
|
||||
highestMatches.insert(info->getUniqueID(), info);
|
||||
}
|
||||
}
|
||||
else if (numProps == numMatched && !highestMatchCount.contains(info->getUniqueID()))
|
||||
} else if (numProps == numMatched && !highestMatchCount.contains(info->getUniqueID()))
|
||||
{
|
||||
highestMatchCount.insert(info->getUniqueID(), numMatched);
|
||||
highestMatches.insert(info->getUniqueID(), info);
|
||||
@@ -292,7 +291,7 @@ void AutoProfileWatcher::runAppCheck()
|
||||
}
|
||||
}
|
||||
|
||||
QHashIterator<QString, AutoProfileInfo*> highIter(highestMatches);
|
||||
QHashIterator<QString, AutoProfileInfo *> highIter(highestMatches);
|
||||
|
||||
while (highIter.hasNext())
|
||||
{
|
||||
@@ -308,7 +307,7 @@ void AutoProfileWatcher::runAppCheck()
|
||||
emit foundApplicableProfile(allDefaultInfo);
|
||||
}
|
||||
|
||||
QHashIterator<QString, AutoProfileInfo*> iter(getDefaultProfileAssignments());
|
||||
QHashIterator<QString, AutoProfileInfo *> iter(getDefaultProfileAssignments());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -397,7 +396,8 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
exe = settings->value(QString("AutoProfile%1Exe").arg(i), "").toString();
|
||||
exe = QDir::toNativeSeparators(exe);
|
||||
|
||||
convToUniqueIDAutoProfGroupSett(settings, QString("AutoProfile%1GUID").arg(i), QString("AutoProfile%1UniqueID").arg(i));
|
||||
convToUniqueIDAutoProfGroupSett(settings, QString("AutoProfile%1GUID").arg(i),
|
||||
QString("AutoProfile%1UniqueID").arg(i));
|
||||
|
||||
uniqueID = settings->value(QString("AutoProfile%1UniqueID").arg(i), "").toString();
|
||||
profile = settings->value(QString("AutoProfile%1Profile").arg(i), "").toString();
|
||||
@@ -406,7 +406,6 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
QString partialTitle = settings->value(QString("AutoProfile%1PartialTitle").arg(i), 0).toString();
|
||||
bool partialTitleBool = partialTitle == "1" ? true : false;
|
||||
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
windowClass = settings->value(QString("AutoProfile%1WindowClass").arg(i), "").toString();
|
||||
#else
|
||||
@@ -415,8 +414,7 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
|
||||
// Check if all required elements exist. If not, assume that the end of the
|
||||
// list has been reached.
|
||||
if ((!exe.isEmpty() || !windowClass.isEmpty() || !windowName.isEmpty()) &&
|
||||
!uniqueID.isEmpty())
|
||||
if ((!exe.isEmpty() || !windowClass.isEmpty() || !windowName.isEmpty()) && !uniqueID.isEmpty())
|
||||
{
|
||||
bool profileActive = active == "1" ? true : false;
|
||||
|
||||
@@ -428,7 +426,7 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
{
|
||||
info->setWindowClass(windowClass);
|
||||
|
||||
QList<AutoProfileInfo*> templist;
|
||||
QList<AutoProfileInfo *> templist;
|
||||
|
||||
if (getWindowClassProfileAssignments().contains(windowClass))
|
||||
templist = getWindowClassProfileAssignments().value(windowClass);
|
||||
@@ -443,13 +441,14 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
info->setWindowName(windowName);
|
||||
qDebug() << "WINDOW NAME IN AUTOPROFILEWATCHER: " << windowName;
|
||||
|
||||
QList<AutoProfileInfo*> templist;
|
||||
QList<AutoProfileInfo *> templist;
|
||||
|
||||
QHashIterator<QString, QList<AutoProfileInfo*> > windows(getWindowNameProfileAssignments());
|
||||
QHashIterator<QString, QList<AutoProfileInfo *>> windows(getWindowNameProfileAssignments());
|
||||
|
||||
qDebug() << "getWindowNameProfileAssignments contains such elements like: ";
|
||||
|
||||
while(windows.hasNext()) {
|
||||
while (windows.hasNext())
|
||||
{
|
||||
|
||||
windows.next();
|
||||
qDebug() << windows.key();
|
||||
@@ -460,7 +459,8 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
qDebug() << "getWindowNameProfileAssignments contains " << windowName;
|
||||
templist = getWindowNameProfileAssignments().value(windowName);
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
qDebug() << "getWindowNameProfileAssignments doesn't contain " << windowName;
|
||||
}
|
||||
@@ -473,7 +473,7 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
{
|
||||
info->setExe(exe);
|
||||
|
||||
QList<AutoProfileInfo*> templist;
|
||||
QList<AutoProfileInfo *> templist;
|
||||
|
||||
if (getAppProfileAssignments().contains(exe))
|
||||
templist = getAppProfileAssignments().value(exe);
|
||||
@@ -484,7 +484,7 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
|
||||
if (!baseExe.isEmpty() && baseExe != exe)
|
||||
{
|
||||
QList<AutoProfileInfo*> templist;
|
||||
QList<AutoProfileInfo *> templist;
|
||||
|
||||
if (getAppProfileAssignments().contains(baseExe))
|
||||
templist = getAppProfileAssignments().value(baseExe);
|
||||
@@ -494,8 +494,7 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
quitSearch = true;
|
||||
}
|
||||
@@ -505,43 +504,42 @@ void AutoProfileWatcher::syncProfileAssignment()
|
||||
settings->getLock()->unlock();
|
||||
}
|
||||
|
||||
|
||||
void AutoProfileWatcher::clearProfileAssignments()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QSet<AutoProfileInfo*> terminateProfiles;
|
||||
QListIterator<QList<AutoProfileInfo*> > iterDelete(getAppProfileAssignments().values());
|
||||
QSet<AutoProfileInfo *> terminateProfiles;
|
||||
QListIterator<QList<AutoProfileInfo *>> iterDelete(getAppProfileAssignments().values());
|
||||
|
||||
while (iterDelete.hasNext())
|
||||
{
|
||||
QList<AutoProfileInfo*> templist = iterDelete.next();
|
||||
QList<AutoProfileInfo *> templist = iterDelete.next();
|
||||
terminateProfiles.unite(templist.toSet());
|
||||
}
|
||||
|
||||
appProfileAssignments.clear();
|
||||
|
||||
QListIterator<QList<AutoProfileInfo*> > iterClassDelete(getWindowClassProfileAssignments().values());
|
||||
QListIterator<QList<AutoProfileInfo *>> iterClassDelete(getWindowClassProfileAssignments().values());
|
||||
|
||||
while (iterClassDelete.hasNext())
|
||||
{
|
||||
QList<AutoProfileInfo*> templist = iterClassDelete.next();
|
||||
QList<AutoProfileInfo *> templist = iterClassDelete.next();
|
||||
terminateProfiles.unite(templist.toSet());
|
||||
}
|
||||
|
||||
windowClassProfileAssignments.clear();
|
||||
|
||||
QListIterator<QList<AutoProfileInfo*> > iterNameDelete(getWindowNameProfileAssignments().values());
|
||||
QListIterator<QList<AutoProfileInfo *>> iterNameDelete(getWindowNameProfileAssignments().values());
|
||||
|
||||
while (iterNameDelete.hasNext())
|
||||
{
|
||||
QList<AutoProfileInfo*> templist = iterNameDelete.next();
|
||||
QList<AutoProfileInfo *> templist = iterNameDelete.next();
|
||||
terminateProfiles.unite(templist.toSet());
|
||||
}
|
||||
|
||||
windowNameProfileAssignments.clear();
|
||||
|
||||
QSetIterator<AutoProfileInfo*> iterTerminate(terminateProfiles);
|
||||
QSetIterator<AutoProfileInfo *> iterTerminate(terminateProfiles);
|
||||
|
||||
while (iterTerminate.hasNext())
|
||||
{
|
||||
@@ -553,7 +551,7 @@ void AutoProfileWatcher::clearProfileAssignments()
|
||||
}
|
||||
}
|
||||
|
||||
QListIterator<AutoProfileInfo*> iterDefaultsDelete(getDefaultProfileAssignments().values());
|
||||
QListIterator<AutoProfileInfo *> iterDefaultsDelete(getDefaultProfileAssignments().values());
|
||||
|
||||
while (iterDefaultsDelete.hasNext())
|
||||
{
|
||||
@@ -576,24 +574,26 @@ QString AutoProfileWatcher::findAppLocation()
|
||||
|
||||
QString exepath = QString();
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
Window currentWindow = 0;
|
||||
int pid = 0;
|
||||
|
||||
currentWindow = X11Extras::getInstance()->getWindowInFocus();
|
||||
if (currentWindow) pid = X11Extras::getInstance()->getApplicationPid(currentWindow);
|
||||
if (pid > 0) exepath = X11Extras::getInstance()->getApplicationLocation(pid);
|
||||
#endif
|
||||
if (currentWindow)
|
||||
pid = X11Extras::getInstance()->getApplicationPid(currentWindow);
|
||||
if (pid > 0)
|
||||
exepath = X11Extras::getInstance()->getApplicationLocation(pid);
|
||||
#endif
|
||||
|
||||
return exepath;
|
||||
}
|
||||
|
||||
QList<AutoProfileInfo*>* AutoProfileWatcher::getCustomDefaults()
|
||||
QList<AutoProfileInfo *> *AutoProfileWatcher::getCustomDefaults()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QList<AutoProfileInfo*> *temp = new QList<AutoProfileInfo*>();
|
||||
QHashIterator<QString, AutoProfileInfo*> iter(getDefaultProfileAssignments());
|
||||
QList<AutoProfileInfo *> *temp = new QList<AutoProfileInfo *>();
|
||||
QHashIterator<QString, AutoProfileInfo *> iter(getDefaultProfileAssignments());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -604,14 +604,13 @@ QList<AutoProfileInfo*>* AutoProfileWatcher::getCustomDefaults()
|
||||
return temp;
|
||||
}
|
||||
|
||||
AutoProfileInfo* AutoProfileWatcher::getDefaultAllProfile()
|
||||
AutoProfileInfo *AutoProfileWatcher::getDefaultAllProfile()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return allDefaultInfo;
|
||||
}
|
||||
|
||||
|
||||
bool AutoProfileWatcher::isUniqueIDLocked(QString uniqueID)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -619,34 +618,34 @@ bool AutoProfileWatcher::isUniqueIDLocked(QString uniqueID)
|
||||
return getUniqeIDSetLocal().contains(uniqueID);
|
||||
}
|
||||
|
||||
QHash<QString, QList<AutoProfileInfo*> > const& AutoProfileWatcher::getAppProfileAssignments() {
|
||||
QHash<QString, QList<AutoProfileInfo *>> const &AutoProfileWatcher::getAppProfileAssignments()
|
||||
{
|
||||
|
||||
return appProfileAssignments;
|
||||
}
|
||||
|
||||
QHash<QString, QList<AutoProfileInfo*> > const& AutoProfileWatcher::getWindowClassProfileAssignments() {
|
||||
QHash<QString, QList<AutoProfileInfo *>> const &AutoProfileWatcher::getWindowClassProfileAssignments()
|
||||
{
|
||||
|
||||
return windowClassProfileAssignments;
|
||||
}
|
||||
|
||||
QHash<QString, QList<AutoProfileInfo*> > const& AutoProfileWatcher::getWindowNameProfileAssignments() {
|
||||
QHash<QString, QList<AutoProfileInfo *>> const &AutoProfileWatcher::getWindowNameProfileAssignments()
|
||||
{
|
||||
|
||||
return windowNameProfileAssignments;
|
||||
}
|
||||
|
||||
QHash<QString, AutoProfileInfo*> const& AutoProfileWatcher::getDefaultProfileAssignments() {
|
||||
QHash<QString, AutoProfileInfo *> const &AutoProfileWatcher::getDefaultProfileAssignments()
|
||||
{
|
||||
|
||||
return defaultProfileAssignments;
|
||||
}
|
||||
|
||||
QSet<QString> &AutoProfileWatcher::getUniqeIDSetLocal() { return uniqueIDSet; }
|
||||
|
||||
QSet<QString>& AutoProfileWatcher::getUniqeIDSetLocal() {
|
||||
|
||||
return uniqueIDSet;
|
||||
}
|
||||
|
||||
|
||||
void AutoProfileWatcher::convToUniqueIDAutoProfGroupSett(QSettings* sett, QString guidAutoProfSett, QString uniqueAutoProfSett)
|
||||
void AutoProfileWatcher::convToUniqueIDAutoProfGroupSett(QSettings *sett, QString guidAutoProfSett,
|
||||
QString uniqueAutoProfSett)
|
||||
{
|
||||
if (sett->contains(guidAutoProfSett))
|
||||
{
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AUTOPROFILEWATCHER_H
|
||||
#define AUTOPROFILEWATCHER_H
|
||||
|
||||
#include <QTimer>
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
class AntiMicroSettings;
|
||||
class AutoProfileInfo;
|
||||
@@ -32,55 +31,54 @@ class AutoProfileWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit AutoProfileWatcher(AntiMicroSettings *settings, QObject *parent = nullptr);
|
||||
~AutoProfileWatcher();
|
||||
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
static void disconnectWindowTimer();
|
||||
static AutoProfileWatcher* getAutoProfileWatcherInstance();
|
||||
QList<AutoProfileInfo*>* getCustomDefaults();
|
||||
AutoProfileInfo* getDefaultAllProfile();
|
||||
//bool isGUIDLocked(QString guid);
|
||||
static AutoProfileWatcher *getAutoProfileWatcherInstance();
|
||||
QList<AutoProfileInfo *> *getCustomDefaults();
|
||||
AutoProfileInfo *getDefaultAllProfile();
|
||||
// bool isGUIDLocked(QString guid);
|
||||
bool isUniqueIDLocked(QString uniqueID);
|
||||
QHash<QString, QList<AutoProfileInfo*> > const& getAppProfileAssignments();
|
||||
QHash<QString, QList<AutoProfileInfo*> > const& getWindowClassProfileAssignments();
|
||||
QHash<QString, QList<AutoProfileInfo*> > const& getWindowNameProfileAssignments();
|
||||
QHash<QString, AutoProfileInfo*> const& getDefaultProfileAssignments();
|
||||
QHash<QString, QList<AutoProfileInfo *>> const &getAppProfileAssignments();
|
||||
QHash<QString, QList<AutoProfileInfo *>> const &getWindowClassProfileAssignments();
|
||||
QHash<QString, QList<AutoProfileInfo *>> const &getWindowNameProfileAssignments();
|
||||
QHash<QString, AutoProfileInfo *> const &getDefaultProfileAssignments();
|
||||
|
||||
static const int CHECKTIME = 500; // time in ms
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
QString findAppLocation();
|
||||
void clearProfileAssignments();
|
||||
void convToUniqueIDAutoProfGroupSett(QSettings* sett, QString guidAutoProfSett, QString uniqueAutoProfSett);
|
||||
void convToUniqueIDAutoProfGroupSett(QSettings *sett, QString guidAutoProfSett, QString uniqueAutoProfSett);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void foundApplicableProfile(AutoProfileInfo *info);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void syncProfileAssignment();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void runAppCheck();
|
||||
|
||||
private:
|
||||
//QSet<QString>& getGuidSetLocal();
|
||||
QSet<QString>& getUniqeIDSetLocal();
|
||||
private:
|
||||
// QSet<QString>& getGuidSetLocal();
|
||||
QSet<QString> &getUniqeIDSetLocal();
|
||||
|
||||
static AutoProfileWatcher* _instance;
|
||||
static AutoProfileWatcher *_instance;
|
||||
static QTimer checkWindowTimer;
|
||||
AntiMicroSettings *settings;
|
||||
QHash<QString, QList<AutoProfileInfo*> > appProfileAssignments;
|
||||
QHash<QString, QList<AutoProfileInfo*> > windowClassProfileAssignments;
|
||||
QHash<QString, QList<AutoProfileInfo*> > windowNameProfileAssignments;
|
||||
QHash<QString, AutoProfileInfo*> defaultProfileAssignments;
|
||||
QHash<QString, QList<AutoProfileInfo *>> appProfileAssignments;
|
||||
QHash<QString, QList<AutoProfileInfo *>> windowClassProfileAssignments;
|
||||
QHash<QString, QList<AutoProfileInfo *>> windowNameProfileAssignments;
|
||||
QHash<QString, AutoProfileInfo *> defaultProfileAssignments;
|
||||
AutoProfileInfo *allDefaultInfo;
|
||||
QString currentApplication;
|
||||
QString currentAppWindowTitle;
|
||||
//QSet<QString> guidSet;
|
||||
// QSet<QString> guidSet;
|
||||
QSet<QString> uniqueIDSet;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,26 +19,25 @@
|
||||
#include "axiseditdialog.h"
|
||||
#include "ui_axiseditdialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "buttoneditdialog.h"
|
||||
#include "mousedialog/mouseaxissettingsdialog.h"
|
||||
#include "event.h"
|
||||
#include "antkeymapper.h"
|
||||
#include "setjoystick.h"
|
||||
#include "inputdevice.h"
|
||||
#include "common.h"
|
||||
#include "joyaxis.h"
|
||||
#include "axisvaluebox.h"
|
||||
#include "setaxisthrottledialog.h"
|
||||
#include "buttoneditdialog.h"
|
||||
#include "common.h"
|
||||
#include "event.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joyaxis.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "messagehandler.h"
|
||||
#include "mousedialog/mouseaxissettingsdialog.h"
|
||||
#include "setaxisthrottledialog.h"
|
||||
#include "setjoystick.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
|
||||
|
||||
AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *parent) :
|
||||
QDialog(parent, Qt::Window),
|
||||
ui(new Ui::AxisEditDialog)
|
||||
AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *parent)
|
||||
: QDialog(parent, Qt::Window)
|
||||
, ui(new Ui::AxisEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -59,7 +58,8 @@ AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *pare
|
||||
actAsTrigger = true;
|
||||
}
|
||||
|
||||
if (actAsTrigger) buildTriggerPresetsMenu();
|
||||
if (actAsTrigger)
|
||||
buildTriggerPresetsMenu();
|
||||
|
||||
ui->horizontalSlider->setValue(axis->getDeadZone());
|
||||
ui->lineEdit->setText(QString::number(axis->getDeadZone()));
|
||||
@@ -72,8 +72,7 @@ AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *pare
|
||||
if (!nButton->getActionName().isEmpty())
|
||||
{
|
||||
ui->nPushButton->setText(nButton->getActionName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->nPushButton->setText(nButton->getSlotsSummary());
|
||||
}
|
||||
@@ -83,22 +82,22 @@ AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *pare
|
||||
if (!pButton->getActionName().isEmpty())
|
||||
{
|
||||
ui->pPushButton->setText(pButton->getActionName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->pPushButton->setText(pButton->getSlotsSummary());
|
||||
}
|
||||
|
||||
int currentThrottle = axis->getThrottle();
|
||||
|
||||
if ((currentThrottle == static_cast<int>(JoyAxis::NegativeThrottle)) || (currentThrottle == static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
if ((currentThrottle == static_cast<int>(JoyAxis::NegativeThrottle)) ||
|
||||
(currentThrottle == static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
{
|
||||
int tempindex = (currentThrottle == static_cast<int>(JoyAxis::NegativeHalfThrottle)) ? 0 : 1;
|
||||
ui->comboBox_2->setCurrentIndex(tempindex);
|
||||
ui->nPushButton->setEnabled(true);
|
||||
ui->pPushButton->setEnabled(false);
|
||||
}
|
||||
else if ((currentThrottle == static_cast<int>(JoyAxis::PositiveThrottle)) || (currentThrottle == static_cast<int>(JoyAxis::PositiveHalfThrottle)))
|
||||
} else if ((currentThrottle == static_cast<int>(JoyAxis::PositiveThrottle)) ||
|
||||
(currentThrottle == static_cast<int>(JoyAxis::PositiveHalfThrottle)))
|
||||
{
|
||||
int tempindex = (currentThrottle == static_cast<int>(JoyAxis::PositiveThrottle)) ? 3 : 4;
|
||||
ui->comboBox_2->setCurrentIndex(tempindex);
|
||||
@@ -113,33 +112,34 @@ AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *pare
|
||||
ui->joyValueLabel->setText(QString::number(axis->getCurrentRawValue()));
|
||||
ui->axisstatusBox->setValue(axis->getCurrentRawValue());
|
||||
|
||||
if (!actAsTrigger) selectAxisCurrentPreset();
|
||||
else selectTriggerPreset();
|
||||
if (!actAsTrigger)
|
||||
selectAxisCurrentPreset();
|
||||
else
|
||||
selectTriggerPreset();
|
||||
|
||||
ui->axisNameLineEdit->setText(axis->getAxisName());
|
||||
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::implementPresets);
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::implementPresets);
|
||||
|
||||
connect(ui->horizontalSlider, &QSlider::valueChanged, this, &AxisEditDialog::updateDeadZoneBox);
|
||||
connect(ui->horizontalSlider, &QSlider::valueChanged, this, [this, axis](int deadzone) {
|
||||
ui->axisstatusBox->setDeadZone(axis, deadzone);
|
||||
});
|
||||
connect(ui->horizontalSlider, &QSlider::valueChanged, this,
|
||||
[this, axis](int deadzone) { ui->axisstatusBox->setDeadZone(axis, deadzone); });
|
||||
|
||||
connect(ui->horizontalSlider, &QSlider::valueChanged, axis, &JoyAxis::setDeadZone);
|
||||
|
||||
connect(ui->horizontalSlider_2, &QSlider::valueChanged, this, &AxisEditDialog::updateMaxZoneBox);
|
||||
connect(ui->horizontalSlider_2, &QSlider::valueChanged, this, [this, axis](int deadzone) {
|
||||
ui->axisstatusBox->setMaxZone(axis, deadzone);
|
||||
});
|
||||
connect(ui->horizontalSlider_2, &QSlider::valueChanged, this,
|
||||
[this, axis](int deadzone) { ui->axisstatusBox->setMaxZone(axis, deadzone); });
|
||||
|
||||
connect(ui->horizontalSlider_2, &QSlider::valueChanged, axis, &JoyAxis::setMaxZoneValue);
|
||||
|
||||
connect(ui->comboBox_2, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::updateThrottleUi);
|
||||
connect(ui->comboBox_2, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::presetForThrottleChange);
|
||||
connect(ui->comboBox_2, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::updateThrottleUi);
|
||||
connect(ui->comboBox_2, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::presetForThrottleChange);
|
||||
|
||||
connect(axis, &JoyAxis::moved, this, [this, axis](int value) {
|
||||
ui->axisstatusBox->setValue(axis, value);
|
||||
});
|
||||
connect(axis, &JoyAxis::moved, this, [this, axis](int value) { ui->axisstatusBox->setValue(axis, value); });
|
||||
|
||||
connect(axis, &JoyAxis::moved, this, &AxisEditDialog::updateJoyValue);
|
||||
|
||||
@@ -157,11 +157,10 @@ AxisEditDialog::AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *pare
|
||||
}
|
||||
|
||||
// for tests
|
||||
AxisEditDialog::AxisEditDialog(QWidget *parent) :
|
||||
QDialog(parent, Qt::Window),
|
||||
ui(new Ui::AxisEditDialog)
|
||||
AxisEditDialog::AxisEditDialog(QWidget *parent)
|
||||
: QDialog(parent, Qt::Window)
|
||||
, ui(new Ui::AxisEditDialog)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AxisEditDialog::~AxisEditDialog()
|
||||
@@ -184,8 +183,10 @@ void AxisEditDialog::implementPresets(int index)
|
||||
actAsTrigger = true;
|
||||
}
|
||||
|
||||
if (actAsTrigger) implementTriggerPresets(index);
|
||||
else implementAxisPresets(index);
|
||||
if (actAsTrigger)
|
||||
implementTriggerPresets(index);
|
||||
else
|
||||
implementAxisPresets(index);
|
||||
}
|
||||
|
||||
void AxisEditDialog::implementAxisPresets(int index)
|
||||
@@ -199,7 +200,7 @@ void AxisEditDialog::implementAxisPresets(int index)
|
||||
InputDevice *tempDevice = m_axis->getParentSet()->getInputDevice();
|
||||
QMetaObject::invokeMethod(tempDevice, "haltServices", Qt::BlockingQueuedConnection);
|
||||
|
||||
switch(index)
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this);
|
||||
@@ -222,33 +223,45 @@ void AxisEditDialog::implementAxisPresets(int index)
|
||||
break;
|
||||
|
||||
case 5:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8),
|
||||
QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2),
|
||||
QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4),
|
||||
QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6),
|
||||
QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
@@ -265,19 +278,15 @@ void AxisEditDialog::implementAxisPresets(int index)
|
||||
nbutton->buildActiveZoneSummaryString();
|
||||
pbutton->buildActiveZoneSummaryString();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (nbuttonslot != nullptr)
|
||||
{
|
||||
JoyAxisButton *button = m_axis->getNAxisButton();
|
||||
QMetaObject::invokeMethod(button, "clearSlotsEventReset",
|
||||
Q_ARG(bool, false));
|
||||
QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false));
|
||||
|
||||
QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, nbuttonslot->getSlotCode()),
|
||||
Q_ARG(int, nbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(int, nbuttonslot->getSlotCode()), Q_ARG(int, nbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode()));
|
||||
|
||||
refreshNButtonLabel();
|
||||
@@ -290,8 +299,7 @@ void AxisEditDialog::implementAxisPresets(int index)
|
||||
QMetaObject::invokeMethod(button, "clearSlotsEventReset", Q_ARG(bool, false));
|
||||
|
||||
QMetaObject::invokeMethod(button, "setAssignedSlot", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, pbuttonslot->getSlotCode()),
|
||||
Q_ARG(int, pbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(int, pbuttonslot->getSlotCode()), Q_ARG(int, pbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode()));
|
||||
|
||||
refreshPButtonLabel();
|
||||
@@ -325,19 +333,19 @@ void AxisEditDialog::updateThrottleUi(int index)
|
||||
{
|
||||
ui->nPushButton->setEnabled(true);
|
||||
ui->pPushButton->setEnabled(false);
|
||||
tempthrottle = (index == 0) ? static_cast<int>(JoyAxis::NegativeHalfThrottle) : static_cast<int>(JoyAxis::NegativeThrottle);
|
||||
}
|
||||
else if (index == 2)
|
||||
tempthrottle =
|
||||
(index == 0) ? static_cast<int>(JoyAxis::NegativeHalfThrottle) : static_cast<int>(JoyAxis::NegativeThrottle);
|
||||
} else if (index == 2)
|
||||
{
|
||||
ui->nPushButton->setEnabled(true);
|
||||
ui->pPushButton->setEnabled(true);
|
||||
tempthrottle = static_cast<int>(JoyAxis::NormalThrottle);
|
||||
}
|
||||
else if ((index == 3) || (index == 4))
|
||||
} else if ((index == 3) || (index == 4))
|
||||
{
|
||||
ui->pPushButton->setEnabled(true);
|
||||
ui->nPushButton->setEnabled(false);
|
||||
tempthrottle = (index == 3) ? static_cast<int>(JoyAxis::PositiveThrottle) : static_cast<int>(JoyAxis::PositiveHalfThrottle);
|
||||
tempthrottle =
|
||||
(index == 3) ? static_cast<int>(JoyAxis::PositiveThrottle) : static_cast<int>(JoyAxis::PositiveHalfThrottle);
|
||||
}
|
||||
|
||||
m_axis->setThrottle(tempthrottle);
|
||||
@@ -379,7 +387,8 @@ void AxisEditDialog::openAdvancedPDialog()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
ButtonEditDialog *dialog = new ButtonEditDialog(m_axis->getPAxisButton(), m_axis->getPAxisButton()->getParentSet()->getInputDevice(), keypadUnlocked, this);
|
||||
ButtonEditDialog *dialog = new ButtonEditDialog(
|
||||
m_axis->getPAxisButton(), m_axis->getPAxisButton()->getParentSet()->getInputDevice(), keypadUnlocked, this);
|
||||
dialog->show();
|
||||
|
||||
connect(dialog, &ButtonEditDialog::finished, this, &AxisEditDialog::refreshPButtonLabel);
|
||||
@@ -390,7 +399,8 @@ void AxisEditDialog::openAdvancedNDialog()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
ButtonEditDialog *dialog = new ButtonEditDialog(m_axis->getNAxisButton(), m_axis->getNAxisButton()->getParentSet()->getInputDevice(), keypadUnlocked, this);
|
||||
ButtonEditDialog *dialog = new ButtonEditDialog(
|
||||
m_axis->getNAxisButton(), m_axis->getNAxisButton()->getParentSet()->getInputDevice(), keypadUnlocked, this);
|
||||
dialog->show();
|
||||
|
||||
connect(dialog, &ButtonEditDialog::finished, this, &AxisEditDialog::refreshNButtonLabel);
|
||||
@@ -409,7 +419,6 @@ void AxisEditDialog::refreshPButtonLabel()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
ui->pPushButton->setText(m_axis->getPAxisButton()->getSlotsSummary());
|
||||
|
||||
}
|
||||
|
||||
void AxisEditDialog::checkFinalSettings()
|
||||
@@ -425,75 +434,82 @@ void AxisEditDialog::selectAxisCurrentPreset()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyAxisButton *naxisbutton = m_axis->getNAxisButton();
|
||||
QList<JoyButtonSlot*> *naxisslots = naxisbutton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *naxisslots = naxisbutton->getAssignedSlots();
|
||||
JoyAxisButton *paxisbutton = m_axis->getPAxisButton();
|
||||
QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
|
||||
if ((naxisslots->length() == 1) && (paxisslots->length() == 1))
|
||||
{
|
||||
JoyButtonSlot *nslot = naxisslots->at(0);
|
||||
JoyButtonSlot *pslot = paxisslots->at(0);
|
||||
|
||||
if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(1);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(2);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseDown))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseDown))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(3);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseUp))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseUp))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(4);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(5);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(6);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(7);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(8);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(9);
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(10);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
else if ((naxisslots->length() == 0) && (paxisslots->length() == 0))
|
||||
} else if ((naxisslots->length() == 0) && (paxisslots->length() == 0))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(11);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(0);
|
||||
}
|
||||
@@ -504,7 +520,7 @@ void AxisEditDialog::selectTriggerPreset()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyAxisButton *paxisbutton = m_axis->getPAxisButton();
|
||||
QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
|
||||
if (paxisslots->length() == 1)
|
||||
{
|
||||
@@ -513,21 +529,18 @@ void AxisEditDialog::selectTriggerPreset()
|
||||
if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) && (pslot->getSlotCode() == JoyButtonSlot::MouseLB))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(1);
|
||||
}
|
||||
else if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) && (pslot->getSlotCode() == JoyButtonSlot::MouseRB))
|
||||
} else if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseRB))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(2);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
else if (paxisslots->length() == 0)
|
||||
} else if (paxisslots->length() == 0)
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(3);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(0);
|
||||
}
|
||||
@@ -542,12 +555,10 @@ void AxisEditDialog::implementTriggerPresets(int index)
|
||||
if (index == 1)
|
||||
{
|
||||
pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLB, JoyButtonSlot::JoyMouseButton, this);
|
||||
}
|
||||
else if (index == 2)
|
||||
} else if (index == 2)
|
||||
{
|
||||
pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseRB, JoyButtonSlot::JoyMouseButton, this);
|
||||
}
|
||||
else if (index == 3)
|
||||
} else if (index == 3)
|
||||
{
|
||||
JoyAxisButton *nbutton = m_axis->getNAxisButton();
|
||||
JoyAxisButton *pbutton = m_axis->getPAxisButton();
|
||||
@@ -566,17 +577,14 @@ void AxisEditDialog::implementTriggerPresets(int index)
|
||||
|
||||
if (nbutton->getAssignedSlots()->length() > 0)
|
||||
{
|
||||
QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(bool, false));
|
||||
QMetaObject::invokeMethod(nbutton, "clearSlotsEventReset", Qt::BlockingQueuedConnection, Q_ARG(bool, false));
|
||||
refreshNButtonLabel();
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset",
|
||||
Q_ARG(bool, false));
|
||||
QMetaObject::invokeMethod(pbutton, "clearSlotsEventReset", Q_ARG(bool, false));
|
||||
|
||||
QMetaObject::invokeMethod(pbutton, "setAssignedSlot", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, pbuttonslot->getSlotCode()),
|
||||
Q_ARG(int, pbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(int, pbuttonslot->getSlotCode()), Q_ARG(int, pbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode()));
|
||||
|
||||
refreshPButtonLabel();
|
||||
@@ -590,10 +598,12 @@ void AxisEditDialog::refreshPreset()
|
||||
|
||||
// Disconnect event associated with presetsComboBox so a change in the index does not
|
||||
// alter the axis buttons
|
||||
disconnect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::implementPresets);
|
||||
disconnect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::implementPresets);
|
||||
selectAxisCurrentPreset();
|
||||
// Reconnect the event
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::implementPresets);
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::implementPresets);
|
||||
}
|
||||
|
||||
void AxisEditDialog::openMouseSettingsDialog()
|
||||
@@ -624,8 +634,7 @@ void AxisEditDialog::updateWindowTitleAxisName()
|
||||
if (!m_axis->getAxisName().isEmpty())
|
||||
{
|
||||
temp.append(m_axis->getPartialName(false, true));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
temp.append(m_axis->getPartialName());
|
||||
}
|
||||
@@ -636,7 +645,8 @@ void AxisEditDialog::updateWindowTitleAxisName()
|
||||
temp.append(" [").append(tr("Set %1").arg(setIndex));
|
||||
|
||||
QString setName = m_axis->getParentSet()->getName();
|
||||
if (!setName.isEmpty()) temp.append(": ").append(setName);
|
||||
if (!setName.isEmpty())
|
||||
temp.append(": ").append(setName);
|
||||
|
||||
temp.append("]");
|
||||
}
|
||||
@@ -689,18 +699,19 @@ void AxisEditDialog::presetForThrottleChange(int index)
|
||||
actAsTrigger = true;
|
||||
}
|
||||
|
||||
disconnect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::implementPresets);
|
||||
disconnect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::implementPresets);
|
||||
|
||||
if (actAsTrigger)
|
||||
{
|
||||
buildTriggerPresetsMenu();
|
||||
selectTriggerPreset();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
buildAxisPresetsMenu();
|
||||
selectAxisCurrentPreset();
|
||||
}
|
||||
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AxisEditDialog::implementPresets);
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&AxisEditDialog::implementPresets);
|
||||
}
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AXISEDITDIALOG_H
|
||||
#define AXISEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
class JoyAxis;
|
||||
class SetAxisThrottleDialog;
|
||||
class QWidget;
|
||||
@@ -35,19 +33,19 @@ class AxisEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *parent=0);
|
||||
AxisEditDialog(QWidget *parent=0);
|
||||
public:
|
||||
explicit AxisEditDialog(JoyAxis *axis, bool keypadUnlocked, QWidget *parent = 0);
|
||||
AxisEditDialog(QWidget *parent = 0);
|
||||
~AxisEditDialog();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void selectAxisCurrentPreset();
|
||||
void selectTriggerPreset();
|
||||
|
||||
void buildTriggerPresetsMenu();
|
||||
void buildAxisPresetsMenu();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::AxisEditDialog *ui;
|
||||
|
||||
JoyAxis *m_axis;
|
||||
@@ -55,7 +53,7 @@ private:
|
||||
SetAxisThrottleDialog *setAxisThrottleConfirm;
|
||||
int initialThrottleState;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void implementAxisPresets(int index);
|
||||
void implementTriggerPresets(int index);
|
||||
void implementPresets(int index);
|
||||
|
||||
@@ -19,19 +19,18 @@
|
||||
#include "axisvaluebox.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "joyaxis.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <qdrawutil.h>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QDebug>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
|
||||
|
||||
AxisValueBox::AxisValueBox(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
AxisValueBox::AxisValueBox(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -54,11 +53,10 @@ void AxisValueBox::setThrottle(int throttle)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
qDebug() << "throttle value at start of function setThrottle: " << throttle;
|
||||
|
||||
|
||||
if ((throttle <= static_cast<int>(JoyAxis::PositiveHalfThrottle)) && (throttle >= static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
if ((throttle <= static_cast<int>(JoyAxis::PositiveHalfThrottle)) &&
|
||||
(throttle >= static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
{
|
||||
|
||||
qDebug() << "throttle variable has been set in setThrottle with: " << throttle;
|
||||
@@ -74,18 +72,16 @@ void AxisValueBox::setValue(int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
qDebug() << "Value for axis from value box at start is: " << value;
|
||||
qDebug() << "throttle variable has value: " << m_throttle;
|
||||
|
||||
|
||||
if ((value >= GlobalVariables::JoyAxis::AXISMIN) && (value <= GlobalVariables::JoyAxis::AXISMAX))
|
||||
{
|
||||
|
||||
qDebug() << "Value for axis from value box is between : " << GlobalVariables::JoyAxis::AXISMIN << " and " << GlobalVariables::JoyAxis::AXISMAX;
|
||||
qDebug() << "Value for axis from value box is between : " << GlobalVariables::JoyAxis::AXISMIN << " and "
|
||||
<< GlobalVariables::JoyAxis::AXISMAX;
|
||||
|
||||
|
||||
switch(m_throttle)
|
||||
switch (m_throttle)
|
||||
{
|
||||
case -2:
|
||||
this->joyValue = (value <= 0) ? value : (-value);
|
||||
@@ -112,24 +108,22 @@ void AxisValueBox::setValue(int value)
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisValueBox::setValue(JoyAxis* axis, int value)
|
||||
void AxisValueBox::setValue(JoyAxis *axis, int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
m_axis = axis;
|
||||
|
||||
|
||||
qDebug() << "Value for axis from value box at start is: " << value;
|
||||
qDebug() << "throttle variable has value: " << m_throttle;
|
||||
|
||||
|
||||
if ((value >= axis->getAxisMinCal()) && (value <= axis->getAxisMaxCal()))
|
||||
{
|
||||
|
||||
qDebug() << "Value for axis from value box is between : " << axis->getAxisMinCal() << " and " << axis->getAxisMaxCal();
|
||||
qDebug() << "Value for axis from value box is between : " << axis->getAxisMinCal() << " and "
|
||||
<< axis->getAxisMaxCal();
|
||||
|
||||
|
||||
switch(m_throttle)
|
||||
switch (m_throttle)
|
||||
{
|
||||
|
||||
case -2:
|
||||
@@ -169,7 +163,7 @@ void AxisValueBox::setDeadZone(int deadZone)
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisValueBox::setDeadZone(JoyAxis* axis, int deadZone)
|
||||
void AxisValueBox::setDeadZone(JoyAxis *axis, int deadZone)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -202,7 +196,7 @@ void AxisValueBox::setMaxZone(int maxZone)
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisValueBox::setMaxZone(JoyAxis* axis, int maxZone)
|
||||
void AxisValueBox::setMaxZone(JoyAxis *axis, int maxZone)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -262,7 +256,7 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
|
||||
|
||||
Q_UNUSED(event);
|
||||
|
||||
QPainter paint (this);
|
||||
QPainter paint(this);
|
||||
|
||||
paint.setPen(palette().base().color());
|
||||
paint.setBrush(palette().base().color());
|
||||
@@ -272,8 +266,7 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
qDrawShadeRect(&paint, lboxstart, 0, lboxend, height(), palette(), true, 2, 0, &brush);
|
||||
qDrawShadeRect(&paint, rboxstart, 0, rboxend, height(), palette(), true, 2, 0, &brush);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
qDrawShadeRect(&paint, lboxstart, 0, singlewidth, height(), palette(), true, 2, 0, &brush);
|
||||
}
|
||||
@@ -282,12 +275,10 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
|
||||
if (abs(joyValue) <= m_deadZone)
|
||||
{
|
||||
innerColor = Qt::gray;
|
||||
}
|
||||
else if (abs(joyValue) >= m_maxZone)
|
||||
} else if (abs(joyValue) >= m_maxZone)
|
||||
{
|
||||
innerColor = Qt::red;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
innerColor = Qt::blue;
|
||||
}
|
||||
@@ -301,8 +292,7 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
|
||||
if (joyValue > 0)
|
||||
{
|
||||
paint.drawRect(((m_throttle == 0) ? rboxstart : lboxstart) + 2, 2, barlength, boxheight);
|
||||
}
|
||||
else if (joyValue < 0)
|
||||
} else if (joyValue < 0)
|
||||
{
|
||||
paint.drawRect(lboxstart + barwidth - 2 - barlength, 2, barlength, boxheight);
|
||||
}
|
||||
@@ -323,15 +313,16 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
|
||||
paint.setPen(Qt::red);
|
||||
qDrawPlainRect(&paint, rboxstart + 2 + maxLine, 2, 4, boxheight + 2, Qt::black, 1, &maxBrush);
|
||||
qDrawPlainRect(&paint, lboxend - maxLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &maxBrush);
|
||||
}
|
||||
else if ((m_throttle == static_cast<int>(JoyAxis::PositiveThrottle)) || (m_throttle == static_cast<int>(JoyAxis::PositiveHalfThrottle)))
|
||||
} else if ((m_throttle == static_cast<int>(JoyAxis::PositiveThrottle)) ||
|
||||
(m_throttle == static_cast<int>(JoyAxis::PositiveHalfThrottle)))
|
||||
{
|
||||
qDrawPlainRect(&paint, lboxstart + deadLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &brush);
|
||||
paint.setPen(Qt::red);
|
||||
qDrawPlainRect(&paint, lboxstart + maxLine, 2, 4, boxheight + 2, Qt::black, 1, &maxBrush);
|
||||
}
|
||||
|
||||
else if ((m_throttle == static_cast<int>(JoyAxis::NegativeThrottle)) || (m_throttle == static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
else if ((m_throttle == static_cast<int>(JoyAxis::NegativeThrottle)) ||
|
||||
(m_throttle == static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
{
|
||||
qDrawPlainRect(&paint, singleend - deadLine - 2, 2, 4, boxheight + 2, Qt::black, 1, &brush);
|
||||
paint.setPen(Qt::red);
|
||||
@@ -339,21 +330,22 @@ void AxisValueBox::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int AxisValueBox::getMaxAxValue() {
|
||||
int AxisValueBox::getMaxAxValue()
|
||||
{
|
||||
|
||||
bool axisDefined = false;
|
||||
if (m_axis != nullptr) axisDefined = true;
|
||||
if (m_axis != nullptr)
|
||||
axisDefined = true;
|
||||
|
||||
return (axisDefined && (m_axis->getAxisMaxCal() != -1)) ? m_axis->getAxisMaxCal() : GlobalVariables::JoyAxis::AXISMAX;
|
||||
}
|
||||
|
||||
|
||||
int AxisValueBox::getMinAxValue() {
|
||||
int AxisValueBox::getMinAxValue()
|
||||
{
|
||||
|
||||
bool axisDefined = false;
|
||||
if (m_axis != nullptr) axisDefined = true;
|
||||
if (m_axis != nullptr)
|
||||
axisDefined = true;
|
||||
|
||||
return (axisDefined && (m_axis->getAxisMinCal() != -1)) ? m_axis->getAxisMinCal() : GlobalVariables::JoyAxis::AXISMIN;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AXISVALUEBOX_H
|
||||
#define AXISVALUEBOX_H
|
||||
|
||||
@@ -29,7 +28,7 @@ class JoyAxis;
|
||||
class AxisValueBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
explicit AxisValueBox(QWidget *parent = nullptr);
|
||||
|
||||
int getDeadZone();
|
||||
@@ -39,21 +38,21 @@ public:
|
||||
int getMinAxValue();
|
||||
int getMaxAxValue();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void setThrottle(int throttle);
|
||||
void setValue(int value);
|
||||
void setValue(JoyAxis* axis, int value);
|
||||
void setValue(JoyAxis *axis, int value);
|
||||
void setDeadZone(int deadZone);
|
||||
void setDeadZone(JoyAxis* axis, int deadZone);
|
||||
void setDeadZone(JoyAxis *axis, int deadZone);
|
||||
void setMaxZone(int maxZone);
|
||||
void setMaxZone(JoyAxis* axis, int deadZone);
|
||||
void setMaxZone(JoyAxis *axis, int deadZone);
|
||||
|
||||
private:
|
||||
JoyAxis* m_axis;
|
||||
private:
|
||||
JoyAxis *m_axis;
|
||||
int m_deadZone;
|
||||
int m_maxZone;
|
||||
int joyValue;
|
||||
@@ -66,7 +65,6 @@ private:
|
||||
int rboxend;
|
||||
int singlewidth;
|
||||
int singleend;
|
||||
|
||||
};
|
||||
|
||||
#endif // AXISVALUEBOX_H
|
||||
|
||||
@@ -19,36 +19,34 @@
|
||||
#include "buttoneditdialog.h"
|
||||
#include "ui_buttoneditdialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "joybutton.h"
|
||||
#include "keyboard/virtualkeyboardmousewidget.h"
|
||||
#include "advancebuttondialog.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joybutton.h"
|
||||
#include "keyboard/virtualkeyboardmousewidget.h"
|
||||
#include "messagehandler.h"
|
||||
#include "quicksetdialog.h"
|
||||
|
||||
#include "event.h"
|
||||
#include "antkeymapper.h"
|
||||
#include "eventhandlerfactory.h"
|
||||
#include "setjoystick.h"
|
||||
#include "inputdevice.h"
|
||||
#include "common.h"
|
||||
#include "event.h"
|
||||
#include "eventhandlerfactory.h"
|
||||
#include "inputdevice.h"
|
||||
#include "setjoystick.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
|
||||
ButtonEditDialog *ButtonEditDialog::instance = nullptr;
|
||||
|
||||
ButtonEditDialog* ButtonEditDialog::instance = nullptr;
|
||||
|
||||
|
||||
ButtonEditDialog::ButtonEditDialog(InputDevice* joystick, bool isNumKeypad, QWidget *parent) :
|
||||
QDialog(parent, Qt::Window),
|
||||
helper(),
|
||||
ui(new Ui::ButtonEditDialog)
|
||||
ButtonEditDialog::ButtonEditDialog(InputDevice *joystick, bool isNumKeypad, QWidget *parent)
|
||||
: QDialog(parent, Qt::Window)
|
||||
, helper()
|
||||
, ui(new Ui::ButtonEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -81,22 +79,22 @@ ButtonEditDialog::ButtonEditDialog(InputDevice* joystick, bool isNumKeypad, QWid
|
||||
|
||||
ignoreRelease = false;
|
||||
|
||||
|
||||
qDebug() << "Thread in ButtonEditDialog";
|
||||
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
ui->virtualKeyMouseTabWidget->hide();
|
||||
ui->virtualKeyMouseTabWidget->deleteLater();
|
||||
ui->virtualKeyMouseTabWidget = new VirtualKeyboardMouseWidget(joystick , &helper, m_isNumKeypad, currentQuickDialog, nullptr, this);
|
||||
ui->virtualKeyMouseTabWidget =
|
||||
new VirtualKeyboardMouseWidget(joystick, &helper, m_isNumKeypad, currentQuickDialog, nullptr, this);
|
||||
ui->verticalLayout->insertWidget(1, ui->virtualKeyMouseTabWidget);
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
|
||||
connect(qApp, &QApplication::focusChanged, this, &ButtonEditDialog::checkForKeyboardWidgetFocus);
|
||||
|
||||
connect(ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::selectionCleared, this, &ButtonEditDialog::refreshSlotSummaryLabel);
|
||||
connect(ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::selectionCleared, this,
|
||||
&ButtonEditDialog::refreshSlotSummaryLabel);
|
||||
|
||||
connect(this, &ButtonEditDialog::keyGrabbed, this, &ButtonEditDialog::processSlotAssignment);
|
||||
connect(this, &ButtonEditDialog::selectionCleared, this, &ButtonEditDialog::clearButtonSlots);
|
||||
@@ -104,17 +102,18 @@ ButtonEditDialog::ButtonEditDialog(InputDevice* joystick, bool isNumKeypad, QWid
|
||||
connect(ui->toggleCheckBox, &QCheckBox::clicked, this, &ButtonEditDialog::changeToggleSetting);
|
||||
connect(ui->turboCheckBox, &QCheckBox::clicked, this, &ButtonEditDialog::changeTurboSetting);
|
||||
connect(ui->advancedPushButton, &QPushButton::clicked, this, &ButtonEditDialog::openAdvancedDialog);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::establishVirtualKeyboardAdvancedSignalConnections);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::establishVirtualMouseAdvancedSignalConnections);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget,
|
||||
&VirtualKeyboardMouseWidget::establishVirtualKeyboardAdvancedSignalConnections);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget,
|
||||
&VirtualKeyboardMouseWidget::establishVirtualMouseAdvancedSignalConnections);
|
||||
|
||||
refreshForLastBtn();
|
||||
}
|
||||
|
||||
|
||||
ButtonEditDialog::ButtonEditDialog(JoyButton* button, InputDevice* joystick, bool isNumKeypad, QWidget *parent) :
|
||||
QDialog(parent, Qt::Window),
|
||||
helper(),
|
||||
ui(new Ui::ButtonEditDialog)
|
||||
ButtonEditDialog::ButtonEditDialog(JoyButton *button, InputDevice *joystick, bool isNumKeypad, QWidget *parent)
|
||||
: QDialog(parent, Qt::Window)
|
||||
, helper()
|
||||
, ui(new Ui::ButtonEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -151,42 +150,41 @@ ButtonEditDialog::ButtonEditDialog(JoyButton* button, InputDevice* joystick, boo
|
||||
|
||||
ui->virtualKeyMouseTabWidget->hide();
|
||||
ui->virtualKeyMouseTabWidget->deleteLater();
|
||||
ui->virtualKeyMouseTabWidget = new VirtualKeyboardMouseWidget(joystick, &helper, m_isNumKeypad, currentQuickDialog, button, this);
|
||||
ui->virtualKeyMouseTabWidget =
|
||||
new VirtualKeyboardMouseWidget(joystick, &helper, m_isNumKeypad, currentQuickDialog, button, this);
|
||||
ui->verticalLayout->insertWidget(1, ui->virtualKeyMouseTabWidget);
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
|
||||
connect(qApp, &QApplication::focusChanged, this, &ButtonEditDialog::checkForKeyboardWidgetFocus);
|
||||
|
||||
connect(ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::selectionCleared, this, &ButtonEditDialog::refreshSlotSummaryLabel);
|
||||
connect(ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::selectionCleared, this,
|
||||
&ButtonEditDialog::refreshSlotSummaryLabel);
|
||||
|
||||
connect(this, &ButtonEditDialog::keyGrabbed, this, &ButtonEditDialog::processSlotAssignment);
|
||||
connect(this, &ButtonEditDialog::selectionCleared, this, &ButtonEditDialog::clearButtonSlots); // used to clear button sets
|
||||
connect(this, &ButtonEditDialog::selectionCleared, this,
|
||||
&ButtonEditDialog::clearButtonSlots); // used to clear button sets
|
||||
|
||||
connect(ui->toggleCheckBox, &QCheckBox::clicked, this, &ButtonEditDialog::changeToggleSetting);
|
||||
connect(ui->turboCheckBox, &QCheckBox::clicked, this, &ButtonEditDialog::changeTurboSetting);
|
||||
connect(ui->advancedPushButton, &QPushButton::clicked, this, &ButtonEditDialog::openAdvancedDialog);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::establishVirtualKeyboardAdvancedSignalConnections);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::establishVirtualMouseAdvancedSignalConnections);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget,
|
||||
&VirtualKeyboardMouseWidget::establishVirtualKeyboardAdvancedSignalConnections);
|
||||
connect(this, &ButtonEditDialog::advancedDialogOpened, ui->virtualKeyMouseTabWidget,
|
||||
&VirtualKeyboardMouseWidget::establishVirtualMouseAdvancedSignalConnections);
|
||||
|
||||
refreshForLastBtn();
|
||||
}
|
||||
|
||||
// for tests
|
||||
ButtonEditDialog::ButtonEditDialog(QWidget *parent) :
|
||||
QDialog(parent, Qt::Window),
|
||||
helper(),
|
||||
ui(new Ui::ButtonEditDialog)
|
||||
ButtonEditDialog::ButtonEditDialog(QWidget *parent)
|
||||
: QDialog(parent, Qt::Window)
|
||||
, helper()
|
||||
, ui(new Ui::ButtonEditDialog)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
ButtonEditDialog* ButtonEditDialog::getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
ButtonEditDialog *ButtonEditDialog::getInstance() { return instance; }
|
||||
|
||||
void ButtonEditDialog::checkForKeyboardWidgetFocus(QWidget *old, QWidget *now)
|
||||
{
|
||||
@@ -195,12 +193,10 @@ void ButtonEditDialog::checkForKeyboardWidgetFocus(QWidget *old, QWidget *now)
|
||||
Q_UNUSED(old);
|
||||
Q_UNUSED(now);
|
||||
|
||||
if (ui->virtualKeyMouseTabWidget->hasFocus() &&
|
||||
ui->virtualKeyMouseTabWidget->isKeyboardTabVisible())
|
||||
if (ui->virtualKeyMouseTabWidget->hasFocus() && ui->virtualKeyMouseTabWidget->isKeyboardTabVisible())
|
||||
{
|
||||
grabKeyboard();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
releaseKeyboard();
|
||||
}
|
||||
@@ -215,7 +211,6 @@ ButtonEditDialog::~ButtonEditDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void ButtonEditDialog::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -223,7 +218,7 @@ void ButtonEditDialog::keyPressEvent(QKeyEvent *event)
|
||||
bool ignore = false;
|
||||
// Ignore the following keys that might
|
||||
// trigger an event in QDialog::keyPressEvent
|
||||
switch(event->key())
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Escape:
|
||||
case Qt::Key_Right:
|
||||
@@ -231,8 +226,7 @@ void ButtonEditDialog::keyPressEvent(QKeyEvent *event)
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
{
|
||||
case Qt::Key_Return: {
|
||||
ignore = true;
|
||||
break;
|
||||
}
|
||||
@@ -240,7 +234,8 @@ void ButtonEditDialog::keyPressEvent(QKeyEvent *event)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ignore) QDialog::keyPressEvent(event);
|
||||
if (!ignore)
|
||||
QDialog::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void ButtonEditDialog::keyReleaseEvent(QKeyEvent *event)
|
||||
@@ -252,15 +247,14 @@ void ButtonEditDialog::keyReleaseEvent(QKeyEvent *event)
|
||||
if (ui->actionNameLineEdit->hasFocus() || ui->buttonNameLineEdit->hasFocus())
|
||||
{
|
||||
QDialog::keyReleaseEvent(event);
|
||||
}
|
||||
else if (ui->virtualKeyMouseTabWidget->isKeyboardTabVisible())
|
||||
} else if (ui->virtualKeyMouseTabWidget->isKeyboardTabVisible())
|
||||
{
|
||||
int controlcode = event->nativeScanCode();
|
||||
int virtualactual = event->nativeVirtualKey();
|
||||
|
||||
BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();
|
||||
|
||||
#if defined(WITH_X11)
|
||||
#if defined(WITH_X11)
|
||||
int finalvirtual = 0;
|
||||
int checkalias = 0;
|
||||
|
||||
@@ -277,76 +271,68 @@ void ButtonEditDialog::keyReleaseEvent(QKeyEvent *event)
|
||||
QtKeyMapperBase *x11KeyMapper = AntKeyMapper::getInstance()->getNativeKeyMapper();
|
||||
Q_ASSERT(x11KeyMapper != nullptr);
|
||||
checkalias = x11KeyMapper->returnQtKey(finalvirtual);
|
||||
finalvirtual = AntKeyMapper::getInstance()->returnVirtualKey(checkalias); // Find corresponding Linux input key for the Qt key.
|
||||
finalvirtual = AntKeyMapper::getInstance()->returnVirtualKey(
|
||||
checkalias); // Find corresponding Linux input key for the Qt key.
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
BACKEND_ELSE_IF (handler->getIdentifier() == "xtest")
|
||||
BACKEND_ELSE_IF(handler->getIdentifier() == "xtest")
|
||||
{
|
||||
// Check for alias against group 1 keysym.
|
||||
checkalias = AntKeyMapper::getInstance()->returnQtKey(finalvirtual);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Not running on xcb platform.
|
||||
finalvirtual = controlcode;
|
||||
checkalias = AntKeyMapper::getInstance()->returnQtKey(finalvirtual);
|
||||
}
|
||||
|
||||
#else
|
||||
#else
|
||||
int finalvirtual = 0;
|
||||
int checkalias = 0;
|
||||
if (QApplication::platformName() == QStringLiteral("xcb"))
|
||||
{
|
||||
finalvirtual = AntKeyMapper::getInstance()->returnVirtualKey(event->key());
|
||||
checkalias = AntKeyMapper::getInstance()->returnQtKey(finalvirtual);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Not running on xcb platform.
|
||||
finalvirtual = controlcode;
|
||||
checkalias = AntKeyMapper::getInstance()->returnQtKey(finalvirtual);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (!ignoreRelease && (event->modifiers() & Qt::ControlModifier) && (event->key() == Qt::Key_X))
|
||||
{
|
||||
controlcode = 0;
|
||||
ignoreRelease = true;
|
||||
emit selectionCleared();
|
||||
}
|
||||
else if (!ignoreRelease && (controlcode <= 0))
|
||||
} else if (!ignoreRelease && (controlcode <= 0))
|
||||
{
|
||||
controlcode = 0;
|
||||
}
|
||||
else if (ignoreRelease)
|
||||
} else if (ignoreRelease)
|
||||
{
|
||||
controlcode = 0;
|
||||
ignoreRelease = false;
|
||||
}
|
||||
|
||||
|
||||
if (controlcode > 0 && (checkalias > 0) && (finalvirtual > 0))
|
||||
{
|
||||
JoyButtonSlot *tempslot = new JoyButtonSlot(finalvirtual, checkalias, JoyButtonSlot::JoyKeyboard, this);
|
||||
emit keyGrabbed(tempslot);
|
||||
}
|
||||
else if ((controlcode > 0) && (virtualactual > 0))
|
||||
} else if ((controlcode > 0) && (virtualactual > 0))
|
||||
{
|
||||
JoyButtonSlot *tempslot = new JoyButtonSlot(virtualactual, JoyButtonSlot::JoyKeyboard, this);
|
||||
emit keyGrabbed(tempslot);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QDialog::keyReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QDialog::keyReleaseEvent(event);
|
||||
}
|
||||
@@ -356,25 +342,34 @@ void ButtonEditDialog::refreshSlotSummaryLabel()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (lastJoyButton != nullptr) ui->slotSummaryLabel->setText(lastJoyButton->getSlotsString().replace("&", "&&"));
|
||||
else ui->slotSummaryLabel->setText(tr("No button"));
|
||||
if (lastJoyButton != nullptr)
|
||||
ui->slotSummaryLabel->setText(lastJoyButton->getSlotsString().replace("&", "&&"));
|
||||
else
|
||||
ui->slotSummaryLabel->setText(tr("No button"));
|
||||
}
|
||||
|
||||
|
||||
void ButtonEditDialog::changeToggleSetting()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (lastJoyButton != nullptr) lastJoyButton->setToggle(ui->toggleCheckBox->isChecked());
|
||||
else QMessageBox::information(this, tr("Last button"), tr("To change settings for last button, it must be at least one assignment from keyboard to gamepad"));
|
||||
if (lastJoyButton != nullptr)
|
||||
lastJoyButton->setToggle(ui->toggleCheckBox->isChecked());
|
||||
else
|
||||
QMessageBox::information(
|
||||
this, tr("Last button"),
|
||||
tr("To change settings for last button, it must be at least one assignment from keyboard to gamepad"));
|
||||
}
|
||||
|
||||
void ButtonEditDialog::changeTurboSetting()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (lastJoyButton != nullptr) lastJoyButton->setUseTurbo(ui->turboCheckBox->isChecked());
|
||||
else QMessageBox::information(this, tr("Last button"), tr("To change settings of turbo for last button, it must be at least one assignment from keyboard to gamepad"));
|
||||
if (lastJoyButton != nullptr)
|
||||
lastJoyButton->setUseTurbo(ui->turboCheckBox->isChecked());
|
||||
else
|
||||
QMessageBox::information(
|
||||
this, tr("Last button"),
|
||||
tr("To change settings of turbo for last button, it must be at least one assignment from keyboard to gamepad"));
|
||||
}
|
||||
|
||||
void ButtonEditDialog::openAdvancedDialog()
|
||||
@@ -394,30 +389,41 @@ void ButtonEditDialog::openAdvancedDialog()
|
||||
disconnect(this, &ButtonEditDialog::selectionCleared, nullptr, nullptr);
|
||||
disconnect(this, &ButtonEditDialog::selectionFinished, nullptr, nullptr);
|
||||
|
||||
connect(dialog, &AdvanceButtonDialog::finished, ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::establishVirtualKeyboardSingleSignalConnections);
|
||||
connect(dialog, &AdvanceButtonDialog::finished, ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::establishVirtualMouseSignalConnections);
|
||||
connect(dialog, &AdvanceButtonDialog::finished, ui->virtualKeyMouseTabWidget,
|
||||
&VirtualKeyboardMouseWidget::establishVirtualKeyboardSingleSignalConnections);
|
||||
connect(dialog, &AdvanceButtonDialog::finished, ui->virtualKeyMouseTabWidget,
|
||||
&VirtualKeyboardMouseWidget::establishVirtualMouseSignalConnections);
|
||||
connect(dialog, &AdvanceButtonDialog::finished, this, &ButtonEditDialog::closedAdvancedDialog);
|
||||
connect(dialog, &AdvanceButtonDialog::turboButtonEnabledChange, this, &ButtonEditDialog::setTurboButtonEnabled);
|
||||
|
||||
connect(this, &ButtonEditDialog::sendTempSlotToAdvanced, dialog, &AdvanceButtonDialog::placeNewSlot);
|
||||
connect(this, &ButtonEditDialog::keyGrabbed, dialog, &AdvanceButtonDialog::placeNewSlot);
|
||||
connect(this, &ButtonEditDialog::selectionCleared, dialog, &AdvanceButtonDialog::clearAllSlots);
|
||||
connect(ui->virtualKeyMouseTabWidget, static_cast<void (VirtualKeyboardMouseWidget::*)(JoyButtonSlot*)>(&VirtualKeyboardMouseWidget::selectionMade), dialog, &AdvanceButtonDialog::placeNewSlot);
|
||||
connect(ui->virtualKeyMouseTabWidget, static_cast<void (VirtualKeyboardMouseWidget::*)(int,int)>(&VirtualKeyboardMouseWidget::selectionMade), this, &ButtonEditDialog::createTempSlot);
|
||||
connect(ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::selectionCleared, dialog, &AdvanceButtonDialog::clearAllSlots);
|
||||
connect(ui->virtualKeyMouseTabWidget,
|
||||
static_cast<void (VirtualKeyboardMouseWidget::*)(JoyButtonSlot *)>(
|
||||
&VirtualKeyboardMouseWidget::selectionMade),
|
||||
dialog, &AdvanceButtonDialog::placeNewSlot);
|
||||
connect(ui->virtualKeyMouseTabWidget,
|
||||
static_cast<void (VirtualKeyboardMouseWidget::*)(int, int)>(&VirtualKeyboardMouseWidget::selectionMade),
|
||||
this, &ButtonEditDialog::createTempSlot);
|
||||
connect(ui->virtualKeyMouseTabWidget, &VirtualKeyboardMouseWidget::selectionCleared, dialog,
|
||||
&AdvanceButtonDialog::clearAllSlots);
|
||||
|
||||
connect(this, &ButtonEditDialog::finished, dialog, &AdvanceButtonDialog::close);
|
||||
emit advancedDialogOpened();
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QMessageBox::information(this, tr("No choice"), tr("Before you open window with advanced settins, you have to choice a key"));
|
||||
QMessageBox::information(this, tr("No choice"),
|
||||
tr("Before you open window with advanced settins, you have to choice a key"));
|
||||
}
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
QMessageBox::information(this, tr("Last button"), tr("To open advanced dialog, it's needed to map at least one button from keyboard to gamepad"));
|
||||
QMessageBox::information(
|
||||
this, tr("Last button"),
|
||||
tr("To open advanced dialog, it's needed to map at least one button from keyboard to gamepad"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,8 +431,7 @@ void ButtonEditDialog::createTempSlot(int keycode, int alias)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyButtonSlot *slot = new JoyButtonSlot(keycode, alias,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
JoyButtonSlot *slot = new JoyButtonSlot(keycode, alias, JoyButtonSlot::JoyKeyboard, this);
|
||||
emit sendTempSlotToAdvanced(slot);
|
||||
}
|
||||
|
||||
@@ -434,14 +439,14 @@ void ButtonEditDialog::checkTurboSetting(bool state)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (lastJoyButton != nullptr) {
|
||||
if (lastJoyButton != nullptr)
|
||||
{
|
||||
|
||||
if (lastJoyButton->containsSequence())
|
||||
{
|
||||
ui->turboCheckBox->setChecked(false);
|
||||
ui->turboCheckBox->setEnabled(false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->turboCheckBox->setChecked(state);
|
||||
ui->turboCheckBox->setEnabled(true);
|
||||
@@ -462,13 +467,14 @@ void ButtonEditDialog::closedAdvancedDialog()
|
||||
|
||||
refreshForLastBtn();
|
||||
|
||||
disconnect(ui->virtualKeyMouseTabWidget, static_cast<void (VirtualKeyboardMouseWidget::*)(int,int)>(&VirtualKeyboardMouseWidget::selectionMade), this, nullptr);
|
||||
disconnect(ui->virtualKeyMouseTabWidget,
|
||||
static_cast<void (VirtualKeyboardMouseWidget::*)(int, int)>(&VirtualKeyboardMouseWidget::selectionMade), this,
|
||||
nullptr);
|
||||
|
||||
// Re-connect previously disconnected event
|
||||
connect(this, &ButtonEditDialog::keyGrabbed, this, &ButtonEditDialog::processSlotAssignment);
|
||||
connect(this, &ButtonEditDialog::selectionCleared, this, &ButtonEditDialog::clearButtonSlots);
|
||||
connect(this, &ButtonEditDialog::selectionCleared, this, &ButtonEditDialog::sendSelectionFinished);
|
||||
|
||||
}
|
||||
|
||||
void ButtonEditDialog::processSlotAssignment(JoyButtonSlot *tempslot)
|
||||
@@ -477,9 +483,10 @@ void ButtonEditDialog::processSlotAssignment(JoyButtonSlot *tempslot)
|
||||
|
||||
if (withoutQuickSetDialog)
|
||||
{
|
||||
invokeMethodLastBtn(lastJoyButton, &helper, "setAssignedSlot", tempslot->getSlotCode(), tempslot->getSlotCodeAlias(), -1, tempslot->getSlotMode(), false, false, Qt::QueuedConnection, Qt::QueuedConnection, Qt::QueuedConnection);
|
||||
}
|
||||
else
|
||||
invokeMethodLastBtn(lastJoyButton, &helper, "setAssignedSlot", tempslot->getSlotCode(), tempslot->getSlotCodeAlias(),
|
||||
-1, tempslot->getSlotMode(), false, false, Qt::QueuedConnection, Qt::QueuedConnection,
|
||||
Qt::QueuedConnection);
|
||||
} else
|
||||
{
|
||||
if ((currentQuickDialog == nullptr) && (!buttonEventInterval.isValid() || (buttonEventInterval.elapsed() > 1000)))
|
||||
{
|
||||
@@ -488,10 +495,14 @@ void ButtonEditDialog::processSlotAssignment(JoyButtonSlot *tempslot)
|
||||
// it's good for oversensitive buttons and axes, which can
|
||||
// create QuickSetDialog windows many times for one key
|
||||
|
||||
if (!buttonEventInterval.isValid()) buttonEventInterval.start();
|
||||
else buttonEventInterval.restart();
|
||||
if (!buttonEventInterval.isValid())
|
||||
buttonEventInterval.start();
|
||||
else
|
||||
buttonEventInterval.restart();
|
||||
|
||||
currentQuickDialog = new QuickSetDialog(joystick, &helper, "setAssignedSlot", tempslot->getSlotCode(), tempslot->getSlotCodeAlias(), -1, tempslot->getSlotMode(), false, false, this);
|
||||
currentQuickDialog =
|
||||
new QuickSetDialog(joystick, &helper, "setAssignedSlot", tempslot->getSlotCode(),
|
||||
tempslot->getSlotCodeAlias(), -1, tempslot->getSlotMode(), false, false, this);
|
||||
currentQuickDialog->show();
|
||||
connect(currentQuickDialog, &QuickSetDialog::finished, this, &ButtonEditDialog::nullifyDialogPointer);
|
||||
}
|
||||
@@ -507,8 +518,9 @@ void ButtonEditDialog::clearButtonSlots()
|
||||
if (lastJoyButton != nullptr)
|
||||
QMetaObject::invokeMethod(lastJoyButton, "clearSlotsEventReset", Q_ARG(bool, false));
|
||||
else
|
||||
QMessageBox::information(this, tr("Last button"), tr("Slots for button couldn't be cleared, because there was not any set button from keyboard for gamepad. Map at least one button from keyboard to gamepad"));
|
||||
|
||||
QMessageBox::information(this, tr("Last button"),
|
||||
tr("Slots for button couldn't be cleared, because there was not any set button from "
|
||||
"keyboard for gamepad. Map at least one button from keyboard to gamepad"));
|
||||
}
|
||||
|
||||
void ButtonEditDialog::sendSelectionFinished()
|
||||
@@ -522,9 +534,13 @@ void ButtonEditDialog::updateWindowTitleButtonName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (lastJoyButton != nullptr) {
|
||||
if (lastJoyButton != nullptr)
|
||||
{
|
||||
|
||||
QString temp = QString(tr("As last gamepad button has been set")).append(" \"").append(lastJoyButton->getPartialName(false, true)).append("\" ");
|
||||
QString temp = QString(tr("As last gamepad button has been set"))
|
||||
.append(" \"")
|
||||
.append(lastJoyButton->getPartialName(false, true))
|
||||
.append("\" ");
|
||||
|
||||
if (lastJoyButton->getParentSet()->getIndex() != 0)
|
||||
{
|
||||
@@ -532,20 +548,21 @@ void ButtonEditDialog::updateWindowTitleButtonName()
|
||||
temp.append(" [").append(tr("Index %1").arg(setIndex));
|
||||
QString setName = lastJoyButton->getParentSet()->getName();
|
||||
|
||||
if (!setName.isEmpty()) temp.append(": ").append(setName);
|
||||
if (!setName.isEmpty())
|
||||
temp.append(": ").append(setName);
|
||||
|
||||
temp.append("]");
|
||||
}
|
||||
|
||||
setWindowTitle(temp);
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
setWindowTitle(tr("Choose your keyboard key"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ButtonEditDialog::nullifyDialogPointer()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -560,10 +577,11 @@ void ButtonEditDialog::nullifyDialogPointer()
|
||||
refreshForLastBtn();
|
||||
}
|
||||
|
||||
void ButtonEditDialog::refreshForLastBtn()
|
||||
{
|
||||
|
||||
void ButtonEditDialog::refreshForLastBtn() {
|
||||
|
||||
if (lastJoyButton != nullptr) {
|
||||
if (lastJoyButton != nullptr)
|
||||
{
|
||||
|
||||
ui->slotSummaryLabel->setText(lastJoyButton->getSlotsString());
|
||||
|
||||
@@ -578,9 +596,10 @@ void ButtonEditDialog::refreshForLastBtn() {
|
||||
if (!lastJoyButton->getButtonName().isEmpty())
|
||||
ui->buttonNameLineEdit->setText(lastJoyButton->getButtonName());
|
||||
|
||||
if (lastJoyButton != nullptr) {
|
||||
if (lastJoyButton != nullptr)
|
||||
{
|
||||
|
||||
QListIterator<JoyButtonSlot*> iter(*(lastJoyButton->getAssignedSlots()));
|
||||
QListIterator<JoyButtonSlot *> iter(*(lastJoyButton->getAssignedSlots()));
|
||||
|
||||
ui->virtualKeyMouseTabWidget->disableMouseSettingButton();
|
||||
|
||||
@@ -588,7 +607,7 @@ void ButtonEditDialog::refreshForLastBtn() {
|
||||
{
|
||||
JoyButtonSlot *buttonslot = iter.next();
|
||||
|
||||
switch(buttonslot->getSlotMode())
|
||||
switch (buttonslot->getSlotMode())
|
||||
{
|
||||
case JoyButtonSlot::JoyMouseMovement:
|
||||
case JoyButtonSlot::JoyMouseButton:
|
||||
@@ -598,7 +617,6 @@ void ButtonEditDialog::refreshForLastBtn() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,13 +630,16 @@ void ButtonEditDialog::refreshForLastBtn() {
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
void ButtonEditDialog::invokeMethodLastBtn(JoyButton* lastJoyBtn, ButtonEditDialogHelper* helper, const char* invokeString, int code, int alias, int index, JoyButtonSlot::JoySlotInputAction mode, bool withClear, bool withTrue, Qt::ConnectionType connTypeForAlias, Qt::ConnectionType connTypeForNothing, Qt::ConnectionType connTypeForAll)
|
||||
void ButtonEditDialog::invokeMethodLastBtn(JoyButton *lastJoyBtn, ButtonEditDialogHelper *helper, const char *invokeString,
|
||||
int code, int alias, int index, JoyButtonSlot::JoySlotInputAction mode,
|
||||
bool withClear, bool withTrue, Qt::ConnectionType connTypeForAlias,
|
||||
Qt::ConnectionType connTypeForNothing, Qt::ConnectionType connTypeForAll)
|
||||
{
|
||||
QPointer<JoyButton> lastBtn = lastJoyBtn;
|
||||
if (helper != nullptr) helper = new ButtonEditDialogHelper();
|
||||
if (helper != nullptr)
|
||||
helper = new ButtonEditDialogHelper();
|
||||
|
||||
QPointer<ButtonEditDialogHelper> btnEditDHelper = helper;
|
||||
|
||||
@@ -627,56 +648,45 @@ void ButtonEditDialog::invokeMethodLastBtn(JoyButton* lastJoyBtn, ButtonEditDial
|
||||
helper->setThisButton(lastJoyBtn);
|
||||
helper->moveToThread(lastJoyBtn->thread());
|
||||
|
||||
|
||||
qDebug() << "Thread in QuickSetDialog";
|
||||
|
||||
|
||||
if (withClear) QMetaObject::invokeMethod(lastJoyBtn, "clearSlotsEventReset", Q_ARG(bool, withTrue));
|
||||
if (withClear)
|
||||
QMetaObject::invokeMethod(lastJoyBtn, "clearSlotsEventReset", Q_ARG(bool, withTrue));
|
||||
|
||||
// when alias exists but not index
|
||||
if ((alias != -1) && (index == -1)) {
|
||||
if ((alias != -1) && (index == -1))
|
||||
{
|
||||
|
||||
QMetaObject::invokeMethod(helper, invokeString, connTypeForAlias,
|
||||
Q_ARG(int, code),
|
||||
Q_ARG(int, alias),
|
||||
QMetaObject::invokeMethod(helper, invokeString, connTypeForAlias, Q_ARG(int, code), Q_ARG(int, alias),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, mode));
|
||||
|
||||
// when alias doesn't exists and index too
|
||||
} else if ((alias == -1) && (index == -1)) {
|
||||
} else if ((alias == -1) && (index == -1))
|
||||
{
|
||||
|
||||
QMetaObject::invokeMethod(helper, invokeString, connTypeForNothing,
|
||||
Q_ARG(int, code),
|
||||
QMetaObject::invokeMethod(helper, invokeString, connTypeForNothing, Q_ARG(int, code),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, mode));
|
||||
|
||||
// when all exist (code, alias, index)
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
if (lastJoyBtn->isPartVDPad()) connTypeForAll = Qt::BlockingQueuedConnection;
|
||||
if (lastJoyBtn->isPartVDPad())
|
||||
connTypeForAll = Qt::BlockingQueuedConnection;
|
||||
|
||||
QMetaObject::invokeMethod(helper, invokeString, connTypeForAll,
|
||||
Q_ARG(int, code),
|
||||
Q_ARG(int, alias),
|
||||
Q_ARG(int, index),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, mode));
|
||||
QMetaObject::invokeMethod(helper, invokeString, connTypeForAll, Q_ARG(int, code), Q_ARG(int, alias),
|
||||
Q_ARG(int, index), Q_ARG(JoyButtonSlot::JoySlotInputAction, mode));
|
||||
}
|
||||
}
|
||||
|
||||
if (lastBtn.isNull()) lastBtn.clear();
|
||||
if (btnEditDHelper.isNull()) btnEditDHelper.clear();
|
||||
if (lastBtn.isNull())
|
||||
lastBtn.clear();
|
||||
if (btnEditDHelper.isNull())
|
||||
btnEditDHelper.clear();
|
||||
}
|
||||
|
||||
JoyButton *ButtonEditDialog::getLastJoyButton() { return lastJoyButton; }
|
||||
|
||||
JoyButton* ButtonEditDialog::getLastJoyButton() {
|
||||
void ButtonEditDialog::setUpLastJoyButton(JoyButton *newButton) { lastJoyButton = newButton; }
|
||||
|
||||
return lastJoyButton;
|
||||
}
|
||||
|
||||
void ButtonEditDialog::setUpLastJoyButton(JoyButton * newButton) {
|
||||
|
||||
lastJoyButton = newButton;
|
||||
}
|
||||
|
||||
ButtonEditDialogHelper& ButtonEditDialog::getHelperLocal() {
|
||||
|
||||
return helper;
|
||||
}
|
||||
ButtonEditDialogHelper &ButtonEditDialog::getHelperLocal() { return helper; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BUTTONEDITDIALOGTWO_H
|
||||
#define BUTTONEDITDIALOGTWO_H
|
||||
|
||||
@@ -39,27 +38,31 @@ class ButtonEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ButtonEditDialog(JoyButton* button, InputDevice* joystick, bool isNumKeypad, QWidget *parent = nullptr); // called for chosen button
|
||||
explicit ButtonEditDialog(InputDevice* joystick, bool isNumKeypad, QWidget *parent = nullptr); // Accessed by pressing the "Quick Set" button
|
||||
public:
|
||||
explicit ButtonEditDialog(JoyButton *button, InputDevice *joystick, bool isNumKeypad,
|
||||
QWidget *parent = nullptr); // called for chosen button
|
||||
explicit ButtonEditDialog(InputDevice *joystick, bool isNumKeypad,
|
||||
QWidget *parent = nullptr); // Accessed by pressing the "Quick Set" button
|
||||
ButtonEditDialog(QWidget *parent = 0);
|
||||
~ButtonEditDialog();
|
||||
|
||||
static ButtonEditDialog* getInstance();
|
||||
JoyButton* getLastJoyButton();
|
||||
void setUpLastJoyButton(JoyButton*);
|
||||
static ButtonEditDialog *getInstance();
|
||||
JoyButton *getLastJoyButton();
|
||||
void setUpLastJoyButton(JoyButton *);
|
||||
void refreshForLastBtn();
|
||||
void invokeMethodLastBtn(JoyButton* lastJoyBtn, ButtonEditDialogHelper* helper, const char* invokeString, int code, int alias, int index, JoyButtonSlot::JoySlotInputAction mode, bool withClear, bool withTrue, Qt::ConnectionType connTypeForAlias, Qt::ConnectionType connTypeForNothing, Qt::ConnectionType connTypeForAll);
|
||||
void invokeMethodLastBtn(JoyButton *lastJoyBtn, ButtonEditDialogHelper *helper, const char *invokeString, int code,
|
||||
int alias, int index, JoyButtonSlot::JoySlotInputAction mode, bool withClear, bool withTrue,
|
||||
Qt::ConnectionType connTypeForAlias, Qt::ConnectionType connTypeForNothing,
|
||||
Qt::ConnectionType connTypeForAll);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void keyReleaseEvent(QKeyEvent *event);
|
||||
virtual void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
ButtonEditDialogHelper helper;
|
||||
Ui::ButtonEditDialog *ui;
|
||||
ButtonEditDialogHelper& getHelperLocal();
|
||||
ButtonEditDialogHelper &getHelperLocal();
|
||||
|
||||
QElapsedTimer buttonEventInterval;
|
||||
InputDevice *joystick;
|
||||
@@ -67,11 +70,11 @@ private:
|
||||
bool ignoreRelease;
|
||||
bool withoutQuickSetDialog;
|
||||
bool m_isNumKeypad;
|
||||
JoyButton* lastJoyButton;
|
||||
JoyButton *lastJoyButton;
|
||||
|
||||
static ButtonEditDialog *instance;
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void advancedDialogOpened();
|
||||
void sendTempSlotToAdvanced(JoyButtonSlot *tempslot);
|
||||
void keyGrabbed(JoyButtonSlot *tempslot);
|
||||
@@ -79,7 +82,7 @@ signals:
|
||||
void selectionFinished();
|
||||
void buttonDialogClosed();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void nullifyDialogPointer();
|
||||
void refreshSlotSummaryLabel();
|
||||
void changeToggleSetting();
|
||||
|
||||
@@ -19,36 +19,34 @@
|
||||
#include "ui_calibration.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joybuttontypes/joycontrolstickmodifierbutton.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "joytabwidget.h"
|
||||
#include "inputdevice.h"
|
||||
#include "messagehandler.h"
|
||||
#include "joybuttontypes/joycontrolstickmodifierbutton.h"
|
||||
|
||||
#include <SDL2/SDL_joystick.h>
|
||||
|
||||
#include <QtConcurrent>
|
||||
#include <QFuture>
|
||||
#include <QTabWidget>
|
||||
#include <QProgressBar>
|
||||
#include <QMessageBox>
|
||||
#include <QLayoutItem>
|
||||
#include <QPointer>
|
||||
#include <QDebug>
|
||||
#include <QFuture>
|
||||
#include <QLayoutItem>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QProgressBar>
|
||||
#include <QTabWidget>
|
||||
#include <QtConcurrent>
|
||||
|
||||
|
||||
|
||||
Calibration::Calibration(InputDevice* joystick, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Calibration),
|
||||
currentJoystick(joystick),
|
||||
helper(currentJoystick->getActiveSetJoystick()->getJoyStick(0))
|
||||
Calibration::Calibration(InputDevice *joystick, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::Calibration)
|
||||
, currentJoystick(joystick)
|
||||
, helper(currentJoystick->getActiveSetJoystick()->getJoyStick(0))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
setAttribute( Qt::WA_DeleteOnClose, true );
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
setWindowTitle(tr("Calibration"));
|
||||
|
||||
sumX = 0;
|
||||
@@ -87,8 +85,8 @@ Calibration::Calibration(InputDevice* joystick, QWidget *parent) :
|
||||
if (controlstick.isNull())
|
||||
controlstick.clear();
|
||||
|
||||
QList<JoyControlStick*> sticksList = currentJoystick->getActiveSetJoystick()->getSticks().values();
|
||||
QListIterator<JoyControlStick*> currStick(sticksList);
|
||||
QList<JoyControlStick *> sticksList = currentJoystick->getActiveSetJoystick()->getSticks().values();
|
||||
QListIterator<JoyControlStick *> currStick(sticksList);
|
||||
|
||||
while (currStick.hasNext())
|
||||
{
|
||||
@@ -98,17 +96,14 @@ Calibration::Calibration(InputDevice* joystick, QWidget *parent) :
|
||||
connect(currentJoystick, &InputDevice::destroyed, this, &Calibration::close);
|
||||
connect(ui->saveBtn, &QPushButton::clicked, this, &Calibration::saveSettings);
|
||||
connect(ui->cancelBtn, &QPushButton::clicked, this, &Calibration::close);
|
||||
connect(ui->axesBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Calibration::createAxesConnection);
|
||||
connect(ui->axesBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&Calibration::createAxesConnection);
|
||||
connect(ui->startButton, &QPushButton::clicked, this, &Calibration::startCalibration);
|
||||
connect(ui->resetBtn, &QPushButton::clicked, [this](bool clicked)
|
||||
{
|
||||
resetSettings(false, clicked);
|
||||
});
|
||||
connect(ui->resetBtn, &QPushButton::clicked, [this](bool clicked) { resetSettings(false, clicked); });
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Calibration::~Calibration()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -122,13 +117,14 @@ Calibration::~Calibration()
|
||||
*/
|
||||
void Calibration::resetSettings(bool silentReset, bool)
|
||||
{
|
||||
if (!silentReset) {
|
||||
if (!silentReset)
|
||||
{
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Do you really want to reset settings of current axis?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
switch(msgBox.exec())
|
||||
switch (msgBox.exec())
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
restoreCalValues();
|
||||
@@ -141,8 +137,7 @@ void Calibration::resetSettings(bool silentReset, bool)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
restoreCalValues();
|
||||
ui->steps->clear();
|
||||
@@ -205,46 +200,41 @@ void Calibration::restoreCalValues()
|
||||
* @param min value for Y - negative value
|
||||
* @return Nothing
|
||||
*/
|
||||
void Calibration::setQuadraticZoneCalibrated(int &max_axis_val_x, int &min_axis_val_x, int &max_axis_val_y, int &min_axis_val_y) {
|
||||
void Calibration::setQuadraticZoneCalibrated(int &max_axis_val_x, int &min_axis_val_x, int &max_axis_val_y,
|
||||
int &min_axis_val_y)
|
||||
{
|
||||
|
||||
if (max_axis_val_x > abs(min_axis_val_x)) max_axis_val_x = abs(min_axis_val_x);
|
||||
else min_axis_val_x = -(max_axis_val_x);
|
||||
if (max_axis_val_x > abs(min_axis_val_x))
|
||||
max_axis_val_x = abs(min_axis_val_x);
|
||||
else
|
||||
min_axis_val_x = -(max_axis_val_x);
|
||||
|
||||
if (max_axis_val_y > abs(min_axis_val_y)) max_axis_val_y = abs(min_axis_val_y);
|
||||
else min_axis_val_y = -(max_axis_val_y);
|
||||
if (max_axis_val_y > abs(min_axis_val_y))
|
||||
max_axis_val_y = abs(min_axis_val_y);
|
||||
else
|
||||
min_axis_val_y = -(max_axis_val_y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Moves deadzone position after changing center position of axes
|
||||
* @return Moved deadzone position
|
||||
*/
|
||||
int Calibration::calibratedDeadZone(int center, int deadzone)
|
||||
{
|
||||
return (center + deadzone);
|
||||
}
|
||||
int Calibration::calibratedDeadZone(int center, int deadzone) { return (center + deadzone); }
|
||||
|
||||
int Calibration::fakeMapFunc(const int &x) { return x; }
|
||||
|
||||
int Calibration::fakeMapFunc(const int &x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
void Calibration::summarizeValues(int &numbFromList, const int &mappednumb)
|
||||
{
|
||||
numbFromList += mappednumb;
|
||||
}
|
||||
|
||||
void Calibration::summarizeValues(int &numbFromList, const int &mappednumb) { numbFromList += mappednumb; }
|
||||
|
||||
void Calibration::getMinVal(int &numbFromList, const int &mappednumb)
|
||||
{
|
||||
if (numbFromList > mappednumb) numbFromList = mappednumb;
|
||||
if (numbFromList > mappednumb)
|
||||
numbFromList = mappednumb;
|
||||
}
|
||||
|
||||
|
||||
void Calibration::getMaxVal(int &numbFromList, const int &mappednumb)
|
||||
{
|
||||
if (numbFromList < mappednumb) numbFromList = mappednumb;
|
||||
if (numbFromList < mappednumb)
|
||||
numbFromList = mappednumb;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,13 +247,14 @@ void Calibration::startCalibration()
|
||||
|
||||
bool confirmed = true;
|
||||
|
||||
if (stick->wasCalibrated()) {
|
||||
if (stick->wasCalibrated())
|
||||
{
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Calibration was saved for the preset. Do you really want to reset settings?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
|
||||
switch(msgBox.exec())
|
||||
switch (msgBox.exec())
|
||||
{
|
||||
case QMessageBox::Ok:
|
||||
confirmed = true;
|
||||
@@ -278,8 +269,7 @@ void Calibration::startCalibration()
|
||||
confirmed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
center_calibrated_x = 0;
|
||||
center_calibrated_y = 0;
|
||||
@@ -295,8 +285,8 @@ void Calibration::startCalibration()
|
||||
y_es_val.clear();
|
||||
}
|
||||
|
||||
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr) && confirmed) {
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr) && confirmed)
|
||||
{
|
||||
|
||||
center_calibrated_x = 0;
|
||||
center_calibrated_y = 0;
|
||||
@@ -314,7 +304,8 @@ void Calibration::startCalibration()
|
||||
stick->setCalibrationFlag(false);
|
||||
calibrated = false;
|
||||
|
||||
ui->steps->setText(tr("Place the joystick in the center position.\n\nIt's the part, where often you don't have to move. Just skip it in such situation."));
|
||||
ui->steps->setText(tr("Place the joystick in the center position.\n\nIt's the part, where often you don't have to "
|
||||
"move. Just skip it in such situation."));
|
||||
this->setWindowTitle(tr("Calibrating center"));
|
||||
ui->startButton->setText(tr("Start second step"));
|
||||
update();
|
||||
@@ -327,13 +318,14 @@ void Calibration::startCalibration()
|
||||
QFuture<int> resY = QtConcurrent::mappedReduced(yValues, &Calibration::fakeMapFunc, &Calibration::summarizeValues);
|
||||
sumY = resY.result();
|
||||
|
||||
|
||||
if ((sumX != 0) && (sumY != 0)) {
|
||||
if ((sumX != 0) && (sumY != 0))
|
||||
{
|
||||
|
||||
center_calibrated_x = sumX / x_es_val.count();
|
||||
center_calibrated_y = sumY / y_es_val.count();
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
center_calibrated_x = 0;
|
||||
center_calibrated_y = 0;
|
||||
@@ -364,7 +356,8 @@ void Calibration::startSecondStep()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr)) {
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr))
|
||||
{
|
||||
|
||||
ui->steps->setText(tr("\nPlace the joystick in the top-left corner many times"));
|
||||
this->setWindowTitle(tr("Calibrating position"));
|
||||
@@ -373,8 +366,8 @@ void Calibration::startSecondStep()
|
||||
qDebug() << "X_ES_VAL: " << x_es_val.count(QString("-"));
|
||||
qDebug() << "Y_ES_VAL: " << y_es_val.count(QString("-"));
|
||||
|
||||
|
||||
if (enoughProb(x_es_val.count(QString("-")), y_es_val.count(QString("-")), QString("-"))) {
|
||||
if (enoughProb(x_es_val.count(QString("-")), y_es_val.count(QString("-")), QString("-")))
|
||||
{
|
||||
|
||||
int min_x = 0;
|
||||
int min_y = 0;
|
||||
@@ -404,7 +397,6 @@ void Calibration::startSecondStep()
|
||||
update();
|
||||
disconnect(ui->startButton, &QPushButton::clicked, this, nullptr);
|
||||
connect(ui->startButton, &QPushButton::clicked, this, &Calibration::startLastStep);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -417,14 +409,16 @@ void Calibration::startLastStep()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr)) {
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr))
|
||||
{
|
||||
|
||||
ui->steps->setText(tr("\nPlace the joystick in the bottom-right corner"));
|
||||
this->setWindowTitle(tr("Calibrating position"));
|
||||
ui->startButton->setText(tr("Start final step"));
|
||||
update();
|
||||
|
||||
if (enoughProb(x_es_val.count(QString("+")), y_es_val.count(QString("+")), QString("+"))) {
|
||||
if (enoughProb(x_es_val.count(QString("+")), y_es_val.count(QString("+")), QString("+")))
|
||||
{
|
||||
|
||||
int max_x = 0;
|
||||
int max_y = 0;
|
||||
@@ -449,8 +443,8 @@ void Calibration::startLastStep()
|
||||
|
||||
setQuadraticZoneCalibrated(max_axis_val_x, min_axis_val_x, max_axis_val_y, min_axis_val_y);
|
||||
|
||||
deadzone_calibrated_x = (max_axis_val_y + max_axis_val_x)/4;
|
||||
deadzone_calibrated_y = (max_axis_val_y + max_axis_val_x)/4;
|
||||
deadzone_calibrated_x = (max_axis_val_y + max_axis_val_x) / 4;
|
||||
deadzone_calibrated_y = (max_axis_val_y + max_axis_val_x) / 4;
|
||||
|
||||
QString text3 = ui->Informations->text();
|
||||
text3.append(tr("\n\nrange X: %1 - %2").arg(min_axis_val_x).arg(max_axis_val_x));
|
||||
@@ -477,7 +471,6 @@ void Calibration::startLastStep()
|
||||
|
||||
disconnect(ui->startButton, &QPushButton::clicked, this, nullptr);
|
||||
connect(ui->startButton, &QPushButton::clicked, this, &Calibration::startCalibration);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -490,7 +483,8 @@ void Calibration::saveSettings()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr)) {
|
||||
if ((joyAxisX != nullptr) && (joyAxisY != nullptr))
|
||||
{
|
||||
|
||||
joyAxisX->setAxisCenterCal(center_calibrated_x);
|
||||
joyAxisY->setAxisCenterCal(center_calibrated_y);
|
||||
@@ -536,16 +530,18 @@ bool Calibration::enoughProb(int x_count, int y_count, QString character)
|
||||
|
||||
bool enough = true;
|
||||
|
||||
if ((x_count < 5) || (y_count < 5)) {
|
||||
if ((x_count < 5) || (y_count < 5))
|
||||
{
|
||||
if (character == QString("-"))
|
||||
{
|
||||
enough = false;
|
||||
QMessageBox::information(this, tr("Dead zone calibration"), tr("You have to move axes to the top-left corner at least five times."));
|
||||
}
|
||||
else if (character == QString("+"))
|
||||
QMessageBox::information(this, tr("Dead zone calibration"),
|
||||
tr("You have to move axes to the top-left corner at least five times."));
|
||||
} else if (character == QString("+"))
|
||||
{
|
||||
enough = false;
|
||||
QMessageBox::information(this, tr("Dead zone calibration"), tr("You have to move axes to the bottom-right corner at least five times."));
|
||||
QMessageBox::information(this, tr("Dead zone calibration"),
|
||||
tr("You have to move axes to the bottom-right corner at least five times."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,15 +560,16 @@ int Calibration::chooseMinMax(QString min_max_sign, QList<int> ax_values)
|
||||
|
||||
int min_max = 0;
|
||||
|
||||
foreach(int val, ax_values)
|
||||
foreach (int val, ax_values)
|
||||
{
|
||||
if (min_max_sign == QString("+"))
|
||||
{
|
||||
if (min_max < val) min_max = val;
|
||||
}
|
||||
else
|
||||
if (min_max < val)
|
||||
min_max = val;
|
||||
} else
|
||||
{
|
||||
if (min_max > val) min_max = val;
|
||||
if (min_max > val)
|
||||
min_max = val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,10 +585,14 @@ void Calibration::checkX(int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (value > 0) {
|
||||
if (x_es_val.count(QString("+")) <= 100) x_es_val.insert(QString("+"), value);
|
||||
} else if (value < 0) {
|
||||
if (x_es_val.count(QString("-")) <= 100) x_es_val.insert(QString("-"), value);
|
||||
if (value > 0)
|
||||
{
|
||||
if (x_es_val.count(QString("+")) <= 100)
|
||||
x_es_val.insert(QString("+"), value);
|
||||
} else if (value < 0)
|
||||
{
|
||||
if (x_es_val.count(QString("-")) <= 100)
|
||||
x_es_val.insert(QString("-"), value);
|
||||
}
|
||||
|
||||
axisBarX->setValue(value);
|
||||
@@ -607,12 +608,14 @@ void Calibration::checkY(int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (value > 0) {
|
||||
if (value > 0)
|
||||
{
|
||||
|
||||
if (y_es_val.count(QString("+")) <= 100)
|
||||
y_es_val.insert(QString("+"), value);
|
||||
|
||||
} else if (value < 0) {
|
||||
} else if (value < 0)
|
||||
{
|
||||
|
||||
if (y_es_val.count(QString("-")) <= 100)
|
||||
y_es_val.insert(QString("-"), value);
|
||||
@@ -631,8 +634,8 @@ void Calibration::updateAxesBox()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
ui->axesBox->clear();
|
||||
QList<JoyControlStick*> sticksList = currentJoystick->getActiveSetJoystick()->getSticks().values();
|
||||
QListIterator<JoyControlStick*> currStick(sticksList);
|
||||
QList<JoyControlStick *> sticksList = currentJoystick->getActiveSetJoystick()->getSticks().values();
|
||||
QListIterator<JoyControlStick *> currStick(sticksList);
|
||||
|
||||
while (currStick.hasNext())
|
||||
{
|
||||
@@ -650,13 +653,14 @@ void Calibration::createAxesConnection()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (ui->saveBtn->isEnabled()) {
|
||||
if (ui->saveBtn->isEnabled())
|
||||
{
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Do you want to save calibration of current axis?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
switch(msgBox.exec())
|
||||
switch (msgBox.exec())
|
||||
{
|
||||
case QMessageBox::Yes:
|
||||
saveSettings();
|
||||
@@ -667,15 +671,16 @@ void Calibration::createAxesConnection()
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
while(!ui->progressBarsLayout->isEmpty()) {
|
||||
while (!ui->progressBarsLayout->isEmpty())
|
||||
{
|
||||
|
||||
QLayout *hb = ui->progressBarsLayout->takeAt(0)->layout();
|
||||
|
||||
while(!hb->isEmpty()) {
|
||||
while (!hb->isEmpty())
|
||||
{
|
||||
|
||||
QWidget *w = hb->takeAt(0)->widget();
|
||||
delete w;
|
||||
@@ -686,7 +691,8 @@ void Calibration::createAxesConnection()
|
||||
|
||||
update();
|
||||
|
||||
QPointer<JoyControlStick> controlstick = currentJoystick->getActiveSetJoystick()->getJoyStick(ui->axesBox->currentIndex());
|
||||
QPointer<JoyControlStick> controlstick =
|
||||
currentJoystick->getActiveSetJoystick()->getJoyStick(ui->axesBox->currentIndex());
|
||||
this->stick = controlstick.data();
|
||||
|
||||
center_calibrated_x = controlstick->getAxisX()->getAxisCenterCal();
|
||||
@@ -704,8 +710,10 @@ void Calibration::createAxesConnection()
|
||||
calibrated = controlstick->wasCalibrated();
|
||||
text = controlstick->getCalibrationSummary();
|
||||
|
||||
if (calibrated) ui->resetBtn->setEnabled(true);
|
||||
else ui->resetBtn->setEnabled(false);
|
||||
if (calibrated)
|
||||
ui->resetBtn->setEnabled(true);
|
||||
else
|
||||
ui->resetBtn->setEnabled(false);
|
||||
|
||||
controlstick.data()->getModifierButton()->establishPropertyUpdatedConnections();
|
||||
helper.moveToThread(controlstick.data()->thread());
|
||||
@@ -715,7 +723,8 @@ void Calibration::createAxesConnection()
|
||||
|
||||
update();
|
||||
|
||||
if (controlstick.isNull()) controlstick.clear();
|
||||
if (controlstick.isNull())
|
||||
controlstick.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -723,7 +732,7 @@ void Calibration::createAxesConnection()
|
||||
* @param pointer to stick
|
||||
* @return nothing
|
||||
*/
|
||||
void Calibration::setProgressBars(JoyControlStick* controlstick)
|
||||
void Calibration::setProgressBars(JoyControlStick *controlstick)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -770,7 +779,6 @@ void Calibration::setProgressBars(JoyControlStick* controlstick)
|
||||
|
||||
connect(joyAxisX, &JoyAxis::moved, this, &Calibration::checkX);
|
||||
connect(joyAxisY, &JoyAxis::moved, this, &Calibration::checkY);
|
||||
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -787,8 +795,8 @@ void Calibration::setProgressBars(int setJoyNr, int stickNr)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyControlStick* controlstick = currentJoystick->getActiveSetJoystick()->getJoyStick(stickNr);
|
||||
//helper.moveToThread(controlstick->thread());
|
||||
JoyControlStick *controlstick = currentJoystick->getActiveSetJoystick()->getJoyStick(stickNr);
|
||||
// helper.moveToThread(controlstick->thread());
|
||||
|
||||
joyAxisX = controlstick->getAxisX();
|
||||
joyAxisY = controlstick->getAxisY();
|
||||
@@ -833,7 +841,6 @@ void Calibration::setProgressBars(int setJoyNr, int stickNr)
|
||||
|
||||
connect(joyAxisX, &JoyAxis::moved, this, &Calibration::checkX);
|
||||
connect(joyAxisY, &JoyAxis::moved, this, &Calibration::checkY);
|
||||
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CALIBRATION_H
|
||||
#define CALIBRATION_H
|
||||
|
||||
@@ -25,7 +24,6 @@
|
||||
|
||||
#include <QProgressBar>
|
||||
|
||||
|
||||
class JoyControlStick;
|
||||
class InputDevice;
|
||||
|
||||
@@ -37,23 +35,22 @@ class Calibration : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Calibration(InputDevice* joystick, QWidget *parent = 0);
|
||||
public:
|
||||
explicit Calibration(InputDevice *joystick, QWidget *parent = 0);
|
||||
~Calibration();
|
||||
|
||||
int chooseMinMax(QString min_max_sign, QList<int> ax_values);
|
||||
void setQuadraticZoneCalibrated(int &max_axis_val_x, int &min_axis_val_x, int &max_axis_val_y, int &min_axis_val_y);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void setProgressBars(int setJoyNr, int stickNr);
|
||||
void setProgressBars(JoyControlStick* controlstick);
|
||||
void setProgressBars(JoyControlStick *controlstick);
|
||||
void updateAxesBox();
|
||||
void restoreCalValues();
|
||||
bool enoughProb(int x_count, int y_count, QString character);
|
||||
int calibratedDeadZone(int center, int deadzone);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
static int fakeMapFunc(const int &x);
|
||||
static void summarizeValues(int &numbFromList, const int &mappednumb);
|
||||
static void getMinVal(int &numbFromList, const int &mappednumb);
|
||||
@@ -61,14 +58,14 @@ private:
|
||||
|
||||
Ui::Calibration *ui;
|
||||
JoyControlStick *stick;
|
||||
InputDevice* currentJoystick;
|
||||
InputDevice *currentJoystick;
|
||||
JoyControlStickEditDialogHelper helper;
|
||||
JoyAxis* joyAxisX;
|
||||
JoyAxis* joyAxisY;
|
||||
JoyAxis *joyAxisX;
|
||||
JoyAxis *joyAxisY;
|
||||
QProgressBar *axisBarX;
|
||||
QProgressBar *axisBarY;
|
||||
QMultiHash<QString,int> x_es_val;
|
||||
QMultiHash<QString,int> y_es_val;
|
||||
QMultiHash<QString, int> x_es_val;
|
||||
QMultiHash<QString, int> y_es_val;
|
||||
int center_calibrated_x;
|
||||
int center_calibrated_y;
|
||||
int max_axis_val_x;
|
||||
@@ -82,7 +79,7 @@ private:
|
||||
bool calibrated;
|
||||
QString text;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void saveSettings();
|
||||
void checkX(int value);
|
||||
void checkY(int value);
|
||||
@@ -91,13 +88,12 @@ public slots:
|
||||
void startSecondStep();
|
||||
void startLastStep();
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
void resetSettings(bool silentReset, bool clicked = false);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void deadZoneChanged(int value);
|
||||
void propertyUpdated();
|
||||
|
||||
};
|
||||
|
||||
#endif // CALIBRATION_H
|
||||
|
||||
@@ -21,17 +21,15 @@
|
||||
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
|
||||
#include "x11extras.h"
|
||||
|
||||
|
||||
|
||||
CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CapturedWindowInfoDialog)
|
||||
CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::CapturedWindowInfoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -53,8 +51,7 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent)
|
||||
{
|
||||
ui->winClassCheckBox->setEnabled(false);
|
||||
ui->winClassCheckBox->setChecked(false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->winClassCheckBox->setChecked(true);
|
||||
setRadioDefault = true;
|
||||
@@ -70,8 +67,7 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent)
|
||||
{
|
||||
ui->winTitleCheckBox->setEnabled(false);
|
||||
ui->winTitleCheckBox->setChecked(false);
|
||||
}
|
||||
else if (!setRadioDefault)
|
||||
} else if (!setRadioDefault)
|
||||
{
|
||||
ui->winTitleCheckBox->setChecked(true);
|
||||
setRadioDefault = true;
|
||||
@@ -90,24 +86,21 @@ CapturedWindowInfoDialog::CapturedWindowInfoDialog(long window, QWidget *parent)
|
||||
ui->winPathLabel->setText(exepath);
|
||||
winPath = exepath;
|
||||
|
||||
if (!setRadioDefault) ui->winTitleCheckBox->setChecked(true);
|
||||
if (!setRadioDefault)
|
||||
ui->winTitleCheckBox->setChecked(true);
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->winPathCheckBox->setEnabled(false);
|
||||
ui->winPathCheckBox->setChecked(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
ui->winPathCheckBox->setEnabled(false);
|
||||
ui->winPathCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
if (winClass.isEmpty() && winName.isEmpty() &&
|
||||
winPath.isEmpty())
|
||||
if (winClass.isEmpty() && winName.isEmpty() && winPath.isEmpty())
|
||||
{
|
||||
QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
button->setEnabled(false);
|
||||
@@ -137,8 +130,10 @@ void CapturedWindowInfoDialog::populateOption()
|
||||
{
|
||||
selectedMatch = selectedMatch | WindowPath;
|
||||
|
||||
if (ui->winPathChoiceComboBox->currentIndex() == 0) fullWinPath = true;
|
||||
else fullWinPath = false;
|
||||
if (ui->winPathChoiceComboBox->currentIndex() == 0)
|
||||
fullWinPath = true;
|
||||
else
|
||||
fullWinPath = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UNIXWINDOWINFODIALOG_H
|
||||
#define UNIXWINDOWINFODIALOG_H
|
||||
|
||||
@@ -32,12 +31,12 @@ class CapturedWindowInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
explicit CapturedWindowInfoDialog(long window, QWidget *parent = nullptr);
|
||||
~CapturedWindowInfoDialog();
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
WindowNone = 0,
|
||||
WindowClass = (1 << 0),
|
||||
WindowName = (1 << 1),
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
bool useFullWindowPath();
|
||||
CapturedWindowOption getSelectedOptions();
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::CapturedWindowInfoDialog *ui;
|
||||
|
||||
CapturedWindowOption selectedMatch;
|
||||
@@ -61,8 +60,7 @@ private:
|
||||
QString winPath;
|
||||
bool fullWinPath;
|
||||
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void populateOption();
|
||||
};
|
||||
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
|
||||
#include "commandlineutility.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "common.h"
|
||||
#include "eventhandlerfactory.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QCommandLineParser>
|
||||
#include <QApplication>
|
||||
|
||||
QStringList CommandLineUtility::eventGeneratorsList = EventHandlerFactory::buildEventGeneratorList();
|
||||
|
||||
CommandLineUtility::CommandLineUtility(QObject *parent) :
|
||||
QObject(parent)
|
||||
CommandLineUtility::CommandLineUtility(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -55,8 +55,8 @@ CommandLineUtility::CommandLineUtility(QObject *parent) :
|
||||
eventGenerator = EventHandlerFactory::fallBackIdentifier();
|
||||
}
|
||||
|
||||
|
||||
void CommandLineUtility::parseArguments(QCommandLineParser* parser) {
|
||||
void CommandLineUtility::parseArguments(QCommandLineParser *parser)
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -69,16 +69,13 @@ void CommandLineUtility::parseArguments(QCommandLineParser* parser) {
|
||||
|
||||
qDebug() << "tray is set";
|
||||
|
||||
|
||||
launchInTray = true;
|
||||
hideTrayIcon = false;
|
||||
}
|
||||
else if (parser->isSet("no-tray"))
|
||||
} else if (parser->isSet("no-tray"))
|
||||
{
|
||||
|
||||
qDebug() << "no-tray is set";
|
||||
|
||||
|
||||
hideTrayIcon = true;
|
||||
launchInTray = false;
|
||||
}
|
||||
@@ -129,21 +126,20 @@ void CommandLineUtility::parseArguments(QCommandLineParser* parser) {
|
||||
{
|
||||
daemonMode = true;
|
||||
}
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
if (parser->isSet("display"))
|
||||
{
|
||||
if (!parser->value("display").isEmpty())
|
||||
{
|
||||
displayString = parser->value("display");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("No display string was specified."));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(WITH_UINPUT) && defined(WITH_XTEST))
|
||||
#if (defined(WITH_UINPUT) && defined(WITH_XTEST))
|
||||
|
||||
if (parser->isSet("eventgen"))
|
||||
{
|
||||
@@ -153,26 +149,28 @@ void CommandLineUtility::parseArguments(QCommandLineParser* parser) {
|
||||
{
|
||||
eventGenerator = "";
|
||||
setErrorMessage(QObject::tr("An invalid event generator was specified."));
|
||||
}
|
||||
else if (!eventGenText.isEmpty() && eventGeneratorsList.contains(eventGenText))
|
||||
} else if (!eventGenText.isEmpty() && eventGeneratorsList.contains(eventGenText))
|
||||
{
|
||||
eventGenerator = eventGenText;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("No event generator string was specified."));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (parser->isSet("log-level"))
|
||||
{
|
||||
QString logLevelText = parser->value("log-level");
|
||||
|
||||
if (logLevelText == "debug") currentLogLevel = Logger::LOG_DEBUG;
|
||||
else if (logLevelText == "info") currentLogLevel = Logger::LOG_INFO;
|
||||
else if (logLevelText == "warn") currentLogLevel = Logger::LOG_WARNING;
|
||||
else if (logLevelText == "error") currentLogLevel = Logger::LOG_ERROR;
|
||||
if (logLevelText == "debug")
|
||||
currentLogLevel = Logger::LOG_DEBUG;
|
||||
else if (logLevelText == "info")
|
||||
currentLogLevel = Logger::LOG_INFO;
|
||||
else if (logLevelText == "warn")
|
||||
currentLogLevel = Logger::LOG_WARNING;
|
||||
else if (logLevelText == "error")
|
||||
currentLogLevel = Logger::LOG_ERROR;
|
||||
}
|
||||
|
||||
if (parser->isSet("log-file"))
|
||||
@@ -180,8 +178,7 @@ void CommandLineUtility::parseArguments(QCommandLineParser* parser) {
|
||||
if (!parser->value("log-file").isEmpty())
|
||||
{
|
||||
currentLogFile = parser->value("log-file");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("No log file specified."));
|
||||
}
|
||||
@@ -191,55 +188,53 @@ void CommandLineUtility::parseArguments(QCommandLineParser* parser) {
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineUtility::parseArgsProfile(QCommandLineParser* parser)
|
||||
void CommandLineUtility::parseArgsProfile(QCommandLineParser *parser)
|
||||
{
|
||||
QFileInfo profileFileInfo(parser->value("profile"));
|
||||
|
||||
if (profileFileInfo.exists() && (profileFileInfo.suffix() != "amgp") && (profileFileInfo.suffix() != "xml"))
|
||||
{
|
||||
setErrorMessage(QObject::tr("Profile location %1 is not an XML file.").arg(parser->value("profile")));
|
||||
}
|
||||
else if (profileFileInfo.exists() && ((profileFileInfo.suffix() == "amgp") || (profileFileInfo.suffix() == "xml")))
|
||||
} else if (profileFileInfo.exists() && ((profileFileInfo.suffix() == "amgp") || (profileFileInfo.suffix() == "xml")))
|
||||
{
|
||||
QString tempProfileLocation = profileFileInfo.absoluteFilePath();
|
||||
ControllerOptionsInfo tempInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
tempInfo.setProfileLocation(tempProfileLocation);
|
||||
controllerOptionsList.replace(currentListsIndex, tempInfo);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("Profile location %1 does not exist.").arg(parser->value("profile")));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineUtility::parseArgsPrControle(QCommandLineParser* parser)
|
||||
void CommandLineUtility::parseArgsPrControle(QCommandLineParser *parser)
|
||||
{
|
||||
bool validNumber = false;
|
||||
int tempNumber = parser->value("profile-controller").toInt(&validNumber);
|
||||
|
||||
if (validNumber)
|
||||
{
|
||||
if (controllerNumber == 0) controllerNumber = tempNumber;
|
||||
if (controllerNumber == 0)
|
||||
controllerNumber = tempNumber;
|
||||
|
||||
ControllerOptionsInfo tempInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
tempInfo.setControllerNumber(tempNumber);
|
||||
controllerOptionsList.replace(currentListsIndex, tempInfo);
|
||||
}
|
||||
else if (!parser->value("profile-controller").isEmpty())
|
||||
} else if (!parser->value("profile-controller").isEmpty())
|
||||
{
|
||||
if (controllerIDString.isEmpty()) controllerIDString = parser->value("profile-controller");
|
||||
if (controllerIDString.isEmpty())
|
||||
controllerIDString = parser->value("profile-controller");
|
||||
|
||||
ControllerOptionsInfo tempInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
tempInfo.setControllerID(parser->value("profile-controller"));
|
||||
controllerOptionsList.replace(currentListsIndex, tempInfo);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("Controller identifier is not a valid value."));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineUtility::parseArgsUnload(QCommandLineParser* parser)
|
||||
void CommandLineUtility::parseArgsUnload(QCommandLineParser *parser)
|
||||
{
|
||||
ControllerOptionsInfo gameControllerOptionInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
gameControllerOptionInfo.setProfileLocation("");
|
||||
@@ -266,27 +261,24 @@ void CommandLineUtility::parseArgsUnload(QCommandLineParser* parser)
|
||||
gameControllerOptionInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
gameControllerOptionInfo.setControllerNumber(controllerNumber);
|
||||
controllerOptionsList.replace(currentListsIndex, gameControllerOptionInfo);
|
||||
}
|
||||
else if (!unloadedProfText.isEmpty())
|
||||
} else if (!unloadedProfText.isEmpty())
|
||||
{
|
||||
controllerIDString = unloadedProfText;
|
||||
gameControllerOptionInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
gameControllerOptionInfo.setControllerID(controllerIDString);
|
||||
controllerOptionsList.replace(currentListsIndex, gameControllerOptionInfo);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("Controller identifier is not a valid value."));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
unloadProfile = true;
|
||||
profileLocation = "";
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineUtility::parseArgsStartSet(QCommandLineParser* parser)
|
||||
void CommandLineUtility::parseArgsStartSet(QCommandLineParser *parser)
|
||||
{
|
||||
QStringList parserValues = QStringList() << parser->values("startSet");
|
||||
QListIterator<QString> profileForStartset(parserValues);
|
||||
@@ -305,8 +297,7 @@ void CommandLineUtility::parseArgsStartSet(QCommandLineParser* parser)
|
||||
ControllerOptionsInfo tempInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
tempInfo.setStartSetNumber(startSetNumber);
|
||||
controllerOptionsList.replace(currentListsIndex, tempInfo);
|
||||
}
|
||||
else if (validNumber)
|
||||
} else if (validNumber)
|
||||
{
|
||||
setErrorMessage(QObject::tr("An invalid set number '%1' was specified.").arg(tempNumber));
|
||||
}
|
||||
@@ -321,31 +312,29 @@ void CommandLineUtility::parseArgsStartSet(QCommandLineParser* parser)
|
||||
ControllerOptionsInfo tempInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
tempInfo.setControllerNumber(controllerNumber);
|
||||
controllerOptionsList.replace(currentListsIndex, tempInfo);
|
||||
}
|
||||
else if (!startSetText.isEmpty())
|
||||
} else if (!startSetText.isEmpty())
|
||||
{
|
||||
controllerIDString = startSetText;
|
||||
ControllerOptionsInfo tempInfo = getControllerOptionsList().at(currentListsIndex);
|
||||
tempInfo.setControllerID(controllerIDString);
|
||||
controllerOptionsList.replace(currentListsIndex, tempInfo);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("Controller identifier '%s'' is not a valid value.").arg(startSetText));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("No set number was specified."));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineUtility::parseArgsMap(QCommandLineParser* parser)
|
||||
void CommandLineUtility::parseArgsMap(QCommandLineParser *parser)
|
||||
{
|
||||
QString mapOptionText = parser->value("map");
|
||||
|
||||
if (!mapOptionText.isEmpty()) {
|
||||
if (!mapOptionText.isEmpty())
|
||||
{
|
||||
|
||||
bool validNumber = false;
|
||||
int tempNumber = mapOptionText.toInt(&validNumber);
|
||||
@@ -354,18 +343,15 @@ void CommandLineUtility::parseArgsMap(QCommandLineParser* parser)
|
||||
{
|
||||
controllerNumber = tempNumber;
|
||||
mappingController = true;
|
||||
}
|
||||
else if (!mapOptionText.isEmpty())
|
||||
} else if (!mapOptionText.isEmpty())
|
||||
{
|
||||
controllerIDString = mapOptionText;
|
||||
mappingController = true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("Controller identifier is not a valid value."));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
setErrorMessage(QObject::tr("No controller was specified."));
|
||||
}
|
||||
@@ -483,7 +469,6 @@ QString CommandLineUtility::getEventGenerator()
|
||||
return eventGenerator;
|
||||
}
|
||||
|
||||
|
||||
bool CommandLineUtility::launchAsDaemon()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -498,7 +483,6 @@ QString CommandLineUtility::getDisplayString()
|
||||
return displayString;
|
||||
}
|
||||
|
||||
|
||||
Logger::LogLevel CommandLineUtility::getCurrentLogLevel()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -506,14 +490,16 @@ Logger::LogLevel CommandLineUtility::getCurrentLogLevel()
|
||||
return currentLogLevel;
|
||||
}
|
||||
|
||||
QString CommandLineUtility::getCurrentLogFile() {
|
||||
QString CommandLineUtility::getCurrentLogFile()
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return currentLogFile;
|
||||
}
|
||||
|
||||
QString CommandLineUtility::getErrorText() {
|
||||
QString CommandLineUtility::getErrorText()
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -528,7 +514,7 @@ void CommandLineUtility::setErrorMessage(QString temp)
|
||||
encounteredError = true;
|
||||
}
|
||||
|
||||
QList<ControllerOptionsInfo> const& CommandLineUtility::getControllerOptionsList()
|
||||
QList<ControllerOptionsInfo> const &CommandLineUtility::getControllerOptionsList()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef COMMANDLINEPARSER_H
|
||||
#define COMMANDLINEPARSER_H
|
||||
|
||||
@@ -24,11 +23,10 @@ class QCommandLineParser;
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
class ControllerOptionsInfo
|
||||
{
|
||||
|
||||
class ControllerOptionsInfo {
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
ControllerOptionsInfo()
|
||||
{
|
||||
controllerNumber = 0;
|
||||
@@ -36,70 +34,31 @@ public:
|
||||
unloadProfile = false;
|
||||
}
|
||||
|
||||
bool hasProfile()
|
||||
{
|
||||
return !profileLocation.isEmpty();
|
||||
}
|
||||
bool hasProfile() { return !profileLocation.isEmpty(); }
|
||||
|
||||
QString getProfileLocation()
|
||||
{
|
||||
return profileLocation;
|
||||
}
|
||||
QString getProfileLocation() { return profileLocation; }
|
||||
|
||||
void setProfileLocation(QString location)
|
||||
{
|
||||
profileLocation = location;
|
||||
}
|
||||
void setProfileLocation(QString location) { profileLocation = location; }
|
||||
|
||||
bool hasControllerNumber()
|
||||
{
|
||||
return (controllerNumber > 0);
|
||||
}
|
||||
bool hasControllerNumber() { return (controllerNumber > 0); }
|
||||
|
||||
int getControllerNumber()
|
||||
{
|
||||
return controllerNumber;
|
||||
}
|
||||
int getControllerNumber() { return controllerNumber; }
|
||||
|
||||
void setControllerNumber(int temp)
|
||||
{
|
||||
controllerNumber = temp;
|
||||
}
|
||||
void setControllerNumber(int temp) { controllerNumber = temp; }
|
||||
|
||||
bool hasControllerID()
|
||||
{
|
||||
return !controllerIDString.isEmpty();
|
||||
}
|
||||
bool hasControllerID() { return !controllerIDString.isEmpty(); }
|
||||
|
||||
QString getControllerID()
|
||||
{
|
||||
return controllerIDString;
|
||||
}
|
||||
QString getControllerID() { return controllerIDString; }
|
||||
|
||||
void setControllerID(QString temp)
|
||||
{
|
||||
controllerIDString = temp;
|
||||
}
|
||||
void setControllerID(QString temp) { controllerIDString = temp; }
|
||||
|
||||
bool isUnloadRequested()
|
||||
{
|
||||
return unloadProfile;
|
||||
}
|
||||
bool isUnloadRequested() { return unloadProfile; }
|
||||
|
||||
void setUnloadRequest(bool status)
|
||||
{
|
||||
unloadProfile = status;
|
||||
}
|
||||
void setUnloadRequest(bool status) { unloadProfile = status; }
|
||||
|
||||
int getStartSetNumber()
|
||||
{
|
||||
return startSetNumber;
|
||||
}
|
||||
int getStartSetNumber() { return startSetNumber; }
|
||||
|
||||
int getJoyStartSetNumber()
|
||||
{
|
||||
return startSetNumber - 1;
|
||||
}
|
||||
int getJoyStartSetNumber() { return startSetNumber - 1; }
|
||||
|
||||
void setStartSetNumber(int temp)
|
||||
{
|
||||
@@ -109,7 +68,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
QString profileLocation;
|
||||
int controllerNumber;
|
||||
QString controllerIDString;
|
||||
@@ -121,10 +80,10 @@ class CommandLineUtility : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit CommandLineUtility(QObject *parent = nullptr);
|
||||
|
||||
void parseArguments(QCommandLineParser* parser);
|
||||
void parseArguments(QCommandLineParser *parser);
|
||||
|
||||
bool isLaunchInTrayEnabled();
|
||||
bool isTrayHidden();
|
||||
@@ -148,18 +107,18 @@ public:
|
||||
QString getCurrentLogFile();
|
||||
QString getErrorText();
|
||||
|
||||
QList<int>* getJoyStartSetNumberList();
|
||||
QList<ControllerOptionsInfo> const& getControllerOptionsList();
|
||||
QList<int> *getJoyStartSetNumberList();
|
||||
QList<ControllerOptionsInfo> const &getControllerOptionsList();
|
||||
|
||||
bool launchAsDaemon();
|
||||
QString getDisplayString();
|
||||
|
||||
Logger::LogLevel getCurrentLogLevel();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void setErrorMessage(QString temp);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool launchInTray;
|
||||
bool hideTrayIcon;
|
||||
bool encounteredError;
|
||||
@@ -186,12 +145,11 @@ private:
|
||||
|
||||
static QStringList eventGeneratorsList;
|
||||
|
||||
void parseArgsProfile(QCommandLineParser* parser);
|
||||
void parseArgsPrControle(QCommandLineParser* parser);
|
||||
void parseArgsUnload(QCommandLineParser* parser);
|
||||
void parseArgsStartSet(QCommandLineParser* parser);
|
||||
void parseArgsMap(QCommandLineParser* parser);
|
||||
|
||||
void parseArgsProfile(QCommandLineParser *parser);
|
||||
void parseArgsPrControle(QCommandLineParser *parser);
|
||||
void parseArgsUnload(QCommandLineParser *parser);
|
||||
void parseArgsStartSet(QCommandLineParser *parser);
|
||||
void parseArgsMap(QCommandLineParser *parser);
|
||||
};
|
||||
|
||||
#endif // COMMANDLINEPARSER_H
|
||||
|
||||
@@ -20,16 +20,14 @@
|
||||
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QReadWriteLock>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QLibraryInfo>
|
||||
#include <QReadWriteLock>
|
||||
|
||||
|
||||
namespace PadderCommon
|
||||
namespace PadderCommon {
|
||||
QString preferredProfileDir(AntiMicroSettings *settings)
|
||||
{
|
||||
QString preferredProfileDir(AntiMicroSettings *settings)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QString lastProfileDir = settings->value("LastProfileDir", "").toString();
|
||||
@@ -40,14 +38,16 @@ namespace PadderCommon
|
||||
{
|
||||
QFileInfo dirinfo(defaultProfileDir);
|
||||
|
||||
if (dirinfo.isDir() && dirinfo.isReadable()) lookupDir = defaultProfileDir;
|
||||
if (dirinfo.isDir() && dirinfo.isReadable())
|
||||
lookupDir = defaultProfileDir;
|
||||
}
|
||||
|
||||
if (lookupDir.isEmpty() && !lastProfileDir.isEmpty())
|
||||
{
|
||||
QFileInfo dirinfo(lastProfileDir);
|
||||
|
||||
if (dirinfo.isDir() && dirinfo.isReadable()) lookupDir = lastProfileDir;
|
||||
if (dirinfo.isDir() && dirinfo.isReadable())
|
||||
lookupDir = lastProfileDir;
|
||||
}
|
||||
|
||||
if (lookupDir.isEmpty())
|
||||
@@ -56,10 +56,10 @@ namespace PadderCommon
|
||||
}
|
||||
|
||||
return lookupDir;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList arguments(const int &argc, char **argv)
|
||||
{
|
||||
QStringList arguments(const int &argc, char **argv)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QStringList list = QStringList();
|
||||
@@ -68,10 +68,10 @@ namespace PadderCommon
|
||||
list << QString::fromLocal8Bit(argv[a]);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
QStringList parseArgumentsString(QString tempString)
|
||||
{
|
||||
QStringList parseArgumentsString(QString tempString)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
bool inside = (!tempString.isEmpty() && tempString.at(0) == QChar('"'));
|
||||
@@ -83,25 +83,25 @@ namespace PadderCommon
|
||||
{
|
||||
QString temp = iter.next();
|
||||
|
||||
if (inside) finalList.append(temp);
|
||||
else finalList.append(temp.split(QRegExp("\\s+"), QString::SkipEmptyParts));
|
||||
if (inside)
|
||||
finalList.append(temp);
|
||||
else
|
||||
finalList.append(temp.split(QRegExp("\\s+"), QString::SkipEmptyParts));
|
||||
|
||||
inside = !inside;
|
||||
}
|
||||
|
||||
return finalList;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Reload main application and base Qt translation files.
|
||||
* @param Based Qt translator
|
||||
* @param Application translator
|
||||
* @param Language code
|
||||
*/
|
||||
void reloadTranslations(QTranslator *translator,
|
||||
QTranslator *appTranslator,
|
||||
QString language)
|
||||
{
|
||||
void reloadTranslations(QTranslator *translator, QTranslator *appTranslator, QString language)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
// Remove application specific translation strings
|
||||
@@ -116,29 +116,30 @@ namespace PadderCommon
|
||||
qApp->installTranslator(appTranslator);
|
||||
|
||||
// Load application specific translation strings
|
||||
translator->load("antimicrox_" + language, QApplication::applicationDirPath().append("/../share/antimicrox/translations"));
|
||||
translator->load("antimicrox_" + language,
|
||||
QApplication::applicationDirPath().append("/../share/antimicrox/translations"));
|
||||
|
||||
qApp->installTranslator(translator);
|
||||
}
|
||||
}
|
||||
|
||||
void lockInputDevices()
|
||||
{
|
||||
void lockInputDevices()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
sdlWaitMutex.lock();
|
||||
}
|
||||
}
|
||||
|
||||
void unlockInputDevices()
|
||||
{
|
||||
void unlockInputDevices()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
sdlWaitMutex.unlock();
|
||||
}
|
||||
|
||||
QWaitCondition waitThisOut;
|
||||
QMutex sdlWaitMutex;
|
||||
QMutex inputDaemonMutex;
|
||||
QReadWriteLock editingLock;
|
||||
bool editingBindings = false;
|
||||
MouseHelper mouseHelperObj;
|
||||
}
|
||||
|
||||
QWaitCondition waitThisOut;
|
||||
QMutex sdlWaitMutex;
|
||||
QMutex inputDaemonMutex;
|
||||
QReadWriteLock editingLock;
|
||||
bool editingBindings = false;
|
||||
MouseHelper mouseHelperObj;
|
||||
} // namespace PadderCommon
|
||||
|
||||
107
src/common.h
107
src/common.h
@@ -16,12 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include "config.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "config.h"
|
||||
#include "mousehelper.h"
|
||||
|
||||
#include <QDir>
|
||||
@@ -29,81 +28,73 @@
|
||||
#include <QTranslator>
|
||||
#include <QWaitCondition>
|
||||
|
||||
|
||||
|
||||
namespace PadderCommon
|
||||
namespace PadderCommon {
|
||||
inline QString configPath()
|
||||
{
|
||||
inline QString configPath() {
|
||||
|
||||
return (!qgetenv("XDG_CONFIG_HOME").isEmpty()) ?
|
||||
QString::fromUtf8(qgetenv("XDG_CONFIG_HOME")) + "/antimicrox" :
|
||||
QDir::homePath() + "/.config/antimicrox";
|
||||
}
|
||||
return (!qgetenv("XDG_CONFIG_HOME").isEmpty()) ? QString::fromUtf8(qgetenv("XDG_CONFIG_HOME")) + "/antimicrox"
|
||||
: QDir::homePath() + "/.config/antimicrox";
|
||||
}
|
||||
|
||||
const QString configFileName = "antimicrox_settings.ini";
|
||||
inline QString configFilePath() {
|
||||
const QString configFileName = "antimicrox_settings.ini";
|
||||
inline QString configFilePath() { return QString(configPath()).append("/").append(configFileName); }
|
||||
|
||||
return QString(configPath()).append("/").append(configFileName);
|
||||
|
||||
}
|
||||
|
||||
inline QString configLegacyFilePath() {
|
||||
QString configPath = (!qgetenv("XDG_CONFIG_HOME").isEmpty()) ?
|
||||
QString::fromUtf8(qgetenv("XDG_CONFIG_HOME")) + "/antimicroX" :
|
||||
QDir::homePath() + "/.config/antimicroX";
|
||||
inline QString configLegacyFilePath()
|
||||
{
|
||||
QString configPath = (!qgetenv("XDG_CONFIG_HOME").isEmpty())
|
||||
? QString::fromUtf8(qgetenv("XDG_CONFIG_HOME")) + "/antimicroX"
|
||||
: QDir::homePath() + "/.config/antimicroX";
|
||||
|
||||
return QString(configPath).append("/").append("antimicroX_settings.ini");
|
||||
}
|
||||
}
|
||||
|
||||
const int LATESTCONFIGFILEVERSION = 19;
|
||||
// Specify the last known profile version that requires a migration
|
||||
// to be performed in order to be compatible with the latest version.
|
||||
const int LATESTCONFIGMIGRATIONVERSION = 5;
|
||||
const QString localSocketKey = "antimicroxSignalListener";
|
||||
const QString githubProjectPage = "https://github.com/AntiMicroX/antimicrox/";
|
||||
const QString githubIssuesPage = "https://github.com/AntiMicroX/antimicrox/issues";
|
||||
const QString wikiPage = QString("%1/wiki").arg(githubProjectPage);
|
||||
const int LATESTCONFIGFILEVERSION = 19;
|
||||
// Specify the last known profile version that requires a migration
|
||||
// to be performed in order to be compatible with the latest version.
|
||||
const int LATESTCONFIGMIGRATIONVERSION = 5;
|
||||
const QString localSocketKey = "antimicroxSignalListener";
|
||||
const QString githubProjectPage = "https://github.com/AntiMicroX/antimicrox/";
|
||||
const QString githubIssuesPage = "https://github.com/AntiMicroX/antimicrox/issues";
|
||||
const QString wikiPage = QString("%1/wiki").arg(githubProjectPage);
|
||||
|
||||
const QString mouseDeviceName("antimicrox Mouse Emulation");
|
||||
const QString keyboardDeviceName("antimicrox Keyboard Emulation");
|
||||
const QString springMouseDeviceName("antimicrox Abs Mouse Emulation");
|
||||
const QString mouseDeviceName("antimicrox Mouse Emulation");
|
||||
const QString keyboardDeviceName("antimicrox Keyboard Emulation");
|
||||
const QString springMouseDeviceName("antimicrox Abs Mouse Emulation");
|
||||
|
||||
const int ANTIMICROX_MAJOR_VERSION = PROJECT_MAJOR_VERSION;
|
||||
const int ANTIMICROX_MINOR_VERSION = PROJECT_MINOR_VERSION;
|
||||
const int ANTIMICROX_PATCH_VERSION = PROJECT_PATCH_VERSION;
|
||||
const int ANTIMICROX_MAJOR_VERSION = PROJECT_MAJOR_VERSION;
|
||||
const int ANTIMICROX_MINOR_VERSION = PROJECT_MINOR_VERSION;
|
||||
const int ANTIMICROX_PATCH_VERSION = PROJECT_PATCH_VERSION;
|
||||
|
||||
const QString programVersion = (ANTIMICROX_PATCH_VERSION > 0) ?
|
||||
QString("%1.%2.%3").arg(ANTIMICROX_MAJOR_VERSION)
|
||||
.arg(ANTIMICROX_MINOR_VERSION).arg(ANTIMICROX_PATCH_VERSION) :
|
||||
QString("%1.%2").arg(ANTIMICROX_MAJOR_VERSION)
|
||||
.arg(ANTIMICROX_MINOR_VERSION);
|
||||
const QString programVersion =
|
||||
(ANTIMICROX_PATCH_VERSION > 0)
|
||||
? QString("%1.%2.%3").arg(ANTIMICROX_MAJOR_VERSION).arg(ANTIMICROX_MINOR_VERSION).arg(ANTIMICROX_PATCH_VERSION)
|
||||
: QString("%1.%2").arg(ANTIMICROX_MAJOR_VERSION).arg(ANTIMICROX_MINOR_VERSION);
|
||||
|
||||
extern QWaitCondition waitThisOut;
|
||||
extern QMutex sdlWaitMutex;
|
||||
extern QMutex inputDaemonMutex;
|
||||
extern bool editingBindings;
|
||||
extern QReadWriteLock editingLock;
|
||||
extern MouseHelper mouseHelperObj;
|
||||
extern QWaitCondition waitThisOut;
|
||||
extern QMutex sdlWaitMutex;
|
||||
extern QMutex inputDaemonMutex;
|
||||
extern bool editingBindings;
|
||||
extern QReadWriteLock editingLock;
|
||||
extern MouseHelper mouseHelperObj;
|
||||
|
||||
QString preferredProfileDir(AntiMicroSettings *settings);
|
||||
QStringList arguments(const int &argc, char **argv);
|
||||
QStringList parseArgumentsString(QString tempString);
|
||||
void reloadTranslations(QTranslator *translator,
|
||||
QTranslator *appTranslator,
|
||||
QString language);
|
||||
void lockInputDevices();
|
||||
void unlockInputDevices();
|
||||
QString preferredProfileDir(AntiMicroSettings *settings);
|
||||
QStringList arguments(const int &argc, char **argv);
|
||||
QStringList parseArgumentsString(QString tempString);
|
||||
void reloadTranslations(QTranslator *translator, QTranslator *appTranslator, QString language);
|
||||
void lockInputDevices();
|
||||
void unlockInputDevices();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* \brief Returns the "human-readable" name of the given profile.
|
||||
*/
|
||||
inline QString getProfileName(QFileInfo& profile) {
|
||||
inline QString getProfileName(QFileInfo &profile)
|
||||
{
|
||||
QString retVal = profile.completeBaseName();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
} // namespace PadderCommon
|
||||
|
||||
Q_DECLARE_METATYPE(QThread*)
|
||||
Q_DECLARE_METATYPE(QThread *)
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
@@ -18,20 +18,19 @@
|
||||
|
||||
#include "dpadcontextmenu.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "joydpad.h"
|
||||
#include "mousedialog/mousedpadsettingsdialog.h"
|
||||
#include "antkeymapper.h"
|
||||
#include "inputdevice.h"
|
||||
#include "common.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joydpad.h"
|
||||
#include "messagehandler.h"
|
||||
#include "mousedialog/mousedpadsettingsdialog.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
#include <QHash>
|
||||
|
||||
|
||||
DPadContextMenu::DPadContextMenu(JoyDPad *dpad, QWidget *parent) :
|
||||
QMenu(parent),
|
||||
helper(dpad)
|
||||
DPadContextMenu::DPadContextMenu(JoyDPad *dpad, QWidget *parent)
|
||||
: QMenu(parent)
|
||||
, helper(dpad)
|
||||
{
|
||||
this->dpad = dpad;
|
||||
|
||||
@@ -50,7 +49,7 @@ void DPadContextMenu::buildMenu()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QActionGroup *presetGroup = new QActionGroup(this);
|
||||
QAction* action = nullptr;
|
||||
QAction *action = nullptr;
|
||||
int presetMode = 0;
|
||||
int currentPreset = getPresetIndex();
|
||||
|
||||
@@ -67,10 +66,14 @@ void DPadContextMenu::buildMenu()
|
||||
|
||||
QActionGroup *modesGroup = new QActionGroup(this);
|
||||
|
||||
generateActionMode(modesGroup, action, tr("Standard"), static_cast<int>(dpad->getJoyMode()), static_cast<int>(JoyDPad::StandardMode));
|
||||
generateActionMode(modesGroup, action, tr("Eight Way"), static_cast<int>(dpad->getJoyMode()), static_cast<int>(JoyDPad::EightWayMode));
|
||||
generateActionMode(modesGroup, action, tr("4 Way Cardinal"), static_cast<int>(dpad->getJoyMode()), static_cast<int>(JoyDPad::FourWayCardinal));
|
||||
generateActionMode(modesGroup, action, tr("4 Way Diagonal"), static_cast<int>(dpad->getJoyMode()), static_cast<int>(JoyDPad::FourWayDiagonal));
|
||||
generateActionMode(modesGroup, action, tr("Standard"), static_cast<int>(dpad->getJoyMode()),
|
||||
static_cast<int>(JoyDPad::StandardMode));
|
||||
generateActionMode(modesGroup, action, tr("Eight Way"), static_cast<int>(dpad->getJoyMode()),
|
||||
static_cast<int>(JoyDPad::EightWayMode));
|
||||
generateActionMode(modesGroup, action, tr("4 Way Cardinal"), static_cast<int>(dpad->getJoyMode()),
|
||||
static_cast<int>(JoyDPad::FourWayCardinal));
|
||||
generateActionMode(modesGroup, action, tr("4 Way Diagonal"), static_cast<int>(dpad->getJoyMode()),
|
||||
static_cast<int>(JoyDPad::FourWayDiagonal));
|
||||
|
||||
this->addSeparator();
|
||||
|
||||
@@ -80,31 +83,29 @@ void DPadContextMenu::buildMenu()
|
||||
connect(action, &QAction::triggered, this, &DPadContextMenu::openMouseSettingsDialog);
|
||||
}
|
||||
|
||||
void DPadContextMenu::generateActionPreset(QAction* action, QString actionText, int currentPreset, int& presetMode, QActionGroup* presetGroup)
|
||||
void DPadContextMenu::generateActionPreset(QAction *action, QString actionText, int currentPreset, int &presetMode,
|
||||
QActionGroup *presetGroup)
|
||||
{
|
||||
action = this->addAction(actionText);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action] {
|
||||
setDPadPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action] { setDPadPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
}
|
||||
|
||||
void DPadContextMenu::generateActionMode(QActionGroup *modesGroup, QAction* action, QString actionText, int currentPreset, int presetMode)
|
||||
void DPadContextMenu::generateActionMode(QActionGroup *modesGroup, QAction *action, QString actionText, int currentPreset,
|
||||
int presetMode)
|
||||
{
|
||||
action = this->addAction(actionText);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action] {
|
||||
setDPadMode(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action] { setDPadMode(action); });
|
||||
|
||||
modesGroup->addAction(action);
|
||||
}
|
||||
@@ -112,7 +113,7 @@ void DPadContextMenu::generateActionMode(QActionGroup *modesGroup, QAction* acti
|
||||
/**
|
||||
* @brief Set the appropriate mode for a DPad based on the item chosen.
|
||||
*/
|
||||
void DPadContextMenu::setDPadMode(QAction* action)
|
||||
void DPadContextMenu::setDPadMode(QAction *action)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -124,7 +125,7 @@ void DPadContextMenu::setDPadMode(QAction* action)
|
||||
* @brief Assign the appropriate slots to DPad buttons based on the preset item
|
||||
* that was chosen.
|
||||
*/
|
||||
void DPadContextMenu::setDPadPreset(QAction* action)
|
||||
void DPadContextMenu::setDPadPreset(QAction *action)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -139,8 +140,7 @@ void DPadContextMenu::setDPadPreset(QAction* action)
|
||||
JoyButtonSlot *downLeftButtonSlot = nullptr;
|
||||
JoyButtonSlot *downRightButtonSlot = nullptr;
|
||||
|
||||
|
||||
switch(item)
|
||||
switch (item)
|
||||
{
|
||||
case 0:
|
||||
|
||||
@@ -202,10 +202,14 @@ void DPadContextMenu::setDPadPreset(QAction* action)
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this);
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
dpad->setJoyMode(JoyDPad::StandardMode);
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
@@ -216,10 +220,14 @@ void DPadContextMenu::setDPadPreset(QAction* action)
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this);
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
dpad->setJoyMode(JoyDPad::StandardMode);
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
@@ -230,32 +238,51 @@ void DPadContextMenu::setDPadPreset(QAction* action)
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
if ((dpad->getJoyMode() == JoyDPad::StandardMode) ||
|
||||
(dpad->getJoyMode() == JoyDPad::FourWayCardinal))
|
||||
if ((dpad->getJoyMode() == JoyDPad::StandardMode) || (dpad->getJoyMode() == JoyDPad::FourWayCardinal))
|
||||
{
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
}
|
||||
else if (dpad->getJoyMode() == JoyDPad::EightWayMode)
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8),
|
||||
QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2),
|
||||
QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4),
|
||||
QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6),
|
||||
QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
} else if (dpad->getJoyMode() == JoyDPad::EightWayMode)
|
||||
{
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8),
|
||||
QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2),
|
||||
QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4),
|
||||
QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6),
|
||||
QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
}
|
||||
else if (dpad->getJoyMode() == JoyDPad::FourWayDiagonal)
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7),
|
||||
QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9),
|
||||
QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1),
|
||||
QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3),
|
||||
QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
} else if (dpad->getJoyMode() == JoyDPad::FourWayDiagonal)
|
||||
{
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7),
|
||||
QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9),
|
||||
QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1),
|
||||
QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3),
|
||||
QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
}
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
@@ -269,7 +296,7 @@ void DPadContextMenu::setDPadPreset(QAction* action)
|
||||
break;
|
||||
}
|
||||
|
||||
QHash<JoyDPadButton::JoyDPadDirections, JoyButtonSlot*> tempHash;
|
||||
QHash<JoyDPadButton::JoyDPadDirections, JoyButtonSlot *> tempHash;
|
||||
tempHash.insert(JoyDPadButton::DpadUp, upButtonSlot);
|
||||
tempHash.insert(JoyDPadButton::DpadDown, downButtonSlot);
|
||||
tempHash.insert(JoyDPadButton::DpadLeft, leftButtonSlot);
|
||||
@@ -298,16 +325,16 @@ int DPadContextMenu::getPresetIndex()
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
JoyDPadButton *upButton = dpad->getJoyButton(JoyDPadButton::DpadUp);
|
||||
QList<JoyButtonSlot*> *upslots = upButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *upslots = upButton->getAssignedSlots();
|
||||
|
||||
JoyDPadButton *downButton = dpad->getJoyButton(JoyDPadButton::DpadDown);
|
||||
QList<JoyButtonSlot*> *downslots = downButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *downslots = downButton->getAssignedSlots();
|
||||
|
||||
JoyDPadButton *leftButton = dpad->getJoyButton(JoyDPadButton::DpadLeft);
|
||||
QList<JoyButtonSlot*> *leftslots = leftButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *leftslots = leftButton->getAssignedSlots();
|
||||
|
||||
JoyDPadButton *rightButton = dpad->getJoyButton(JoyDPadButton::DpadRight);
|
||||
QList<JoyButtonSlot*> *rightslots = rightButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *rightslots = rightButton->getAssignedSlots();
|
||||
|
||||
if ((upslots->length() == 1) && (downslots->length() == 1) && (leftslots->length() == 1) && (rightslots->length() == 1))
|
||||
{
|
||||
@@ -316,57 +343,81 @@ int DPadContextMenu::getPresetIndex()
|
||||
JoyButtonSlot *leftslot = leftslots->at(0);
|
||||
JoyButtonSlot *rightslot = rightslots->at(0);
|
||||
|
||||
if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
{
|
||||
result = 2;
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
{
|
||||
result = 3;
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
{
|
||||
result = 4;
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
{
|
||||
result = 5;
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
{
|
||||
result = 6;
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(downslot->getSlotCode() ==
|
||||
AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(leftslot->getSlotCode() ==
|
||||
AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
{
|
||||
result = 7;
|
||||
}
|
||||
}
|
||||
else if ((upslots->length() == 0) && (downslots->length() == 0) && (leftslots->length() == 0) && (rightslots->length() == 0))
|
||||
} else if ((upslots->length() == 0) && (downslots->length() == 0) && (leftslots->length() == 0) &&
|
||||
(rightslots->length() == 0))
|
||||
{
|
||||
result = 8;
|
||||
}
|
||||
@@ -388,7 +439,4 @@ void DPadContextMenu::openMouseSettingsDialog()
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
DPadContextMenuHelper& DPadContextMenu::getHelper() {
|
||||
|
||||
return helper;
|
||||
}
|
||||
DPadContextMenuHelper &DPadContextMenu::getHelper() { return helper; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DPADCONTEXTMENU_H
|
||||
#define DPADCONTEXTMENU_H
|
||||
|
||||
@@ -31,26 +30,28 @@ class DPadContextMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit DPadContextMenu(JoyDPad *dpad, QWidget *parent = nullptr);
|
||||
void buildMenu();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int getPresetIndex();
|
||||
|
||||
private slots:
|
||||
void setDPadPreset(QAction* action);
|
||||
void setDPadMode(QAction* action);
|
||||
private slots:
|
||||
void setDPadPreset(QAction *action);
|
||||
void setDPadMode(QAction *action);
|
||||
void openMouseSettingsDialog();
|
||||
|
||||
private:
|
||||
DPadContextMenuHelper& getHelper();
|
||||
private:
|
||||
DPadContextMenuHelper &getHelper();
|
||||
|
||||
JoyDPad *dpad;
|
||||
DPadContextMenuHelper helper;
|
||||
|
||||
void generateActionPreset(QAction* action, QString actionText, int currentPreset, int& presetMode, QActionGroup* presetGroup);
|
||||
void generateActionMode(QActionGroup *modesGroup, QAction* action, QString actionText, int currentPreset, int presetMode);
|
||||
void generateActionPreset(QAction *action, QString actionText, int currentPreset, int &presetMode,
|
||||
QActionGroup *presetGroup);
|
||||
void generateActionMode(QActionGroup *modesGroup, QAction *action, QString actionText, int currentPreset,
|
||||
int presetMode);
|
||||
};
|
||||
|
||||
#endif // DPADCONTEXTMENU_H
|
||||
|
||||
@@ -19,25 +19,23 @@
|
||||
#include "dpadeditdialog.h"
|
||||
#include "ui_dpadeditdialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "joydpad.h"
|
||||
#include "mousedialog/mousedpadsettingsdialog.h"
|
||||
#include "event.h"
|
||||
#include "antkeymapper.h"
|
||||
#include "setjoystick.h"
|
||||
#include "inputdevice.h"
|
||||
#include "common.h"
|
||||
#include "event.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joydpad.h"
|
||||
#include "messagehandler.h"
|
||||
#include "mousedialog/mousedpadsettingsdialog.h"
|
||||
#include "setjoystick.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHashIterator>
|
||||
#include <QList>
|
||||
|
||||
|
||||
|
||||
DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent) :
|
||||
QDialog(parent, Qt::Window),
|
||||
ui(new Ui::DPadEditDialog),
|
||||
helper(dpad)
|
||||
DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent)
|
||||
: QDialog(parent, Qt::Window)
|
||||
, ui(new Ui::DPadEditDialog)
|
||||
, helper(dpad)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -51,8 +49,7 @@ DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent) :
|
||||
|
||||
updateWindowTitleDPadName();
|
||||
|
||||
|
||||
switch(dpad->getJoyMode())
|
||||
switch (dpad->getJoyMode())
|
||||
{
|
||||
case JoyDPad::StandardMode:
|
||||
ui->joyModeComboBox->setCurrentIndex(0);
|
||||
@@ -69,7 +66,6 @@ DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent) :
|
||||
case JoyDPad::FourWayDiagonal:
|
||||
ui->joyModeComboBox->setCurrentIndex(3);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
selectCurrentPreset();
|
||||
@@ -82,14 +78,18 @@ DPadEditDialog::DPadEditDialog(JoyDPad *dpad, QWidget *parent) :
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DPadEditDialog::implementPresets);
|
||||
connect(ui->joyModeComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DPadEditDialog::implementModes);
|
||||
connect(ui->presetsComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&DPadEditDialog::implementPresets);
|
||||
connect(ui->joyModeComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&DPadEditDialog::implementModes);
|
||||
connect(ui->mouseSettingsPushButton, &QPushButton::clicked, this, &DPadEditDialog::openMouseSettingsDialog);
|
||||
connect(ui->dpadNameLineEdit, &QLineEdit::textEdited, dpad, &JoyDPad::setDPadName);
|
||||
|
||||
connect(ui->dpadDelaySlider, static_cast<void (QSlider::*)(int)>(&QSlider::valueChanged), &helper, &DPadEditDialogHelper::updateJoyDPadDelay);
|
||||
connect(ui->dpadDelaySlider, static_cast<void (QSlider::*)(int)>(&QSlider::valueChanged), &helper,
|
||||
&DPadEditDialogHelper::updateJoyDPadDelay);
|
||||
connect(dpad, &JoyDPad::dpadDelayChanged, this, &DPadEditDialog::updateDPadDelaySpinBox);
|
||||
connect(ui->dpadDelayDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &DPadEditDialog::updateDPadDelaySlider);
|
||||
connect(ui->dpadDelayDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this,
|
||||
&DPadEditDialog::updateDPadDelaySlider);
|
||||
|
||||
connect(dpad, &JoyDPad::dpadNameChanged, this, &DPadEditDialog::updateWindowTitleDPadName);
|
||||
}
|
||||
@@ -114,7 +114,7 @@ void DPadEditDialog::implementPresets(int index)
|
||||
JoyButtonSlot *downLeftButtonSlot = nullptr;
|
||||
JoyButtonSlot *downRightButtonSlot = nullptr;
|
||||
|
||||
switch(index)
|
||||
switch (index)
|
||||
{
|
||||
case 1:
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
@@ -178,10 +178,14 @@ void DPadEditDialog::implementPresets(int index)
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this);
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
|
||||
@@ -193,10 +197,14 @@ void DPadEditDialog::implementPresets(int index)
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this);
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
|
||||
@@ -208,32 +216,51 @@ void DPadEditDialog::implementPresets(int index)
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
if ((ui->joyModeComboBox->currentIndex() == 0) ||
|
||||
(ui->joyModeComboBox->currentIndex() == 2))
|
||||
if ((ui->joyModeComboBox->currentIndex() == 0) || (ui->joyModeComboBox->currentIndex() == 2))
|
||||
{
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
}
|
||||
else if (ui->joyModeComboBox->currentIndex() == 1)
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8),
|
||||
QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2),
|
||||
QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4),
|
||||
QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6),
|
||||
QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
} else if (ui->joyModeComboBox->currentIndex() == 1)
|
||||
{
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
upButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8),
|
||||
QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
downButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2),
|
||||
QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
leftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4),
|
||||
QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
rightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6),
|
||||
QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
}
|
||||
else if (ui->joyModeComboBox->currentIndex() == 3)
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7),
|
||||
QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9),
|
||||
QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1),
|
||||
QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3),
|
||||
QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
} else if (ui->joyModeComboBox->currentIndex() == 3)
|
||||
{
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7), QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9), QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1), QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3), QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
upLeftButtonSlot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_7),
|
||||
QtKeyMapperBase::AntKey_KP_7, JoyButtonSlot::JoyKeyboard, this);
|
||||
upRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_9),
|
||||
QtKeyMapperBase::AntKey_KP_9, JoyButtonSlot::JoyKeyboard, this);
|
||||
downLeftButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_1),
|
||||
QtKeyMapperBase::AntKey_KP_1, JoyButtonSlot::JoyKeyboard, this);
|
||||
downRightButtonSlot =
|
||||
new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_3),
|
||||
QtKeyMapperBase::AntKey_KP_3, JoyButtonSlot::JoyKeyboard, this);
|
||||
}
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
@@ -253,7 +280,7 @@ void DPadEditDialog::implementPresets(int index)
|
||||
break;
|
||||
}
|
||||
|
||||
QHash<JoyDPadButton::JoyDPadDirections, JoyButtonSlot*> tempHash;
|
||||
QHash<JoyDPadButton::JoyDPadDirections, JoyButtonSlot *> tempHash;
|
||||
tempHash.insert(JoyDPadButton::DpadUp, upButtonSlot);
|
||||
tempHash.insert(JoyDPadButton::DpadDown, downButtonSlot);
|
||||
tempHash.insert(JoyDPadButton::DpadLeft, leftButtonSlot);
|
||||
@@ -267,7 +294,6 @@ void DPadEditDialog::implementPresets(int index)
|
||||
QMetaObject::invokeMethod(&helper, "setFromPendingSlots", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
void DPadEditDialog::implementModes(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -276,7 +302,7 @@ void DPadEditDialog::implementModes(int index)
|
||||
|
||||
dpad->releaseButtonEvents();
|
||||
|
||||
switch(index)
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
dpad->setJoyMode(JoyDPad::StandardMode);
|
||||
@@ -303,16 +329,16 @@ void DPadEditDialog::selectCurrentPreset()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyDPadButton *upButton = dpad->getJoyButton(JoyDPadButton::DpadUp);
|
||||
QList<JoyButtonSlot*> *upslots = upButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *upslots = upButton->getAssignedSlots();
|
||||
|
||||
JoyDPadButton *downButton = dpad->getJoyButton(JoyDPadButton::DpadDown);
|
||||
QList<JoyButtonSlot*> *downslots = downButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *downslots = downButton->getAssignedSlots();
|
||||
|
||||
JoyDPadButton *leftButton = dpad->getJoyButton(JoyDPadButton::DpadLeft);
|
||||
QList<JoyButtonSlot*> *leftslots = leftButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *leftslots = leftButton->getAssignedSlots();
|
||||
|
||||
JoyDPadButton *rightButton = dpad->getJoyButton(JoyDPadButton::DpadRight);
|
||||
QList<JoyButtonSlot*> *rightslots = rightButton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *rightslots = rightButton->getAssignedSlots();
|
||||
|
||||
if ((upslots->length() == 1) && (downslots->length() == 1) && (leftslots->length() == 1) && (rightslots->length() == 1))
|
||||
{
|
||||
@@ -321,58 +347,81 @@ void DPadEditDialog::selectCurrentPreset()
|
||||
JoyButtonSlot *leftslot = leftslots->at(0);
|
||||
JoyButtonSlot *rightslot = rightslots->at(0);
|
||||
|
||||
if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(1);
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(2);
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(3);
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(upslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(downslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(leftslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(rightslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(4);
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(5);
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(6);
|
||||
}
|
||||
else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (downslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (leftslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
} else if ((upslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(upslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(downslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(downslot->getSlotCode() ==
|
||||
AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)) &&
|
||||
(leftslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(leftslot->getSlotCode() ==
|
||||
AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(rightslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(rightslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(7);
|
||||
}
|
||||
}
|
||||
else if ((upslots->length() == 0) && (downslots->length() == 0) &&
|
||||
(leftslots->length() == 0) && (rightslots->length() == 0))
|
||||
} else if ((upslots->length() == 0) && (downslots->length() == 0) && (leftslots->length() == 0) &&
|
||||
(rightslots->length() == 0))
|
||||
{
|
||||
ui->presetsComboBox->setCurrentIndex(8);
|
||||
}
|
||||
@@ -431,8 +480,10 @@ void DPadEditDialog::updateWindowTitleDPadName()
|
||||
|
||||
QString temp = QString(tr("Set")).append(" ");
|
||||
|
||||
if (!dpad->getDpadName().isEmpty()) temp.append(dpad->getName(false, true));
|
||||
else temp.append(dpad->getName());
|
||||
if (!dpad->getDpadName().isEmpty())
|
||||
temp.append(dpad->getName(false, true));
|
||||
else
|
||||
temp.append(dpad->getName());
|
||||
|
||||
if (dpad->getParentSet()->getIndex() != 0)
|
||||
{
|
||||
@@ -451,17 +502,8 @@ void DPadEditDialog::updateWindowTitleDPadName()
|
||||
setWindowTitle(temp);
|
||||
}
|
||||
|
||||
JoyDPad* DPadEditDialog::getDPad() const {
|
||||
JoyDPad *DPadEditDialog::getDPad() const { return dpad; }
|
||||
|
||||
return dpad;
|
||||
}
|
||||
DPadEditDialogHelper const &DPadEditDialog::getHelper() { return helper; }
|
||||
|
||||
DPadEditDialogHelper const& DPadEditDialog::getHelper() {
|
||||
|
||||
return helper;
|
||||
}
|
||||
|
||||
DPadEditDialogHelper& DPadEditDialog::getHelperLocal() {
|
||||
|
||||
return helper;
|
||||
}
|
||||
DPadEditDialogHelper &DPadEditDialog::getHelperLocal() { return helper; }
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#ifndef DPADEDITDIALOG_H
|
||||
#define DPADEDITDIALOG_H
|
||||
|
||||
|
||||
#include "uihelpers/dpadeditdialoghelper.h"
|
||||
|
||||
#include <QDialog>
|
||||
@@ -35,17 +34,17 @@ class DPadEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit DPadEditDialog(JoyDPad *dpad, QWidget *parent = nullptr);
|
||||
~DPadEditDialog();
|
||||
|
||||
JoyDPad* getDPad() const;
|
||||
DPadEditDialogHelper const& getHelper();
|
||||
JoyDPad *getDPad() const;
|
||||
DPadEditDialogHelper const &getHelper();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void selectCurrentPreset();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void implementPresets(int index);
|
||||
void implementModes(int index);
|
||||
void openMouseSettingsDialog();
|
||||
@@ -54,13 +53,12 @@ private slots:
|
||||
void updateDPadDelaySpinBox(int value);
|
||||
void updateDPadDelaySlider(double value);
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::DPadEditDialog *ui;
|
||||
DPadEditDialogHelper& getHelperLocal();
|
||||
DPadEditDialogHelper &getHelperLocal();
|
||||
|
||||
JoyDPad *dpad;
|
||||
DPadEditDialogHelper helper;
|
||||
|
||||
};
|
||||
|
||||
#endif // DPADEDITDIALOG_H
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
#include "dpadpushbutton.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "joydpad.h"
|
||||
#include "dpadcontextmenu.h"
|
||||
#include "joydpad.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
DPadPushButton::DPadPushButton(JoyDPad *dpad, bool displayNames, QWidget *parent) :
|
||||
FlashButtonWidget(displayNames, parent)
|
||||
DPadPushButton::DPadPushButton(JoyDPad *dpad, bool displayNames, QWidget *parent)
|
||||
: FlashButtonWidget(displayNames, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -42,7 +42,7 @@ DPadPushButton::DPadPushButton(JoyDPad *dpad, bool displayNames, QWidget *parent
|
||||
connect(dpad, &JoyDPad::dpadNameChanged, this, &DPadPushButton::refreshLabel);
|
||||
}
|
||||
|
||||
JoyDPad* DPadPushButton::getDPad() const
|
||||
JoyDPad *DPadPushButton::getDPad() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -55,13 +55,13 @@ QString DPadPushButton::generateLabel()
|
||||
|
||||
QString temp = QString();
|
||||
|
||||
if (!dpad->getDpadName().isEmpty()) temp.append(dpad->getName(false, ifDisplayNames()));
|
||||
else temp.append(dpad->getName());
|
||||
|
||||
if (!dpad->getDpadName().isEmpty())
|
||||
temp.append(dpad->getName(false, ifDisplayNames()));
|
||||
else
|
||||
temp.append(dpad->getName());
|
||||
|
||||
qDebug() << "Dpad button name is: " << temp;
|
||||
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DPADPUSHBUTTON_H
|
||||
#define DPADPUSHBUTTON_H
|
||||
|
||||
|
||||
#include "flashbuttonwidget.h"
|
||||
|
||||
|
||||
class JoyDPad;
|
||||
class QWidget;
|
||||
|
||||
@@ -31,25 +28,24 @@ class DPadPushButton : public FlashButtonWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit DPadPushButton(JoyDPad *dpad, bool displayNames, QWidget *parent = nullptr);
|
||||
|
||||
JoyDPad* getDPad() const;
|
||||
JoyDPad *getDPad() const;
|
||||
void tryFlash();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
QString generateLabel() override;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void disableFlashes() override;
|
||||
void enableFlashes() override;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void showContextMenu(const QPoint &point);
|
||||
|
||||
private:
|
||||
private:
|
||||
JoyDPad *dpad;
|
||||
|
||||
};
|
||||
|
||||
#endif // DPADPUSHBUTTON_H
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
|
||||
#include "dpadpushbuttongroup.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "joydpad.h"
|
||||
#include "joydpadbuttonwidget.h"
|
||||
#include "dpadpushbutton.h"
|
||||
#include "buttoneditdialog.h"
|
||||
#include "dpadeditdialog.h"
|
||||
#include "dpadpushbutton.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joydpad.h"
|
||||
#include "joydpadbuttonwidget.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHash>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
|
||||
DPadPushButtonGroup::DPadPushButtonGroup(JoyDPad *dpad, bool keypadUnlocked, bool displayNames, QWidget *parent) :
|
||||
QGridLayout(parent)
|
||||
DPadPushButtonGroup::DPadPushButtonGroup(JoyDPad *dpad, bool keypadUnlocked, bool displayNames, QWidget *parent)
|
||||
: QGridLayout(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -49,7 +49,7 @@ void DPadPushButtonGroup::generateButtons()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHash<int, JoyDPadButton*> *buttons = dpad->getJoyButtons();
|
||||
QHash<int, JoyDPadButton *> *buttons = dpad->getJoyButtons();
|
||||
|
||||
upLeftButton = generateBtnForGrid(buttons, 9, 0, 0);
|
||||
upButton = generateBtnForGrid(buttons, 1, 0, 1);
|
||||
@@ -68,14 +68,13 @@ void DPadPushButtonGroup::generateButtons()
|
||||
downRightButton = generateBtnForGrid(buttons, 6, 2, 2);
|
||||
}
|
||||
|
||||
JoyDPadButtonWidget* DPadPushButtonGroup::generateBtnForGrid(QHash<int, JoyDPadButton*> *buttons, int dpadDirection, int cellRow, int cellCol)
|
||||
JoyDPadButtonWidget *DPadPushButtonGroup::generateBtnForGrid(QHash<int, JoyDPadButton *> *buttons, int dpadDirection,
|
||||
int cellRow, int cellCol)
|
||||
{
|
||||
JoyDPadButton *button = buttons->value(static_cast<JoyDPadButton::JoyDPadDirections>(dpadDirection));
|
||||
JoyDPadButtonWidget *pushbutton = new JoyDPadButtonWidget(button, displayNames, parentWidget());
|
||||
|
||||
connect(pushbutton, &JoyDPadButtonWidget::clicked, this, [this, pushbutton] {
|
||||
openDPadButtonDialog(pushbutton);
|
||||
});
|
||||
connect(pushbutton, &JoyDPadButtonWidget::clicked, this, [this, pushbutton] { openDPadButtonDialog(pushbutton); });
|
||||
|
||||
button->establishPropertyUpdatedConnections();
|
||||
connect(button, &JoyDPadButton::slotsChanged, this, &DPadPushButtonGroup::propogateSlotsChanged);
|
||||
@@ -88,16 +87,14 @@ void DPadPushButtonGroup::changeButtonLayout()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if ((dpad->getJoyMode() == JoyDPad::StandardMode) ||
|
||||
(dpad->getJoyMode() == JoyDPad::EightWayMode) ||
|
||||
if ((dpad->getJoyMode() == JoyDPad::StandardMode) || (dpad->getJoyMode() == JoyDPad::EightWayMode) ||
|
||||
(dpad->getJoyMode() == JoyDPad::FourWayCardinal))
|
||||
{
|
||||
upButton->setVisible(true);
|
||||
downButton->setVisible(true);
|
||||
leftButton->setVisible(true);
|
||||
rightButton->setVisible(true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
upButton->setVisible(false);
|
||||
downButton->setVisible(false);
|
||||
@@ -105,15 +102,13 @@ void DPadPushButtonGroup::changeButtonLayout()
|
||||
rightButton->setVisible(false);
|
||||
}
|
||||
|
||||
if ((dpad->getJoyMode() == JoyDPad::EightWayMode) ||
|
||||
(dpad->getJoyMode() == JoyDPad::FourWayDiagonal))
|
||||
if ((dpad->getJoyMode() == JoyDPad::EightWayMode) || (dpad->getJoyMode() == JoyDPad::FourWayDiagonal))
|
||||
{
|
||||
upLeftButton->setVisible(true);
|
||||
upRightButton->setVisible(true);
|
||||
downLeftButton->setVisible(true);
|
||||
downRightButton->setVisible(true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
upLeftButton->setVisible(false);
|
||||
upRightButton->setVisible(false);
|
||||
@@ -129,20 +124,21 @@ void DPadPushButtonGroup::propogateSlotsChanged()
|
||||
emit buttonSlotChanged();
|
||||
}
|
||||
|
||||
JoyDPad* DPadPushButtonGroup::getDPad() const
|
||||
JoyDPad *DPadPushButtonGroup::getDPad() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return dpad;
|
||||
}
|
||||
|
||||
void DPadPushButtonGroup::openDPadButtonDialog(JoyButtonWidget* buttonWidget)
|
||||
void DPadPushButtonGroup::openDPadButtonDialog(JoyButtonWidget *buttonWidget)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyButton *button = buttonWidget->getJoyButton();
|
||||
|
||||
ButtonEditDialog *dialog = new ButtonEditDialog(button, dpad->getParentSet()->getInputDevice(), keypadUnlocked, parentWidget());
|
||||
ButtonEditDialog *dialog =
|
||||
new ButtonEditDialog(button, dpad->getParentSet()->getInputDevice(), keypadUnlocked, parentWidget());
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DPADPUSHBUTTONGROUP_H
|
||||
#define DPADPUSHBUTTONGROUP_H
|
||||
|
||||
@@ -33,27 +32,27 @@ class DPadPushButtonGroup : public QGridLayout
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit DPadPushButtonGroup(JoyDPad *dpad, bool keypadUnlocked, bool displayNames = false, QWidget *parent = nullptr);
|
||||
|
||||
JoyDPad *getDPad() const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void generateButtons();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void buttonSlotChanged();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void changeButtonLayout();
|
||||
void toggleNameDisplay();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void propogateSlotsChanged();
|
||||
void openDPadButtonDialog(JoyButtonWidget* buttonWidget);
|
||||
void openDPadButtonDialog(JoyButtonWidget *buttonWidget);
|
||||
void showDPadDialog();
|
||||
|
||||
private:
|
||||
private:
|
||||
JoyDPad *dpad;
|
||||
bool keypadUnlocked;
|
||||
bool displayNames;
|
||||
@@ -70,7 +69,8 @@ private:
|
||||
|
||||
DPadPushButton *dpadWidget;
|
||||
|
||||
JoyDPadButtonWidget * generateBtnForGrid(QHash<int, JoyDPadButton*> *buttons, int dpadDirection , int cellRow, int cellCol);
|
||||
JoyDPadButtonWidget *generateBtnForGrid(QHash<int, JoyDPadButton *> *buttons, int dpadDirection, int cellRow,
|
||||
int cellCol);
|
||||
};
|
||||
|
||||
#endif // DPADPUSHBUTTONGROUP_H
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
#include "editalldefaultautoprofiledialog.h"
|
||||
#include "ui_editalldefaultautoprofiledialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "autoprofileinfo.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "autoprofileinfo.h"
|
||||
#include "common.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
EditAllDefaultAutoProfileDialog::EditAllDefaultAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::EditAllDefaultAutoProfileDialog)
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::EditAllDefaultAutoProfileDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -48,8 +47,10 @@ EditAllDefaultAutoProfileDialog::EditAllDefaultAutoProfileDialog(AutoProfileInfo
|
||||
if (!info->getProfileLocation().isEmpty())
|
||||
ui->profileLineEdit->setText(info->getProfileLocation());
|
||||
|
||||
connect(ui->profileBrowsePushButton, &QPushButton::clicked, this, &EditAllDefaultAutoProfileDialog::openProfileBrowseDialog);
|
||||
connect(this, &EditAllDefaultAutoProfileDialog::accepted, this, &EditAllDefaultAutoProfileDialog::saveAutoProfileInformation);
|
||||
connect(ui->profileBrowsePushButton, &QPushButton::clicked, this,
|
||||
&EditAllDefaultAutoProfileDialog::openProfileBrowseDialog);
|
||||
connect(this, &EditAllDefaultAutoProfileDialog::accepted, this,
|
||||
&EditAllDefaultAutoProfileDialog::saveAutoProfileInformation);
|
||||
}
|
||||
|
||||
EditAllDefaultAutoProfileDialog::~EditAllDefaultAutoProfileDialog()
|
||||
@@ -64,22 +65,24 @@ void EditAllDefaultAutoProfileDialog::openProfileBrowseDialog()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QString preferredProfileDir = PadderCommon::preferredProfileDir(settings);
|
||||
QString profileFilename = QFileDialog::getOpenFileName(this, tr("Open Config"), preferredProfileDir, QString("Config Files (*.amgp *.xml)"));
|
||||
QString profileFilename =
|
||||
QFileDialog::getOpenFileName(this, tr("Open Config"), preferredProfileDir, QString("Config Files (*.amgp *.xml)"));
|
||||
|
||||
if (!profileFilename.isNull() && !profileFilename.isEmpty()) ui->profileLineEdit->setText(profileFilename);
|
||||
if (!profileFilename.isNull() && !profileFilename.isEmpty())
|
||||
ui->profileLineEdit->setText(profileFilename);
|
||||
}
|
||||
|
||||
void EditAllDefaultAutoProfileDialog::saveAutoProfileInformation()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
//info->setGUID("all");
|
||||
// info->setGUID("all");
|
||||
info->setUniqueID("all");
|
||||
info->setProfileLocation(ui->profileLineEdit->text());
|
||||
info->setActive(true);
|
||||
}
|
||||
|
||||
AutoProfileInfo* EditAllDefaultAutoProfileDialog::getAutoProfile() const
|
||||
AutoProfileInfo *EditAllDefaultAutoProfileDialog::getAutoProfile() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -107,8 +110,7 @@ void EditAllDefaultAutoProfileDialog::accept()
|
||||
if (validForm)
|
||||
{
|
||||
QDialog::accept();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(errorString);
|
||||
@@ -117,7 +119,4 @@ void EditAllDefaultAutoProfileDialog::accept()
|
||||
}
|
||||
}
|
||||
|
||||
AntiMicroSettings* EditAllDefaultAutoProfileDialog::getSettings() const {
|
||||
|
||||
return settings;
|
||||
}
|
||||
AntiMicroSettings *EditAllDefaultAutoProfileDialog::getSettings() const { return settings; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EDITALLDEFAULTAUTOPROFILEDIALOG_H
|
||||
#define EDITALLDEFAULTAUTOPROFILEDIALOG_H
|
||||
|
||||
@@ -34,26 +33,23 @@ class EditAllDefaultAutoProfileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditAllDefaultAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings,
|
||||
QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit EditAllDefaultAutoProfileDialog(AutoProfileInfo *info, AntiMicroSettings *settings, QWidget *parent = nullptr);
|
||||
~EditAllDefaultAutoProfileDialog();
|
||||
|
||||
AutoProfileInfo* getAutoProfile() const;
|
||||
AntiMicroSettings* getSettings() const;
|
||||
AutoProfileInfo *getAutoProfile() const;
|
||||
AntiMicroSettings *getSettings() const;
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void accept();
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::EditAllDefaultAutoProfileDialog *ui;
|
||||
|
||||
AutoProfileInfo *info;
|
||||
AntiMicroSettings *settings;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void openProfileBrowseDialog();
|
||||
void saveAutoProfileInformation();
|
||||
};
|
||||
|
||||
284
src/event.cpp
284
src/event.cpp
@@ -16,31 +16,29 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <QVariant>
|
||||
#include <QApplication>
|
||||
#include <cmath>
|
||||
#include <QFileInfo>
|
||||
#include <QStringList>
|
||||
#include <QCursor>
|
||||
#include <QDesktopWidget>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <cmath>
|
||||
|
||||
#include "event.h"
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "eventhandlerfactory.h"
|
||||
#include "globalvariables.h"
|
||||
#include "joybutton.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
|
||||
#if defined(WITH_X11)
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include "x11extras.h"
|
||||
#include "x11extras.h"
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
#include <X11/extensions/XTest.h>
|
||||
@@ -48,16 +46,12 @@
|
||||
#endif
|
||||
|
||||
#if defined(WITH_UINPUT)
|
||||
#include "uinputhelper.h"
|
||||
#include "uinputhelper.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// TODO: Implement function for determining final mouse pointer position
|
||||
// based around a fixed bounding box resolution.
|
||||
void fakeAbsMouseCoordinates(double springX, double springY,
|
||||
int width, int height,
|
||||
int &finalx, int &finaly, int screen)
|
||||
void fakeAbsMouseCoordinates(double springX, double springY, int width, int height, int &finalx, int &finaly, int screen)
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -72,8 +66,7 @@ void fakeAbsMouseCoordinates(double springX, double springY,
|
||||
int destMidWidth = 0;
|
||||
int destMidHeight = 0;
|
||||
|
||||
QRect deskRect = PadderCommon::mouseHelperObj.getDesktopWidget()
|
||||
->screenGeometry(screen);
|
||||
QRect deskRect = PadderCommon::mouseHelperObj.getDesktopWidget()->screenGeometry(screen);
|
||||
|
||||
screenWidth = deskRect.width();
|
||||
screenHeight = deskRect.height();
|
||||
@@ -85,8 +78,7 @@ void fakeAbsMouseCoordinates(double springX, double springY,
|
||||
{
|
||||
destSpringWidth = qMin(width, screenWidth);
|
||||
destSpringHeight = qMin(height, screenHeight);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
destSpringWidth = screenWidth;
|
||||
destSpringHeight = screenHeight;
|
||||
@@ -109,34 +101,34 @@ void sendevent(JoyButtonSlot *slot, bool pressed)
|
||||
if (device == JoyButtonSlot::JoyKeyboard)
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendKeyboardEvent(slot, pressed);
|
||||
}
|
||||
else if (device == JoyButtonSlot::JoyMouseButton)
|
||||
} else if (device == JoyButtonSlot::JoyMouseButton)
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseButtonEvent(slot, pressed);
|
||||
}
|
||||
else if ((device == JoyButtonSlot::JoyTextEntry) && pressed && !slot->getTextData().isEmpty())
|
||||
} else if ((device == JoyButtonSlot::JoyTextEntry) && pressed && !slot->getTextData().isEmpty())
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendTextEntryEvent(slot->getTextData());
|
||||
}
|
||||
else if ((device == JoyButtonSlot::JoyExecute) && pressed && !slot->getTextData().isEmpty())
|
||||
} else if ((device == JoyButtonSlot::JoyExecute) && pressed && !slot->getTextData().isEmpty())
|
||||
{
|
||||
if (slot->getExtraData().canConvert<QString>())
|
||||
{
|
||||
QString argumentsString = slot->getExtraData().toString();
|
||||
//QStringList argumentsTempList(PadderCommon::parseArgumentsString(argumentsString));
|
||||
bool success = QProcess::startDetached(QString("%1 %2 %3").arg(detectedScriptExt(slot->getTextData())).arg(slot->getTextData()).arg(argumentsString));
|
||||
if (!success) qDebug() << "Script cannot be executed";
|
||||
}
|
||||
else
|
||||
// QStringList argumentsTempList(PadderCommon::parseArgumentsString(argumentsString));
|
||||
bool success = QProcess::startDetached(QString("%1 %2 %3")
|
||||
.arg(detectedScriptExt(slot->getTextData()))
|
||||
.arg(slot->getTextData())
|
||||
.arg(argumentsString));
|
||||
if (!success)
|
||||
qDebug() << "Script cannot be executed";
|
||||
} else
|
||||
{
|
||||
bool success = QProcess::startDetached(QString("%1 %2").arg(detectedScriptExt(slot->getTextData())).arg(slot->getTextData()));
|
||||
if (!success) qDebug() << "Script cannot be executed";
|
||||
|
||||
bool success = QProcess::startDetached(
|
||||
QString("%1 %2").arg(detectedScriptExt(slot->getTextData())).arg(slot->getTextData()));
|
||||
if (!success)
|
||||
qDebug() << "Script cannot be executed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString detectedScriptExt(QString file)
|
||||
{
|
||||
QFileInfo fileinfo(file);
|
||||
@@ -158,12 +150,18 @@ QString detectedScriptExt(QString file)
|
||||
* need to find another way
|
||||
*/
|
||||
|
||||
if (fileinfo.completeSuffix() == "sh" || firstLine.contains("bin/bash")) return "/bin/sh";
|
||||
else if (fileinfo.completeSuffix() == "py" && firstLine.contains("python3")) return "python3";
|
||||
else if (fileinfo.completeSuffix() == "py" && firstLine.contains("python")) return "python";
|
||||
else if (fileinfo.completeSuffix() == "pl" || firstLine.contains("usr/bin/perl")) return "perl";
|
||||
else if (fileinfo.completeSuffix() == "php" || firstLine.contains("/php")) return "php";
|
||||
else if (fileinfo.completeSuffix() == "rb" || firstLine.contains("ruby")) return "ruby";
|
||||
if (fileinfo.completeSuffix() == "sh" || firstLine.contains("bin/bash"))
|
||||
return "/bin/sh";
|
||||
else if (fileinfo.completeSuffix() == "py" && firstLine.contains("python3"))
|
||||
return "python3";
|
||||
else if (fileinfo.completeSuffix() == "py" && firstLine.contains("python"))
|
||||
return "python";
|
||||
else if (fileinfo.completeSuffix() == "pl" || firstLine.contains("usr/bin/perl"))
|
||||
return "perl";
|
||||
else if (fileinfo.completeSuffix() == "php" || firstLine.contains("/php"))
|
||||
return "php";
|
||||
else if (fileinfo.completeSuffix() == "rb" || firstLine.contains("ruby"))
|
||||
return "ruby";
|
||||
|
||||
// when run "chmod +x file_name"
|
||||
return "";
|
||||
@@ -180,9 +178,8 @@ void sendevent(int code1, int code2)
|
||||
// TODO: Re-implement spring event generation to simplify the process
|
||||
// and reduce overhead. Refactor old function to only be used when an absmouse
|
||||
// position must be faked.
|
||||
void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring,
|
||||
PadderCommon::springModeInfo *relativeSpring,
|
||||
int* const mousePosX, int* const mousePosY)
|
||||
void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring, PadderCommon::springModeInfo *relativeSpring,
|
||||
int *const mousePosX, int *const mousePosY)
|
||||
{
|
||||
Q_UNUSED(relativeSpring)
|
||||
Q_UNUSED(mousePosX)
|
||||
@@ -216,8 +213,7 @@ void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring,
|
||||
{
|
||||
displacementX = fullSpring->displacementX;
|
||||
displacementY = fullSpring->displacementY;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
displacementX = fullSpring->displacementX;
|
||||
displacementY = fullSpring->displacementY;
|
||||
@@ -256,18 +252,14 @@ void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring,
|
||||
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
fakeAbsMouseCoordinates(displacementX, displacementY,
|
||||
springWidth, springHeight, xmovecoor, ymovecoor,
|
||||
fakeAbsMouseCoordinates(displacementX, displacementY, springWidth, springHeight, xmovecoor, ymovecoor,
|
||||
fullSpring->screen);
|
||||
}
|
||||
else if (handler->getIdentifier() == "uinput")
|
||||
} else if (handler->getIdentifier() == "uinput")
|
||||
{
|
||||
fakeAbsMouseCoordinates(displacementX, displacementY,
|
||||
springWidth, springHeight, xmovecoor, ymovecoor,
|
||||
fakeAbsMouseCoordinates(displacementX, displacementY, springWidth, springHeight, xmovecoor, ymovecoor,
|
||||
fullSpring->screen);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
PadderCommon::mouseHelperObj.springMouseMoving = false;
|
||||
PadderCommon::mouseHelperObj.pivotPoint[0] = -1;
|
||||
@@ -279,17 +271,16 @@ void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring,
|
||||
// pointer to fake absolute mouse moves. Otherwise, don't worry about
|
||||
// current position of the mouse and just send an absolute mouse pointer
|
||||
// event.
|
||||
void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
PadderCommon::springModeInfo *relativeSpring,
|
||||
int* const mousePosX, int* const mousePosY)
|
||||
void sendSpringEvent(PadderCommon::springModeInfo *fullSpring, PadderCommon::springModeInfo *relativeSpring,
|
||||
int *const mousePosX, int *const mousePosY)
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
PadderCommon::mouseHelperObj.mouseTimer.stop();
|
||||
|
||||
if (((fullSpring->displacementX >= -2.0) && (fullSpring->displacementX <= 1.0) &&
|
||||
(fullSpring->displacementY >= -2.0) && (fullSpring->displacementY <= 1.0)) ||
|
||||
if (((fullSpring->displacementX >= -2.0) && (fullSpring->displacementX <= 1.0) && (fullSpring->displacementY >= -2.0) &&
|
||||
(fullSpring->displacementY <= 1.0)) ||
|
||||
(relativeSpring && ((relativeSpring->displacementX >= -2.0) && (relativeSpring->displacementX <= 1.0) &&
|
||||
(relativeSpring->displacementY >= -2.0) && (relativeSpring->displacementY <= 1.0))))
|
||||
{
|
||||
@@ -315,8 +306,7 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
fullSpring->screen = -1;
|
||||
}
|
||||
|
||||
QRect deskRect = PadderCommon::mouseHelperObj.getDesktopWidget()
|
||||
->screenGeometry(fullSpring->screen);
|
||||
QRect deskRect = PadderCommon::mouseHelperObj.getDesktopWidget()->screenGeometry(fullSpring->screen);
|
||||
|
||||
width = deskRect.width();
|
||||
height = deskRect.height();
|
||||
@@ -326,8 +316,7 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
if (QApplication::platformName() == QStringLiteral("xcb"))
|
||||
{
|
||||
currentPoint = X11Extras::getInstance()->getPos();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
currentPoint = QCursor::pos();
|
||||
}
|
||||
@@ -346,8 +335,7 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
{
|
||||
destSpringWidth = qMin(springWidth, width);
|
||||
destSpringHeight = qMin(springHeight, height);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
destSpringWidth = width;
|
||||
destSpringHeight = height;
|
||||
@@ -364,8 +352,7 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
if (PadderCommon::mouseHelperObj.pivotPoint[0] != -1)
|
||||
{
|
||||
pivotX = PadderCommon::mouseHelperObj.pivotPoint[0];
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
pivotX = currentMouseX;
|
||||
}
|
||||
@@ -373,15 +360,18 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
if (PadderCommon::mouseHelperObj.pivotPoint[1] != -1)
|
||||
{
|
||||
pivotY = PadderCommon::mouseHelperObj.pivotPoint[1];
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
pivotY = currentMouseY;
|
||||
}
|
||||
}
|
||||
|
||||
xmovecoor = (fullSpring->displacementX >= -1.0) ? (midwidth + (fullSpring->displacementX * destMidWidth) + deskRect.x()): pivotX;
|
||||
ymovecoor = (fullSpring->displacementY >= -1.0) ? (midheight + (fullSpring->displacementY * destMidHeight) + deskRect.y()) : pivotY;
|
||||
xmovecoor = (fullSpring->displacementX >= -1.0)
|
||||
? (midwidth + (fullSpring->displacementX * destMidWidth) + deskRect.x())
|
||||
: pivotX;
|
||||
ymovecoor = (fullSpring->displacementY >= -1.0)
|
||||
? (midheight + (fullSpring->displacementY * destMidHeight) + deskRect.y())
|
||||
: pivotY;
|
||||
|
||||
int fullSpringDestX = xmovecoor;
|
||||
int fullSpringDestY = ymovecoor;
|
||||
@@ -407,9 +397,11 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
ymovecoor += yRelativeMoovCoor;
|
||||
}
|
||||
|
||||
if (mousePosX) *mousePosX = xmovecoor;
|
||||
if (mousePosX)
|
||||
*mousePosX = xmovecoor;
|
||||
|
||||
if (mousePosY) *mousePosY = ymovecoor;
|
||||
if (mousePosY)
|
||||
*mousePosY = ymovecoor;
|
||||
|
||||
if ((xmovecoor != currentMouseX) || (ymovecoor != currentMouseY))
|
||||
{
|
||||
@@ -425,24 +417,18 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
{
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor,
|
||||
ymovecoor,
|
||||
-1);
|
||||
}
|
||||
else if (handler->getIdentifier() == "uinput")
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor, ymovecoor, -1);
|
||||
} else if (handler->getIdentifier() == "uinput")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseSpringEvent(xmovecoor, ymovecoor,
|
||||
width + deskRect.x(), height + deskRect.y());
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseSpringEvent(
|
||||
xmovecoor, ymovecoor, width + deskRect.x(), height + deskRect.y());
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseEvent(xmovecoor - currentMouseX,
|
||||
ymovecoor - currentMouseY);
|
||||
}
|
||||
}
|
||||
else if (!PadderCommon::mouseHelperObj.springMouseMoving && relativeSpring &&
|
||||
} else if (!PadderCommon::mouseHelperObj.springMouseMoving && relativeSpring &&
|
||||
((relativeSpring->displacementX >= -1.0) || (relativeSpring->displacementY >= -1.0)) &&
|
||||
((diffx >= (destRelativeWidth * .013)) || (diffy >= (destRelativeHeight * .013))))
|
||||
{
|
||||
@@ -453,28 +439,21 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
{
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor,
|
||||
ymovecoor,
|
||||
-1);
|
||||
}
|
||||
else if (handler->getIdentifier() == "uinput")
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor, ymovecoor, -1);
|
||||
} else if (handler->getIdentifier() == "uinput")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseSpringEvent(xmovecoor, ymovecoor,
|
||||
width + deskRect.x(), height + deskRect.y());
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseSpringEvent(
|
||||
xmovecoor, ymovecoor, width + deskRect.x(), height + deskRect.y());
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseEvent(xmovecoor - currentMouseX, ymovecoor - currentMouseY);
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseEvent(xmovecoor - currentMouseX,
|
||||
ymovecoor - currentMouseY);
|
||||
}
|
||||
|
||||
PadderCommon::mouseHelperObj.mouseTimer.start(
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
}
|
||||
else if (!PadderCommon::mouseHelperObj.springMouseMoving &&
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
} else if (!PadderCommon::mouseHelperObj.springMouseMoving &&
|
||||
((diffx >= (destSpringWidth * .013)) || (diffy >= (destSpringHeight * .013))))
|
||||
{
|
||||
PadderCommon::mouseHelperObj.springMouseMoving = true;
|
||||
@@ -484,28 +463,20 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
{
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor,
|
||||
ymovecoor,
|
||||
-1);
|
||||
}
|
||||
else if (handler->getIdentifier() == "uinput")
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor, ymovecoor, -1);
|
||||
} else if (handler->getIdentifier() == "uinput")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseSpringEvent(xmovecoor, ymovecoor,
|
||||
width + deskRect.x(), height + deskRect.y());
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseSpringEvent(
|
||||
xmovecoor, ymovecoor, width + deskRect.x(), height + deskRect.y());
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseEvent(xmovecoor - currentMouseX,
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseEvent(xmovecoor - currentMouseX,
|
||||
ymovecoor - currentMouseY);
|
||||
}
|
||||
|
||||
|
||||
PadderCommon::mouseHelperObj.mouseTimer.start(
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
}
|
||||
|
||||
else if (PadderCommon::mouseHelperObj.springMouseMoving && ((diffx < 2) && (diffy < 2)))
|
||||
@@ -521,41 +492,31 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
{
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor,
|
||||
ymovecoor,
|
||||
-1);
|
||||
}
|
||||
else if (handler->getIdentifier() == "uinput")
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseAbsEvent(xmovecoor, ymovecoor, -1);
|
||||
} else if (handler->getIdentifier() == "uinput")
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseSpringEvent(xmovecoor, ymovecoor,
|
||||
width + deskRect.x(), height + deskRect.y());
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseSpringEvent(
|
||||
xmovecoor, ymovecoor, width + deskRect.x(), height + deskRect.y());
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
EventHandlerFactory::getInstance()->handler()
|
||||
->sendMouseEvent(xmovecoor - currentMouseX,
|
||||
EventHandlerFactory::getInstance()->handler()->sendMouseEvent(xmovecoor - currentMouseX,
|
||||
ymovecoor - currentMouseY);
|
||||
}
|
||||
|
||||
PadderCommon::mouseHelperObj.mouseTimer.start(
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
}
|
||||
|
||||
|
||||
PadderCommon::mouseHelperObj.previousCursorLocation[0] = currentMouseX;
|
||||
PadderCommon::mouseHelperObj.previousCursorLocation[1] = currentMouseY;
|
||||
PadderCommon::mouseHelperObj.pivotPoint[0] = fullSpringDestX;
|
||||
PadderCommon::mouseHelperObj.pivotPoint[1] = fullSpringDestY;
|
||||
}
|
||||
else if ((PadderCommon::mouseHelperObj.previousCursorLocation[0] == xmovecoor) &&
|
||||
} else if ((PadderCommon::mouseHelperObj.previousCursorLocation[0] == xmovecoor) &&
|
||||
(PadderCommon::mouseHelperObj.previousCursorLocation[1] == ymovecoor))
|
||||
{
|
||||
PadderCommon::mouseHelperObj.springMouseMoving = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
PadderCommon::mouseHelperObj.previousCursorLocation[0] = currentMouseX;
|
||||
PadderCommon::mouseHelperObj.previousCursorLocation[1] = currentMouseY;
|
||||
@@ -563,11 +524,9 @@ void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
PadderCommon::mouseHelperObj.pivotPoint[1] = fullSpringDestY;
|
||||
|
||||
PadderCommon::mouseHelperObj.mouseTimer.start(
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
PadderCommon::mouseHelperObj.springMouseMoving = false;
|
||||
PadderCommon::mouseHelperObj.pivotPoint[0] = -1;
|
||||
@@ -588,7 +547,7 @@ int X11KeySymToKeycode(QString key)
|
||||
#ifdef WITH_XTEST
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
tempcode = XKeysymToKeycode(display, XStringToKeysym(key.toUtf8().data()));
|
||||
}
|
||||
#endif
|
||||
@@ -604,7 +563,6 @@ int X11KeySymToKeycode(QString key)
|
||||
return tempcode;
|
||||
}
|
||||
|
||||
|
||||
QString keycodeToKeyString(int keycode, int alias)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -618,15 +576,14 @@ QString keycodeToKeyString(int keycode, int alias)
|
||||
if (keycode <= 0)
|
||||
{
|
||||
newkey = "[NO KEY]";
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
newkey = QString("0x%1").arg(keycode, 0, 16);
|
||||
QString tempkey = XKeysymToString(XkbKeycodeToKeysym(display, static_cast<KeyCode>(keycode), 0, 0));
|
||||
QString tempalias = X11Extras::getInstance()->getDisplayString(tempkey);
|
||||
@@ -634,8 +591,7 @@ QString keycodeToKeyString(int keycode, int alias)
|
||||
if (!tempalias.isEmpty())
|
||||
{
|
||||
newkey = tempalias;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
XKeyPressedEvent tempevent;
|
||||
tempevent.keycode = keycode;
|
||||
@@ -655,8 +611,7 @@ QString keycodeToKeyString(int keycode, int alias)
|
||||
|
||||
qDebug() << "NEWKEY:" << newkey << endl;
|
||||
qDebug() << "NEWKEY LEGNTH:" << numchars << endl;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
newkey = tempkey;
|
||||
}
|
||||
@@ -669,8 +624,10 @@ QString keycodeToKeyString(int keycode, int alias)
|
||||
{
|
||||
QString tempalias = UInputHelper::getInstance()->getDisplayString(keycode);
|
||||
|
||||
if (!tempalias.isEmpty()) newkey = tempalias;
|
||||
else newkey = QString("0x%1").arg(keycode, 0, 16);
|
||||
if (!tempalias.isEmpty())
|
||||
newkey = tempalias;
|
||||
else
|
||||
newkey = QString("0x%1").arg(keycode, 0, 16);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -682,17 +639,17 @@ int X11KeyCodeToX11KeySym(int keycode)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
return XkbKeycodeToKeysym(display, static_cast<KeyCode>(keycode), 0, 0);
|
||||
|
||||
#else
|
||||
#else
|
||||
|
||||
Q_UNUSED(keycode)
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
QString keysymToKeyString(int keysym, int alias)
|
||||
@@ -701,28 +658,27 @@ QString keysymToKeyString(int keysym, int alias)
|
||||
|
||||
QString newkey = QString();
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
Q_UNUSED(alias)
|
||||
|
||||
BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();
|
||||
|
||||
if (handler->getIdentifier() == "xtest")
|
||||
{
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
int keycode = 0;
|
||||
|
||||
if (keysym > 0)
|
||||
keycode = XKeysymToKeycode(display, static_cast<KeySym>(keysym));
|
||||
|
||||
newkey = keycodeToKeyString(keycode);
|
||||
}
|
||||
else if (handler->getIdentifier() == "uinput")
|
||||
} else if (handler->getIdentifier() == "uinput")
|
||||
{
|
||||
newkey = keycodeToKeyString(keysym);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
newkey = keycodeToKeyString(keysym, alias);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return newkey;
|
||||
}
|
||||
|
||||
28
src/event.h
28
src/event.h
@@ -16,35 +16,29 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "joybuttonslot.h"
|
||||
#include "springmousemoveinfo.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
void sendevent (JoyButtonSlot *slot, bool pressed=true);
|
||||
void sendevent(JoyButtonSlot *slot, bool pressed = true);
|
||||
void sendevent(int code1, int code2);
|
||||
void sendKeybEvent(JoyButtonSlot *slot, bool pressed=true);
|
||||
void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring,
|
||||
PadderCommon::springModeInfo *relativeSpring=0,
|
||||
int* const mousePosX=0, int* const mousePos=0);
|
||||
void sendKeybEvent(JoyButtonSlot *slot, bool pressed = true);
|
||||
void sendSpringEventRefactor(PadderCommon::springModeInfo *fullSpring, PadderCommon::springModeInfo *relativeSpring = 0,
|
||||
int *const mousePosX = 0, int *const mousePos = 0);
|
||||
|
||||
void sendSpringEvent(PadderCommon::springModeInfo *fullSpring,
|
||||
PadderCommon::springModeInfo *relativeSpring=0,
|
||||
int* const mousePosX=0, int* const mousePos=0);
|
||||
void sendSpringEvent(PadderCommon::springModeInfo *fullSpring, PadderCommon::springModeInfo *relativeSpring = 0,
|
||||
int *const mousePosX = 0, int *const mousePos = 0);
|
||||
|
||||
void fakeAbsMouseCoordinates(double springX, double springY,
|
||||
int width, int height,
|
||||
int &finalx, int &finaly, int screen=-1);
|
||||
void fakeAbsMouseCoordinates(double springX, double springY, int width, int height, int &finalx, int &finaly,
|
||||
int screen = -1);
|
||||
|
||||
QString detectedScriptExt(QString file);
|
||||
int X11KeySymToKeycode(QString key);
|
||||
QString keycodeToKeyString(int keycode, int alias=0);
|
||||
QString keycodeToKeyString(int keycode, int alias = 0);
|
||||
int X11KeyCodeToX11KeySym(int keycode);
|
||||
QString keysymToKeyString(int keysym, int alias=0);
|
||||
QString keysymToKeyString(int keysym, int alias = 0);
|
||||
|
||||
#endif // EVENT_H
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
|
||||
#include "eventhandlerfactory.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "eventhandlers/baseeventhandler.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QHash>
|
||||
|
||||
static QHash<QString, QString> buildDisplayNames()
|
||||
{
|
||||
@@ -39,29 +38,26 @@ static QHash<QString, QString> buildDisplayNames()
|
||||
|
||||
QHash<QString, QString> handlerDisplayNames = buildDisplayNames();
|
||||
|
||||
EventHandlerFactory* EventHandlerFactory::instance = nullptr;
|
||||
EventHandlerFactory *EventHandlerFactory::instance = nullptr;
|
||||
|
||||
|
||||
|
||||
EventHandlerFactory::EventHandlerFactory(QString handler, QObject *parent) :
|
||||
QObject(parent)
|
||||
EventHandlerFactory::EventHandlerFactory(QString handler, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
#ifdef WITH_UINPUT
|
||||
#ifdef WITH_UINPUT
|
||||
|
||||
if (handler == "uinput")
|
||||
eventHandler = new UInputEventHandler(this);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
#ifdef WITH_XTEST
|
||||
|
||||
if (handler == "xtest")
|
||||
eventHandler = new XTestEventHandler(this);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
EventHandlerFactory::~EventHandlerFactory()
|
||||
@@ -75,7 +71,7 @@ EventHandlerFactory::~EventHandlerFactory()
|
||||
}
|
||||
}
|
||||
|
||||
EventHandlerFactory* EventHandlerFactory::getInstance(QString handler)
|
||||
EventHandlerFactory *EventHandlerFactory::getInstance(QString handler)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -83,8 +79,10 @@ EventHandlerFactory* EventHandlerFactory::getInstance(QString handler)
|
||||
{
|
||||
QStringList temp = buildEventGeneratorList();
|
||||
|
||||
if (!handler.isEmpty() && temp.contains(handler)) instance = new EventHandlerFactory(handler);
|
||||
else instance = new EventHandlerFactory(fallBackIdentifier());
|
||||
if (!handler.isEmpty() && temp.contains(handler))
|
||||
instance = new EventHandlerFactory(handler);
|
||||
else
|
||||
instance = new EventHandlerFactory(fallBackIdentifier());
|
||||
}
|
||||
|
||||
return instance;
|
||||
@@ -101,7 +99,7 @@ void EventHandlerFactory::deleteInstance()
|
||||
}
|
||||
}
|
||||
|
||||
BaseEventHandler* EventHandlerFactory::handler()
|
||||
BaseEventHandler *EventHandlerFactory::handler()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -114,13 +112,13 @@ QString EventHandlerFactory::fallBackIdentifier()
|
||||
|
||||
QString temp = QString();
|
||||
|
||||
#if defined(WITH_XTEST)
|
||||
#if defined(WITH_XTEST)
|
||||
temp = "xtest";
|
||||
#elif defined(WITH_UINPUT)
|
||||
#elif defined(WITH_UINPUT)
|
||||
temp = "uinput";
|
||||
#else
|
||||
#else
|
||||
temp = "xtest";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -16,37 +16,33 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef EVENTHANDLERFACTORY_H
|
||||
#define EVENTHANDLERFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
#ifdef WITH_UINPUT
|
||||
#ifdef WITH_UINPUT
|
||||
#include "eventhandlers/uinputeventhandler.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
#ifdef WITH_XTEST
|
||||
#include "eventhandlers/xtesteventhandler.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WITH_XTEST
|
||||
#ifdef WITH_XTEST
|
||||
#define ADD_XTEST 1
|
||||
#else
|
||||
#else
|
||||
#define ADD_XTEST 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WITH_UINPUT
|
||||
#ifdef WITH_UINPUT
|
||||
#define ADD_UINPUT 1
|
||||
#else
|
||||
#else
|
||||
#define ADD_UINPUT 0
|
||||
#endif
|
||||
|
||||
#define NUM_BACKENDS (ADD_XTEST + ADD_UINPUT)
|
||||
#endif
|
||||
|
||||
#define NUM_BACKENDS (ADD_XTEST + ADD_UINPUT)
|
||||
|
||||
#if (NUM_BACKENDS > 1)
|
||||
#define BACKEND_ELSE_IF else if
|
||||
@@ -56,26 +52,24 @@
|
||||
|
||||
class BaseEventHandler;
|
||||
|
||||
|
||||
class EventHandlerFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static EventHandlerFactory* getInstance(QString handler = "");
|
||||
public:
|
||||
static EventHandlerFactory *getInstance(QString handler = "");
|
||||
void deleteInstance();
|
||||
BaseEventHandler* handler();
|
||||
BaseEventHandler *handler();
|
||||
static QString fallBackIdentifier();
|
||||
static QStringList buildEventGeneratorList();
|
||||
static QString handlerDisplayName(QString handler);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
explicit EventHandlerFactory(QString handler, QObject *parent = nullptr);
|
||||
~EventHandlerFactory();
|
||||
|
||||
BaseEventHandler *eventHandler;
|
||||
static EventHandlerFactory *instance;
|
||||
|
||||
};
|
||||
|
||||
#endif // EVENTHANDLERFACTORY_H
|
||||
|
||||
@@ -23,19 +23,13 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
BaseEventHandler::BaseEventHandler(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
BaseEventHandler::~BaseEventHandler()
|
||||
BaseEventHandler::BaseEventHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
BaseEventHandler::~BaseEventHandler() { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
QString BaseEventHandler::getErrorString()
|
||||
{
|
||||
@@ -48,10 +42,7 @@ QString BaseEventHandler::getErrorString()
|
||||
* @brief Do nothing by default. Allow child classes to specify text to output
|
||||
* to a text stream.
|
||||
*/
|
||||
void BaseEventHandler::printPostMessages()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
void BaseEventHandler::printPostMessages() { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
/**
|
||||
* @brief Do nothing by default. Useful for child classes to define behavior.
|
||||
@@ -75,8 +66,7 @@ void BaseEventHandler::sendMouseAbsEvent(int xDis, int yDis, int screen)
|
||||
* @param Bounding box width
|
||||
* @param Bounding box height
|
||||
*/
|
||||
void BaseEventHandler::sendMouseSpringEvent(int xDis, int yDis,
|
||||
int width, int height)
|
||||
void BaseEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int height)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BASEEVENTHANDLER_H
|
||||
#define BASEEVENTHANDLER_H
|
||||
|
||||
@@ -24,12 +23,11 @@
|
||||
|
||||
class JoyButtonSlot;
|
||||
|
||||
|
||||
class BaseEventHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit BaseEventHandler(QObject *parent = nullptr);
|
||||
virtual ~BaseEventHandler();
|
||||
|
||||
@@ -41,8 +39,7 @@ public:
|
||||
virtual void sendMouseEvent(int xDis, int yDis) = 0;
|
||||
virtual void sendMouseAbsEvent(int xDis, int yDis, int screen);
|
||||
|
||||
virtual void sendMouseSpringEvent(int xDis, int yDis,
|
||||
int width, int height);
|
||||
virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height);
|
||||
virtual void sendMouseSpringEvent(int xDis, int yDis);
|
||||
|
||||
virtual void sendTextEntryEvent(QString maintext);
|
||||
@@ -52,10 +49,8 @@ public:
|
||||
virtual void printPostMessages();
|
||||
QString getErrorString();
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
QString lastErrorString;
|
||||
|
||||
};
|
||||
|
||||
#endif // BASEEVENTHANDLER_H
|
||||
|
||||
@@ -16,29 +16,27 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cmath>
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/uinput.h>
|
||||
#include <cmath>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QStringList>
|
||||
#include <QStringListIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
|
||||
#include <antkeymapper.h>
|
||||
#include <common.h>
|
||||
#include <joybuttonslot.h>
|
||||
#include <logger.h>
|
||||
#include <common.h>
|
||||
|
||||
|
||||
static const QString mouseDeviceName = PadderCommon::mouseDeviceName;
|
||||
static const QString keyboardDeviceName = PadderCommon::keyboardDeviceName;
|
||||
static const QString springMouseDeviceName = PadderCommon::springMouseDeviceName;
|
||||
|
||||
|
||||
#ifdef WITH_X11
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QApplication>
|
||||
@@ -47,24 +45,18 @@ static const QString springMouseDeviceName = PadderCommon::springMouseDeviceName
|
||||
#include <x11extras.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "uinputeventhandler.h"
|
||||
#include "messagehandler.h"
|
||||
#include "uinputeventhandler.h"
|
||||
|
||||
|
||||
UInputEventHandler::UInputEventHandler(QObject *parent) :
|
||||
BaseEventHandler(parent)
|
||||
UInputEventHandler::UInputEventHandler(QObject *parent)
|
||||
: BaseEventHandler(parent)
|
||||
{
|
||||
keyboardFileHandler = 0;
|
||||
mouseFileHandler = 0;
|
||||
springMouseFileHandler = 0;
|
||||
}
|
||||
|
||||
|
||||
UInputEventHandler::~UInputEventHandler()
|
||||
{
|
||||
cleanupUinputEvHand();
|
||||
}
|
||||
UInputEventHandler::~UInputEventHandler() { cleanupUinputEvHand(); }
|
||||
|
||||
/**
|
||||
* @brief Initialize keyboard and mouse virtual devices. Each device will
|
||||
@@ -109,7 +101,6 @@ bool UInputEventHandler::init()
|
||||
QTimer::singleShot(2000, this, SLOT(x11ResetMouseAccelerationChange()));
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -120,8 +111,7 @@ bool UInputEventHandler::init()
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::initDevice(int& device, QString name, bool& result)
|
||||
void UInputEventHandler::initDevice(int &device, QString name, bool &result)
|
||||
{
|
||||
device = openUInputHandle();
|
||||
|
||||
@@ -131,26 +121,22 @@ void UInputEventHandler::initDevice(int& device, QString name, bool& result)
|
||||
{
|
||||
setSpringMouseEvents(device);
|
||||
createUInputSpringMouseDevice(device);
|
||||
}
|
||||
else if (name == "mouseFileHandler")
|
||||
} else if (name == "mouseFileHandler")
|
||||
{
|
||||
setRelMouseEvents(device);
|
||||
createUInputMouseDevice(device);
|
||||
}
|
||||
else if (name == "keyboardFileHandler")
|
||||
} else if (name == "keyboardFileHandler")
|
||||
{
|
||||
setKeyboardEvents(device);
|
||||
populateKeyCodes(device);
|
||||
createUInputKeyboardDevice(device);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef WITH_X11
|
||||
void UInputEventHandler::x11ResetMouseAccelerationChange()
|
||||
{
|
||||
@@ -161,12 +147,7 @@ void UInputEventHandler::x11ResetMouseAccelerationChange()
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool UInputEventHandler::cleanup()
|
||||
{
|
||||
return cleanupUinputEvHand();
|
||||
}
|
||||
|
||||
bool UInputEventHandler::cleanup() { return cleanupUinputEvHand(); }
|
||||
|
||||
bool UInputEventHandler::cleanupUinputEvHand()
|
||||
{
|
||||
@@ -191,7 +172,6 @@ bool UInputEventHandler::cleanupUinputEvHand()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendKeyboardEvent(JoyButtonSlot *slot, bool pressed)
|
||||
{
|
||||
JoyButtonSlot::JoySlotInputAction device = slot->getSlotMode();
|
||||
@@ -203,7 +183,6 @@ void UInputEventHandler::sendKeyboardEvent(JoyButtonSlot *slot, bool pressed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)
|
||||
{
|
||||
JoyButtonSlot::JoySlotInputAction device = slot->getSlotMode();
|
||||
@@ -216,73 +195,62 @@ void UInputEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)
|
||||
unsigned int tempcode = BTN_LEFT;
|
||||
switch (code)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
case 3: {
|
||||
tempcode = BTN_RIGHT;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
case 2: {
|
||||
tempcode = BTN_MIDDLE;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
tempcode = BTN_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
write_uinput_event(mouseFileHandler, EV_KEY, tempcode, pressed ? 1 : 0);
|
||||
}
|
||||
else if (code == 4)
|
||||
} else if (code == 4)
|
||||
{
|
||||
if (pressed)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_REL, REL_WHEEL, 1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (code == 5)
|
||||
} else if (code == 5)
|
||||
{
|
||||
if (pressed)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_REL, REL_WHEEL, -1);
|
||||
}
|
||||
}
|
||||
else if (code == 6)
|
||||
} else if (code == 6)
|
||||
{
|
||||
if (pressed)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_REL, REL_HWHEEL, 1);
|
||||
}
|
||||
}
|
||||
else if (code == 7)
|
||||
} else if (code == 7)
|
||||
{
|
||||
if (pressed)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_REL, REL_HWHEEL, -1);
|
||||
}
|
||||
}
|
||||
else if (code == 8)
|
||||
} else if (code == 8)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_KEY, BTN_SIDE, pressed ? 1 : 0);
|
||||
}
|
||||
else if (code == 9)
|
||||
} else if (code == 9)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_KEY, BTN_EXTRA, pressed ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendMouseEvent(int xDis, int yDis)
|
||||
{
|
||||
write_uinput_event(mouseFileHandler, EV_REL, REL_X, xDis, false);
|
||||
write_uinput_event(mouseFileHandler, EV_REL, REL_Y, yDis);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendMouseAbsEvent(int xDis, int yDis, int screen)
|
||||
{
|
||||
Q_UNUSED(screen);
|
||||
@@ -291,9 +259,7 @@ void UInputEventHandler::sendMouseAbsEvent(int xDis, int yDis, int screen)
|
||||
write_uinput_event(springMouseFileHandler, EV_ABS, ABS_Y, yDis);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis,
|
||||
int width, int height)
|
||||
void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int height)
|
||||
{
|
||||
if ((width > 0) && (height > 0))
|
||||
{
|
||||
@@ -306,11 +272,9 @@ void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis)
|
||||
{
|
||||
if ((xDis >= -1.0) && (xDis <= 1.0) &&
|
||||
(yDis >= -1.0) && (yDis <= 1.0))
|
||||
if ((xDis >= -1.0) && (xDis <= 1.0) && (yDis >= -1.0) && (yDis <= 1.0))
|
||||
{
|
||||
int fx = ceil(32767 * xDis);
|
||||
int fy = ceil(32767 * yDis);
|
||||
@@ -318,7 +282,6 @@ void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int UInputEventHandler::openUInputHandle()
|
||||
{
|
||||
int filehandle = -1;
|
||||
@@ -348,8 +311,7 @@ int UInputEventHandler::openUInputHandle()
|
||||
lastErrorString = tr("Could not find a valid uinput device file.\n"
|
||||
"Please check that you have the uinput module loaded.\n"
|
||||
"lsmod | grep uinput");
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QByteArray tempArray = possibleLocation.toUtf8();
|
||||
filehandle = open(tempArray.constData(), O_WRONLY | O_NONBLOCK);
|
||||
@@ -359,8 +321,7 @@ int UInputEventHandler::openUInputHandle()
|
||||
lastErrorString = tr("Could not open uinput device file\n"
|
||||
"Please check that you have permission to write to the device");
|
||||
lastErrorString.append("\n").append(possibleLocation);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
uinputDeviceLocation = possibleLocation;
|
||||
}
|
||||
@@ -369,14 +330,12 @@ int UInputEventHandler::openUInputHandle()
|
||||
return filehandle;
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::setKeyboardEvents(int filehandle)
|
||||
{
|
||||
ioctl(filehandle, UI_SET_EVBIT, EV_KEY);
|
||||
ioctl(filehandle, UI_SET_EVBIT, EV_SYN);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::setRelMouseEvents(int filehandle)
|
||||
{
|
||||
ioctl(filehandle, UI_SET_EVBIT, EV_KEY);
|
||||
@@ -395,7 +354,6 @@ void UInputEventHandler::setRelMouseEvents(int filehandle)
|
||||
ioctl(filehandle, UI_SET_KEYBIT, BTN_EXTRA);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::setSpringMouseEvents(int filehandle)
|
||||
{
|
||||
ioctl(filehandle, UI_SET_EVBIT, EV_KEY);
|
||||
@@ -417,7 +375,6 @@ void UInputEventHandler::setSpringMouseEvents(int filehandle)
|
||||
ioctl(filehandle, UI_SET_KEYBIT, BTN_TOOL_PEN);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::populateKeyCodes(int filehandle)
|
||||
{
|
||||
for (unsigned int i = KEY_ESC; i <= KEY_MICMUTE; i++)
|
||||
@@ -426,7 +383,6 @@ void UInputEventHandler::populateKeyCodes(int filehandle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::createUInputKeyboardDevice(int filehandle)
|
||||
{
|
||||
struct uinput_user_dev uidev;
|
||||
@@ -443,7 +399,6 @@ void UInputEventHandler::createUInputKeyboardDevice(int filehandle)
|
||||
ioctl(filehandle, UI_DEV_CREATE);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::createUInputMouseDevice(int filehandle)
|
||||
{
|
||||
struct uinput_user_dev uidev;
|
||||
@@ -460,7 +415,6 @@ void UInputEventHandler::createUInputMouseDevice(int filehandle)
|
||||
ioctl(filehandle, UI_DEV_CREATE);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::createUInputSpringMouseDevice(int filehandle)
|
||||
{
|
||||
struct uinput_user_dev uidev;
|
||||
@@ -485,16 +439,13 @@ void UInputEventHandler::createUInputSpringMouseDevice(int filehandle)
|
||||
ioctl(filehandle, UI_DEV_CREATE);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::closeUInputDevice(int filehandle)
|
||||
{
|
||||
ioctl(filehandle, UI_DEV_DESTROY);
|
||||
close(filehandle);
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::write_uinput_event(int filehandle, int type,
|
||||
int code, int value, bool syn)
|
||||
void UInputEventHandler::write_uinput_event(int filehandle, int type, int code, int value, bool syn)
|
||||
{
|
||||
struct input_event ev;
|
||||
struct input_event ev2;
|
||||
@@ -519,17 +470,9 @@ void UInputEventHandler::write_uinput_event(int filehandle, int type,
|
||||
}
|
||||
}
|
||||
|
||||
QString UInputEventHandler::getName() { return QString("uinput"); }
|
||||
|
||||
QString UInputEventHandler::getName()
|
||||
{
|
||||
return QString("uinput");
|
||||
}
|
||||
|
||||
|
||||
QString UInputEventHandler::getIdentifier()
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
QString UInputEventHandler::getIdentifier() { return getName(); }
|
||||
|
||||
/**
|
||||
* @brief Print extra help messages to stdout.
|
||||
@@ -547,22 +490,21 @@ void UInputEventHandler::printPostMessages()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::sendTextEntryEvent(QString maintext)
|
||||
{
|
||||
AntKeyMapper *mapper = AntKeyMapper::getInstance();
|
||||
|
||||
if ((mapper != nullptr) && mapper->getKeyMapper())
|
||||
{
|
||||
QtUInputKeyMapper *keymapper = qobject_cast<QtUInputKeyMapper*>(mapper->getKeyMapper());
|
||||
#ifdef WITH_X11
|
||||
QtUInputKeyMapper *keymapper = qobject_cast<QtUInputKeyMapper *>(mapper->getKeyMapper());
|
||||
#ifdef WITH_X11
|
||||
QtX11KeyMapper *nativeWinKeyMapper = nullptr;
|
||||
|
||||
if (mapper->getNativeKeyMapper())
|
||||
{
|
||||
nativeWinKeyMapper = qobject_cast<QtX11KeyMapper*>(mapper->getNativeKeyMapper());
|
||||
nativeWinKeyMapper = qobject_cast<QtX11KeyMapper *>(mapper->getNativeKeyMapper());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QList<unsigned int> tempList;
|
||||
|
||||
@@ -574,7 +516,7 @@ void UInputEventHandler::sendTextEntryEvent(QString maintext)
|
||||
temp.virtualkey = 0;
|
||||
temp.modifiers = Qt::NoModifier;
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
if (nativeWinKeyMapper != nullptr)
|
||||
{
|
||||
QtX11KeyMapper::charKeyInformation tempX11 = nativeWinKeyMapper->getCharKeyInformation(maintext.at(i));
|
||||
@@ -585,19 +527,17 @@ void UInputEventHandler::sendTextEntryEvent(QString maintext)
|
||||
{
|
||||
temp.virtualkey = keymapper->returnVirtualKey(tempQtKey);
|
||||
temp.modifiers = tempX11.modifiers;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
temp = keymapper->getCharKeyInformation(maintext.at(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
#endif
|
||||
#endif
|
||||
temp = keymapper->getCharKeyInformation(maintext.at(i));
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (temp.virtualkey > KEY_RESERVED)
|
||||
{
|
||||
@@ -629,8 +569,7 @@ void UInputEventHandler::sendTextEntryEvent(QString maintext)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UInputEventHandler::testAndAppend(bool tested, QList<unsigned int>& tempList, unsigned int key)
|
||||
void UInputEventHandler::testAndAppend(bool tested, QList<unsigned int> &tempList, unsigned int key)
|
||||
{
|
||||
if (tested)
|
||||
{
|
||||
@@ -639,26 +578,10 @@ void UInputEventHandler::testAndAppend(bool tested, QList<unsigned int>& tempLis
|
||||
}
|
||||
}
|
||||
|
||||
int UInputEventHandler::getKeyboardFileHandler() { return keyboardFileHandler; }
|
||||
|
||||
int UInputEventHandler::getKeyboardFileHandler() {
|
||||
int UInputEventHandler::getMouseFileHandler() { return mouseFileHandler; }
|
||||
|
||||
return keyboardFileHandler;
|
||||
}
|
||||
int UInputEventHandler::getSpringMouseFileHandler() { return springMouseFileHandler; }
|
||||
|
||||
|
||||
int UInputEventHandler::getMouseFileHandler() {
|
||||
|
||||
return mouseFileHandler;
|
||||
}
|
||||
|
||||
|
||||
int UInputEventHandler::getSpringMouseFileHandler() {
|
||||
|
||||
return springMouseFileHandler;
|
||||
}
|
||||
|
||||
|
||||
const QString UInputEventHandler::getUinputDeviceLocation() {
|
||||
|
||||
return uinputDeviceLocation;
|
||||
}
|
||||
const QString UInputEventHandler::getUinputDeviceLocation() { return uinputDeviceLocation; }
|
||||
|
||||
@@ -25,7 +25,7 @@ class UInputEventHandler : public BaseEventHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit UInputEventHandler(QObject *parent = nullptr);
|
||||
~UInputEventHandler();
|
||||
|
||||
@@ -36,8 +36,7 @@ public:
|
||||
virtual void sendMouseEvent(int xDis, int yDis) override;
|
||||
virtual void sendMouseAbsEvent(int xDis, int yDis, int screen) override;
|
||||
|
||||
virtual void sendMouseSpringEvent(int xDis, int yDis,
|
||||
int width, int height) override;
|
||||
virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override;
|
||||
virtual void sendMouseSpringEvent(int xDis, int yDis) override;
|
||||
|
||||
virtual QString getName() override;
|
||||
@@ -51,7 +50,7 @@ public:
|
||||
int getSpringMouseFileHandler();
|
||||
const QString getUinputDeviceLocation();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int openUInputHandle();
|
||||
void setKeyboardEvents(int filehandle);
|
||||
void setRelMouseEvents(int filehandle);
|
||||
@@ -61,24 +60,22 @@ protected:
|
||||
void createUInputMouseDevice(int filehandle);
|
||||
void createUInputSpringMouseDevice(int filehandle);
|
||||
void closeUInputDevice(int filehandle);
|
||||
void write_uinput_event(int filehandle, int type,
|
||||
int code, int value, bool syn=true);
|
||||
void write_uinput_event(int filehandle, int type, int code, int value, bool syn = true);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
#ifdef WITH_X11
|
||||
void x11ResetMouseAccelerationChange();
|
||||
#endif
|
||||
|
||||
private:
|
||||
private:
|
||||
int keyboardFileHandler;
|
||||
int mouseFileHandler;
|
||||
int springMouseFileHandler;
|
||||
QString uinputDeviceLocation;
|
||||
|
||||
bool cleanupUinputEvHand();
|
||||
void testAndAppend(bool tested, QList<unsigned int>& tempList, unsigned int key);
|
||||
void initDevice(int& device, QString name, bool& result);
|
||||
|
||||
void testAndAppend(bool tested, QList<unsigned int> &tempList, unsigned int key);
|
||||
void initDevice(int &device, QString name, bool &result);
|
||||
};
|
||||
|
||||
#endif // UINPUTEVENTHANDLER_H
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
#include "xtesteventhandler.h"
|
||||
|
||||
#include "antkeymapper.h"
|
||||
#include "globalvariables.h"
|
||||
#include "joybuttonslot.h"
|
||||
#include "antkeymapper.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
@@ -29,19 +29,13 @@
|
||||
|
||||
#include "x11extras.h"
|
||||
|
||||
|
||||
XTestEventHandler::XTestEventHandler(QObject *parent) :
|
||||
BaseEventHandler(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
XTestEventHandler::~XTestEventHandler()
|
||||
XTestEventHandler::XTestEventHandler(QObject *parent)
|
||||
: BaseEventHandler(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
XTestEventHandler::~XTestEventHandler() { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
bool XTestEventHandler::init()
|
||||
{
|
||||
@@ -57,7 +51,6 @@ bool XTestEventHandler::init()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool XTestEventHandler::cleanup()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -65,12 +58,11 @@ bool XTestEventHandler::cleanup()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::sendKeyboardEvent(JoyButtonSlot *slot, bool pressed)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
|
||||
JoyButtonSlot::JoySlotInputAction device = slot->getSlotMode();
|
||||
|
||||
@@ -88,12 +80,11 @@ void XTestEventHandler::sendKeyboardEvent(JoyButtonSlot *slot, bool pressed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
JoyButtonSlot::JoySlotInputAction device = slot->getSlotMode();
|
||||
|
||||
int code = slot->getSlotCode();
|
||||
@@ -105,27 +96,24 @@ void XTestEventHandler::sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::sendMouseEvent(int xDis, int yDis)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
XTestFakeRelativeMotionEvent(display, xDis, yDis, 0);
|
||||
XFlush(display);
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::sendMouseAbsEvent(int xDis, int yDis, int screen)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
XTestFakeMotionEvent(display, screen, xDis, yDis, 0);
|
||||
XFlush(display);
|
||||
}
|
||||
|
||||
|
||||
QString XTestEventHandler::getName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -133,7 +121,6 @@ QString XTestEventHandler::getName()
|
||||
return QString("XTest");
|
||||
}
|
||||
|
||||
|
||||
QString XTestEventHandler::getIdentifier()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -141,7 +128,6 @@ QString XTestEventHandler::getIdentifier()
|
||||
return QString("xtest");
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::sendTextEntryEvent(QString maintext)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -150,8 +136,8 @@ void XTestEventHandler::sendTextEntryEvent(QString maintext)
|
||||
|
||||
if ((mapper != nullptr) && mapper->getKeyMapper())
|
||||
{
|
||||
Display* display = X11Extras::getInstance()->display();
|
||||
QtX11KeyMapper *keymapper = qobject_cast<QtX11KeyMapper*>(mapper->getKeyMapper());
|
||||
Display *display = X11Extras::getInstance()->display();
|
||||
QtX11KeyMapper *keymapper = qobject_cast<QtX11KeyMapper *>(mapper->getKeyMapper());
|
||||
|
||||
for (int i = 0; i < maintext.size(); i++)
|
||||
{
|
||||
@@ -217,8 +203,8 @@ void XTestEventHandler::sendTextEntryEvent(QString maintext)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int height) {
|
||||
void XTestEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int height)
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -228,14 +214,6 @@ void XTestEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int
|
||||
Q_UNUSED(height);
|
||||
}
|
||||
|
||||
void XTestEventHandler::sendMouseSpringEvent(int, int) { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
void XTestEventHandler::sendMouseSpringEvent(int, int)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
void XTestEventHandler::printPostMessages()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
void XTestEventHandler::printPostMessages() { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
@@ -16,21 +16,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XTESTEVENTHANDLER_H
|
||||
#define XTESTEVENTHANDLER_H
|
||||
|
||||
#include "baseeventhandler.h"
|
||||
|
||||
|
||||
class JoyButtonSlot;
|
||||
|
||||
|
||||
class XTestEventHandler : public BaseEventHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit XTestEventHandler(QObject *parent = nullptr);
|
||||
virtual ~XTestEventHandler();
|
||||
|
||||
@@ -42,8 +39,7 @@ public:
|
||||
void sendMouseEvent(int xDis, int yDis) override;
|
||||
void sendMouseAbsEvent(int xDis, int yDis, int screen) override;
|
||||
|
||||
void sendMouseSpringEvent(int xDis, int yDis,
|
||||
int width, int height) override;
|
||||
void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override;
|
||||
void sendMouseSpringEvent(int xDis, int yDis) override;
|
||||
|
||||
void sendTextEntryEvent(QString maintext) override;
|
||||
@@ -51,7 +47,6 @@ public:
|
||||
QString getName() override;
|
||||
QString getIdentifier() override;
|
||||
void printPostMessages() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // XTESTEVENTHANDLER_H
|
||||
|
||||
@@ -19,15 +19,14 @@
|
||||
#include "extraprofilesettingsdialog.h"
|
||||
#include "ui_extraprofilesettingsdialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "inputdevice.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
ExtraProfileSettingsDialog::ExtraProfileSettingsDialog(InputDevice *device, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ExtraProfileSettingsDialog)
|
||||
ExtraProfileSettingsDialog::ExtraProfileSettingsDialog(InputDevice *device, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::ExtraProfileSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -67,7 +66,4 @@ void ExtraProfileSettingsDialog::changeDeviceKeyPress(int value)
|
||||
ui->pressValueLabel->setText(QString::number(temppress / 1000.0, 'g', 3).append("").append(tr("s")));
|
||||
}
|
||||
|
||||
InputDevice* ExtraProfileSettingsDialog::getDevice() const {
|
||||
|
||||
return device;
|
||||
}
|
||||
InputDevice *ExtraProfileSettingsDialog::getDevice() const { return device; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KEYDELAYDIALOG_H
|
||||
#define KEYDELAYDIALOG_H
|
||||
|
||||
@@ -33,18 +32,18 @@ class ExtraProfileSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit ExtraProfileSettingsDialog(InputDevice *device, QWidget *parent = nullptr);
|
||||
~ExtraProfileSettingsDialog();
|
||||
|
||||
InputDevice* getDevice() const;
|
||||
InputDevice *getDevice() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::ExtraProfileSettingsDialog *ui;
|
||||
|
||||
InputDevice *device;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void changeDeviceKeyPress(int value);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#define MAKE_CONTROLLER_ID( nVID, nPID ) (unsigned int)( nVID << 16 | nPID )
|
||||
#define MAKE_CONTROLLER_ID(nVID, nPID) (unsigned int)(nVID << 16 | nPID)
|
||||
|
||||
#include "xbox360wireless.h"
|
||||
//#include "SDL-mirror/src/joystick/SDL_sysjoystick.h"
|
||||
|
||||
|
||||
|
||||
|
||||
Xbox360Wireless::Xbox360Wireless()
|
||||
{
|
||||
SDL_Joystick Xbox360;
|
||||
@@ -19,17 +16,20 @@ Xbox360Wireless::Xbox360Wireless()
|
||||
Xbox360.nbuttons = 15;
|
||||
// Xbox360.nballs = 0;
|
||||
|
||||
if (Xbox360.naxes > 0) {
|
||||
Xbox360.axes = (SDL_JoystickAxisInfo *) SDL_calloc(Xbox360.naxes, sizeof(SDL_JoystickAxisInfo));
|
||||
if (Xbox360.naxes > 0)
|
||||
{
|
||||
Xbox360.axes = (SDL_JoystickAxisInfo *)SDL_calloc(Xbox360.naxes, sizeof(SDL_JoystickAxisInfo));
|
||||
}
|
||||
if (Xbox360.nhats > 0) {
|
||||
Xbox360.hats = (Uint8 *) SDL_calloc(Xbox360.nhats, sizeof(Uint8));
|
||||
if (Xbox360.nhats > 0)
|
||||
{
|
||||
Xbox360.hats = (Uint8 *)SDL_calloc(Xbox360.nhats, sizeof(Uint8));
|
||||
}
|
||||
//if (Xbox360.nballs > 0) {
|
||||
// if (Xbox360.nballs > 0) {
|
||||
// Xbox360.balls = (struct balldelta *) SDL_calloc(Xbox360.balls, sizeof(*Xbox360.balls));
|
||||
// }
|
||||
if (Xbox360.nbuttons > 0) {
|
||||
Xbox360.buttons = (Uint8 *) SDL_calloc(Xbox360.nbuttons, sizeof(Uint8));
|
||||
if (Xbox360.nbuttons > 0)
|
||||
{
|
||||
Xbox360.buttons = (Uint8 *)SDL_calloc(Xbox360.nbuttons, sizeof(Uint8));
|
||||
}
|
||||
|
||||
Xbox360.attached = SDL_TRUE;
|
||||
@@ -41,10 +41,8 @@ Xbox360Wireless::Xbox360Wireless()
|
||||
// _SDL_JoystickDriver - it's faked class so there is no need to use detection from system level
|
||||
|
||||
result = &Xbox360;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Xbox360Wireless::~Xbox360Wireless()
|
||||
{
|
||||
SDL_free(result->name);
|
||||
@@ -57,39 +55,19 @@ Xbox360Wireless::~Xbox360Wireless()
|
||||
SDL_free(result);
|
||||
}
|
||||
|
||||
char *Xbox360Wireless::GUID()
|
||||
{
|
||||
return "030000005e040000e002000000000000";
|
||||
}
|
||||
char *Xbox360Wireless::GUID() { return "030000005e040000e002000000000000"; }
|
||||
|
||||
char *Xbox360Wireless::name()
|
||||
{
|
||||
return "Xbox Wireless Controller";
|
||||
}
|
||||
char *Xbox360Wireless::name() { return "Xbox Wireless Controller"; }
|
||||
|
||||
unsigned int Xbox360Wireless::deviceId()
|
||||
{
|
||||
return MAKE_CONTROLLER_ID( 0x045e, 0x0291 );
|
||||
}
|
||||
unsigned int Xbox360Wireless::deviceId() { return MAKE_CONTROLLER_ID(0x045e, 0x0291); }
|
||||
|
||||
int Xbox360Wireless::controllerType()
|
||||
{
|
||||
return 31; // k_eControllerType_XBox360Controller
|
||||
}
|
||||
|
||||
SDL_JoystickType Xbox360Wireless::joystickType()
|
||||
{
|
||||
return SDL_JoystickType::SDL_JOYSTICK_TYPE_GAMECONTROLLER;
|
||||
}
|
||||
|
||||
SDL_JoystickGUID Xbox360Wireless::joyGUID()
|
||||
{
|
||||
return SDL_JoystickGetGUIDFromString(GUID());
|
||||
}
|
||||
|
||||
SDL_Joystick* Xbox360Wireless::getResult()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
SDL_JoystickType Xbox360Wireless::joystickType() { return SDL_JoystickType::SDL_JOYSTICK_TYPE_GAMECONTROLLER; }
|
||||
|
||||
SDL_JoystickGUID Xbox360Wireless::joyGUID() { return SDL_JoystickGetGUIDFromString(GUID()); }
|
||||
|
||||
SDL_Joystick *Xbox360Wireless::getResult() { return result; }
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <SDL2/SDL_joystick.h>
|
||||
|
||||
|
||||
typedef struct _SDL_JoystickAxisInfo
|
||||
{
|
||||
Sint16 initial_value; /* Initial axis state */
|
||||
@@ -27,10 +26,11 @@ struct _SDL_Joystick
|
||||
Uint8 *hats; /* Current hat states */
|
||||
|
||||
int nballs; /* Number of trackballs on the joystick */
|
||||
struct balldelta {
|
||||
struct balldelta
|
||||
{
|
||||
int dx;
|
||||
int dy;
|
||||
} *balls; /* Current ball motion deltas */
|
||||
} * balls; /* Current ball motion deltas */
|
||||
|
||||
int nbuttons; /* Number of buttons on the joystick */
|
||||
Uint8 *buttons; /* Current button states */
|
||||
@@ -52,22 +52,20 @@ struct _SDL_Joystick
|
||||
class Xbox360Wireless
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
Xbox360Wireless();
|
||||
~Xbox360Wireless();
|
||||
|
||||
char* GUID();
|
||||
char* name();
|
||||
char *GUID();
|
||||
char *name();
|
||||
unsigned int deviceId();
|
||||
int controllerType();
|
||||
SDL_JoystickType joystickType();
|
||||
SDL_JoystickGUID joyGUID();
|
||||
SDL_Joystick* getResult();
|
||||
|
||||
private:
|
||||
SDL_Joystick* result;
|
||||
SDL_Joystick *getResult();
|
||||
|
||||
private:
|
||||
SDL_Joystick *result;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,15 +21,14 @@
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStyle>
|
||||
#include <QFontMetrics>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
FlashButtonWidget::FlashButtonWidget(QWidget *parent) :
|
||||
QPushButton(parent)
|
||||
FlashButtonWidget::FlashButtonWidget(QWidget *parent)
|
||||
: QPushButton(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -38,8 +37,8 @@ FlashButtonWidget::FlashButtonWidget(QWidget *parent) :
|
||||
leftAlignText = false;
|
||||
}
|
||||
|
||||
FlashButtonWidget::FlashButtonWidget(bool displayNames, QWidget *parent) :
|
||||
QPushButton(parent)
|
||||
FlashButtonWidget::FlashButtonWidget(bool displayNames, QWidget *parent)
|
||||
: QPushButton(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -78,9 +77,7 @@ void FlashButtonWidget::refreshLabel()
|
||||
|
||||
setText(generateLabel());
|
||||
|
||||
|
||||
qDebug() << "label has been set: " << generateLabel();
|
||||
|
||||
}
|
||||
|
||||
bool FlashButtonWidget::isButtonFlashing()
|
||||
@@ -127,7 +124,7 @@ void FlashButtonWidget::paintEvent(QPaintEvent *event)
|
||||
|
||||
while ((this->width() < fm.width(text())) && (tempScaledFont.pointSize() >= 7))
|
||||
{
|
||||
tempScaledFont.setPointSize(tempScaledFont.pointSize()-1);
|
||||
tempScaledFont.setPointSize(tempScaledFont.pointSize() - 1);
|
||||
painter.setFont(tempScaledFont);
|
||||
fm = painter.fontMetrics();
|
||||
reduce = true;
|
||||
@@ -143,8 +140,7 @@ void FlashButtonWidget::paintEvent(QPaintEvent *event)
|
||||
setStyleSheet("text-align: left;");
|
||||
this->style()->unpolish(this);
|
||||
this->style()->polish(this);
|
||||
}
|
||||
else if (!reduce && leftAlignText)
|
||||
} else if (!reduce && leftAlignText)
|
||||
{
|
||||
leftAlignText = !leftAlignText;
|
||||
setStyleSheet("text-align: center;");
|
||||
@@ -165,7 +161,4 @@ void FlashButtonWidget::retranslateUi()
|
||||
refreshLabel();
|
||||
}
|
||||
|
||||
bool FlashButtonWidget::ifDisplayNames() {
|
||||
|
||||
return m_displayNames;
|
||||
}
|
||||
bool FlashButtonWidget::ifDisplayNames() { return m_displayNames; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FLASHBUTTONWIDGET_H
|
||||
#define FLASHBUTTONWIDGET_H
|
||||
|
||||
@@ -25,13 +24,12 @@
|
||||
class QWidget;
|
||||
class QPaintEvent;
|
||||
|
||||
|
||||
class FlashButtonWidget : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isflashing READ isButtonFlashing)
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit FlashButtonWidget(QWidget *parent = nullptr);
|
||||
explicit FlashButtonWidget(bool displayNames, QWidget *parent = nullptr);
|
||||
|
||||
@@ -39,30 +37,29 @@ public:
|
||||
void setDisplayNames(bool display);
|
||||
bool isDisplayingNames();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual QString generateLabel() = 0;
|
||||
virtual void retranslateUi();
|
||||
bool ifDisplayNames();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void flashed(bool flashing);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void refreshLabel();
|
||||
void toggleNameDisplay();
|
||||
virtual void disableFlashes() = 0;
|
||||
virtual void enableFlashes() = 0;
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
void flash();
|
||||
void unflash();
|
||||
|
||||
private:
|
||||
private:
|
||||
bool isflashing;
|
||||
bool m_displayNames;
|
||||
bool leftAlignText;
|
||||
|
||||
};
|
||||
|
||||
#endif // FLASHBUTTONWIDGET_H
|
||||
|
||||
@@ -18,26 +18,25 @@
|
||||
|
||||
#include "gamecontroller.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "common.h"
|
||||
#include "gamecontrollerdpad.h"
|
||||
#include "gamecontrollerset.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "globalvariables.h"
|
||||
#include "joybuttontypes/joycontrolstickbutton.h"
|
||||
#include "common.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "messagehandler.h"
|
||||
//#include "logger.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
GameController::GameController(SDL_GameController *controller, int deviceIndex,
|
||||
AntiMicroSettings *settings, int counterUniques, QObject *parent) :
|
||||
InputDevice(SDL_GameControllerGetJoystick(controller), deviceIndex, settings, parent)
|
||||
GameController::GameController(SDL_GameController *controller, int deviceIndex, AntiMicroSettings *settings,
|
||||
int counterUniques, QObject *parent)
|
||||
: InputDevice(SDL_GameControllerGetJoystick(controller), deviceIndex, settings, parent)
|
||||
{
|
||||
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -56,7 +55,6 @@ GameController::GameController(SDL_GameController *controller, int deviceIndex,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -64,7 +62,6 @@ QString GameController::getName()
|
||||
return QString(tr("Game Controller")).append(" ").append(QString::number(getRealJoyNumber()));
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getSDLName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -86,7 +83,6 @@ QString GameController::getXmlName()
|
||||
return GlobalVariables::GameController::xmlName;
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getGUIDString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -94,7 +90,6 @@ QString GameController::getGUIDString()
|
||||
return getRawGUIDString();
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getVendorString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -102,7 +97,6 @@ QString GameController::getVendorString()
|
||||
return getRawVendorString();
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getProductIDString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -110,7 +104,6 @@ QString GameController::getProductIDString()
|
||||
return getRawProductIDString();
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getUniqueIDString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -118,11 +111,7 @@ QString GameController::getUniqueIDString()
|
||||
return getRawUniqueIDString();
|
||||
}
|
||||
|
||||
QString GameController::getProductVersion()
|
||||
{
|
||||
return getRawProductVersion();
|
||||
}
|
||||
|
||||
QString GameController::getProductVersion() { return getRawProductVersion(); }
|
||||
|
||||
QString GameController::getRawGUIDString()
|
||||
{
|
||||
@@ -146,7 +135,6 @@ QString GameController::getRawGUIDString()
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getRawVendorString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -156,8 +144,8 @@ QString GameController::getRawVendorString()
|
||||
if (controller != nullptr)
|
||||
{
|
||||
Uint16 tempVendor = SDL_GameControllerGetVendor(controller);
|
||||
char buffer [50];
|
||||
sprintf (buffer, "%u", tempVendor);
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%u", tempVendor);
|
||||
|
||||
temp = QString(buffer);
|
||||
}
|
||||
@@ -165,7 +153,6 @@ QString GameController::getRawVendorString()
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getRawProductIDString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -175,8 +162,8 @@ QString GameController::getRawProductIDString()
|
||||
if (controller != nullptr)
|
||||
{
|
||||
Uint16 tempProduct = SDL_GameControllerGetProduct(controller) + counterUniques;
|
||||
char buffer [50];
|
||||
sprintf (buffer, "%u", tempProduct);
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%u", tempProduct);
|
||||
|
||||
temp = QString(buffer);
|
||||
}
|
||||
@@ -193,8 +180,8 @@ QString GameController::getRawProductVersion()
|
||||
if (controller != nullptr)
|
||||
{
|
||||
Uint16 tempProductVersion = SDL_GameControllerGetProductVersion(controller);
|
||||
char buffer [50];
|
||||
sprintf (buffer, "%u", tempProductVersion);
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%u", tempProductVersion);
|
||||
|
||||
temp = QString(buffer);
|
||||
}
|
||||
@@ -202,13 +189,11 @@ QString GameController::getRawProductVersion()
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getRawUniqueIDString()
|
||||
{
|
||||
return (getRawGUIDString() + getRawVendorString() + getRawProductIDString());
|
||||
}
|
||||
|
||||
|
||||
void GameController::closeSDLDevice()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -220,7 +205,6 @@ void GameController::closeSDLDevice()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GameController::getNumberRawButtons()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -228,19 +212,15 @@ int GameController::getNumberRawButtons()
|
||||
return SDL_CONTROLLER_BUTTON_MAX;
|
||||
}
|
||||
|
||||
|
||||
int GameController::getNumberRawAxes()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
qDebug() << "Controller has " << SDL_CONTROLLER_AXIS_MAX << " raw axes";
|
||||
|
||||
|
||||
return SDL_CONTROLLER_AXIS_MAX;
|
||||
}
|
||||
|
||||
|
||||
int GameController::getNumberRawHats()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -248,13 +228,10 @@ int GameController::getNumberRawHats()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GameController::setCounterUniques(int counter)
|
||||
{
|
||||
counterUniques = counter;
|
||||
}
|
||||
void GameController::setCounterUniques(int counter) { counterUniques = counter; }
|
||||
|
||||
|
||||
void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &buttons, QHash<int, SDL_GameControllerAxis> &axes, QList<SDL_GameControllerButtonBind> &hatButtons)
|
||||
void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &buttons, QHash<int, SDL_GameControllerAxis> &axes,
|
||||
QList<SDL_GameControllerButtonBind> &hatButtons)
|
||||
{
|
||||
|
||||
for (int i = 0; i < SDL_JoystickNumHats(getJoyHandle()); i++)
|
||||
@@ -262,10 +239,8 @@ void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &button
|
||||
SDL_GameControllerButton currentButton = static_cast<SDL_GameControllerButton>(i);
|
||||
SDL_GameControllerButtonBind bound = SDL_GameControllerGetBindForButton(this->controller, currentButton);
|
||||
|
||||
|
||||
qDebug() << "Hat " << (i + 1);
|
||||
|
||||
|
||||
if (bound.bindType == SDL_CONTROLLER_BINDTYPE_HAT)
|
||||
{
|
||||
hatButtons.append(bound);
|
||||
@@ -277,7 +252,6 @@ void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &button
|
||||
|
||||
qDebug() << "Button " << (i + 1);
|
||||
|
||||
|
||||
SDL_GameControllerButton currentButton = static_cast<SDL_GameControllerButton>(i);
|
||||
SDL_GameControllerButtonBind bound = SDL_GameControllerGetBindForButton(this->controller, currentButton);
|
||||
|
||||
@@ -292,7 +266,6 @@ void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &button
|
||||
|
||||
qDebug() << "Axis " << (i + 1);
|
||||
|
||||
|
||||
SDL_GameControllerAxis currentAxis = static_cast<SDL_GameControllerAxis>(i);
|
||||
SDL_GameControllerButtonBind bound = SDL_GameControllerGetBindForAxis(this->controller, currentAxis);
|
||||
|
||||
@@ -303,7 +276,6 @@ void GameController::fillContainers(QHash<int, SDL_GameControllerButton> &button
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getBindStringForAxis(int index, bool)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -311,15 +283,12 @@ QString GameController::getBindStringForAxis(int index, bool)
|
||||
QString temp = QString();
|
||||
|
||||
SDL_GameControllerButtonBind bind =
|
||||
SDL_GameControllerGetBindForAxis(controller,
|
||||
static_cast<SDL_GameControllerAxis>(index));
|
||||
|
||||
SDL_GameControllerGetBindForAxis(controller, static_cast<SDL_GameControllerAxis>(index));
|
||||
|
||||
if (bind.bindType == SDL_CONTROLLER_BINDTYPE_BUTTON)
|
||||
{
|
||||
temp.append(QString("Button %1").arg(bind.value.button));
|
||||
}
|
||||
else if (bind.bindType == SDL_CONTROLLER_BINDTYPE_AXIS)
|
||||
} else if (bind.bindType == SDL_CONTROLLER_BINDTYPE_AXIS)
|
||||
{
|
||||
temp.append(QString("Axis %1").arg(bind.value.axis + 1));
|
||||
}
|
||||
@@ -327,7 +296,6 @@ QString GameController::getBindStringForAxis(int index, bool)
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
QString GameController::getBindStringForButton(int index, bool trueIndex)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -335,35 +303,30 @@ QString GameController::getBindStringForButton(int index, bool trueIndex)
|
||||
QString temp = QString();
|
||||
|
||||
SDL_GameControllerButtonBind bind =
|
||||
SDL_GameControllerGetBindForButton(controller,
|
||||
static_cast<SDL_GameControllerButton>(index));
|
||||
|
||||
SDL_GameControllerGetBindForButton(controller, static_cast<SDL_GameControllerButton>(index));
|
||||
|
||||
int offset = trueIndex ? 0 : 1;
|
||||
int bindInt = static_cast<int>(bind.bindType);
|
||||
|
||||
switch(bindInt) {
|
||||
switch (bindInt)
|
||||
{
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
||||
temp.append(QString("Button %1").arg(bind.value.button + offset));
|
||||
break;
|
||||
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_AXIS:
|
||||
temp.append(QString("Axis %1").arg(bind.value.axis + offset));
|
||||
break;
|
||||
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_HAT:
|
||||
temp.append(QString("Hat %1.%2").arg(bind.value.hat.hat + offset)
|
||||
.arg(bind.value.hat.hat_mask));
|
||||
temp.append(QString("Hat %1.%2").arg(bind.value.hat.hat + offset).arg(bind.value.hat.hat_mask));
|
||||
break;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
SDL_GameControllerButtonBind GameController::getBindForAxis(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -371,7 +334,6 @@ SDL_GameControllerButtonBind GameController::getBindForAxis(int index)
|
||||
return SDL_GameControllerGetBindForAxis(controller, static_cast<SDL_GameControllerAxis>(index));
|
||||
}
|
||||
|
||||
|
||||
SDL_GameControllerButtonBind GameController::getBindForButton(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -379,24 +341,11 @@ SDL_GameControllerButtonBind GameController::getBindForButton(int index)
|
||||
return SDL_GameControllerGetBindForButton(controller, static_cast<SDL_GameControllerButton>(index));
|
||||
}
|
||||
|
||||
void GameController::buttonClickEvent(int) { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
void GameController::buttonClickEvent(int)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
void GameController::buttonReleaseEvent(int)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
void GameController::axisActivatedEvent(int, int, int)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
void GameController::buttonReleaseEvent(int) { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
void GameController::axisActivatedEvent(int, int, int) { qInstallMessageHandler(MessageHandler::myMessageOutput); }
|
||||
|
||||
SDL_JoystickID GameController::getSDLJoystickID()
|
||||
{
|
||||
@@ -416,21 +365,19 @@ bool GameController::isGameController()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if GUID passed matches the expected GUID for a device.
|
||||
* Needed for xinput GUID abstraction.
|
||||
* @param GUID string
|
||||
* @return if GUID is considered a match.
|
||||
*/
|
||||
//bool GameController::isRelevantGUID(QString tempGUID)
|
||||
// bool GameController::isRelevantGUID(QString tempGUID)
|
||||
//{
|
||||
// qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
// return InputDevice::isRelevantGUID(tempGUID);
|
||||
//}
|
||||
|
||||
|
||||
bool GameController::isRelevantUniqueID(QString tempUniqueID)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -438,7 +385,6 @@ bool GameController::isRelevantUniqueID(QString tempUniqueID)
|
||||
return InputDevice::isRelevantUniqueID(tempUniqueID);
|
||||
}
|
||||
|
||||
|
||||
void GameController::rawButtonEvent(int index, bool pressed)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -449,15 +395,13 @@ void GameController::rawButtonEvent(int index, bool pressed)
|
||||
{
|
||||
rawbuttons.insert(index, pressed);
|
||||
emit rawButtonClick(index);
|
||||
}
|
||||
else if (knownbutton && !pressed)
|
||||
} else if (knownbutton && !pressed)
|
||||
{
|
||||
rawbuttons.remove(index);
|
||||
emit rawButtonRelease(index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameController::rawAxisEvent(int index, int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -468,8 +412,7 @@ void GameController::rawAxisEvent(int index, int value)
|
||||
{
|
||||
axisvalues.insert(index, value);
|
||||
emit rawAxisActivated(index, value);
|
||||
}
|
||||
else if (knownaxis && (fabs(value) < rawAxisDeadZone))
|
||||
} else if (knownaxis && (fabs(value) < rawAxisDeadZone))
|
||||
{
|
||||
axisvalues.remove(index);
|
||||
emit rawAxisReleased(index, value);
|
||||
@@ -478,7 +421,6 @@ void GameController::rawAxisEvent(int index, int value)
|
||||
emit rawAxisMoved(index, value);
|
||||
}
|
||||
|
||||
|
||||
void GameController::rawDPadEvent(int index, int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -489,34 +431,17 @@ void GameController::rawDPadEvent(int index, int value)
|
||||
{
|
||||
dpadvalues.insert(index, value);
|
||||
emit rawDPadButtonClick(index, value);
|
||||
}
|
||||
else if (knowndpad && (value == 0))
|
||||
} else if (knowndpad && (value == 0))
|
||||
{
|
||||
dpadvalues.remove(index);
|
||||
emit rawDPadButtonRelease(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, bool> const &GameController::getRawbuttons() { return rawbuttons; }
|
||||
|
||||
QHash<int, bool> const& GameController::getRawbuttons() {
|
||||
QHash<int, int> const &GameController::getAxisvalues() { return axisvalues; }
|
||||
|
||||
return rawbuttons;
|
||||
}
|
||||
QHash<int, int> const &GameController::getDpadvalues() { return dpadvalues; }
|
||||
|
||||
|
||||
QHash<int, int> const& GameController::getAxisvalues() {
|
||||
|
||||
return axisvalues;
|
||||
}
|
||||
|
||||
|
||||
QHash<int, int> const& GameController::getDpadvalues() {
|
||||
|
||||
return dpadvalues;
|
||||
}
|
||||
|
||||
|
||||
SDL_GameController* GameController::getController() const {
|
||||
|
||||
return controller;
|
||||
}
|
||||
SDL_GameController *GameController::getController() const { return controller; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLER_H
|
||||
#define GAMECONTROLLER_H
|
||||
|
||||
@@ -33,8 +32,9 @@ class GameController : public InputDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameController(SDL_GameController *controller, int deviceIndex, AntiMicroSettings *settings, int counterUniques, QObject *parent = nullptr);
|
||||
public:
|
||||
explicit GameController(SDL_GameController *controller, int deviceIndex, AntiMicroSettings *settings, int counterUniques,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
virtual QString getName() override;
|
||||
virtual QString getSDLName() override;
|
||||
@@ -61,32 +61,33 @@ public:
|
||||
virtual int getNumberRawHats() override;
|
||||
void setCounterUniques(int counter) override;
|
||||
|
||||
QString getBindStringForAxis(int index, bool trueIndex=true);
|
||||
QString getBindStringForButton(int index, bool trueIndex=true);
|
||||
QString getBindStringForAxis(int index, bool trueIndex = true);
|
||||
QString getBindStringForButton(int index, bool trueIndex = true);
|
||||
|
||||
SDL_GameControllerButtonBind getBindForAxis(int index);
|
||||
SDL_GameControllerButtonBind getBindForButton(int index);
|
||||
|
||||
//bool isRelevantGUID(QString tempGUID);
|
||||
// bool isRelevantGUID(QString tempGUID);
|
||||
bool isRelevantUniqueID(QString tempUniqueID);
|
||||
void rawButtonEvent(int index, bool pressed);
|
||||
void rawAxisEvent(int index, int value);
|
||||
void rawDPadEvent(int index, int value);
|
||||
|
||||
QHash<int, bool> const& getRawbuttons();
|
||||
QHash<int, int> const& getAxisvalues();
|
||||
QHash<int, int> const& getDpadvalues();
|
||||
QHash<int, bool> const &getRawbuttons();
|
||||
QHash<int, int> const &getAxisvalues();
|
||||
QHash<int, int> const &getDpadvalues();
|
||||
|
||||
SDL_GameController *getController() const;
|
||||
|
||||
void fillContainers(QHash<int, SDL_GameControllerButton> &buttons, QHash<int, SDL_GameControllerAxis> &axes, QList<SDL_GameControllerButtonBind> &hatButtons);
|
||||
void fillContainers(QHash<int, SDL_GameControllerButton> &buttons, QHash<int, SDL_GameControllerAxis> &axes,
|
||||
QList<SDL_GameControllerButtonBind> &hatButtons);
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
virtual void axisActivatedEvent(int setindex, int axisindex, int value) override;
|
||||
virtual void buttonClickEvent(int buttonindex) override;
|
||||
virtual void buttonReleaseEvent(int buttonindex) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
QHash<int, bool> rawbuttons;
|
||||
QHash<int, int> axisvalues;
|
||||
QHash<int, int> dpadvalues;
|
||||
@@ -94,7 +95,6 @@ private:
|
||||
|
||||
SDL_JoystickID joystickID;
|
||||
SDL_GameController *controller;
|
||||
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLER_H
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
#include "gamecontrollerdpad.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "joybutton.h"
|
||||
#include "messagehandler.h"
|
||||
#include "setjoystick.h"
|
||||
#include "joybutton.h"
|
||||
#include "xml/joydpadxml.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
GameControllerDPad::GameControllerDPad(JoyButton *upButton, JoyButton *downButton, JoyButton *leftButton, JoyButton *rightButton,
|
||||
int index, int originset, SetJoystick *parentSet, QObject *parent) :
|
||||
VDPad(upButton, downButton, leftButton, rightButton, index, originset, parentSet, parent)
|
||||
GameControllerDPad::GameControllerDPad(JoyButton *upButton, JoyButton *downButton, JoyButton *leftButton,
|
||||
JoyButton *rightButton, int index, int originset, SetJoystick *parentSet,
|
||||
QObject *parent)
|
||||
: VDPad(upButton, downButton, leftButton, rightButton, index, originset, parentSet, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
QString GameControllerDPad::getName(bool forceFullFormat, bool displayName)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -49,8 +48,7 @@ QString GameControllerDPad::getName(bool forceFullFormat, bool displayName)
|
||||
}
|
||||
|
||||
label.append(getDpadName());
|
||||
}
|
||||
else if (!getDefaultDpadName().isEmpty())
|
||||
} else if (!getDefaultDpadName().isEmpty())
|
||||
{
|
||||
if (forceFullFormat)
|
||||
{
|
||||
@@ -58,8 +56,7 @@ QString GameControllerDPad::getName(bool forceFullFormat, bool displayName)
|
||||
}
|
||||
|
||||
label.append(getDefaultDpadName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(tr("DPad")).append(" ");
|
||||
label.append(QString::number(getRealJoyNumber()));
|
||||
@@ -68,7 +65,6 @@ QString GameControllerDPad::getName(bool forceFullFormat, bool displayName)
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
QString GameControllerDPad::getXmlName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERDPAD_H
|
||||
#define GAMECONTROLLERDPAD_H
|
||||
|
||||
@@ -33,7 +32,7 @@ class GameControllerDPad : public VDPad
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit GameControllerDPad(JoyButton *upButton, JoyButton *downButton, JoyButton *leftButton, JoyButton *rightButton,
|
||||
int index, int originset, SetJoystick *parentSet, QObject *parent = nullptr);
|
||||
|
||||
|
||||
@@ -18,29 +18,27 @@
|
||||
|
||||
#include "gamecontrollerset.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "gamecontroller/xml/gamecontrollertriggerxml.h"
|
||||
#include "gamecontrollerdpad.h"
|
||||
#include "gamecontrollertrigger.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "xml/joydpadxml.h"
|
||||
#include "messagehandler.h"
|
||||
#include "xml/joyaxisxml.h"
|
||||
#include "gamecontroller/xml/gamecontrollertriggerxml.h"
|
||||
#include "xml/joybuttonxml.h"
|
||||
#include "xml/joydpadxml.h"
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
||||
GameControllerSet::GameControllerSet(InputDevice *device, int index, QObject *parent) :
|
||||
SetJoystick(device, index, false, parent)
|
||||
GameControllerSet::GameControllerSet(InputDevice *device, int index, QObject *parent)
|
||||
: SetJoystick(device, index, false, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
resetSticks();
|
||||
}
|
||||
|
||||
|
||||
void GameControllerSet::reset()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -78,7 +76,8 @@ void GameControllerSet::populateSticksDPad()
|
||||
JoyButton *buttonDown = getJoyButton(SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||
JoyButton *buttonLeft = getJoyButton(SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||
JoyButton *buttonRight = getJoyButton(SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
GameControllerDPad *controllerDPad = new GameControllerDPad(buttonUp, buttonDown, buttonLeft, buttonRight, 0, getIndex(), this, this);
|
||||
GameControllerDPad *controllerDPad =
|
||||
new GameControllerDPad(buttonUp, buttonDown, buttonLeft, buttonRight, 0, getIndex(), this, this);
|
||||
controllerDPad->setDefaultDPadName("DPad");
|
||||
addVDPad(0, controllerDPad);
|
||||
|
||||
@@ -100,22 +99,19 @@ void GameControllerSet::populateSticksDPad()
|
||||
getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT)->setDefaultAxisName(tr("R Trigger"));
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void readConf(T* x, QXmlStreamReader *xml)
|
||||
template <typename T> void readConf(T *x, QXmlStreamReader *xml)
|
||||
{
|
||||
if (x != nullptr)
|
||||
{
|
||||
x->readConfig(xml);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
xml->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerSet::readConfDpad(QXmlStreamReader *xml, QList<SDL_GameControllerButtonBind> &hatButtons, bool vdpadExists, bool dpadExists)
|
||||
void GameControllerSet::readConfDpad(QXmlStreamReader *xml, QList<SDL_GameControllerButtonBind> &hatButtons,
|
||||
bool vdpadExists, bool dpadExists)
|
||||
{
|
||||
int index = xml->attributes().value("index").toString().toInt();
|
||||
index = index - 1;
|
||||
@@ -132,7 +128,7 @@ void GameControllerSet::readConfDpad(QXmlStreamReader *xml, QList<SDL_GameContro
|
||||
}
|
||||
|
||||
VDPad *dpad = nullptr;
|
||||
JoyDPadXml<VDPad>* dpadXml = nullptr;
|
||||
JoyDPadXml<VDPad> *dpadXml = nullptr;
|
||||
|
||||
if (found)
|
||||
{
|
||||
@@ -143,16 +139,13 @@ void GameControllerSet::readConfDpad(QXmlStreamReader *xml, QList<SDL_GameContro
|
||||
if ((dpad != nullptr) && !vdpadExists)
|
||||
{
|
||||
dpadXml->readConfig(xml);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
xml->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerSet::readJoystickConfig(QXmlStreamReader *xml,
|
||||
QHash<int, SDL_GameControllerButton> &buttons,
|
||||
void GameControllerSet::readJoystickConfig(QXmlStreamReader *xml, QHash<int, SDL_GameControllerButton> &buttons,
|
||||
QHash<int, SDL_GameControllerAxis> &axes,
|
||||
QList<SDL_GameControllerButtonBind> &hatButtons)
|
||||
{
|
||||
@@ -172,28 +165,27 @@ void GameControllerSet::readJoystickConfig(QXmlStreamReader *xml,
|
||||
{
|
||||
int index = xml->attributes().value("index").toString().toInt();
|
||||
JoyButton *button = nullptr;
|
||||
JoyButtonXml* joyButtonXml = nullptr;
|
||||
JoyButtonXml *joyButtonXml = nullptr;
|
||||
|
||||
if (buttons.contains(index-1))
|
||||
if (buttons.contains(index - 1))
|
||||
{
|
||||
SDL_GameControllerButton current = buttons.value(index-1);
|
||||
SDL_GameControllerButton current = buttons.value(index - 1);
|
||||
button = getJoyButton(current);
|
||||
joyButtonXml = new JoyButtonXml(button);
|
||||
}
|
||||
|
||||
readConf(joyButtonXml, xml);
|
||||
|
||||
}
|
||||
else if ((xml->name() == "axis") && xml->isStartElement())
|
||||
} else if ((xml->name() == "axis") && xml->isStartElement())
|
||||
{
|
||||
int index = xml->attributes().value("index").toString().toInt();
|
||||
GameControllerTrigger *trigger = nullptr;
|
||||
GameControllerTriggerXml* gameContrTriggerXml = nullptr;
|
||||
GameControllerTriggerXml *gameContrTriggerXml = nullptr;
|
||||
|
||||
if (axes.contains(index-1))
|
||||
if (axes.contains(index - 1))
|
||||
{
|
||||
SDL_GameControllerAxis current = axes.value(index-1);
|
||||
trigger = qobject_cast<GameControllerTrigger*>(getJoyAxis(static_cast<int>(current)));
|
||||
SDL_GameControllerAxis current = axes.value(index - 1);
|
||||
trigger = qobject_cast<GameControllerTrigger *>(getJoyAxis(static_cast<int>(current)));
|
||||
gameContrTriggerXml = new GameControllerTriggerXml(trigger);
|
||||
}
|
||||
|
||||
@@ -201,25 +193,20 @@ void GameControllerSet::readJoystickConfig(QXmlStreamReader *xml,
|
||||
{
|
||||
gameContrTriggerXml->readJoystickConfig(xml);
|
||||
delete gameContrTriggerXml;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
xml->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "dpad") && xml->isStartElement())
|
||||
} else if ((xml->name() == "dpad") && xml->isStartElement())
|
||||
{
|
||||
readConfDpad(xml, hatButtons, vdpadExists, dpadExists);
|
||||
}
|
||||
else if ((xml->name() == "stick") && xml->isStartElement())
|
||||
} else if ((xml->name() == "stick") && xml->isStartElement())
|
||||
{
|
||||
getElemFromXml("stick", xml);
|
||||
}
|
||||
else if ((xml->name() == "vdpad") && xml->isStartElement())
|
||||
} else if ((xml->name() == "vdpad") && xml->isStartElement())
|
||||
{
|
||||
readConfDpad(xml, hatButtons, vdpadExists, dpadExists);
|
||||
}
|
||||
else if ((xml->name() == "name") && xml->isStartElement())
|
||||
} else if ((xml->name() == "name") && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
|
||||
@@ -227,8 +214,7 @@ void GameControllerSet::readJoystickConfig(QXmlStreamReader *xml,
|
||||
{
|
||||
setName(temptext);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -239,7 +225,6 @@ void GameControllerSet::readJoystickConfig(QXmlStreamReader *xml,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerSet::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -253,20 +238,16 @@ void GameControllerSet::readConfig(QXmlStreamReader *xml)
|
||||
if ((xml->name() == "button") && xml->isStartElement())
|
||||
{
|
||||
getElemFromXml("button", xml);
|
||||
}
|
||||
else if ((xml->name() == "trigger") && xml->isStartElement())
|
||||
} else if ((xml->name() == "trigger") && xml->isStartElement())
|
||||
{
|
||||
getElemFromXml("trigger", xml);
|
||||
}
|
||||
else if ((xml->name() == "stick") && xml->isStartElement())
|
||||
} else if ((xml->name() == "stick") && xml->isStartElement())
|
||||
{
|
||||
getElemFromXml("stick", xml);
|
||||
}
|
||||
else if ((xml->name() == "dpad") && xml->isStartElement())
|
||||
} else if ((xml->name() == "dpad") && xml->isStartElement())
|
||||
{
|
||||
getElemFromXml("dpad", xml);
|
||||
}
|
||||
else if ((xml->name() == "name") && xml->isStartElement())
|
||||
} else if ((xml->name() == "name") && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
|
||||
@@ -274,8 +255,7 @@ void GameControllerSet::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
setName(temptext);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -286,79 +266,75 @@ void GameControllerSet::readConfig(QXmlStreamReader *xml)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerSet::getElemFromXml(QString elemName, QXmlStreamReader *xml)
|
||||
{
|
||||
int index = xml->attributes().value("index").toString().toInt();
|
||||
|
||||
if (elemName == "button") {
|
||||
JoyButton *button = getJoyButton(index-1);
|
||||
JoyButtonXml* joyButtonXml = new JoyButtonXml(button, this);
|
||||
if (elemName == "button")
|
||||
{
|
||||
JoyButton *button = getJoyButton(index - 1);
|
||||
JoyButtonXml *joyButtonXml = new JoyButtonXml(button, this);
|
||||
readConf(joyButtonXml, xml);
|
||||
}
|
||||
else if (elemName == "dpad") {
|
||||
GameControllerDPad *vdpad = qobject_cast<GameControllerDPad*>(getVDPad(index-1));
|
||||
JoyDPadXml<GameControllerDPad>* dpadXml = new JoyDPadXml<GameControllerDPad>(vdpad);
|
||||
} else if (elemName == "dpad")
|
||||
{
|
||||
GameControllerDPad *vdpad = qobject_cast<GameControllerDPad *>(getVDPad(index - 1));
|
||||
JoyDPadXml<GameControllerDPad> *dpadXml = new JoyDPadXml<GameControllerDPad>(vdpad);
|
||||
readConf(dpadXml, xml);
|
||||
|
||||
// if (!dpadXml.isNull()) delete dpadXml;
|
||||
}
|
||||
else if (elemName == "trigger")
|
||||
} else if (elemName == "trigger")
|
||||
{
|
||||
GameControllerTrigger *axis = nullptr;
|
||||
GameControllerTriggerXml* triggerAxisXml = nullptr;
|
||||
GameControllerTriggerXml *triggerAxisXml = nullptr;
|
||||
|
||||
switch(index - 1)
|
||||
switch (index - 1)
|
||||
{
|
||||
// for older profiles
|
||||
case 0:
|
||||
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERLEFT));
|
||||
axis = qobject_cast<GameControllerTrigger *>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERLEFT));
|
||||
triggerAxisXml = new GameControllerTriggerXml(axis, this);
|
||||
readConf(triggerAxisXml, xml);
|
||||
break;
|
||||
|
||||
// for older profiles
|
||||
case 1:
|
||||
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
|
||||
axis = qobject_cast<GameControllerTrigger *>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
|
||||
triggerAxisXml = new GameControllerTriggerXml(axis, this);
|
||||
readConf(triggerAxisXml, xml);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERLEFT));
|
||||
axis = qobject_cast<GameControllerTrigger *>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERLEFT));
|
||||
triggerAxisXml = new GameControllerTriggerXml(axis, this);
|
||||
readConf(triggerAxisXml, xml);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
axis = qobject_cast<GameControllerTrigger*>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
|
||||
axis = qobject_cast<GameControllerTrigger *>(getJoyAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT));
|
||||
triggerAxisXml = new GameControllerTriggerXml(axis, this);
|
||||
readConf(triggerAxisXml, xml);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (elemName == "stick") {
|
||||
} else if (elemName == "stick")
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
index -= 1;
|
||||
JoyControlStick *stick = getJoyStick(index);
|
||||
readConf(stick, xml);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
xml->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerSet::refreshAxes()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
deleteAxes();
|
||||
|
||||
|
||||
for (int i = 0; i < getInputDevice()->getNumberRawAxes(); i++)
|
||||
{
|
||||
if ((i == static_cast<int>(SDL_CONTROLLER_AXIS_TRIGGERLEFT)) ||
|
||||
@@ -367,8 +343,7 @@ void GameControllerSet::refreshAxes()
|
||||
GameControllerTrigger *trigger = new GameControllerTrigger(i, getIndex(), this, this);
|
||||
getAxes()->insert(i, trigger);
|
||||
enableAxisConnections(trigger);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
JoyAxis *axis = new JoyAxis(i, getIndex(), this, this);
|
||||
getAxes()->insert(i, axis);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERSET_H
|
||||
#define GAMECONTROLLERSET_H
|
||||
|
||||
@@ -27,31 +26,30 @@
|
||||
class QXmlStreamReader;
|
||||
class InputDevice;
|
||||
|
||||
|
||||
class GameControllerSet : public SetJoystick
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit GameControllerSet(InputDevice *device, int index, QObject *parent = nullptr);
|
||||
|
||||
virtual void refreshAxes();
|
||||
|
||||
virtual void readConfig(QXmlStreamReader *xml); // GameControllerSetXml
|
||||
virtual void readJoystickConfig(QXmlStreamReader *xml,
|
||||
QHash<int, SDL_GameControllerButton> &buttons,
|
||||
virtual void readJoystickConfig(QXmlStreamReader *xml, QHash<int, SDL_GameControllerButton> &buttons,
|
||||
QHash<int, SDL_GameControllerAxis> &axes,
|
||||
QList<SDL_GameControllerButtonBind> &hatButtons); // GameControllerSetXml class
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void populateSticksDPad();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
virtual void reset();
|
||||
|
||||
private:
|
||||
private:
|
||||
void getElemFromXml(QString elemName, QXmlStreamReader *xml); // GameControllerSetXml class
|
||||
void readConfDpad(QXmlStreamReader *xml, QList<SDL_GameControllerButtonBind> &hatButtons, bool vdpadExists, bool dpadExists); // GameControllerSetXml class
|
||||
void readConfDpad(QXmlStreamReader *xml, QList<SDL_GameControllerButtonBind> &hatButtons, bool vdpadExists,
|
||||
bool dpadExists); // GameControllerSetXml class
|
||||
void resetSticks();
|
||||
};
|
||||
|
||||
|
||||
@@ -20,22 +20,22 @@
|
||||
|
||||
#include "gamecontrollertrigger.h"
|
||||
|
||||
#include "gamecontrollertriggerbutton.h"
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "gamecontrollertriggerbutton.h"
|
||||
#include "xml/joyaxisxml.h"
|
||||
|
||||
#include <SDL2/SDL_gamecontroller.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
|
||||
const GameControllerTrigger::ThrottleTypes GameControllerTrigger::DEFAULTTHROTTLE =
|
||||
GameControllerTrigger::PositiveHalfThrottle;
|
||||
|
||||
const GameControllerTrigger::ThrottleTypes GameControllerTrigger::DEFAULTTHROTTLE = GameControllerTrigger::PositiveHalfThrottle;
|
||||
|
||||
GameControllerTrigger::GameControllerTrigger(int index, int originset, SetJoystick *parentSet, QObject *parent) :
|
||||
JoyAxis(index, originset, parentSet, parent)
|
||||
GameControllerTrigger::GameControllerTrigger(int index, int originset, SetJoystick *parentSet, QObject *parent)
|
||||
: JoyAxis(index, originset, parentSet, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -44,7 +44,6 @@ GameControllerTrigger::GameControllerTrigger(int index, int originset, SetJoysti
|
||||
reset(index);
|
||||
}
|
||||
|
||||
|
||||
void GameControllerTrigger::reset(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -53,7 +52,6 @@ void GameControllerTrigger::reset(int index)
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
|
||||
void GameControllerTrigger::reset()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -81,7 +79,6 @@ void GameControllerTrigger::reset()
|
||||
pendingIgnoreSets = false;
|
||||
}
|
||||
|
||||
|
||||
QString GameControllerTrigger::getXmlName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -89,7 +86,6 @@ QString GameControllerTrigger::getXmlName()
|
||||
return GlobalVariables::GameControllerTrigger::xmlName;
|
||||
}
|
||||
|
||||
|
||||
QString GameControllerTrigger::getPartialName(bool forceFullFormat, bool displayNames)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -104,8 +100,7 @@ QString GameControllerTrigger::getPartialName(bool forceFullFormat, bool display
|
||||
{
|
||||
label.append(" ").append(tr("Trigger"));
|
||||
}
|
||||
}
|
||||
else if (!defaultAxisName.isEmpty())
|
||||
} else if (!defaultAxisName.isEmpty())
|
||||
{
|
||||
label.append(defaultAxisName);
|
||||
|
||||
@@ -113,8 +108,7 @@ QString GameControllerTrigger::getPartialName(bool forceFullFormat, bool display
|
||||
{
|
||||
label.append(" ").append(tr("Trigger"));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(tr("Trigger")).append(" ");
|
||||
label.append(QString::number(getRealJoyIndex() - SDL_CONTROLLER_AXIS_TRIGGERLEFT));
|
||||
@@ -136,7 +130,6 @@ void GameControllerTrigger::correctJoystickThrottle()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GameControllerTrigger::getDefaultDeadZone()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -144,7 +137,6 @@ int GameControllerTrigger::getDefaultDeadZone()
|
||||
return GlobalVariables::GameControllerTrigger::AXISDEADZONE;
|
||||
}
|
||||
|
||||
|
||||
int GameControllerTrigger::getDefaultMaxZone()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -152,7 +144,6 @@ int GameControllerTrigger::getDefaultMaxZone()
|
||||
return GlobalVariables::GameControllerTrigger::AXISMAXZONE;
|
||||
}
|
||||
|
||||
|
||||
JoyAxis::ThrottleTypes GameControllerTrigger::getDefaultThrottle()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERTRIGGER_H
|
||||
#define GAMECONTROLLERTRIGGER_H
|
||||
|
||||
@@ -30,7 +29,7 @@ class GameControllerTrigger : public JoyAxis
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit GameControllerTrigger(int index, int originset, SetJoystick *parentSet, QObject *parent = nullptr);
|
||||
|
||||
virtual QString getXmlName(); // GameControllerTriggerXml class
|
||||
@@ -42,13 +41,12 @@ public:
|
||||
|
||||
static const ThrottleTypes DEFAULTTHROTTLE;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
virtual void reset();
|
||||
virtual void reset(int index);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void correctJoystickThrottle();
|
||||
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLERTRIGGER_H
|
||||
|
||||
@@ -19,23 +19,22 @@
|
||||
#include "gamecontrollertriggerbutton.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joyaxis.h"
|
||||
#include "messagehandler.h"
|
||||
#include "setjoystick.h"
|
||||
#include "joyaxis.h"
|
||||
#include "inputdevice.h"
|
||||
#include "xml/joybuttonxml.h"
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
||||
GameControllerTriggerButton::GameControllerTriggerButton(JoyAxis *axis, int index, int originset, SetJoystick *parentSet, QObject *parent) :
|
||||
JoyAxisButton(axis, index, originset, parentSet, parent)
|
||||
GameControllerTriggerButton::GameControllerTriggerButton(JoyAxis *axis, int index, int originset, SetJoystick *parentSet,
|
||||
QObject *parent)
|
||||
: JoyAxisButton(axis, index, originset, parentSet, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
}
|
||||
|
||||
|
||||
QString GameControllerTriggerButton::getXmlName()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -43,22 +42,20 @@ QString GameControllerTriggerButton::getXmlName()
|
||||
return GlobalVariables::GameControllerTriggerButton::xmlName;
|
||||
}
|
||||
|
||||
|
||||
void GameControllerTriggerButton::readJoystickConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
if (xml->isStartElement() && (xml->name() == GlobalVariables::JoyAxisButton::xmlName))
|
||||
{
|
||||
disconnect(this, &GameControllerTriggerButton::slotsChanged, m_parentSet->getInputDevice(), &InputDevice::profileEdited);
|
||||
disconnect(this, &GameControllerTriggerButton::slotsChanged, m_parentSet->getInputDevice(),
|
||||
&InputDevice::profileEdited);
|
||||
|
||||
xml->readNextStartElement();
|
||||
|
||||
|
||||
while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != GlobalVariables::JoyAxisButton::xmlName)))
|
||||
{
|
||||
JoyButtonXml* joyButtonXml = new JoyButtonXml(this);
|
||||
JoyButtonXml *joyButtonXml = new JoyButtonXml(this);
|
||||
bool found = joyButtonXml->readButtonConfig(xml);
|
||||
|
||||
if (!found)
|
||||
@@ -69,6 +66,7 @@ void GameControllerTriggerButton::readJoystickConfig(QXmlStreamReader *xml)
|
||||
xml->readNextStartElement();
|
||||
}
|
||||
|
||||
connect(this, &GameControllerTriggerButton::slotsChanged, m_parentSet->getInputDevice(), &InputDevice::profileEdited);
|
||||
connect(this, &GameControllerTriggerButton::slotsChanged, m_parentSet->getInputDevice(),
|
||||
&InputDevice::profileEdited);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERBUTTON_H
|
||||
#define GAMECONTROLLERBUTTON_H
|
||||
|
||||
@@ -26,17 +25,16 @@ class QXmlStreamReader;
|
||||
class SetJoystick;
|
||||
class JoyAxis;
|
||||
|
||||
|
||||
class GameControllerTriggerButton : public JoyAxisButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameControllerTriggerButton(JoyAxis *axis, int index, int originset, SetJoystick *parentSet, QObject *parent = nullptr);
|
||||
public:
|
||||
explicit GameControllerTriggerButton(JoyAxis *axis, int index, int originset, SetJoystick *parentSet,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
virtual QString getXmlName(); // GameContrTriggerBtnXml class
|
||||
void readJoystickConfig(QXmlStreamReader *xml); // GameContrTriggerBtnXml class
|
||||
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLERBUTTON_H
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
#include "gamecontroller/gamecontrollerdpad.h"
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
||||
GameControllerDPadXml::GameControllerDPadXml(GameControllerDPad* gameContrDpad, QObject* parent) : JoyDPadXml<VDPad>(gameContrDpad, parent)
|
||||
GameControllerDPadXml::GameControllerDPadXml(GameControllerDPad *gameContrDpad, QObject *parent)
|
||||
: JoyDPadXml<VDPad>(gameContrDpad, parent)
|
||||
{
|
||||
dpadXml = new JoyDPadXml<GameControllerDPad>(gameContrDpad, this);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERDPADXML_H
|
||||
#define GAMECONTROLLERDPADXML_H
|
||||
|
||||
@@ -24,18 +23,17 @@
|
||||
class GameControllerDPad;
|
||||
class QXmlStreamReader;
|
||||
|
||||
|
||||
class GameControllerDPadXml : public JoyDPadXml<VDPad>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameControllerDPadXml(GameControllerDPad* gameContrDpad, QObject* parent = nullptr);
|
||||
public:
|
||||
explicit GameControllerDPadXml(GameControllerDPad *gameContrDpad, QObject *parent = nullptr);
|
||||
|
||||
void readJoystickConfig(QXmlStreamReader *xml);
|
||||
|
||||
private:
|
||||
JoyDPadXml<GameControllerDPad>* dpadXml;
|
||||
private:
|
||||
JoyDPadXml<GameControllerDPad> *dpadXml;
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLERDPADXML_H
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
#include <SDL2/SDL_gamecontroller.h>
|
||||
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
|
||||
GameControllerTriggerXml::GameControllerTriggerXml(GameControllerTrigger* gameContrTrigger, QObject *parent) : JoyAxisXml(gameContrTrigger, parent)
|
||||
GameControllerTriggerXml::GameControllerTriggerXml(GameControllerTrigger *gameContrTrigger, QObject *parent)
|
||||
: JoyAxisXml(gameContrTrigger, parent)
|
||||
{
|
||||
m_gameContrTrigger = gameContrTrigger;
|
||||
joyButtonXmlNAxis = new JoyButtonXml(gameContrTrigger->getNAxisButton(), this);
|
||||
@@ -56,19 +56,18 @@ void GameControllerTriggerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
|
||||
qDebug() << "Index for axis in readJoystickConfig is: " << index;
|
||||
|
||||
switch (index) {
|
||||
switch (index)
|
||||
{
|
||||
|
||||
case 1:
|
||||
found = true;
|
||||
triggerButton =
|
||||
qobject_cast<GameControllerTriggerButton*>(m_gameContrTrigger->getNAxisButton());
|
||||
triggerButton = qobject_cast<GameControllerTriggerButton *>(m_gameContrTrigger->getNAxisButton());
|
||||
triggerButton->readJoystickConfig(xml);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
found = true;
|
||||
triggerButton =
|
||||
qobject_cast<GameControllerTriggerButton*>(m_gameContrTrigger->getPAxisButton());
|
||||
triggerButton = qobject_cast<GameControllerTriggerButton *>(m_gameContrTrigger->getPAxisButton());
|
||||
triggerButton->readJoystickConfig(xml);
|
||||
break;
|
||||
}
|
||||
@@ -87,7 +86,8 @@ void GameControllerTriggerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
m_gameContrTrigger->setThrottle(static_cast<int>(JoyAxis::PositiveHalfThrottle));
|
||||
m_gameContrTrigger->setCurrentRawValue(m_gameContrTrigger->getCurrentThrottledDeadValue());
|
||||
m_gameContrTrigger->updateCurrentThrottledValue(m_gameContrTrigger->calculateThrottledValue(m_gameContrTrigger->getCurrentRawValue()));
|
||||
m_gameContrTrigger->updateCurrentThrottledValue(
|
||||
m_gameContrTrigger->calculateThrottledValue(m_gameContrTrigger->getCurrentRawValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void GameControllerTriggerXml::writeConfig(QXmlStreamWriter *xml)
|
||||
|
||||
xml->writeStartElement("throttle");
|
||||
|
||||
switch(m_gameContrTrigger->getThrottle())
|
||||
switch (m_gameContrTrigger->getThrottle())
|
||||
{
|
||||
case -2:
|
||||
xml->writeCharacters("negativehalf");
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERTRIGGERXML_H
|
||||
#define GAMECONTROLLERTRIGGERXML_H
|
||||
|
||||
@@ -23,20 +22,19 @@
|
||||
|
||||
class GameControllerTrigger;
|
||||
|
||||
|
||||
class GameControllerTriggerXml : public JoyAxisXml
|
||||
{
|
||||
|
||||
public:
|
||||
explicit GameControllerTriggerXml(GameControllerTrigger* gameContrTrigger, QObject *parent = 0);
|
||||
explicit GameControllerTriggerXml(GameControllerTrigger *gameContrTrigger, QObject *parent = 0);
|
||||
|
||||
void readJoystickConfig(QXmlStreamReader *xml);
|
||||
virtual void writeConfig(QXmlStreamWriter *xml);
|
||||
|
||||
private:
|
||||
GameControllerTrigger* m_gameContrTrigger;
|
||||
JoyButtonXml* joyButtonXmlNAxis;
|
||||
JoyButtonXml* joyButtonXmlPAxis;
|
||||
GameControllerTrigger *m_gameContrTrigger;
|
||||
JoyButtonXml *joyButtonXmlNAxis;
|
||||
JoyButtonXml *joyButtonXmlPAxis;
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLERTRIGGERXML_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include "gamecontroller/gamecontroller.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "common.h"
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
//#include "logger.h"
|
||||
#include "gamecontroller/gamecontrollerdpad.h"
|
||||
@@ -30,11 +30,12 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
|
||||
GameControllerXml::GameControllerXml(GameController* gameController, QObject *parent) : InputDeviceXml(gameController, parent)
|
||||
GameControllerXml::GameControllerXml(GameController *gameController, QObject *parent)
|
||||
: InputDeviceXml(gameController, parent)
|
||||
{
|
||||
m_gameController = gameController;
|
||||
}
|
||||
@@ -59,7 +60,6 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
|
||||
xml->readNextStartElement();
|
||||
|
||||
|
||||
while (!xml->atEnd() && (!xml->isEndElement() && (xml->name() != "joystick")))
|
||||
{
|
||||
if ((xml->name() == "sets") && xml->isStartElement())
|
||||
@@ -75,11 +75,11 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
|
||||
if ((index >= 0) && (index < m_gameController->getJoystick_sets().size()))
|
||||
{
|
||||
GameControllerSet *currentSet = qobject_cast<GameControllerSet*>(m_gameController->getJoystick_sets().value(index)); // static_cast
|
||||
GameControllerSet *currentSet = qobject_cast<GameControllerSet *>(
|
||||
m_gameController->getJoystick_sets().value(index)); // static_cast
|
||||
currentSet->readJoystickConfig(xml, buttons, axes, hatButtons);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -87,8 +87,7 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
|
||||
xml->readNextStartElement();
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "names") && xml->isStartElement())
|
||||
} else if ((xml->name() == "names") && xml->isStartElement())
|
||||
{
|
||||
bool dpadNameExists = false;
|
||||
bool vdpadNameExists = false;
|
||||
@@ -101,7 +100,6 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
assignVariablesShort(xml, index, temp);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
SDL_GameControllerButton current = buttons.value(index);
|
||||
@@ -111,12 +109,10 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
m_gameController->setButtonName(current, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "axisbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "axisbuttonname") && xml->isStartElement())
|
||||
{
|
||||
assignVariables(xml, index, buttonIndex, temp, true);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
SDL_GameControllerAxis current = axes.value(index);
|
||||
@@ -125,40 +121,33 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
switch (currentInt)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTY: {
|
||||
m_gameController->setStickButtonName(0, buttonIndex, temp);
|
||||
break;
|
||||
}
|
||||
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY: {
|
||||
m_gameController->setStickButtonName(1, buttonIndex, temp);
|
||||
break;
|
||||
}
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: {
|
||||
m_gameController->setAxisName(current, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "controlstickbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "controlstickbuttonname") && xml->isStartElement())
|
||||
{
|
||||
assignVariables(xml, index, buttonIndex, temp, false);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
m_gameController->setStickButtonName(index, buttonIndex, temp);
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "dpadbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "dpadbuttonname") && xml->isStartElement())
|
||||
{
|
||||
assignVariables(xml, index, buttonIndex, temp, false);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
bool found = false;
|
||||
@@ -184,19 +173,18 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
JoyDPadButton *dpadbutton = dpad->getJoyButton(buttonIndex);
|
||||
|
||||
if ((dpad != nullptr) && (dpadbutton != nullptr) && dpadbutton->getActionName().isEmpty())
|
||||
if ((dpad != nullptr) && (dpadbutton != nullptr) &&
|
||||
dpadbutton->getActionName().isEmpty())
|
||||
{
|
||||
m_gameController->setVDPadButtonName(index, buttonIndex, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "vdpadbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "vdpadbuttonname") && xml->isStartElement())
|
||||
{
|
||||
assignVariables(xml, index, buttonIndex, temp, false);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
bool found = false;
|
||||
@@ -221,19 +209,18 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
JoyDPadButton *dpadbutton = dpad->getJoyButton(buttonIndex);
|
||||
|
||||
if ((dpad != nullptr) && (dpadbutton != nullptr) && dpadbutton->getActionName().isEmpty())
|
||||
if ((dpad != nullptr) && (dpadbutton != nullptr) &&
|
||||
dpadbutton->getActionName().isEmpty())
|
||||
{
|
||||
m_gameController->setVDPadButtonName(index, buttonIndex, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "axisname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "axisname") && xml->isStartElement())
|
||||
{
|
||||
assignVariablesShort(xml, index, temp);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
if (axes.contains(index))
|
||||
@@ -242,26 +229,21 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
m_gameController->setAxisName(static_cast<int>(current), temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "controlstickname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "controlstickname") && xml->isStartElement())
|
||||
{
|
||||
assignVariablesShort(xml, index, temp);
|
||||
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
m_gameController->setStickName(index, temp);
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "dpadname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "dpadname") && xml->isStartElement())
|
||||
{
|
||||
readJoystickConfigXmlLong(hatButtons, dpadNameExists, vdpadNameExists, xml);
|
||||
}
|
||||
else if ((xml->name() == "vdpadname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "vdpadname") && xml->isStartElement())
|
||||
{
|
||||
readJoystickConfigXmlLong(hatButtons, dpadNameExists, vdpadNameExists, xml);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -269,21 +251,19 @@ void GameControllerXml::readJoystickConfig(QXmlStreamReader *xml)
|
||||
|
||||
xml->readNextStartElement();
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "keyPressTime") && xml->isStartElement())
|
||||
} else if ((xml->name() == "keyPressTime") && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
int tempchoice = temptext.toInt();
|
||||
|
||||
if (tempchoice >= 10) m_gameController->setDeviceKeyPressTime(tempchoice);
|
||||
if (tempchoice >= 10)
|
||||
m_gameController->setDeviceKeyPressTime(tempchoice);
|
||||
|
||||
}
|
||||
else if ((xml->name() == "profilename") && xml->isStartElement())
|
||||
} else if ((xml->name() == "profilename") && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
m_gameController->setProfileName(temptext);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -300,7 +280,6 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
if (xml->isStartElement() && (xml->name() == m_gameController->getXmlName()))
|
||||
{
|
||||
m_gameController->transferReset();
|
||||
@@ -324,8 +303,7 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
m_gameController->getJoystick_sets().value(index)->readConfig(xml);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -333,8 +311,7 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
|
||||
xml->readNextStartElement();
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "names") && xml->isStartElement())
|
||||
} else if ((xml->name() == "names") && xml->isStartElement())
|
||||
{
|
||||
xml->readNextStartElement();
|
||||
|
||||
@@ -343,32 +320,25 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
if ((xml->name() == "buttonname") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesShort("buttonname", xml);
|
||||
}
|
||||
else if ((xml->name() == "triggerbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "triggerbuttonname") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesLong("triggerbuttonname", xml);
|
||||
}
|
||||
else if ((xml->name() == "controlstickbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "controlstickbuttonname") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesMiddle("controlstickbuttonname", xml);
|
||||
}
|
||||
else if ((xml->name() == "dpadbuttonname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "dpadbuttonname") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesMiddle("dpadbuttonname", xml);
|
||||
}
|
||||
else if ((xml->name() == "triggername") && xml->isStartElement())
|
||||
} else if ((xml->name() == "triggername") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesLong("triggername", xml);
|
||||
}
|
||||
else if ((xml->name() == "controlstickname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "controlstickname") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesShort("controlstickname", xml);
|
||||
}
|
||||
else if ((xml->name() == "dpadname") && xml->isStartElement())
|
||||
} else if ((xml->name() == "dpadname") && xml->isStartElement())
|
||||
{
|
||||
readXmlNamesShort("dpadname", xml);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -376,8 +346,7 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
|
||||
xml->readNextStartElement();
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "keyPressTime") && xml->isStartElement())
|
||||
} else if ((xml->name() == "keyPressTime") && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
int tempchoice = temptext.toInt();
|
||||
@@ -386,13 +355,11 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
{
|
||||
m_gameController->setDeviceKeyPressTime(tempchoice);
|
||||
}
|
||||
}
|
||||
else if ((xml->name() == "profilename") && xml->isStartElement())
|
||||
} else if ((xml->name() == "profilename") && xml->isStartElement())
|
||||
{
|
||||
QString temptext = xml->readElementText();
|
||||
m_gameController->setProfileName(temptext);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// If none of the above, skip the element
|
||||
xml->skipCurrentElement();
|
||||
@@ -403,8 +370,7 @@ void GameControllerXml::readConfig(QXmlStreamReader *xml)
|
||||
|
||||
m_gameController->reInitButtons();
|
||||
|
||||
}
|
||||
else if (xml->isStartElement() && (xml->name() == "joystick"))
|
||||
} else if (xml->isStartElement() && (xml->name() == "joystick"))
|
||||
{
|
||||
this->readJoystickConfig(xml);
|
||||
}
|
||||
@@ -422,8 +388,8 @@ void GameControllerXml::writeConfig(QXmlStreamWriter *xml)
|
||||
xml->writeTextElement("sdlname", m_gameController->getSDLName());
|
||||
xml->writeComment("The Unique ID for a joystick is included for informational purposes only.");
|
||||
xml->writeTextElement("uniqueID", m_gameController->getUniqueIDString());
|
||||
// xml->writeComment("The GUID for a joystick is included for informational purposes only.");
|
||||
// xml->writeTextElement("guid", m_gameController->getGUIDString());
|
||||
// xml->writeComment("The GUID for a joystick is included for informational purposes only.");
|
||||
// xml->writeTextElement("guid", m_gameController->getGUIDString());
|
||||
|
||||
if (!m_gameController->getProfileName().isEmpty())
|
||||
{
|
||||
@@ -441,20 +407,21 @@ void GameControllerXml::writeConfig(QXmlStreamWriter *xml)
|
||||
|
||||
xml->writeEndElement(); // </names>
|
||||
|
||||
if ((m_gameController->getDeviceKeyPressTime() > 0) && (m_gameController->getDeviceKeyPressTime() != GlobalVariables::InputDevice::DEFAULTKEYPRESSTIME))
|
||||
if ((m_gameController->getDeviceKeyPressTime() > 0) &&
|
||||
(m_gameController->getDeviceKeyPressTime() != GlobalVariables::InputDevice::DEFAULTKEYPRESSTIME))
|
||||
{
|
||||
xml->writeTextElement("keyPressTime", QString::number(m_gameController->getDeviceKeyPressTime()));
|
||||
}
|
||||
|
||||
xml->writeStartElement("sets");
|
||||
|
||||
QHashIterator<int, SetJoystick*> currHash(m_gameController->getJoystick_sets());
|
||||
while (currHash.hasNext()) {
|
||||
QHashIterator<int, SetJoystick *> currHash(m_gameController->getJoystick_sets());
|
||||
while (currHash.hasNext())
|
||||
{
|
||||
currHash.next();
|
||||
currHash.value()->writeConfig(xml);
|
||||
}
|
||||
|
||||
|
||||
xml->writeEndElement();
|
||||
|
||||
xml->writeEndElement();
|
||||
@@ -462,9 +429,10 @@ void GameControllerXml::writeConfig(QXmlStreamWriter *xml)
|
||||
|
||||
void GameControllerXml::writeXmlForButtons(SetJoystick *tempSet, QXmlStreamWriter *xml)
|
||||
{
|
||||
QHashIterator<int, JoyButton*> currBtn(tempSet->getButtons());
|
||||
QHashIterator<int, JoyButton *> currBtn(tempSet->getButtons());
|
||||
|
||||
while (currBtn.hasNext()) {
|
||||
while (currBtn.hasNext())
|
||||
{
|
||||
currBtn.next();
|
||||
|
||||
if ((currBtn.value() != nullptr) && !currBtn.value()->getButtonName().isEmpty())
|
||||
@@ -477,12 +445,12 @@ void GameControllerXml::writeXmlForButtons(SetJoystick *tempSet, QXmlStreamWrite
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerXml::writeXmlForAxes(SetJoystick *tempSet, QXmlStreamWriter *xml)
|
||||
{
|
||||
QHashIterator<int, JoyAxis*> currAxis(*tempSet->getAxes());
|
||||
QHashIterator<int, JoyAxis *> currAxis(*tempSet->getAxes());
|
||||
|
||||
while (currAxis.hasNext()) {
|
||||
while (currAxis.hasNext())
|
||||
{
|
||||
currAxis.next();
|
||||
|
||||
if (currAxis.value() != nullptr)
|
||||
@@ -497,12 +465,10 @@ void GameControllerXml::writeXmlForAxes(SetJoystick *tempSet, QXmlStreamWriter *
|
||||
|
||||
writeXmlAxBtn(currAxis.value(), currAxis.value()->getNAxisButton(), xml);
|
||||
writeXmlAxBtn(currAxis.value(), currAxis.value()->getPAxisButton(), xml);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerXml::writeXmlAxBtn(JoyAxis *axis, JoyAxisButton *axisbutton, QXmlStreamWriter *xml)
|
||||
{
|
||||
if (!axisbutton->getButtonName().isEmpty())
|
||||
@@ -515,12 +481,12 @@ void GameControllerXml::writeXmlAxBtn(JoyAxis *axis, JoyAxisButton *axisbutton,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerXml::writeXmlForSticks(SetJoystick *tempSet, QXmlStreamWriter *xml)
|
||||
{
|
||||
QHashIterator<int, JoyControlStick*> currStick(tempSet->getSticks());
|
||||
QHashIterator<int, JoyControlStick *> currStick(tempSet->getSticks());
|
||||
|
||||
while (currStick.hasNext()) {
|
||||
while (currStick.hasNext())
|
||||
{
|
||||
currStick.next();
|
||||
|
||||
if (currStick.value() != nullptr)
|
||||
@@ -533,8 +499,8 @@ void GameControllerXml::writeXmlForSticks(SetJoystick *tempSet, QXmlStreamWriter
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton*> *buttons = currStick.value()->getButtons();
|
||||
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton*> iter(*buttons);
|
||||
QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton *> *buttons = currStick.value()->getButtons();
|
||||
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton *> iter(*buttons);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -553,12 +519,12 @@ void GameControllerXml::writeXmlForSticks(SetJoystick *tempSet, QXmlStreamWriter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerXml::writeXmlForVDpad(QXmlStreamWriter *xml)
|
||||
{
|
||||
QHashIterator<int, VDPad*> currVDPad(m_gameController->getActiveSetJoystick()->getVdpads());
|
||||
QHashIterator<int, VDPad *> currVDPad(m_gameController->getActiveSetJoystick()->getVdpads());
|
||||
|
||||
while (currVDPad.hasNext()) {
|
||||
while (currVDPad.hasNext())
|
||||
{
|
||||
currVDPad.next();
|
||||
|
||||
if (currVDPad.value() != nullptr)
|
||||
@@ -571,8 +537,8 @@ void GameControllerXml::writeXmlForVDpad(QXmlStreamWriter *xml)
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
QHash<int, JoyDPadButton*> *temp = currVDPad.value()->getButtons();
|
||||
QHashIterator<int, JoyDPadButton*> iter(*temp);
|
||||
QHash<int, JoyDPadButton *> *temp = currVDPad.value()->getButtons();
|
||||
QHashIterator<int, JoyDPadButton *> iter(*temp);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -600,13 +566,15 @@ void GameControllerXml::readXmlNamesShort(QString name, QXmlStreamReader *xml)
|
||||
|
||||
if ((index >= 0) && !temp.isEmpty())
|
||||
{
|
||||
if (name == "buttonname") m_gameController->setButtonName(index, temp);
|
||||
else if (name == "controlstickname") m_gameController->setStickName(index, temp);
|
||||
else if (name == "dpadname") m_gameController->setVDPadName(index, temp);
|
||||
if (name == "buttonname")
|
||||
m_gameController->setButtonName(index, temp);
|
||||
else if (name == "controlstickname")
|
||||
m_gameController->setStickName(index, temp);
|
||||
else if (name == "dpadname")
|
||||
m_gameController->setVDPadName(index, temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameControllerXml::readXmlNamesMiddle(QString name, QXmlStreamReader *xml)
|
||||
{
|
||||
int index = -1;
|
||||
@@ -615,25 +583,24 @@ void GameControllerXml::readXmlNamesMiddle(QString name, QXmlStreamReader *xml)
|
||||
|
||||
assignVariables(xml, index, buttonIndex, temp, false);
|
||||
|
||||
if ((name == "dpadbuttonname") && (index >= 0) && !temp.isEmpty()) m_gameController->setVDPadButtonName(index, buttonIndex, temp);
|
||||
else if ((name == "controlstickbuttonname") && (index >= 0) && !temp.isEmpty()) m_gameController->setStickButtonName(index, buttonIndex, temp);
|
||||
if ((name == "dpadbuttonname") && (index >= 0) && !temp.isEmpty())
|
||||
m_gameController->setVDPadButtonName(index, buttonIndex, temp);
|
||||
else if ((name == "controlstickbuttonname") && (index >= 0) && !temp.isEmpty())
|
||||
m_gameController->setStickButtonName(index, buttonIndex, temp);
|
||||
}
|
||||
|
||||
|
||||
void GameControllerXml::readXmlNamesLong(QString name, QXmlStreamReader *xml)
|
||||
{
|
||||
int index = xml->attributes().value("index").toString().toInt();
|
||||
QString temp = xml->readElementText();
|
||||
index = (index - 1) + SDL_CONTROLLER_AXIS_TRIGGERLEFT;
|
||||
|
||||
if ((index == SDL_CONTROLLER_AXIS_TRIGGERLEFT ||
|
||||
index == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) && !temp.isEmpty())
|
||||
if ((index == SDL_CONTROLLER_AXIS_TRIGGERLEFT || index == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) && !temp.isEmpty())
|
||||
{
|
||||
if (name == "triggername")
|
||||
{
|
||||
m_gameController->setAxisName(index, temp);
|
||||
}
|
||||
else if (name == "triggerbuttonname")
|
||||
} else if (name == "triggerbuttonname")
|
||||
{
|
||||
int buttonIndex = xml->attributes().value("button").toString().toInt();
|
||||
buttonIndex = buttonIndex - 1;
|
||||
@@ -642,7 +609,8 @@ void GameControllerXml::readXmlNamesLong(QString name, QXmlStreamReader *xml)
|
||||
}
|
||||
}
|
||||
|
||||
void GameControllerXml::readJoystickConfigXmlLong(QList<SDL_GameControllerButtonBind>& hatButtons, bool& dpadNameExists, bool& vdpadNameExists, QXmlStreamReader *xml)
|
||||
void GameControllerXml::readJoystickConfigXmlLong(QList<SDL_GameControllerButtonBind> &hatButtons, bool &dpadNameExists,
|
||||
bool &vdpadNameExists, QXmlStreamReader *xml)
|
||||
{
|
||||
int index = -1;
|
||||
bool first = false;
|
||||
@@ -651,13 +619,11 @@ void GameControllerXml::readJoystickConfigXmlLong(QList<SDL_GameControllerButton
|
||||
|
||||
assignVariablesShort(xml, index, temp);
|
||||
|
||||
|
||||
if (xml->name() == "vdpadname")
|
||||
{
|
||||
first = dpadNameExists;
|
||||
second = vdpadNameExists;
|
||||
}
|
||||
else if (xml->name() == "dpadname")
|
||||
} else if (xml->name() == "dpadname")
|
||||
{
|
||||
first = vdpadNameExists;
|
||||
second = dpadNameExists;
|
||||
@@ -694,18 +660,19 @@ void GameControllerXml::readJoystickConfigXmlLong(QList<SDL_GameControllerButton
|
||||
}
|
||||
}
|
||||
|
||||
inline void GameControllerXml::assignVariables(QXmlStreamReader *xml, int& index, int& buttonIndex, QString& temp, bool buttonDecreased)
|
||||
inline void GameControllerXml::assignVariables(QXmlStreamReader *xml, int &index, int &buttonIndex, QString &temp,
|
||||
bool buttonDecreased)
|
||||
{
|
||||
index = xml->attributes().value("index").toString().toInt();
|
||||
buttonIndex = xml->attributes().value("button").toString().toInt();
|
||||
temp = xml->readElementText();
|
||||
index = index - 1;
|
||||
|
||||
if (buttonDecreased) buttonIndex = buttonIndex - 1;
|
||||
if (buttonDecreased)
|
||||
buttonIndex = buttonIndex - 1;
|
||||
}
|
||||
|
||||
|
||||
inline void GameControllerXml::assignVariablesShort(QXmlStreamReader *xml, int& index, QString& temp)
|
||||
inline void GameControllerXml::assignVariablesShort(QXmlStreamReader *xml, int &index, QString &temp)
|
||||
{
|
||||
index = xml->attributes().value("index").toString().toInt();
|
||||
temp = xml->readElementText();
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERXML_H
|
||||
#define GAMECONTROLLERXML_H
|
||||
|
||||
@@ -28,24 +27,22 @@ class QXmlStreamWriter;
|
||||
class JoyAxisButton;
|
||||
class JoyAxis;
|
||||
|
||||
|
||||
class GameControllerXml : public InputDeviceXml
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameControllerXml(GameController* gameController, QObject *parent = nullptr);
|
||||
public:
|
||||
explicit GameControllerXml(GameController *gameController, QObject *parent = nullptr);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void readJoystickConfig(QXmlStreamReader *xml); // GameControllerXml class
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
virtual void readConfig(QXmlStreamReader *xml) override; // GameControllerXml class
|
||||
virtual void writeConfig(QXmlStreamWriter *xml) override; // GameControllerXml class
|
||||
|
||||
private:
|
||||
|
||||
GameController* m_gameController;
|
||||
private:
|
||||
GameController *m_gameController;
|
||||
|
||||
void writeXmlForButtons(SetJoystick *tempSet, QXmlStreamWriter *xml); // GameControllerXml class
|
||||
void writeXmlForAxes(SetJoystick *tempSet, QXmlStreamWriter *xml); // GameControllerXml class
|
||||
@@ -55,11 +52,12 @@ private:
|
||||
void readXmlNamesShort(QString name, QXmlStreamReader *xml); // GameControllerXml class
|
||||
void readXmlNamesMiddle(QString name, QXmlStreamReader *xml); // GameControllerXml class
|
||||
void readXmlNamesLong(QString name, QXmlStreamReader *xml); // GameControllerXml class
|
||||
void readJoystickConfigXmlLong(QList<SDL_GameControllerButtonBind>& hatButtons, bool& dpadNameExists, bool& vdpadNameExists, QXmlStreamReader *xml); // GameControllerXml class
|
||||
|
||||
inline void assignVariables(QXmlStreamReader *xml, int& index, int& buttonIndex, QString& temp, bool buttonDecreased); // GameControllerXml class
|
||||
inline void assignVariablesShort(QXmlStreamReader *xml, int& index, QString& temp); // GameControllerXml class
|
||||
void readJoystickConfigXmlLong(QList<SDL_GameControllerButtonBind> &hatButtons, bool &dpadNameExists,
|
||||
bool &vdpadNameExists, QXmlStreamReader *xml); // GameControllerXml class
|
||||
|
||||
inline void assignVariables(QXmlStreamReader *xml, int &index, int &buttonIndex, QString &temp,
|
||||
bool buttonDecreased); // GameControllerXml class
|
||||
inline void assignVariablesShort(QXmlStreamReader *xml, int &index, QString &temp); // GameControllerXml class
|
||||
};
|
||||
|
||||
#endif // GAMECONTROLLERXML_H
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QTransform>
|
||||
#include <QPaintEvent>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
struct ButtonImagePlacement {
|
||||
struct ButtonImagePlacement
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
GameControllerExample::ButtonType buttontype;
|
||||
@@ -60,8 +60,8 @@ static ButtonImagePlacement buttonLocations[] = {
|
||||
{109, 127, GameControllerExample::Button}, // SDL_CONTROLLER_BUTTON_DPAD_RIGHT
|
||||
};
|
||||
|
||||
GameControllerExample::GameControllerExample(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
GameControllerExample::GameControllerExample(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -89,7 +89,7 @@ void GameControllerExample::paintEvent(QPaintEvent *event)
|
||||
|
||||
paint.setOpacity(0.85);
|
||||
|
||||
switch(current.buttontype)
|
||||
switch (current.buttontype)
|
||||
{
|
||||
|
||||
case Button:
|
||||
@@ -103,7 +103,6 @@ void GameControllerExample::paintEvent(QPaintEvent *event)
|
||||
case AxisY:
|
||||
paint.drawImage(QRect(current.x, current.y, rotatedaxisimage.width(), rotatedaxisimage.height()), rotatedaxisimage);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
paint.setOpacity(1.0);
|
||||
|
||||
@@ -16,39 +16,40 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLEREXAMPLE_H
|
||||
#define GAMECONTROLLEREXAMPLE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QImage>
|
||||
#include <QWidget>
|
||||
|
||||
class QPaintEvent;
|
||||
|
||||
|
||||
class GameControllerExample : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit GameControllerExample(QWidget *parent = nullptr);
|
||||
|
||||
enum ButtonType {
|
||||
Button, AxisX, AxisY,
|
||||
enum ButtonType
|
||||
{
|
||||
Button,
|
||||
AxisX,
|
||||
AxisY,
|
||||
};
|
||||
|
||||
static const int MAXBUTTONINDEX = 20;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void indexUpdated(int index);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void setActiveButton(int button);
|
||||
|
||||
private:
|
||||
private:
|
||||
QImage controllerimage;
|
||||
QImage buttonimage;
|
||||
QImage axisimage;
|
||||
|
||||
@@ -19,25 +19,24 @@
|
||||
#include "gamecontrollermappingdialog.h"
|
||||
#include "ui_gamecontrollermappingdialog.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "inputdevice.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "common.h"
|
||||
#include "inputdevice.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
#include <QListIterator>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndexList>
|
||||
#include <QVariant>
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
#include <QModelIndexList>
|
||||
#include <QStringList>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QTextStream>
|
||||
#include <QAbstractButton>
|
||||
#include <QVariant>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
static QHash<int, QString> initAliases()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -109,12 +108,10 @@ QHash<int, QString> GameControllerMappingDialog::tempaliases = initAliases();
|
||||
QHash<SDL_GameControllerButton, int> GameControllerMappingDialog::buttonPlacement = initButtonPlacement();
|
||||
QHash<SDL_GameControllerAxis, int> GameControllerMappingDialog::axisPlacement = initAxisPlacement();
|
||||
|
||||
GameControllerMappingDialog::GameControllerMappingDialog(InputDevice *device,
|
||||
AntiMicroSettings *settings,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::GameControllerMappingDialog),
|
||||
helper(device)
|
||||
GameControllerMappingDialog::GameControllerMappingDialog(InputDevice *device, AntiMicroSettings *settings, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::GameControllerMappingDialog)
|
||||
, helper(device)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -134,7 +131,7 @@ GameControllerMappingDialog::GameControllerMappingDialog(InputDevice *device,
|
||||
QMetaObject::invokeMethod(device, "haltServices");
|
||||
QMetaObject::invokeMethod(&helper, "setupDeadZones", Qt::BlockingQueuedConnection);
|
||||
|
||||
GameController *controller = qobject_cast<GameController*>(device);
|
||||
GameController *controller = qobject_cast<GameController *>(device);
|
||||
|
||||
if (controller != nullptr)
|
||||
{
|
||||
@@ -143,8 +140,8 @@ GameControllerMappingDialog::GameControllerMappingDialog(InputDevice *device,
|
||||
ui->mappingStringPlainTextEdit->document()->setPlainText(generateSDLMappingString());
|
||||
}
|
||||
|
||||
QString tempWindowTitle = QString(tr("Game Controller Mapping (%1) (#%2)")).arg(device->getSDLName())
|
||||
.arg(device->getRealJoyNumber());
|
||||
QString tempWindowTitle =
|
||||
QString(tr("Game Controller Mapping (%1) (#%2)")).arg(device->getSDLName()).arg(device->getRealJoyNumber());
|
||||
setWindowTitle(tempWindowTitle);
|
||||
|
||||
enableDeviceConnections();
|
||||
@@ -156,13 +153,16 @@ GameControllerMappingDialog::GameControllerMappingDialog(InputDevice *device,
|
||||
currentDeadZoneValue = 20000;
|
||||
int index = ui->axisDeadZoneComboBox->findData(currentDeadZoneValue);
|
||||
|
||||
if (index != -1) ui->axisDeadZoneComboBox->setCurrentIndex(index);
|
||||
if (index != -1)
|
||||
ui->axisDeadZoneComboBox->setCurrentIndex(index);
|
||||
|
||||
connect(device, &InputDevice::destroyed, this, &GameControllerMappingDialog::obliterate);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &GameControllerMappingDialog::saveChanges);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &GameControllerMappingDialog::discardMapping);
|
||||
connect(ui->buttonMappingTableWidget, &QTableWidget::itemSelectionChanged, this, &GameControllerMappingDialog::changeButtonDisplay);
|
||||
connect(ui->axisDeadZoneComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &GameControllerMappingDialog::changeAxisDeadZone);
|
||||
connect(ui->buttonMappingTableWidget, &QTableWidget::itemSelectionChanged, this,
|
||||
&GameControllerMappingDialog::changeButtonDisplay);
|
||||
connect(ui->axisDeadZoneComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&GameControllerMappingDialog::changeAxisDeadZone);
|
||||
connect(this, &GameControllerMappingDialog::finished, this, &GameControllerMappingDialog::enableButtonEvents);
|
||||
|
||||
PadderCommon::unlockInputDevices();
|
||||
@@ -183,13 +183,13 @@ void GameControllerMappingDialog::buttonAssign(int buttonindex)
|
||||
|
||||
if (ui->buttonMappingTableWidget->currentRow() > -1)
|
||||
{
|
||||
QTableWidgetItem* item = ui->buttonMappingTableWidget->currentItem();
|
||||
QTableWidgetItem *item = ui->buttonMappingTableWidget->currentItem();
|
||||
int column = ui->buttonMappingTableWidget->currentColumn();
|
||||
int row = ui->buttonMappingTableWidget->currentRow();
|
||||
|
||||
if (item == nullptr)
|
||||
{
|
||||
item = new QTableWidgetItem(QString("Button %1").arg(buttonindex+1));
|
||||
item = new QTableWidgetItem(QString("Button %1").arg(buttonindex + 1));
|
||||
ui->buttonMappingTableWidget->setItem(row, column, item);
|
||||
}
|
||||
|
||||
@@ -197,9 +197,10 @@ void GameControllerMappingDialog::buttonAssign(int buttonindex)
|
||||
templist.append(QVariant(0));
|
||||
templist.append(QVariant(buttonindex));
|
||||
QAbstractItemModel *model = ui->buttonMappingTableWidget->model();
|
||||
QModelIndexList matchlist = model->match(model->index(0,0), Qt::UserRole, templist, 1, Qt::MatchExactly);
|
||||
QModelIndexList matchlist = model->match(model->index(0, 0), Qt::UserRole, templist, 1, Qt::MatchExactly);
|
||||
|
||||
foreach (const QModelIndex &index, matchlist) {
|
||||
foreach (const QModelIndex &index, matchlist)
|
||||
{
|
||||
QTableWidgetItem *existingItem = ui->buttonMappingTableWidget->item(index.row(), index.column());
|
||||
|
||||
if (existingItem != nullptr)
|
||||
@@ -214,7 +215,7 @@ void GameControllerMappingDialog::buttonAssign(int buttonindex)
|
||||
tempvalue.append(QVariant(buttonindex));
|
||||
|
||||
item->setData(Qt::UserRole, tempvalue);
|
||||
item->setText(QString("Button %1").arg(buttonindex+1));
|
||||
item->setText(QString("Button %1").arg(buttonindex + 1));
|
||||
|
||||
if (row < (ui->buttonMappingTableWidget->rowCount() - 1))
|
||||
ui->buttonMappingTableWidget->setCurrentCell(row + 1, column);
|
||||
@@ -237,15 +238,14 @@ void GameControllerMappingDialog::axisAssign(int axis, int value)
|
||||
|
||||
if (!skip && (ui->buttonMappingTableWidget->currentRow() > -1))
|
||||
{
|
||||
QTableWidgetItem* item = ui->buttonMappingTableWidget->currentItem();
|
||||
QTableWidgetItem *item = ui->buttonMappingTableWidget->currentItem();
|
||||
int column = ui->buttonMappingTableWidget->currentColumn();
|
||||
int row = ui->buttonMappingTableWidget->currentRow();
|
||||
|
||||
if (usingGameController && (value > currentDeadZoneValue) && !getEventTriggerAxesLocal().contains(axis))
|
||||
{
|
||||
getEventTriggerAxesLocal().append(axis);
|
||||
}
|
||||
else if (usingGameController && (value < currentDeadZoneValue))
|
||||
} else if (usingGameController && (value < currentDeadZoneValue))
|
||||
{
|
||||
skip = true;
|
||||
}
|
||||
@@ -254,17 +254,18 @@ void GameControllerMappingDialog::axisAssign(int axis, int value)
|
||||
{
|
||||
if (item == nullptr)
|
||||
{
|
||||
item = new QTableWidgetItem(QString("Axis %1").arg(axis+1));
|
||||
item = new QTableWidgetItem(QString("Axis %1").arg(axis + 1));
|
||||
ui->buttonMappingTableWidget->setItem(row, column, item);
|
||||
}
|
||||
|
||||
QList<QVariant> templist;
|
||||
templist.append(QVariant(axis+1));
|
||||
templist.append(QVariant(axis + 1));
|
||||
templist.append(QVariant(0));
|
||||
QAbstractItemModel *model = ui->buttonMappingTableWidget->model();
|
||||
QModelIndexList matchlist = model->match(model->index(0,0), Qt::UserRole, templist, 1, Qt::MatchExactly);
|
||||
QModelIndexList matchlist = model->match(model->index(0, 0), Qt::UserRole, templist, 1, Qt::MatchExactly);
|
||||
|
||||
foreach (const QModelIndex &index, matchlist) {
|
||||
foreach (const QModelIndex &index, matchlist)
|
||||
{
|
||||
QTableWidgetItem *existingItem = ui->buttonMappingTableWidget->item(index.row(), index.column());
|
||||
|
||||
if (existingItem != nullptr)
|
||||
@@ -275,14 +276,14 @@ void GameControllerMappingDialog::axisAssign(int axis, int value)
|
||||
}
|
||||
|
||||
QList<QVariant> tempvalue;
|
||||
tempvalue.append(QVariant(axis+1));
|
||||
tempvalue.append(QVariant(axis + 1));
|
||||
tempvalue.append(QVariant(0));
|
||||
|
||||
item->setData(Qt::UserRole, tempvalue);
|
||||
item->setText(QString("Axis %1").arg(axis+1));
|
||||
item->setText(QString("Axis %1").arg(axis + 1));
|
||||
|
||||
if (row < (ui->buttonMappingTableWidget->rowCount()-1))
|
||||
ui->buttonMappingTableWidget->setCurrentCell(row+1, column);
|
||||
if (row < (ui->buttonMappingTableWidget->rowCount() - 1))
|
||||
ui->buttonMappingTableWidget->setCurrentCell(row + 1, column);
|
||||
|
||||
ui->mappingStringPlainTextEdit->document()->setPlainText(generateSDLMappingString());
|
||||
}
|
||||
@@ -295,23 +296,24 @@ void GameControllerMappingDialog::dpadAssign(int dpad, int buttonindex)
|
||||
|
||||
if (ui->buttonMappingTableWidget->currentRow() > -1)
|
||||
{
|
||||
QTableWidgetItem* item = ui->buttonMappingTableWidget->currentItem();
|
||||
QTableWidgetItem *item = ui->buttonMappingTableWidget->currentItem();
|
||||
int column = ui->buttonMappingTableWidget->currentColumn();
|
||||
int row = ui->buttonMappingTableWidget->currentRow();
|
||||
|
||||
if (item == nullptr)
|
||||
{
|
||||
item = new QTableWidgetItem(QString("Hat %1.%2").arg(dpad+1).arg(buttonindex));
|
||||
item = new QTableWidgetItem(QString("Hat %1.%2").arg(dpad + 1).arg(buttonindex));
|
||||
ui->buttonMappingTableWidget->setItem(row, column, item);
|
||||
}
|
||||
|
||||
QList<QVariant> templist;
|
||||
templist.append(QVariant(-dpad-1));
|
||||
templist.append(QVariant(-dpad - 1));
|
||||
templist.append(QVariant(buttonindex));
|
||||
QAbstractItemModel *model = ui->buttonMappingTableWidget->model();
|
||||
QModelIndexList matchlist = model->match(model->index(0,0), Qt::UserRole, templist, 1, Qt::MatchExactly);
|
||||
QModelIndexList matchlist = model->match(model->index(0, 0), Qt::UserRole, templist, 1, Qt::MatchExactly);
|
||||
|
||||
foreach (const QModelIndex &index, matchlist) {
|
||||
foreach (const QModelIndex &index, matchlist)
|
||||
{
|
||||
QTableWidgetItem *existingItem = ui->buttonMappingTableWidget->item(index.row(), index.column());
|
||||
|
||||
if (existingItem != nullptr)
|
||||
@@ -322,11 +324,11 @@ void GameControllerMappingDialog::dpadAssign(int dpad, int buttonindex)
|
||||
}
|
||||
|
||||
QList<QVariant> tempvalue;
|
||||
tempvalue.append(QVariant(-dpad-1));
|
||||
tempvalue.append(QVariant(-dpad - 1));
|
||||
tempvalue.append(QVariant(buttonindex));
|
||||
|
||||
item->setData(Qt::UserRole, tempvalue);
|
||||
item->setText(QString("Hat %1.%2").arg(dpad+1).arg(buttonindex));
|
||||
item->setText(QString("Hat %1.%2").arg(dpad + 1).arg(buttonindex));
|
||||
|
||||
if (row < (ui->buttonMappingTableWidget->rowCount() - 1))
|
||||
ui->buttonMappingTableWidget->setCurrentCell(row + 1, column);
|
||||
@@ -342,11 +344,13 @@ void GameControllerMappingDialog::saveChanges()
|
||||
QString mappingString = generateSDLMappingString();
|
||||
|
||||
settings->getLock()->lock();
|
||||
// settings->setValue(QString("Mappings/").append(device->getGUIDString()), mappingString);
|
||||
// settings->setValue(QString("Mappings/%1%2").arg(device->getGUIDString()).arg("Disable"), "0");
|
||||
// settings->setValue(QString("Mappings/").append(device->getGUIDString()), mappingString);
|
||||
// settings->setValue(QString("Mappings/%1%2").arg(device->getGUIDString()).arg("Disable"), "0");
|
||||
|
||||
device->convertToUniqueMappSett(settings, QString("Mappings/").append(device->getGUIDString()), QString("Mappings/").append(device->getUniqueIDString()));
|
||||
device->convertToUniqueMappSett(settings, QString("Mappings/%1%2").arg(device->getGUIDString()).arg("Disable"), QString("Mappings/%1%2").arg(device->getUniqueIDString()).arg("Disable"));
|
||||
device->convertToUniqueMappSett(settings, QString("Mappings/").append(device->getGUIDString()),
|
||||
QString("Mappings/").append(device->getUniqueIDString()));
|
||||
device->convertToUniqueMappSett(settings, QString("Mappings/%1%2").arg(device->getGUIDString()).arg("Disable"),
|
||||
QString("Mappings/%1%2").arg(device->getUniqueIDString()).arg("Disable"));
|
||||
|
||||
settings->setValue(QString("Mappings/").append(device->getUniqueIDString()), mappingString);
|
||||
settings->setValue(QString("Mappings/%1%2").arg(device->getUniqueIDString()).arg("Disable"), "0");
|
||||
@@ -383,17 +387,15 @@ void GameControllerMappingDialog::populateGameControllerBindings(GameController
|
||||
if (!temptext.isEmpty())
|
||||
{
|
||||
QList<QVariant> tempvariant = bindingValues(bind);
|
||||
QTableWidgetItem* item = new QTableWidgetItem();
|
||||
QTableWidgetItem *item = new QTableWidgetItem();
|
||||
ui->buttonMappingTableWidget->setItem(associatedRow, 0, item);
|
||||
item->setText(temptext);
|
||||
item->setData(Qt::UserRole, tempvariant);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Controller has " << controller->getNumberAxes() << " axes";
|
||||
|
||||
|
||||
for (int i = 0; i < controller->getNumberAxes(); i++)
|
||||
{
|
||||
int associatedRow = axisPlacement.value(static_cast<SDL_GameControllerAxis>(i));
|
||||
@@ -405,7 +407,7 @@ void GameControllerMappingDialog::populateGameControllerBindings(GameController
|
||||
if (!temptext.isEmpty())
|
||||
{
|
||||
QList<QVariant> tempvariant = bindingValues(bind);
|
||||
QTableWidgetItem* item = new QTableWidgetItem();
|
||||
QTableWidgetItem *item = new QTableWidgetItem();
|
||||
ui->buttonMappingTableWidget->setItem(associatedRow, 0, item);
|
||||
item->setText(temptext);
|
||||
item->setData(Qt::UserRole, tempvariant);
|
||||
@@ -420,25 +422,23 @@ QString GameControllerMappingDialog::bindingString(SDL_GameControllerButtonBind
|
||||
|
||||
QString temp = QString();
|
||||
|
||||
switch(bind.bindType)
|
||||
switch (bind.bindType)
|
||||
{
|
||||
case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
||||
temp.append(QString("Button %1").arg(bind.value.button+1));
|
||||
temp.append(QString("Button %1").arg(bind.value.button + 1));
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_AXIS:
|
||||
temp.append(QString("Axis %1").arg(bind.value.axis+1));
|
||||
temp.append(QString("Axis %1").arg(bind.value.axis + 1));
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_HAT:
|
||||
temp.append(QString("Hat %1.%2").arg(bind.value.hat.hat+1)
|
||||
.arg(bind.value.hat.hat_mask));
|
||||
temp.append(QString("Hat %1.%2").arg(bind.value.hat.hat + 1).arg(bind.value.hat.hat_mask));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return temp;
|
||||
@@ -450,7 +450,7 @@ QList<QVariant> GameControllerMappingDialog::bindingValues(SDL_GameControllerBut
|
||||
|
||||
QList<QVariant> temp;
|
||||
|
||||
switch(bind.bindType)
|
||||
switch (bind.bindType)
|
||||
{
|
||||
case SDL_CONTROLLER_BINDTYPE_BUTTON:
|
||||
temp.append(QVariant(0));
|
||||
@@ -458,19 +458,18 @@ QList<QVariant> GameControllerMappingDialog::bindingValues(SDL_GameControllerBut
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_AXIS:
|
||||
temp.append(QVariant(bind.value.axis+1));
|
||||
temp.append(QVariant(bind.value.axis + 1));
|
||||
temp.append(QVariant(0));
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLER_BINDTYPE_HAT:
|
||||
temp.append(QVariant(-bind.value.hat.hat-1));
|
||||
temp.append(QVariant(-bind.value.hat.hat - 1));
|
||||
temp.append(QVariant(bind.value.hat.hat_mask));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -485,7 +484,8 @@ void GameControllerMappingDialog::discardMapping(QAbstractButton *button)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Discard Controller Mapping?"));
|
||||
msgBox.setText(tr("Discard mapping for this controller?\n\nIf discarded, the controller will be reverted to a joystick once you refresh all joysticks."));
|
||||
msgBox.setText(tr("Discard mapping for this controller?\n\nIf discarded, the controller will be reverted to a "
|
||||
"joystick once you refresh all joysticks."));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||
|
||||
int status = msgBox.exec();
|
||||
@@ -494,8 +494,7 @@ void GameControllerMappingDialog::discardMapping(QAbstractButton *button)
|
||||
{
|
||||
removeControllerMapping();
|
||||
close();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
enableDeviceConnections();
|
||||
}
|
||||
@@ -509,9 +508,9 @@ void GameControllerMappingDialog::removeControllerMapping()
|
||||
settings->getLock()->lock();
|
||||
|
||||
settings->beginGroup("Mappings");
|
||||
//settings->remove(device->getGUIDString());
|
||||
// settings->remove(device->getGUIDString());
|
||||
settings->remove(device->getUniqueIDString());
|
||||
//settings->remove(QString("%1Disable").arg(device->getGUIDString()));
|
||||
// settings->remove(QString("%1Disable").arg(device->getGUIDString()));
|
||||
settings->remove(QString("%1Disable").arg(device->getUniqueIDString()));
|
||||
settings->endGroup();
|
||||
settings->sync();
|
||||
@@ -551,14 +550,13 @@ void GameControllerMappingDialog::enableButtonEvents(int code)
|
||||
|
||||
Q_UNUSED(code);
|
||||
|
||||
|
||||
bool invoked = QMetaObject::invokeMethod(&helper, "restoreDeviceDeadZones", Qt::BlockingQueuedConnection);
|
||||
if (invoked) qDebug() << "the member restoreDeviceDeadZones could be invoked";
|
||||
else qDebug() << "the member restoreDeviceDeadZones could not be invoked";
|
||||
if (invoked)
|
||||
qDebug() << "the member restoreDeviceDeadZones could be invoked";
|
||||
else
|
||||
qDebug() << "the member restoreDeviceDeadZones could not be invoked";
|
||||
|
||||
// QMetaObject::invokeMethod(&helper, "restoreDeviceDeadZones", Qt::BlockingQueuedConnection);
|
||||
|
||||
|
||||
}
|
||||
|
||||
QString GameControllerMappingDialog::generateSDLMappingString()
|
||||
@@ -566,7 +564,7 @@ QString GameControllerMappingDialog::generateSDLMappingString()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QStringList templist = QStringList();
|
||||
//templist.append(device->getGUIDString());
|
||||
// templist.append(device->getGUIDString());
|
||||
templist.append(device->getUniqueIDString());
|
||||
templist.append(device->getSDLName());
|
||||
templist.append(QString("platform:").append(device->getSDLPlatform()));
|
||||
@@ -588,16 +586,14 @@ QString GameControllerMappingDialog::generateSDLMappingString()
|
||||
{
|
||||
mapNative.append("b");
|
||||
mapNative.append(QString::number(tempassociation.value(1).toInt()));
|
||||
}
|
||||
else if (bindingType > 0)
|
||||
} else if (bindingType > 0)
|
||||
{
|
||||
mapNative.append("a");
|
||||
mapNative.append(QString::number(tempassociation.value(0).toInt()-1));
|
||||
}
|
||||
else if (bindingType < 0)
|
||||
mapNative.append(QString::number(tempassociation.value(0).toInt() - 1));
|
||||
} else if (bindingType < 0)
|
||||
{
|
||||
mapNative.append("h");
|
||||
mapNative.append(QString::number(tempassociation.value(0).toInt()+1));
|
||||
mapNative.append(QString::number(tempassociation.value(0).toInt() + 1));
|
||||
mapNative.append(".").append(QString::number(tempassociation.value(1).toInt()));
|
||||
}
|
||||
}
|
||||
@@ -688,8 +684,7 @@ void GameControllerMappingDialog::changeAxisDeadZone(int index)
|
||||
|
||||
if ((value >= 5000) && (value <= 32000))
|
||||
{
|
||||
QMetaObject::invokeMethod(&helper, "raiseDeadZones", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, value));
|
||||
QMetaObject::invokeMethod(&helper, "raiseDeadZones", Qt::BlockingQueuedConnection, Q_ARG(int, value));
|
||||
currentDeadZoneValue = value;
|
||||
}
|
||||
}
|
||||
@@ -704,14 +699,11 @@ void GameControllerMappingDialog::updateLastAxisLineEdit(JoyAxis *tempAxis, int
|
||||
|
||||
if (device->isGameController())
|
||||
{
|
||||
GameController *controller = qobject_cast<GameController*>(device);
|
||||
axisText = QString("%1: %2").arg(controller->getBindStringForAxis(tempAxis->getIndex(), true))
|
||||
.arg(value);
|
||||
}
|
||||
else
|
||||
GameController *controller = qobject_cast<GameController *>(device);
|
||||
axisText = QString("%1: %2").arg(controller->getBindStringForAxis(tempAxis->getIndex(), true)).arg(value);
|
||||
} else
|
||||
{
|
||||
axisText = QString("Axis %1: %2").arg(tempAxis->getRealJoyIndex())
|
||||
.arg(value);
|
||||
axisText = QString("Axis %1: %2").arg(tempAxis->getRealJoyIndex()).arg(value);
|
||||
}
|
||||
|
||||
ui->lastAxisEventLineEdit->setText(axisText);
|
||||
@@ -724,19 +716,12 @@ void GameControllerMappingDialog::updateLastAxisLineEditRaw(int index, int value
|
||||
|
||||
if (abs(value) >= 2000)
|
||||
{
|
||||
QString axisText = QString("Axis %1: %2").arg(index+1)
|
||||
.arg(value);
|
||||
QString axisText = QString("Axis %1: %2").arg(index + 1).arg(value);
|
||||
|
||||
ui->lastAxisEventLineEdit->setText(axisText);
|
||||
}
|
||||
}
|
||||
|
||||
GameControllerMappingDialogHelper& GameControllerMappingDialog::getHelperLocal() {
|
||||
GameControllerMappingDialogHelper &GameControllerMappingDialog::getHelperLocal() { return helper; }
|
||||
|
||||
return helper;
|
||||
}
|
||||
|
||||
QList<int>& GameControllerMappingDialog::getEventTriggerAxesLocal() {
|
||||
|
||||
return eventTriggerAxes;
|
||||
}
|
||||
QList<int> &GameControllerMappingDialog::getEventTriggerAxesLocal() { return eventTriggerAxes; }
|
||||
|
||||
@@ -16,17 +16,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMECONTROLLERMAPPINGDIALOG_H
|
||||
#define GAMECONTROLLERMAPPINGDIALOG_H
|
||||
|
||||
|
||||
#include "uihelpers/gamecontrollermappingdialoghelper.h"
|
||||
#include "gamecontroller/gamecontroller.h"
|
||||
#include "uihelpers/gamecontrollermappingdialoghelper.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
class InputDevice;
|
||||
class AntiMicroSettings;
|
||||
class QWidget;
|
||||
@@ -40,7 +37,7 @@ class GameControllerMappingDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit GameControllerMappingDialog(InputDevice *device, AntiMicroSettings *settings, QWidget *parent = nullptr);
|
||||
~GameControllerMappingDialog();
|
||||
|
||||
@@ -48,7 +45,7 @@ public:
|
||||
static QHash<SDL_GameControllerButton, int> buttonPlacement;
|
||||
static QHash<SDL_GameControllerAxis, int> axisPlacement;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void populateGameControllerBindings(GameController *controller);
|
||||
void removeControllerMapping();
|
||||
void enableDeviceConnections();
|
||||
@@ -59,13 +56,13 @@ protected:
|
||||
QString bindingString(SDL_GameControllerButtonBind bind);
|
||||
QList<QVariant> bindingValues(SDL_GameControllerButtonBind bind);
|
||||
|
||||
private:
|
||||
private:
|
||||
Ui::GameControllerMappingDialog *ui;
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void mappingUpdate(QString mapping, InputDevice *device);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void buttonAssign(int buttonindex);
|
||||
void axisAssign(int axis, int value);
|
||||
void dpadAssign(int dpad, int buttonindex);
|
||||
@@ -81,9 +78,9 @@ private slots:
|
||||
void updateLastAxisLineEdit(JoyAxis *tempAxis, int value);
|
||||
void updateLastAxisLineEditRaw(int index, int value);
|
||||
|
||||
private:
|
||||
GameControllerMappingDialogHelper& getHelperLocal();
|
||||
QList<int>& getEventTriggerAxesLocal();
|
||||
private:
|
||||
GameControllerMappingDialogHelper &getHelperLocal();
|
||||
QList<int> &getEventTriggerAxesLocal();
|
||||
|
||||
InputDevice *device;
|
||||
AntiMicroSettings *settings;
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
||||
|
||||
// ---- JOYBUTTON --- //
|
||||
|
||||
const QString GlobalVariables::JoyButton::xmlName = "button";
|
||||
@@ -87,7 +85,6 @@ int GlobalVariables::JoyButton::mouseRefreshRate = 5;
|
||||
int GlobalVariables::JoyButton::springModeScreen = -1;
|
||||
int GlobalVariables::JoyButton::gamepadRefreshRate = 10;
|
||||
|
||||
|
||||
// ---- ANTIMICROSETTINGS --- //
|
||||
|
||||
const bool GlobalVariables::AntimicroSettings::defaultDisabledWinEnhanced = false;
|
||||
@@ -103,7 +100,7 @@ const int GlobalVariables::InputDevice::RAISEDDEADZONE = 20000;
|
||||
const int GlobalVariables::InputDevice::DEFAULTKEYREPEATDELAY = 660; // 660 ms
|
||||
const int GlobalVariables::InputDevice::DEFAULTKEYREPEATRATE = 40; // 40 ms. 25 times per second
|
||||
|
||||
//QRegExp GlobalVariables::InputDevice::emptyGUID("^[0]+$");
|
||||
// QRegExp GlobalVariables::InputDevice::emptyGUID("^[0]+$");
|
||||
QRegExp GlobalVariables::InputDevice::emptyUniqueID("^[0]+$");
|
||||
|
||||
// ---- JOYAXIS ---- //
|
||||
@@ -119,8 +116,7 @@ const float GlobalVariables::JoyAxis::JOYSPEED = 20.0;
|
||||
|
||||
const QString GlobalVariables::JoyAxis::xmlName = "axis";
|
||||
|
||||
|
||||
#ifdef WITH_X11
|
||||
#ifdef WITH_X11
|
||||
|
||||
// ---- X11EXTRAS ---- //
|
||||
|
||||
@@ -130,19 +126,16 @@ const QString GlobalVariables::X11Extras::xtestMouseDeviceName = QString("Virtua
|
||||
|
||||
QString GlobalVariables::X11Extras::_customDisplayString = QString("");
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// ---- GameController ---- //
|
||||
|
||||
const QString GlobalVariables::GameController::xmlName = "gamecontroller";
|
||||
|
||||
|
||||
// ---- GameControllerDPad ---- //
|
||||
|
||||
const QString GlobalVariables::GameControllerDPad::xmlName = "dpad";
|
||||
|
||||
|
||||
// ---- GameControllerTrigger ---- //
|
||||
|
||||
const int GlobalVariables::GameControllerTrigger::AXISDEADZONE = 2000;
|
||||
@@ -150,39 +143,32 @@ const int GlobalVariables::GameControllerTrigger::AXISMAXZONE = 32000;
|
||||
|
||||
const QString GlobalVariables::GameControllerTrigger::xmlName = "trigger";
|
||||
|
||||
|
||||
// ---- GameControllerTriggerButton ---- //
|
||||
|
||||
const QString GlobalVariables::GameControllerTriggerButton::xmlName = "triggerbutton";
|
||||
|
||||
|
||||
// ---- InputDaemon ---- //
|
||||
|
||||
const int GlobalVariables::InputDaemon::GAMECONTROLLERTRIGGERRELEASE = 16384;
|
||||
|
||||
|
||||
// ---- VDPad ---- //
|
||||
|
||||
const QString GlobalVariables::VDPad::xmlName = "vdpad";
|
||||
|
||||
|
||||
// ---- SetJoystick ---- //
|
||||
|
||||
const int GlobalVariables::SetJoystick::MAXNAMELENGTH = 30;
|
||||
const int GlobalVariables::SetJoystick::RAISEDDEADZONE = 20000;
|
||||
|
||||
|
||||
// ---- Joystick ---- //
|
||||
|
||||
const QString GlobalVariables::Joystick::xmlName = "joystick";
|
||||
|
||||
|
||||
// ---- JoyDPad ---- //
|
||||
|
||||
const QString GlobalVariables::JoyDPad::xmlName = "dpad";
|
||||
const int GlobalVariables::JoyDPad::DEFAULTDPADDELAY = 0;
|
||||
|
||||
|
||||
// ---- JoyControlStick ---- //
|
||||
|
||||
// Define Pi here.
|
||||
@@ -195,35 +181,28 @@ const int GlobalVariables::JoyControlStick::DEFAULTDIAGONALRANGE = 45;
|
||||
const double GlobalVariables::JoyControlStick::DEFAULTCIRCLE = 0.0;
|
||||
const int GlobalVariables::JoyControlStick::DEFAULTSTICKDELAY = 0;
|
||||
|
||||
|
||||
// ---- JoyButtonSlot ---- //
|
||||
|
||||
const int GlobalVariables::JoyButtonSlot::JOYSPEED = 20;
|
||||
const QString GlobalVariables::JoyButtonSlot::xmlName = "slot";
|
||||
const int GlobalVariables::JoyButtonSlot::MAXTEXTENTRYDISPLAYLENGTH = 40;
|
||||
|
||||
|
||||
|
||||
// ---- AdvanceButtonDialog ---- //
|
||||
|
||||
const int GlobalVariables::AdvanceButtonDialog::MINIMUMTURBO = 2;
|
||||
|
||||
|
||||
// ---- JoyAxisButton ---- //
|
||||
|
||||
const QString GlobalVariables::JoyAxisButton::xmlName = "axisbutton";
|
||||
|
||||
|
||||
// ---- JoyControlStickButton ---- //
|
||||
|
||||
const QString GlobalVariables::JoyControlStickButton::xmlName = "stickbutton";
|
||||
|
||||
|
||||
// ---- JoyControlStickModifierButton ---- //
|
||||
|
||||
const QString GlobalVariables::JoyControlStickModifierButton::xmlName = "stickmodifierbutton";
|
||||
|
||||
|
||||
// ---- JoyDPadButton ---- //
|
||||
|
||||
const QString GlobalVariables::JoyDPadButton::xmlName = "dpadbutton";
|
||||
|
||||
@@ -16,20 +16,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GLOBALVARIABLES_H
|
||||
#define GLOBALVARIABLES_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
namespace GlobalVariables
|
||||
namespace GlobalVariables {
|
||||
class JoyButton
|
||||
{
|
||||
class JoyButton
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
|
||||
static int IDLEMOUSEREFRESHRATE;
|
||||
@@ -89,36 +85,33 @@ namespace GlobalVariables
|
||||
static QHash<int, int> activeMouseButtons;
|
||||
static QList<double> mouseHistoryX;
|
||||
static QList<double> mouseHistoryY;
|
||||
};
|
||||
};
|
||||
|
||||
class AntimicroSettings
|
||||
{
|
||||
class AntimicroSettings
|
||||
{
|
||||
public:
|
||||
|
||||
static const bool defaultDisabledWinEnhanced;
|
||||
static const bool defaultAssociateProfiles;
|
||||
static const int defaultSpringScreen;
|
||||
static const int defaultSDLGamepadPollRate;
|
||||
};
|
||||
};
|
||||
|
||||
class InputDevice
|
||||
{
|
||||
class InputDevice
|
||||
{
|
||||
public:
|
||||
|
||||
static const int NUMBER_JOYSETS;
|
||||
static const int DEFAULTKEYPRESSTIME;
|
||||
static const int RAISEDDEADZONE;
|
||||
static const int DEFAULTKEYREPEATDELAY;
|
||||
static const int DEFAULTKEYREPEATRATE;
|
||||
|
||||
//static QRegExp emptyGUID;
|
||||
// static QRegExp emptyGUID;
|
||||
static QRegExp emptyUniqueID;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyAxis
|
||||
{
|
||||
class JoyAxis
|
||||
{
|
||||
public:
|
||||
|
||||
static const int AXISMIN;
|
||||
static const int AXISMAX;
|
||||
static const int AXISDEADZONE;
|
||||
@@ -127,97 +120,84 @@ namespace GlobalVariables
|
||||
static const float JOYSPEED;
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef WITH_X11
|
||||
|
||||
#ifdef WITH_X11
|
||||
|
||||
class X11Extras
|
||||
{
|
||||
class X11Extras
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString mouseDeviceName;
|
||||
static const QString keyboardDeviceName;
|
||||
static const QString xtestMouseDeviceName;
|
||||
|
||||
static QString _customDisplayString;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
class GameController
|
||||
{
|
||||
class GameController
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class GameControllerDPad
|
||||
{
|
||||
class GameControllerDPad
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class GameControllerTrigger
|
||||
{
|
||||
class GameControllerTrigger
|
||||
{
|
||||
public:
|
||||
|
||||
static const int AXISDEADZONE;
|
||||
static const int AXISMAXZONE;
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class GameControllerTriggerButton
|
||||
{
|
||||
class GameControllerTriggerButton
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class InputDaemon
|
||||
{
|
||||
class InputDaemon
|
||||
{
|
||||
public:
|
||||
|
||||
static const int GAMECONTROLLERTRIGGERRELEASE;
|
||||
};
|
||||
};
|
||||
|
||||
class VDPad
|
||||
{
|
||||
class VDPad
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class SetJoystick
|
||||
{
|
||||
class SetJoystick
|
||||
{
|
||||
public:
|
||||
|
||||
static const int MAXNAMELENGTH;
|
||||
static const int RAISEDDEADZONE;
|
||||
};
|
||||
};
|
||||
|
||||
class Joystick
|
||||
{
|
||||
class Joystick
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyDPad
|
||||
{
|
||||
class JoyDPad
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
static const int DEFAULTDPADDELAY; // unsigned
|
||||
};
|
||||
};
|
||||
|
||||
class JoyControlStick
|
||||
{
|
||||
class JoyControlStick
|
||||
{
|
||||
public:
|
||||
|
||||
static const double PI;
|
||||
|
||||
// Define default values for stick properties.
|
||||
@@ -226,52 +206,46 @@ namespace GlobalVariables
|
||||
static const int DEFAULTDIAGONALRANGE;
|
||||
static const double DEFAULTCIRCLE;
|
||||
static const int DEFAULTSTICKDELAY;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyButtonSlot
|
||||
{
|
||||
class JoyButtonSlot
|
||||
{
|
||||
public:
|
||||
|
||||
static const int JOYSPEED;
|
||||
static const QString xmlName;
|
||||
static const int MAXTEXTENTRYDISPLAYLENGTH;
|
||||
};
|
||||
};
|
||||
|
||||
class AdvanceButtonDialog
|
||||
{
|
||||
class AdvanceButtonDialog
|
||||
{
|
||||
public:
|
||||
|
||||
static const int MINIMUMTURBO;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyAxisButton
|
||||
{
|
||||
class JoyAxisButton
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyControlStickButton
|
||||
{
|
||||
class JoyControlStickButton
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyControlStickModifierButton
|
||||
{
|
||||
class JoyControlStickModifierButton
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
class JoyDPadButton
|
||||
{
|
||||
class JoyDPadButton
|
||||
{
|
||||
public:
|
||||
|
||||
static const QString xmlName;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace GlobalVariables
|
||||
|
||||
#endif // GLOBALVARIABLES_H
|
||||
|
||||
@@ -18,37 +18,35 @@
|
||||
|
||||
#include "inputdaemon.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "logger.h"
|
||||
#include "common.h"
|
||||
#include "joystick.h"
|
||||
#include "joydpad.h"
|
||||
#include "sdleventreader.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "common.h"
|
||||
#include "globalvariables.h"
|
||||
#include "inputdevicebitarraystatus.h"
|
||||
|
||||
#include "joydpad.h"
|
||||
#include "joystick.h"
|
||||
#include "logger.h"
|
||||
#include "messagehandler.h"
|
||||
#include "sdleventreader.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QEventLoop>
|
||||
#include <QMapIterator>
|
||||
#include <QThread>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
|
||||
#define USE_NEW_REFRESH
|
||||
|
||||
InputDaemon::InputDaemon(QMap<SDL_JoystickID, InputDevice*> *joysticks,
|
||||
AntiMicroSettings *settings,
|
||||
bool graphical, QObject *parent) :
|
||||
QObject(parent),
|
||||
pollResetTimer(this)
|
||||
InputDaemon::InputDaemon(QMap<SDL_JoystickID, InputDevice *> *joysticks, AntiMicroSettings *settings, bool graphical,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, pollResetTimer(this)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
m_joysticks = joysticks;
|
||||
//Xbox360Wireless* xbox360class = new Xbox360Wireless();
|
||||
//xbox360 = xbox360class->getResult();
|
||||
// Xbox360Wireless* xbox360class = new Xbox360Wireless();
|
||||
// xbox360 = xbox360class->getResult();
|
||||
this->stopped = false;
|
||||
m_graphical = graphical;
|
||||
m_settings = settings;
|
||||
@@ -65,23 +63,21 @@ InputDaemon::InputDaemon(QMap<SDL_JoystickID, InputDevice*> *joysticks,
|
||||
connect(sdlWorkerThread, &QThread::started, eventWorker, &SDLEventReader::performWork);
|
||||
connect(eventWorker, &SDLEventReader::eventRaised, this, &InputDaemon::run);
|
||||
|
||||
connect(JoyButton::getMouseHelper(), &JoyButtonMouseHelper::gamepadRefreshRateUpdated,
|
||||
eventWorker, &SDLEventReader::updatePollRate);
|
||||
connect(JoyButton::getMouseHelper(), &JoyButtonMouseHelper::gamepadRefreshRateUpdated, eventWorker,
|
||||
&SDLEventReader::updatePollRate);
|
||||
|
||||
connect(JoyButton::getMouseHelper(), &JoyButtonMouseHelper::gamepadRefreshRateUpdated,
|
||||
this, &InputDaemon::updatePollResetRate);
|
||||
connect(JoyButton::getMouseHelper(), &JoyButtonMouseHelper::mouseRefreshRateUpdated,
|
||||
this, &InputDaemon::updatePollResetRate);
|
||||
connect(JoyButton::getMouseHelper(), &JoyButtonMouseHelper::gamepadRefreshRateUpdated, this,
|
||||
&InputDaemon::updatePollResetRate);
|
||||
connect(JoyButton::getMouseHelper(), &JoyButtonMouseHelper::mouseRefreshRateUpdated, this,
|
||||
&InputDaemon::updatePollResetRate);
|
||||
|
||||
// Timer in case SDL does not produce an axis event during a joystick
|
||||
// poll.
|
||||
pollResetTimer.setSingleShot(true);
|
||||
pollResetTimer.setInterval(
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
|
||||
connect(&pollResetTimer, &QTimer::timeout, this,
|
||||
&InputDaemon::resetActiveButtonMouseDistances);
|
||||
connect(&pollResetTimer, &QTimer::timeout, this, &InputDaemon::resetActiveButtonMouseDistances);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +85,8 @@ InputDaemon::~InputDaemon()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (eventWorker != nullptr) quit();
|
||||
if (eventWorker != nullptr)
|
||||
quit();
|
||||
|
||||
if (sdlWorkerThread != nullptr)
|
||||
{
|
||||
@@ -108,7 +105,7 @@ void InputDaemon::startWorker()
|
||||
sdlWorkerThread->start(QThread::HighPriority);
|
||||
}
|
||||
|
||||
void InputDaemon::run ()
|
||||
void InputDaemon::run()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -130,12 +127,12 @@ void InputDaemon::run ()
|
||||
|
||||
if (stopped)
|
||||
{
|
||||
if (m_joysticks->size() > 0) emit complete(m_joysticks->value(0));
|
||||
if (m_joysticks->size() > 0)
|
||||
emit complete(m_joysticks->value(0));
|
||||
|
||||
emit complete();
|
||||
stopped = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
QTimer::singleShot(0, eventWorker, SLOT(performWork()));
|
||||
pollResetTimer.start();
|
||||
@@ -157,7 +154,7 @@ QString InputDaemon::getJoyInfo(Uint16 sdlvalue)
|
||||
{
|
||||
char buffer[50] = {'0'};
|
||||
|
||||
sprintf (buffer, "%u", sdlvalue);
|
||||
sprintf(buffer, "%u", sdlvalue);
|
||||
|
||||
return QString(buffer);
|
||||
}
|
||||
@@ -166,7 +163,7 @@ void InputDaemon::refreshJoysticks()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QMapIterator<SDL_JoystickID, InputDevice*> iter(*m_joysticks);
|
||||
QMapIterator<SDL_JoystickID, InputDevice *> iter(*m_joysticks);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -186,7 +183,7 @@ void InputDaemon::refreshJoysticks()
|
||||
m_settings->getLock()->lock();
|
||||
m_settings->beginGroup("Mappings");
|
||||
|
||||
QMap<QString,int> uniques = QMap<QString,int>();
|
||||
QMap<QString, int> uniques = QMap<QString, int>();
|
||||
int counterUniques = 1;
|
||||
bool duplicatedGamepad = false;
|
||||
|
||||
@@ -195,7 +192,6 @@ void InputDaemon::refreshJoysticks()
|
||||
#ifdef USE_NEW_REFRESH
|
||||
int index = i;
|
||||
|
||||
|
||||
// Check if device is considered a Game Controller at the start.
|
||||
if (SDL_IsGameController(index))
|
||||
{
|
||||
@@ -222,45 +218,44 @@ void InputDaemon::refreshJoysticks()
|
||||
|
||||
// previous value will be erased in map anyway
|
||||
uniques.insert(guidText, uniques[guidText]);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
uniques.insert(guidText, counterUniques);
|
||||
}
|
||||
|
||||
convertMappingsToUnique(m_settings, guidText, guidText + vendor + productID);
|
||||
|
||||
bool disableGameController = m_settings->value(QString("%1Disable").arg(guidText + vendor + productID), false).toBool();
|
||||
bool disableGameController =
|
||||
m_settings->value(QString("%1Disable").arg(guidText + vendor + productID), false).toBool();
|
||||
|
||||
// Check if user has designated device Joystick mode.
|
||||
if (!disableGameController)
|
||||
{
|
||||
int resultDuplicated = 0;
|
||||
if (duplicatedGamepad) resultDuplicated = uniques.value(guidText);
|
||||
if (duplicatedGamepad)
|
||||
resultDuplicated = uniques.value(guidText);
|
||||
|
||||
GameController *damncontroller = new GameController(controller, index, m_settings, resultDuplicated, this);
|
||||
GameController *damncontroller =
|
||||
new GameController(controller, index, m_settings, resultDuplicated, this);
|
||||
duplicatedGamepad = false;
|
||||
connect(damncontroller, &GameController::requestWait, eventWorker, &SDLEventReader::haltServices);
|
||||
m_joysticks->insert(tempJoystickID, damncontroller);
|
||||
trackcontrollers.insert(tempJoystickID, damncontroller);
|
||||
|
||||
emit deviceAdded(damncontroller);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Joystick *joystick = openJoystickDevice(index);
|
||||
|
||||
if (joystick != nullptr)
|
||||
emit deviceAdded(joystick);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
SDL_GameControllerClose(controller); // Make sure to decrement reference count
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Joystick *joystick = openJoystickDevice(index);
|
||||
|
||||
@@ -268,7 +263,6 @@ void InputDaemon::refreshJoysticks()
|
||||
emit deviceAdded(joystick);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
SDL_Joystick *joystick = SDL_JoystickOpen(i);
|
||||
if (joystick != nullptr)
|
||||
@@ -290,8 +284,7 @@ void InputDaemon::refreshJoysticks()
|
||||
SDL_JoystickID joystickID = SDL_JoystickInstanceID(sdlStick);
|
||||
m_joysticks->insert(joystickID, damncontroller);
|
||||
trackcontrollers.insert(joystickID, damncontroller);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Joystick *curJoystick = new Joystick(joystick, i, m_settings, this);
|
||||
connect(curJoystick, &Joystick::requestWait, eventWorker, &SDLEventReader::haltServices);
|
||||
@@ -313,7 +306,7 @@ void InputDaemon::deleteJoysticks()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QMapIterator<SDL_JoystickID, InputDevice*> iter(*m_joysticks);
|
||||
QMapIterator<SDL_JoystickID, InputDevice *> iter(*m_joysticks);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -321,7 +314,6 @@ void InputDaemon::deleteJoysticks()
|
||||
|
||||
for (auto el : joystick->getJoystick_sets().values())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (joystick != nullptr)
|
||||
@@ -356,9 +348,10 @@ void InputDaemon::refresh()
|
||||
QEventLoop q;
|
||||
connect(eventWorker, &SDLEventReader::sdlStarted, &q, &QEventLoop::quit);
|
||||
QTimer::singleShot(0, eventWorker, SLOT(refresh()));
|
||||
//QMetaObject::invokeMethod(eventWorker, "refresh", Qt::BlockingQueuedConnection);
|
||||
// QMetaObject::invokeMethod(eventWorker, "refresh", Qt::BlockingQueuedConnection);
|
||||
|
||||
if (eventWorker->isSDLOpen()) q.exec();
|
||||
if (eventWorker->isSDLOpen())
|
||||
q.exec();
|
||||
|
||||
disconnect(eventWorker, &SDLEventReader::sdlStarted, &q, &QEventLoop::quit);
|
||||
|
||||
@@ -374,7 +367,6 @@ void InputDaemon::refresh()
|
||||
QTimer::singleShot(100, eventWorker, SLOT(performWork()));
|
||||
|
||||
stopped = false;
|
||||
|
||||
}
|
||||
|
||||
void InputDaemon::refreshJoystick(InputDevice *joystick)
|
||||
@@ -402,8 +394,7 @@ void InputDaemon::quit()
|
||||
QMetaObject::invokeMethod(eventWorker, "stop");
|
||||
QMetaObject::invokeMethod(eventWorker, "quit");
|
||||
QMetaObject::invokeMethod(eventWorker, "deleteLater", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
eventWorker->stop();
|
||||
eventWorker->quit();
|
||||
@@ -413,14 +404,13 @@ void InputDaemon::quit()
|
||||
eventWorker = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void InputDaemon::refreshMapping(QString mapping, InputDevice *device)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
bool found = false;
|
||||
|
||||
QMap<QString,int> uniques = QMap<QString,int>();
|
||||
QMap<QString, int> uniques = QMap<QString, int>();
|
||||
int counterUniques = 1;
|
||||
bool duplicatedGamepad = false;
|
||||
|
||||
@@ -440,8 +430,7 @@ void InputDaemon::refreshMapping(QString mapping, InputDevice *device)
|
||||
// Mapping string updated. Perform basic refresh
|
||||
QByteArray tempbarray = mapping.toUtf8();
|
||||
SDL_GameControllerAddMapping(tempbarray.data());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Previously registered as a plain joystick. Add
|
||||
// mapping and check for validity. If SDL accepts it,
|
||||
@@ -466,14 +455,14 @@ void InputDaemon::refreshMapping(QString mapping, InputDevice *device)
|
||||
|
||||
// previous value will be erased in map anyway
|
||||
uniques.insert(guidText, uniques[guidText]);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
uniques.insert(guidText, counterUniques);
|
||||
}
|
||||
|
||||
int resultDuplicated = 0;
|
||||
if (duplicatedGamepad) resultDuplicated = counterUniques;
|
||||
if (duplicatedGamepad)
|
||||
resultDuplicated = counterUniques;
|
||||
|
||||
GameController *damncontroller = new GameController(controller, i, m_settings, resultDuplicated, this);
|
||||
duplicatedGamepad = false;
|
||||
@@ -515,7 +504,7 @@ void InputDaemon::refreshIndexes()
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++)
|
||||
//for (int i = 0; i < 1; i++)
|
||||
// for (int i = 0; i < 1; i++)
|
||||
{
|
||||
SDL_Joystick *joystick = SDL_JoystickOpen(i);
|
||||
// SDL_Joystick *joystick = xbox360;
|
||||
@@ -525,15 +514,14 @@ void InputDaemon::refreshIndexes()
|
||||
|
||||
if (tempdevice != nullptr)
|
||||
tempdevice->setIndex(i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& counterUniques, bool& duplicatedGamepad)
|
||||
void InputDaemon::addInputDevice(int index, QMap<QString, int> &uniques, int &counterUniques, bool &duplicatedGamepad)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
#ifdef USE_NEW_ADD
|
||||
#ifdef USE_NEW_ADD
|
||||
// Check if device is considered a Game Controller at the start.
|
||||
if (SDL_IsGameController(index))
|
||||
{
|
||||
@@ -569,12 +557,11 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
trackcontrollers.insert(tempJoystickID, damncontroller);
|
||||
|
||||
Logger::LogInfo(QString("New game controller found - #%1 [%2]")
|
||||
.arg(index+1)
|
||||
.arg(index + 1)
|
||||
.arg(QTime::currentTime().toString("hh:mm:ss.zzz")));
|
||||
|
||||
emit deviceAdded(damncontroller);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Check if joystick is considered connected.
|
||||
|
||||
@@ -582,29 +569,25 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
if (joystick != nullptr)
|
||||
{
|
||||
Logger::LogInfo(QString("New joystick found - #%1 [%2]")
|
||||
.arg(index+1)
|
||||
.arg(index + 1)
|
||||
.arg(QTime::currentTime().toString("hh:mm:ss.zzz")));
|
||||
|
||||
emit deviceAdded(joystick);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Make sure to decrement reference count
|
||||
SDL_GameControllerClose(controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Joystick *joystick = openJoystickDevice(index);
|
||||
if (joystick != nullptr)
|
||||
{
|
||||
Logger::LogInfo(QString("New joystick found - #%1 [%2]")
|
||||
.arg(index+1)
|
||||
.arg(QTime::currentTime().toString("hh:mm:ss.zzz")));
|
||||
Logger::LogInfo(
|
||||
QString("New joystick found - #%1 [%2]").arg(index + 1).arg(QTime::currentTime().toString("hh:mm:ss.zzz")));
|
||||
|
||||
emit deviceAdded(joystick);
|
||||
}
|
||||
@@ -625,13 +608,13 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
m_settings->getLock()->lock();
|
||||
m_settings->beginGroup("Mappings");
|
||||
|
||||
// QString temp = QString();
|
||||
// SDL_JoystickGUID tempGUID = SDL_JoystickGetGUID(joystick);
|
||||
// char guidString[65] = {'0'};
|
||||
// SDL_JoystickGetGUIDString(tempGUID, guidString, sizeof(guidString));
|
||||
// temp = QString(guidString);
|
||||
// QString temp = QString();
|
||||
// SDL_JoystickGUID tempGUID = SDL_JoystickGetGUID(joystick);
|
||||
// char guidString[65] = {'0'};
|
||||
// SDL_JoystickGetGUIDString(tempGUID, guidString, sizeof(guidString));
|
||||
// temp = QString(guidString);
|
||||
|
||||
// bool disableGameController = m_settings->value(QString("%1Disable").arg(temp), false).toBool();
|
||||
// bool disableGameController = m_settings->value(QString("%1Disable").arg(temp), false).toBool();
|
||||
|
||||
QString guidText = QString();
|
||||
|
||||
@@ -645,8 +628,8 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
if (controller != nullptr)
|
||||
{
|
||||
Uint16 tempVendor = SDL_GameControllerGetVendor(controller);
|
||||
char buffer [50];
|
||||
sprintf (buffer, "%u", tempVendor);
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%u", tempVendor);
|
||||
|
||||
vendor = QString(buffer);
|
||||
}
|
||||
@@ -656,8 +639,8 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
if (controller != nullptr)
|
||||
{
|
||||
Uint16 tempProduct = SDL_GameControllerGetProduct(controller);
|
||||
char buffer [50];
|
||||
sprintf (buffer, "%u", tempProduct);
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%u", tempProduct);
|
||||
|
||||
productID = QString(buffer);
|
||||
}
|
||||
@@ -667,8 +650,7 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
productID = getJoyInfo(SDL_GameControllerGetProduct(controller) + ++uniques[guidText]);
|
||||
duplicatedGamepad = true;
|
||||
uniques.insert(guidText, uniques[guidText]);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
uniques.insert(guidText, counterUniques);
|
||||
}
|
||||
@@ -676,9 +658,11 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
convertMappingsToUnique(m_settings, guidText, guidText + vendor + productID);
|
||||
|
||||
int resultDuplicated = 0;
|
||||
if (duplicatedGamepad) resultDuplicated = uniques[guidText];
|
||||
if (duplicatedGamepad)
|
||||
resultDuplicated = uniques[guidText];
|
||||
|
||||
bool disableGameController = m_settings->value(QString("%1Disable").arg(guidText + vendor + productID), false).toBool();
|
||||
bool disableGameController =
|
||||
m_settings->value(QString("%1Disable").arg(guidText + vendor + productID), false).toBool();
|
||||
|
||||
if (SDL_IsGameController(index) && !disableGameController)
|
||||
{
|
||||
@@ -694,7 +678,8 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
|
||||
if (!m_joysticks->contains(tempJoystickID_local_2))
|
||||
{
|
||||
GameController *damncontroller = new GameController(controller, index, m_settings, resultDuplicated, this);
|
||||
GameController *damncontroller =
|
||||
new GameController(controller, index, m_settings, resultDuplicated, this);
|
||||
connect(damncontroller, &GameController::requestWait, eventWorker, &SDLEventReader::haltServices);
|
||||
m_joysticks->insert(tempJoystickID_local_2, damncontroller);
|
||||
trackcontrollers.insert(tempJoystickID_local_2, damncontroller);
|
||||
@@ -706,14 +691,12 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
}
|
||||
|
||||
duplicatedGamepad = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
m_settings->endGroup();
|
||||
m_settings->getLock()->unlock();
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
Joystick *curJoystick = new Joystick(joystick, index, m_settings, this);
|
||||
m_joysticks->insert(tempJoystickID_local, curJoystick);
|
||||
@@ -724,8 +707,7 @@ void InputDaemon::addInputDevice(int index, QMap<QString,int>& uniques, int& cou
|
||||
|
||||
emit deviceAdded(curJoystick);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Make sure to decrement reference count
|
||||
SDL_JoystickClose(joystick);
|
||||
@@ -750,16 +732,14 @@ Joystick *InputDaemon::openJoystickDevice(int index)
|
||||
curJoystick = new Joystick(joystick, index, m_settings, this);
|
||||
m_joysticks->insert(tempJoystickID, curJoystick);
|
||||
getTrackjoysticksLocal().insert(tempJoystickID, curJoystick);
|
||||
|
||||
}
|
||||
|
||||
return curJoystick;
|
||||
}
|
||||
|
||||
|
||||
InputDeviceBitArrayStatus*
|
||||
InputDaemon::createOrGrabBitStatusEntry(QHash<InputDevice *, InputDeviceBitArrayStatus *> *statusHash,
|
||||
InputDevice *device, bool readCurrent)
|
||||
InputDeviceBitArrayStatus *
|
||||
InputDaemon::createOrGrabBitStatusEntry(QHash<InputDevice *, InputDeviceBitArrayStatus *> *statusHash, InputDevice *device,
|
||||
bool readCurrent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -769,8 +749,7 @@ InputDaemon::createOrGrabBitStatusEntry(QHash<InputDevice *, InputDeviceBitArray
|
||||
{
|
||||
bitArrayStatus = new InputDeviceBitArrayStatus(device, readCurrent);
|
||||
statusHash->insert(device, bitArrayStatus);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
bitArrayStatus = statusHash->value(device);
|
||||
}
|
||||
@@ -789,37 +768,33 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
{
|
||||
case SDL_JOYBUTTONUP: {
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jbutton.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyButton *button = set->getJoyButton(event.jbutton.button);
|
||||
|
||||
if (button != nullptr)
|
||||
{
|
||||
InputDeviceBitArrayStatus *pending = createOrGrabBitStatusEntry(&pendingEventValues, joy);
|
||||
pending->changeButtonStatus(event.jbutton.button,
|
||||
event.type == SDL_JOYBUTTONDOWN ? true : false);
|
||||
pending->changeButtonStatus(event.jbutton.button, event.type == SDL_JOYBUTTONDOWN ? true : false);
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SDL_JOYAXISMOTION:
|
||||
{
|
||||
case SDL_JOYAXISMOTION: {
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jaxis.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyAxis *axis = set->getJoyAxis(event.jaxis.axis);
|
||||
|
||||
if (axis != nullptr)
|
||||
@@ -831,21 +806,19 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
pending->changeAxesStatus(event.jaxis.axis, !axis->inDeadZone(event.jaxis.value));
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SDL_JOYHATMOTION:
|
||||
{
|
||||
case SDL_JOYHATMOTION: {
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jhat.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyDPad *dpad = set->getJoyDPad(event.jhat.hat);
|
||||
|
||||
if (dpad != nullptr)
|
||||
@@ -854,8 +827,7 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
pending->changeHatStatus(event.jhat.hat, (event.jhat.value != 0) ? true : false);
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
@@ -863,13 +835,12 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
{
|
||||
case SDL_CONTROLLERAXISMOTION: {
|
||||
InputDevice *joy = trackcontrollers.value(event.caxis.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyAxis *axis = set->getJoyAxis(event.caxis.axis);
|
||||
|
||||
if (axis != nullptr)
|
||||
@@ -880,10 +851,11 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
(event.caxis.axis != SDL_CONTROLLER_AXIS_TRIGGERRIGHT))
|
||||
{
|
||||
temp->changeAxesStatus(event.caxis.axis, event.caxis.value == 0);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
temp->changeAxesStatus(event.caxis.axis, event.caxis.value == GlobalVariables::InputDaemon::GAMECONTROLLERTRIGGERRELEASE);
|
||||
temp->changeAxesStatus(event.caxis.axis,
|
||||
event.caxis.value ==
|
||||
GlobalVariables::InputDaemon::GAMECONTROLLERTRIGGERRELEASE);
|
||||
}
|
||||
|
||||
InputDeviceBitArrayStatus *pending = createOrGrabBitStatusEntry(&pendingEventValues, joy);
|
||||
@@ -895,20 +867,18 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
{
|
||||
case SDL_CONTROLLERBUTTONUP: {
|
||||
InputDevice *joy = trackcontrollers.value(event.cbutton.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyButton *button = set->getJoyButton(event.cbutton.button);
|
||||
|
||||
if (button != nullptr)
|
||||
{
|
||||
InputDeviceBitArrayStatus *pending = createOrGrabBitStatusEntry(&pendingEventValues, joy);
|
||||
pending->changeButtonStatus(event.cbutton.button,
|
||||
event.type == SDL_CONTROLLERBUTTONDOWN ? true : false);
|
||||
pending->changeButtonStatus(event.cbutton.button, event.type == SDL_CONTROLLERBUTTONDOWN ? true : false);
|
||||
sdlEventQueue->append(event);
|
||||
}
|
||||
}
|
||||
@@ -918,30 +888,26 @@ void InputDaemon::firstInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
case SDL_JOYDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
{
|
||||
case SDL_CONTROLLERDEVICEREMOVED: {
|
||||
sdlEventQueue->append(event);
|
||||
break;
|
||||
}
|
||||
case SDL_QUIT:
|
||||
{
|
||||
case SDL_QUIT: {
|
||||
sdlEventQueue->append(event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<InputDevice*, InputDeviceBitArrayStatus*> genIter(getReleaseEventsGeneratedLocal());
|
||||
QHashIterator<InputDevice *, InputDeviceBitArrayStatus *> genIter(getReleaseEventsGeneratedLocal());
|
||||
|
||||
while (genIter.hasNext())
|
||||
{
|
||||
@@ -950,15 +916,12 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
InputDeviceBitArrayStatus *generatedTemp = genIter.value();
|
||||
QBitArray tempBitArray = generatedTemp->generateFinalBitArray();
|
||||
|
||||
|
||||
qDebug() << "ARRAY: " << tempBitArray;
|
||||
|
||||
|
||||
int bitArraySize = tempBitArray.size();
|
||||
|
||||
qDebug() << "ARRAY SIZE: " << bitArraySize;
|
||||
|
||||
|
||||
if ((bitArraySize > 0) && (tempBitArray.count(true) == device->getNumberAxes()))
|
||||
{
|
||||
if (getPendingEventValuesLocal().contains(device))
|
||||
@@ -968,8 +931,7 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
QBitArray unplugBitArray = createUnplugEventBitArray(device);
|
||||
int pendingBitArraySize = pendingBitArray.size();
|
||||
|
||||
if ((bitArraySize == pendingBitArraySize) &&
|
||||
(pendingBitArray == unplugBitArray))
|
||||
if ((bitArraySize == pendingBitArraySize) && (pendingBitArray == unplugBitArray))
|
||||
{
|
||||
QQueue<SDL_Event> tempQueue;
|
||||
|
||||
@@ -980,18 +942,15 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
{
|
||||
case SDL_JOYBUTTONUP: {
|
||||
tempQueue.enqueue(event);
|
||||
break;
|
||||
}
|
||||
case SDL_JOYAXISMOTION:
|
||||
{
|
||||
case SDL_JOYAXISMOTION: {
|
||||
if (event.jaxis.which != device->getSDLJoystickID())
|
||||
{
|
||||
tempQueue.enqueue(event);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jaxis.which);
|
||||
|
||||
@@ -1012,24 +971,21 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
|
||||
break;
|
||||
}
|
||||
case SDL_JOYHATMOTION:
|
||||
{
|
||||
case SDL_JOYHATMOTION: {
|
||||
tempQueue.enqueue(event);
|
||||
break;
|
||||
}
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
{
|
||||
case SDL_CONTROLLERAXISMOTION: {
|
||||
if (event.caxis.which != device->getSDLJoystickID())
|
||||
{
|
||||
tempQueue.enqueue(event);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
InputDevice *joy = trackcontrollers.value(event.caxis.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyAxis *axis = set->getJoyAxis(event.caxis.axis);
|
||||
|
||||
if (axis != nullptr)
|
||||
@@ -1048,8 +1004,7 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
break;
|
||||
}
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
{
|
||||
case SDL_CONTROLLERBUTTONUP: {
|
||||
|
||||
tempQueue.enqueue(event);
|
||||
break;
|
||||
@@ -1057,13 +1012,11 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
case SDL_JOYDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
{
|
||||
case SDL_CONTROLLERDEVICEADDED: {
|
||||
tempQueue.enqueue(event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
tempQueue.enqueue(event);
|
||||
}
|
||||
}
|
||||
@@ -1076,7 +1029,6 @@ void InputDaemon::modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QBitArray InputDaemon::createUnplugEventBitArray(InputDevice *device)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -1095,16 +1047,15 @@ QBitArray InputDaemon::createUnplugEventBitArray(InputDevice *device)
|
||||
return unplugBitArray;
|
||||
}
|
||||
|
||||
|
||||
void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QMap<QString,int> uniques = QMap<QString,int>();
|
||||
QMap<QString, int> uniques = QMap<QString, int>();
|
||||
int counterUniques = 1;
|
||||
bool duplicatedGamepad = false;
|
||||
|
||||
QHash<SDL_JoystickID, InputDevice*> activeDevices;
|
||||
QHash<SDL_JoystickID, InputDevice *> activeDevices;
|
||||
|
||||
while (!sdlEventQueue->isEmpty())
|
||||
{
|
||||
@@ -1113,13 +1064,12 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
{
|
||||
case SDL_JOYBUTTONUP: {
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jbutton.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyButton *button = set->getJoyButton(event.jbutton.button);
|
||||
|
||||
if (button != nullptr)
|
||||
@@ -1129,8 +1079,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
if (!activeDevices.contains(event.jbutton.which))
|
||||
activeDevices.insert(event.jbutton.which, joy);
|
||||
}
|
||||
}
|
||||
else if (trackcontrollers.contains(event.jbutton.which))
|
||||
} else if (trackcontrollers.contains(event.jbutton.which))
|
||||
{
|
||||
GameController *gamepad = trackcontrollers.value(event.jbutton.which);
|
||||
gamepad->rawButtonEvent(event.jbutton.button, event.type == SDL_JOYBUTTONDOWN ? true : false);
|
||||
@@ -1139,14 +1088,13 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYAXISMOTION:
|
||||
{
|
||||
case SDL_JOYAXISMOTION: {
|
||||
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jaxis.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyAxis *axis = set->getJoyAxis(event.jaxis.axis);
|
||||
|
||||
if (axis != nullptr)
|
||||
@@ -1158,8 +1106,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
|
||||
joy->rawAxisEvent(event.jaxis.which, event.jaxis.value);
|
||||
}
|
||||
else if (trackcontrollers.contains(event.jaxis.which))
|
||||
} else if (trackcontrollers.contains(event.jaxis.which))
|
||||
{
|
||||
GameController *gamepad = trackcontrollers.value(event.jaxis.which);
|
||||
gamepad->rawAxisEvent(event.jaxis.axis, event.jaxis.value);
|
||||
@@ -1168,13 +1115,12 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYHATMOTION:
|
||||
{
|
||||
case SDL_JOYHATMOTION: {
|
||||
InputDevice *joy = getTrackjoysticksLocal().value(event.jhat.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyDPad *dpad = set->getJoyDPad(event.jhat.hat);
|
||||
|
||||
if (dpad != nullptr)
|
||||
@@ -1184,8 +1130,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
if (!activeDevices.contains(event.jhat.which))
|
||||
activeDevices.insert(event.jhat.which, joy);
|
||||
}
|
||||
}
|
||||
else if (trackcontrollers.contains(event.jhat.which))
|
||||
} else if (trackcontrollers.contains(event.jhat.which))
|
||||
{
|
||||
GameController *gamepad = trackcontrollers.value(event.jaxis.which);
|
||||
gamepad->rawDPadEvent(event.jhat.hat, event.jhat.value);
|
||||
@@ -1194,13 +1139,12 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
{
|
||||
case SDL_CONTROLLERAXISMOTION: {
|
||||
InputDevice *joy = trackcontrollers.value(event.caxis.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyAxis *axis = set->getJoyAxis(event.caxis.axis);
|
||||
|
||||
if (axis != nullptr)
|
||||
@@ -1216,13 +1160,12 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
{
|
||||
case SDL_CONTROLLERBUTTONUP: {
|
||||
InputDevice *joy = trackcontrollers.value(event.cbutton.which);
|
||||
|
||||
if (joy != nullptr)
|
||||
{
|
||||
SetJoystick* set = joy->getActiveSetJoystick();
|
||||
SetJoystick *set = joy->getActiveSetJoystick();
|
||||
JoyButton *button = set->getJoyButton(event.cbutton.button);
|
||||
|
||||
if (button != nullptr)
|
||||
@@ -1238,8 +1181,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
{
|
||||
case SDL_CONTROLLERDEVICEREMOVED: {
|
||||
InputDevice *device = m_joysticks->value(event.jdevice.which);
|
||||
|
||||
if (device != nullptr)
|
||||
@@ -1255,14 +1197,12 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
{
|
||||
case SDL_CONTROLLERDEVICEADDED: {
|
||||
addInputDevice(event.jdevice.which, uniques, counterUniques, duplicatedGamepad);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_QUIT:
|
||||
{
|
||||
case SDL_QUIT: {
|
||||
stopped = true;
|
||||
break;
|
||||
}
|
||||
@@ -1272,7 +1212,7 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
}
|
||||
|
||||
// Active possible queued events.
|
||||
QHashIterator<SDL_JoystickID, InputDevice*> activeDevIter(activeDevices);
|
||||
QHashIterator<SDL_JoystickID, InputDevice *> activeDevIter(activeDevices);
|
||||
|
||||
while (activeDevIter.hasNext())
|
||||
{
|
||||
@@ -1284,8 +1224,10 @@ void InputDaemon::secondInputPass(QQueue<SDL_Event> *sdlEventQueue)
|
||||
tempDevice->activatePossibleButtonEvents();
|
||||
}
|
||||
|
||||
if (JoyButton::shouldInvokeMouseEvents(JoyButton::getPendingMouseButtons(), JoyButton::getStaticMouseEventTimer(), JoyButton::getTestOldMouseTime()))
|
||||
JoyButton::invokeMouseEvents(JoyButton::getMouseHelper()); // Do not wait for next event loop run. Execute immediately.
|
||||
if (JoyButton::shouldInvokeMouseEvents(JoyButton::getPendingMouseButtons(), JoyButton::getStaticMouseEventTimer(),
|
||||
JoyButton::getTestOldMouseTime()))
|
||||
JoyButton::invokeMouseEvents(
|
||||
JoyButton::getMouseHelper()); // Do not wait for next event loop run. Execute immediately.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1293,7 +1235,7 @@ void InputDaemon::clearBitArrayStatusInstances()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<InputDevice*, InputDeviceBitArrayStatus*> genIter(getReleaseEventsGeneratedLocal());
|
||||
QHashIterator<InputDevice *, InputDeviceBitArrayStatus *> genIter(getReleaseEventsGeneratedLocal());
|
||||
|
||||
while (genIter.hasNext())
|
||||
{
|
||||
@@ -1308,7 +1250,7 @@ void InputDaemon::clearBitArrayStatusInstances()
|
||||
|
||||
getReleaseEventsGeneratedLocal().clear();
|
||||
|
||||
QHashIterator<InputDevice*, InputDeviceBitArrayStatus*> pendIter(getPendingEventValuesLocal());
|
||||
QHashIterator<InputDevice *, InputDeviceBitArrayStatus *> pendIter(getPendingEventValuesLocal());
|
||||
|
||||
while (pendIter.hasNext())
|
||||
{
|
||||
@@ -1342,13 +1284,13 @@ void InputDaemon::updatePollResetRate(int tempPollRate)
|
||||
bool wasActive = pollResetTimer.isActive();
|
||||
pollResetTimer.stop();
|
||||
pollResetTimer.setInterval(
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
qMax(GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::gamepadRefreshRate) + 1);
|
||||
|
||||
if (wasActive) pollResetTimer.start();
|
||||
if (wasActive)
|
||||
pollResetTimer.start();
|
||||
}
|
||||
|
||||
void InputDaemon::convertMappingsToUnique(QSettings* sett, QString guidString, QString uniqueIdString)
|
||||
void InputDaemon::convertMappingsToUnique(QSettings *sett, QString guidString, QString uniqueIdString)
|
||||
{
|
||||
if (sett->contains(QString("%1Disable").arg(guidString)))
|
||||
{
|
||||
@@ -1370,17 +1312,12 @@ void InputDaemon::convertMappingsToUnique(QSettings* sett, QString guidString, Q
|
||||
}
|
||||
}
|
||||
|
||||
QHash<SDL_JoystickID, Joystick*>& InputDaemon::getTrackjoysticksLocal() {
|
||||
QHash<SDL_JoystickID, Joystick *> &InputDaemon::getTrackjoysticksLocal() { return trackjoysticks; }
|
||||
|
||||
return trackjoysticks;
|
||||
}
|
||||
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*>& InputDaemon::getReleaseEventsGeneratedLocal() {
|
||||
QHash<InputDevice *, InputDeviceBitArrayStatus *> &InputDaemon::getReleaseEventsGeneratedLocal()
|
||||
{
|
||||
|
||||
return releaseEventsGenerated;
|
||||
}
|
||||
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*>& InputDaemon::getPendingEventValuesLocal() {
|
||||
|
||||
return pendingEventValues;
|
||||
}
|
||||
QHash<InputDevice *, InputDeviceBitArrayStatus *> &InputDaemon::getPendingEventValuesLocal() { return pendingEventValues; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INPUTDAEMONTHREAD_H
|
||||
#define INPUTDAEMONTHREAD_H
|
||||
|
||||
@@ -24,7 +23,6 @@
|
||||
//#include "fakeclasses/xbox360wireless.h"
|
||||
#include <SDL2/SDL_events.h>
|
||||
|
||||
|
||||
class InputDevice;
|
||||
class AntiMicroSettings;
|
||||
class InputDeviceBitArrayStatus;
|
||||
@@ -37,17 +35,14 @@ class InputDaemon : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InputDaemon (QMap<SDL_JoystickID, InputDevice*> *joysticks,
|
||||
AntiMicroSettings *settings, bool graphical=true,
|
||||
QObject *parent=0);
|
||||
public:
|
||||
explicit InputDaemon(QMap<SDL_JoystickID, InputDevice *> *joysticks, AntiMicroSettings *settings, bool graphical = true,
|
||||
QObject *parent = 0);
|
||||
~InputDaemon();
|
||||
|
||||
|
||||
protected:
|
||||
InputDeviceBitArrayStatus* createOrGrabBitStatusEntry(
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*> *statusHash,
|
||||
InputDevice *device, bool readCurrent=true);
|
||||
protected:
|
||||
InputDeviceBitArrayStatus *createOrGrabBitStatusEntry(QHash<InputDevice *, InputDeviceBitArrayStatus *> *statusHash,
|
||||
InputDevice *device, bool readCurrent = true);
|
||||
|
||||
QString getJoyInfo(SDL_JoystickGUID sdlvalue);
|
||||
QString getJoyInfo(Uint16 sdlvalue);
|
||||
@@ -56,14 +51,14 @@ protected:
|
||||
void secondInputPass(QQueue<SDL_Event> *sdlEventQueue);
|
||||
void modifyUnplugEvents(QQueue<SDL_Event> *sdlEventQueue);
|
||||
QBitArray createUnplugEventBitArray(InputDevice *device);
|
||||
Joystick* openJoystickDevice(int index);
|
||||
Joystick *openJoystickDevice(int index);
|
||||
|
||||
void clearBitArrayStatusInstances();
|
||||
void convertMappingsToUnique(QSettings* sett, QString guidString, QString uniqueIdString);
|
||||
void convertMappingsToUnique(QSettings *sett, QString guidString, QString uniqueIdString);
|
||||
|
||||
signals:
|
||||
void joystickRefreshed (InputDevice *joystick);
|
||||
void joysticksRefreshed(QMap<SDL_JoystickID, InputDevice*> *joysticks);
|
||||
signals:
|
||||
void joystickRefreshed(InputDevice *joystick);
|
||||
void joysticksRefreshed(QMap<SDL_JoystickID, InputDevice *> *joysticks);
|
||||
void complete(InputDevice *joystick);
|
||||
void complete();
|
||||
|
||||
@@ -71,8 +66,7 @@ signals:
|
||||
void deviceRemoved(SDL_JoystickID deviceID);
|
||||
void deviceAdded(InputDevice *device);
|
||||
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void run();
|
||||
void quit();
|
||||
void refresh();
|
||||
@@ -82,25 +76,25 @@ public slots:
|
||||
void startWorker();
|
||||
void refreshMapping(QString mapping, InputDevice *device);
|
||||
void removeDevice(InputDevice *device);
|
||||
void addInputDevice(int index, QMap<QString,int>& uniques, int &counterUniques, bool &duplicatedGamepad);
|
||||
void addInputDevice(int index, QMap<QString, int> &uniques, int &counterUniques, bool &duplicatedGamepad);
|
||||
void refreshIndexes();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void stop();
|
||||
void resetActiveButtonMouseDistances();
|
||||
void updatePollResetRate(int tempPollRate);
|
||||
|
||||
private:
|
||||
QHash<SDL_JoystickID, Joystick*>& getTrackjoysticksLocal();
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*>& getReleaseEventsGeneratedLocal();
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*>& getPendingEventValuesLocal();
|
||||
private:
|
||||
QHash<SDL_JoystickID, Joystick *> &getTrackjoysticksLocal();
|
||||
QHash<InputDevice *, InputDeviceBitArrayStatus *> &getReleaseEventsGeneratedLocal();
|
||||
QHash<InputDevice *, InputDeviceBitArrayStatus *> &getPendingEventValuesLocal();
|
||||
|
||||
QMap<SDL_JoystickID, InputDevice*> *m_joysticks;
|
||||
QHash<SDL_JoystickID, Joystick*> trackjoysticks;
|
||||
QHash<SDL_JoystickID, GameController*> trackcontrollers;
|
||||
QMap<SDL_JoystickID, InputDevice *> *m_joysticks;
|
||||
QHash<SDL_JoystickID, Joystick *> trackjoysticks;
|
||||
QHash<SDL_JoystickID, GameController *> trackcontrollers;
|
||||
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*> releaseEventsGenerated;
|
||||
QHash<InputDevice*, InputDeviceBitArrayStatus*> pendingEventValues;
|
||||
QHash<InputDevice *, InputDeviceBitArrayStatus *> releaseEventsGenerated;
|
||||
QHash<InputDevice *, InputDeviceBitArrayStatus *> pendingEventValues;
|
||||
|
||||
bool stopped;
|
||||
bool m_graphical;
|
||||
@@ -109,7 +103,7 @@ private:
|
||||
QThread *sdlWorkerThread;
|
||||
AntiMicroSettings *m_settings;
|
||||
QTimer pollResetTimer;
|
||||
//SDL_Joystick* xbox360;
|
||||
// SDL_Joystick* xbox360;
|
||||
};
|
||||
|
||||
#endif // INPUTDAEMONTHREAD_H
|
||||
|
||||
@@ -18,25 +18,24 @@
|
||||
|
||||
#include "inputdevice.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "common.h"
|
||||
#include "antimicrosettings.h"
|
||||
#include "joydpad.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "joybuttontypes/joydpadbutton.h"
|
||||
#include "vdpad.h"
|
||||
#include "common.h"
|
||||
#include "globalvariables.h"
|
||||
#include "joybuttontypes/joycontrolstickbutton.h"
|
||||
#include "joybuttontypes/joydpadbutton.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "joydpad.h"
|
||||
#include "messagehandler.h"
|
||||
#include "vdpad.h"
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
InputDevice::InputDevice(SDL_Joystick* joystick, int deviceIndex, AntiMicroSettings *settings, QObject *parent) :
|
||||
QObject(parent)
|
||||
InputDevice::InputDevice(SDL_Joystick *joystick, int deviceIndex, AntiMicroSettings *settings, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -58,7 +57,7 @@ InputDevice::~InputDevice()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -99,7 +98,7 @@ void InputDevice::reset()
|
||||
|
||||
for (int i = 0; i < GlobalVariables::InputDevice::NUMBER_JOYSETS; i++)
|
||||
{
|
||||
SetJoystick* set = getJoystick_sets().value(i);
|
||||
SetJoystick *set = getJoystick_sets().value(i);
|
||||
set->reset();
|
||||
}
|
||||
}
|
||||
@@ -224,7 +223,7 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
tempSet->getJoyDPad(i)->copyLastDistanceValues(dpad);
|
||||
}
|
||||
|
||||
for (int i=0; i < current_set->getNumberSticks(); i++)
|
||||
for (int i = 0; i < current_set->getNumberSticks(); i++)
|
||||
{
|
||||
// Last distances for elements are taken from associated axes.
|
||||
// Copying is not required here.
|
||||
@@ -253,8 +252,8 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
for (int i = 0; i < current_set->getNumberSticks(); i++)
|
||||
{
|
||||
JoyControlStick::JoyStickDirections value = stickstates.at(i);
|
||||
QList<JoyControlStickButton*> buttonList;
|
||||
QList<JoyControlStickButton*> oldButtonList;
|
||||
QList<JoyControlStickButton *> buttonList;
|
||||
QList<JoyControlStickButton *> oldButtonList;
|
||||
JoyControlStick *stick = current_set->getJoyStick(i);
|
||||
JoyControlStick *oldStick = old_set->getJoyStick(i);
|
||||
|
||||
@@ -262,52 +261,46 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case JoyControlStick::StickRightUp:
|
||||
{
|
||||
case JoyControlStick::StickRightUp: {
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickUp));
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickRight));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickUp));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickRight));
|
||||
break;
|
||||
}
|
||||
case JoyControlStick::StickRightDown:
|
||||
{
|
||||
case JoyControlStick::StickRightDown: {
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickRight));
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickDown));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickRight));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickDown));
|
||||
break;
|
||||
}
|
||||
case JoyControlStick::StickLeftDown:
|
||||
{
|
||||
case JoyControlStick::StickLeftDown: {
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickDown));
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickLeft));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickDown));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickLeft));
|
||||
break;
|
||||
}
|
||||
case JoyControlStick::StickLeftUp:
|
||||
{
|
||||
case JoyControlStick::StickLeftUp: {
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickLeft));
|
||||
buttonList.append(stick->getDirectionButton(JoyControlStick::StickUp));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickLeft));
|
||||
oldButtonList.append(oldStick->getDirectionButton(JoyControlStick::StickUp));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
buttonList.append(stick->getDirectionButton(value));
|
||||
oldButtonList.append(oldStick->getDirectionButton(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value)
|
||||
} else if (value)
|
||||
{
|
||||
buttonList.append(stick->getDirectionButton(value));
|
||||
oldButtonList.append(oldStick->getDirectionButton(value));
|
||||
}
|
||||
|
||||
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton*> iter(*stick->getButtons());
|
||||
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton *> iter(*stick->getButtons());
|
||||
while (iter.hasNext())
|
||||
{
|
||||
JoyControlStickButton *tempButton = iter.next().value();
|
||||
@@ -326,17 +319,17 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
{
|
||||
if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
|
||||
{
|
||||
if ((oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
if ((oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) &&
|
||||
oldButton->getWhileHeldStatus())
|
||||
{
|
||||
// Button from old set involved in a while held set
|
||||
// change. Carry over to new set button to ensure
|
||||
// set changes are done in the proper order.
|
||||
button->setWhileHeldStatus(true);
|
||||
}
|
||||
else if (!button->getWhileHeldStatus())
|
||||
} else if (!button->getWhileHeldStatus())
|
||||
{
|
||||
// Ensure that set change events are performed if needed.
|
||||
//tempignore = false;
|
||||
// tempignore = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,60 +341,54 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
{
|
||||
int value = vdpadstates.at(i);
|
||||
JoyDPad *dpad = current_set->getVDPad(i);
|
||||
QList<JoyDPadButton*> buttonList;
|
||||
QList<JoyDPadButton*> oldButtonList;
|
||||
QList<JoyDPadButton *> buttonList;
|
||||
QList<JoyDPadButton *> oldButtonList;
|
||||
bool valueTrue = (value != 0);
|
||||
|
||||
if ((dpad->getJoyMode() == JoyDPad::StandardMode) && valueTrue)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case JoyDPadButton::DpadRightUp:
|
||||
{
|
||||
case JoyDPadButton::DpadRightUp: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadUp));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadRight));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadUp));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadRight));
|
||||
break;
|
||||
}
|
||||
case JoyDPadButton::DpadRightDown:
|
||||
{
|
||||
case JoyDPadButton::DpadRightDown: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadRight));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadDown));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadRight));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadDown));
|
||||
break;
|
||||
}
|
||||
case JoyDPadButton::DpadLeftDown:
|
||||
{
|
||||
case JoyDPadButton::DpadLeftDown: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadDown));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadDown));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
break;
|
||||
}
|
||||
case JoyDPadButton::DpadLeftUp:
|
||||
{
|
||||
case JoyDPadButton::DpadLeftUp: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadUp));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(JoyDPadButton::DpadUp));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
buttonList.append(dpad->getJoyButton(value));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (valueTrue)
|
||||
} else if (valueTrue)
|
||||
{
|
||||
buttonList.append(dpad->getJoyButton(value));
|
||||
oldButtonList.append(old_set->getVDPad(i)->getJoyButton(value));
|
||||
}
|
||||
|
||||
QHashIterator<int, JoyDPadButton*> iter(*dpad->getJoyButtons());
|
||||
QHashIterator<int, JoyDPadButton *> iter(*dpad->getJoyButtons());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -419,17 +406,17 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
JoyDPadButton *button = buttonList.at(j);
|
||||
JoyDPadButton *oldButton = oldButtonList.at(j);
|
||||
|
||||
if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
|
||||
&& valueTrue && (oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && valueTrue &&
|
||||
(oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
{
|
||||
// Button from old set involved in a while held set
|
||||
// change. Carry over to new set button to ensure
|
||||
// set changes are done in the proper order.
|
||||
|
||||
button->setWhileHeldStatus(true);
|
||||
}
|
||||
else if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
|
||||
&& !valueTrue)
|
||||
} else if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && !valueTrue)
|
||||
{
|
||||
button->setWhileHeldStatus(false);
|
||||
}
|
||||
@@ -443,20 +430,20 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
JoyButton *button = current_set->getJoyButton(i);
|
||||
JoyButton *oldButton = old_set->getJoyButton(i);
|
||||
|
||||
if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && value && (oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && value &&
|
||||
(oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
{
|
||||
// Button from old set involved in a while held set
|
||||
// change. Carry over to new set button to ensure
|
||||
// set changes are done in the proper order.
|
||||
|
||||
button->setWhileHeldStatus(true);
|
||||
}
|
||||
else if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && value && !button->getWhileHeldStatus())
|
||||
} else if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && value &&
|
||||
!button->getWhileHeldStatus())
|
||||
{
|
||||
// Ensure that set change events are performed if needed.
|
||||
tempignore = false;
|
||||
}
|
||||
else if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && !value)
|
||||
} else if (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld && !value)
|
||||
{
|
||||
// Ensure that set change events are performed if needed.
|
||||
button->setWhileHeldStatus(false);
|
||||
@@ -474,7 +461,8 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
JoyAxisButton *oldButton = old_set->getJoyAxis(i)->getAxisButtonByValue(value);
|
||||
JoyAxisButton *button = axis->getAxisButtonByValue(value);
|
||||
|
||||
if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) &&
|
||||
if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) &&
|
||||
(oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
{
|
||||
// Button from old set involved in a while held set
|
||||
@@ -482,14 +470,12 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
// set changes are done in the proper order.
|
||||
|
||||
button->setWhileHeldStatus(true);
|
||||
}
|
||||
else if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) &&
|
||||
!button->getWhileHeldStatus())
|
||||
} else if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && !button->getWhileHeldStatus())
|
||||
{
|
||||
// Ensure that set change events are performed if needed.
|
||||
tempignore = false;
|
||||
}
|
||||
else if (button == nullptr)
|
||||
} else if (button == nullptr)
|
||||
{
|
||||
// Ensure that set change events are performed if needed.
|
||||
axis->getPAxisButton()->setWhileHeldStatus(false);
|
||||
@@ -505,60 +491,54 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
int value = dpadstates.at(i);
|
||||
bool tempignore = false;
|
||||
JoyDPad *dpad = current_set->getJoyDPad(i);
|
||||
QList<JoyDPadButton*> buttonList;
|
||||
QList<JoyDPadButton*> oldButtonList;
|
||||
QList<JoyDPadButton *> buttonList;
|
||||
QList<JoyDPadButton *> oldButtonList;
|
||||
bool valueTrue = (value != 0);
|
||||
|
||||
if ((dpad->getJoyMode() == JoyDPad::StandardMode) && valueTrue)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case JoyDPadButton::DpadRightUp:
|
||||
{
|
||||
case JoyDPadButton::DpadRightUp: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadUp));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadRight));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadUp));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadRight));
|
||||
break;
|
||||
}
|
||||
case JoyDPadButton::DpadRightDown:
|
||||
{
|
||||
case JoyDPadButton::DpadRightDown: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadRight));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadDown));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadRight));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadDown));
|
||||
break;
|
||||
}
|
||||
case JoyDPadButton::DpadLeftDown:
|
||||
{
|
||||
case JoyDPadButton::DpadLeftDown: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadDown));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadDown));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
break;
|
||||
}
|
||||
case JoyDPadButton::DpadLeftUp:
|
||||
{
|
||||
case JoyDPadButton::DpadLeftUp: {
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
buttonList.append(dpad->getJoyButton(JoyDPadButton::DpadUp));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadLeft));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(JoyDPadButton::DpadUp));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
buttonList.append(dpad->getJoyButton(value));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (valueTrue)
|
||||
} else if (valueTrue)
|
||||
{
|
||||
buttonList.append(dpad->getJoyButton(value));
|
||||
oldButtonList.append(old_set->getJoyDPad(i)->getJoyButton(value));
|
||||
}
|
||||
|
||||
QHashIterator<int, JoyDPadButton*> iter(*dpad->getJoyButtons());
|
||||
QHashIterator<int, JoyDPadButton *> iter(*dpad->getJoyButtons());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -574,23 +554,23 @@ void InputDevice::setActiveSetNumber(int index)
|
||||
JoyDPadButton *button = buttonList.at(j);
|
||||
JoyDPadButton *oldButton = oldButtonList.at(j);
|
||||
|
||||
if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
|
||||
&& valueTrue && (oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && valueTrue &&
|
||||
(oldButton->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && oldButton->getWhileHeldStatus())
|
||||
{
|
||||
// Button from old set involved in a while held set
|
||||
// change. Carry over to new set button to ensure
|
||||
// set changes are done in the proper order.
|
||||
|
||||
button->setWhileHeldStatus(true);
|
||||
}
|
||||
else if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
|
||||
&& valueTrue && !button->getWhileHeldStatus())
|
||||
} else if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && valueTrue &&
|
||||
!button->getWhileHeldStatus())
|
||||
{
|
||||
// Ensure that set change events are performed if needed.
|
||||
tempignore = false;
|
||||
}
|
||||
else if ((button != nullptr) && (oldButton != nullptr) && (button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld)
|
||||
&& !valueTrue)
|
||||
} else if ((button != nullptr) && (oldButton != nullptr) &&
|
||||
(button->getChangeSetCondition() == JoyButton::SetChangeWhileHeld) && !valueTrue)
|
||||
{
|
||||
button->setWhileHeldStatus(false);
|
||||
}
|
||||
@@ -614,7 +594,7 @@ int InputDevice::getActiveSetNumber()
|
||||
return active_set;
|
||||
}
|
||||
|
||||
SetJoystick* InputDevice::getActiveSetJoystick()
|
||||
SetJoystick *InputDevice::getActiveSetJoystick()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -656,7 +636,7 @@ int InputDevice::getNumberVDPads()
|
||||
return getActiveSetJoystick()->getNumberVDPads();
|
||||
}
|
||||
|
||||
SetJoystick* InputDevice::getSetJoystick(int index)
|
||||
SetJoystick *InputDevice::getSetJoystick(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -689,8 +669,7 @@ void InputDevice::changeSetAxisButtonAssociation(int button_index, int axis_inde
|
||||
if (button_index == 0)
|
||||
{
|
||||
button = getJoystick_sets().value(newset)->getJoyAxis(axis_index)->getNAxisButton();
|
||||
}
|
||||
else if (button_index == 1)
|
||||
} else if (button_index == 1)
|
||||
{
|
||||
button = getJoystick_sets().value(newset)->getJoyAxis(axis_index)->getPAxisButton();
|
||||
}
|
||||
@@ -704,7 +683,10 @@ void InputDevice::changeSetStickButtonAssociation(int button_index, int stick_in
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyControlStickButton *button = getJoystick_sets().value(newset)->getJoyStick(stick_index)->getDirectionButton(static_cast<JoyControlStick::JoyStickDirections>(button_index));
|
||||
JoyControlStickButton *button = getJoystick_sets()
|
||||
.value(newset)
|
||||
->getJoyStick(stick_index)
|
||||
->getDirectionButton(static_cast<JoyControlStick::JoyStickDirections>(button_index));
|
||||
|
||||
JoyButton::SetChangeCondition tempmode = static_cast<JoyButton::SetChangeCondition>(mode);
|
||||
button->setChangeSetSelection(originset);
|
||||
@@ -746,7 +728,7 @@ void InputDevice::propogateSetAxisThrottleChange(int index, int originset)
|
||||
if (axis != nullptr)
|
||||
{
|
||||
int throttleSetting = axis->getThrottle();
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -805,9 +787,11 @@ void InputDevice::buttonUpEvent(int setindex, int buttonindex)
|
||||
bool old = isActive();
|
||||
buttonDownCount -= 1;
|
||||
|
||||
if (buttonDownCount < 0) buttonDownCount = 0;
|
||||
if (buttonDownCount < 0)
|
||||
buttonDownCount = 0;
|
||||
|
||||
if (isActive() != old) emit released(joyNumber);
|
||||
if (isActive() != old)
|
||||
emit released(joyNumber);
|
||||
}
|
||||
|
||||
void InputDevice::buttonClickEvent(int buttonindex)
|
||||
@@ -846,7 +830,7 @@ void InputDevice::dpadButtonClickEvent(int buttonindex)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyDPadButton *dpadbutton = qobject_cast<JoyDPadButton*>(sender());
|
||||
JoyDPadButton *dpadbutton = qobject_cast<JoyDPadButton *>(sender());
|
||||
|
||||
if (dpadbutton != nullptr)
|
||||
emit rawDPadButtonClick(dpadbutton->getDPad()->getIndex(), buttonindex);
|
||||
@@ -856,7 +840,7 @@ void InputDevice::dpadButtonReleaseEvent(int buttonindex)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyDPadButton *dpadbutton = qobject_cast<JoyDPadButton*>(sender());
|
||||
JoyDPadButton *dpadbutton = qobject_cast<JoyDPadButton *>(sender());
|
||||
|
||||
if (dpadbutton != nullptr)
|
||||
emit rawDPadButtonRelease(dpadbutton->getDPad()->getIndex(), buttonindex);
|
||||
@@ -902,7 +886,7 @@ void InputDevice::setButtonName(int index, QString tempName)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -921,7 +905,7 @@ void InputDevice::setAxisButtonName(int axisIndex, int buttonIndex, QString temp
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -933,10 +917,13 @@ void InputDevice::setAxisButtonName(int axisIndex, int buttonIndex, QString temp
|
||||
{
|
||||
JoyAxisButton *button = nullptr;
|
||||
|
||||
if (buttonIndex == 0) button = axis->getNAxisButton();
|
||||
else if (buttonIndex == 1) button = axis->getPAxisButton();
|
||||
if (buttonIndex == 0)
|
||||
button = axis->getNAxisButton();
|
||||
else if (buttonIndex == 1)
|
||||
button = axis->getPAxisButton();
|
||||
|
||||
if (button != nullptr) button->setButtonName(tempName);
|
||||
if (button != nullptr)
|
||||
button->setButtonName(tempName);
|
||||
}
|
||||
|
||||
connect(tempSet, &SetJoystick::setAxisButtonNameChange, this, &InputDevice::updateSetAxisButtonNames);
|
||||
@@ -947,7 +934,7 @@ void InputDevice::setStickButtonName(int stickIndex, int buttonIndex, QString te
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -971,7 +958,7 @@ void InputDevice::setDPadButtonName(int dpadIndex, int buttonIndex, QString temp
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -983,7 +970,8 @@ void InputDevice::setDPadButtonName(int dpadIndex, int buttonIndex, QString temp
|
||||
{
|
||||
JoyDPadButton *button = dpad->getJoyButton(buttonIndex);
|
||||
|
||||
if (button != nullptr) button->setButtonName(tempName);
|
||||
if (button != nullptr)
|
||||
button->setButtonName(tempName);
|
||||
}
|
||||
|
||||
connect(tempSet, &SetJoystick::setDPadButtonNameChange, this, &InputDevice::updateSetDPadButtonNames);
|
||||
@@ -994,7 +982,7 @@ void InputDevice::setVDPadButtonName(int vdpadIndex, int buttonIndex, QString te
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -1006,7 +994,8 @@ void InputDevice::setVDPadButtonName(int vdpadIndex, int buttonIndex, QString te
|
||||
{
|
||||
JoyDPadButton *button = vdpad->getJoyButton(buttonIndex);
|
||||
|
||||
if (button != nullptr) button->setButtonName(tempName);
|
||||
if (button != nullptr)
|
||||
button->setButtonName(tempName);
|
||||
}
|
||||
|
||||
connect(tempSet, &SetJoystick::setVDPadButtonNameChange, this, &InputDevice::updateSetVDPadButtonNames);
|
||||
@@ -1017,7 +1006,7 @@ void InputDevice::setAxisName(int axisIndex, QString tempName)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -1025,7 +1014,8 @@ void InputDevice::setAxisName(int axisIndex, QString tempName)
|
||||
disconnect(tempSet, &SetJoystick::setAxisNameChange, this, &InputDevice::updateSetAxisNames);
|
||||
JoyAxis *axis = tempSet->getJoyAxis(axisIndex);
|
||||
|
||||
if (axis != nullptr) axis->setAxisName(tempName);
|
||||
if (axis != nullptr)
|
||||
axis->setAxisName(tempName);
|
||||
|
||||
connect(tempSet, &SetJoystick::setAxisNameChange, this, &InputDevice::updateSetAxisNames);
|
||||
}
|
||||
@@ -1035,7 +1025,7 @@ void InputDevice::setStickName(int stickIndex, QString tempName)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -1043,7 +1033,8 @@ void InputDevice::setStickName(int stickIndex, QString tempName)
|
||||
disconnect(tempSet, &SetJoystick::setStickNameChange, this, &InputDevice::updateSetStickNames);
|
||||
JoyControlStick *stick = tempSet->getJoyStick(stickIndex);
|
||||
|
||||
if (stick != nullptr) stick->setStickName(tempName);
|
||||
if (stick != nullptr)
|
||||
stick->setStickName(tempName);
|
||||
|
||||
connect(tempSet, &SetJoystick::setStickNameChange, this, &InputDevice::updateSetStickNames);
|
||||
}
|
||||
@@ -1053,7 +1044,7 @@ void InputDevice::setDPadName(int dpadIndex, QString tempName)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -1061,7 +1052,8 @@ void InputDevice::setDPadName(int dpadIndex, QString tempName)
|
||||
disconnect(tempSet, &SetJoystick::setDPadNameChange, this, &InputDevice::updateSetDPadNames);
|
||||
JoyDPad *dpad = tempSet->getJoyDPad(dpadIndex);
|
||||
|
||||
if (dpad != nullptr) dpad->setDPadName(tempName);
|
||||
if (dpad != nullptr)
|
||||
dpad->setDPadName(tempName);
|
||||
|
||||
connect(tempSet, &SetJoystick::setDPadNameChange, this, &InputDevice::updateSetDPadNames);
|
||||
}
|
||||
@@ -1071,7 +1063,7 @@ void InputDevice::setVDPadName(int vdpadIndex, QString tempName)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QHashIterator<int, SetJoystick*> iter(getJoystick_sets());
|
||||
QHashIterator<int, SetJoystick *> iter(getJoystick_sets());
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -1079,20 +1071,21 @@ void InputDevice::setVDPadName(int vdpadIndex, QString tempName)
|
||||
disconnect(tempSet, &SetJoystick::setVDPadNameChange, this, &InputDevice::updateSetVDPadNames);
|
||||
VDPad *vdpad = tempSet->getVDPad(vdpadIndex);
|
||||
|
||||
if (vdpad != nullptr) vdpad->setDPadName(tempName);
|
||||
if (vdpad != nullptr)
|
||||
vdpad->setDPadName(tempName);
|
||||
|
||||
connect(tempSet, &SetJoystick::setVDPadNameChange, this, &InputDevice::updateSetVDPadNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InputDevice::updateSetButtonNames(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyButton *button = getActiveSetJoystick()->getJoyButton(index);
|
||||
|
||||
if (button != nullptr) setButtonName(index, button->getButtonName());
|
||||
if (button != nullptr)
|
||||
setButtonName(index, button->getButtonName());
|
||||
}
|
||||
|
||||
void InputDevice::updateSetAxisButtonNames(int axisIndex, int buttonIndex)
|
||||
@@ -1105,8 +1098,10 @@ void InputDevice::updateSetAxisButtonNames(int axisIndex, int buttonIndex)
|
||||
{
|
||||
JoyAxisButton *button = nullptr;
|
||||
|
||||
if (buttonIndex == 0) button = axis->getNAxisButton();
|
||||
else if (buttonIndex == 1) button = axis->getPAxisButton();
|
||||
if (buttonIndex == 0)
|
||||
button = axis->getNAxisButton();
|
||||
else if (buttonIndex == 1)
|
||||
button = axis->getPAxisButton();
|
||||
|
||||
if (button != nullptr)
|
||||
setAxisButtonName(axisIndex, buttonIndex, button->getButtonName());
|
||||
@@ -1270,8 +1265,10 @@ void InputDevice::setIndex(int index)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (index >= 0) joyNumber = index;
|
||||
else joyNumber = 0;
|
||||
if (index >= 0)
|
||||
joyNumber = index;
|
||||
else
|
||||
joyNumber = 0;
|
||||
}
|
||||
|
||||
void InputDevice::setDeviceKeyPressTime(int newPressTime)
|
||||
@@ -1323,9 +1320,11 @@ QString InputDevice::getStringIdentifier()
|
||||
QString tempUniqueID = getUniqueIDString();
|
||||
QString tempName = getSDLName();
|
||||
|
||||
if (!tempUniqueID.isEmpty()) identifier = tempUniqueID;
|
||||
if (!tempUniqueID.isEmpty())
|
||||
identifier = tempUniqueID;
|
||||
// else if (!tempGUID.isEmpty()) identifier = tempGUID;
|
||||
else if (!tempName.isEmpty()) identifier = tempName;
|
||||
else if (!tempName.isEmpty())
|
||||
identifier = tempName;
|
||||
|
||||
return identifier;
|
||||
}
|
||||
@@ -1463,7 +1462,8 @@ bool InputDevice::hasCalibrationThrottle(int axisNum)
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (getCali().contains(axisNum)) result = true;
|
||||
if (getCali().contains(axisNum))
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1514,7 +1514,7 @@ void InputDevice::sendLoadProfileRequest(QString location)
|
||||
emit requestProfileLoad(location);
|
||||
}
|
||||
|
||||
AntiMicroSettings* InputDevice::getSettings()
|
||||
AntiMicroSettings *InputDevice::getSettings()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -1530,19 +1530,21 @@ bool InputDevice::isKnownController()
|
||||
if (isGameController())
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
m_settings->beginGroup("Mappings");
|
||||
|
||||
// if (m_settings->contains(getGUIDString())) result = true;
|
||||
// else if (m_settings->contains(QString("%1%2").arg(getGUIDString()).arg("Disabled"))) result = true;
|
||||
// if (m_settings->contains(getGUIDString())) result = true;
|
||||
// else if (m_settings->contains(QString("%1%2").arg(getGUIDString()).arg("Disabled"))) result = true;
|
||||
|
||||
convertToUniqueMappSett(m_settings, getGUIDString(), getUniqueIDString());
|
||||
convertToUniqueMappSett(m_settings, (QString("%1%2").arg(getGUIDString()).arg("Disabled")), (QString("%1%2").arg(getUniqueIDString()).arg("Disabled")));
|
||||
convertToUniqueMappSett(m_settings, (QString("%1%2").arg(getGUIDString()).arg("Disabled")),
|
||||
(QString("%1%2").arg(getUniqueIDString()).arg("Disabled")));
|
||||
|
||||
if (m_settings->contains(getUniqueIDString())) result = true;
|
||||
else if (m_settings->contains(QString("%1%2").arg(getUniqueIDString()).arg("Disabled"))) result = true;
|
||||
if (m_settings->contains(getUniqueIDString()))
|
||||
result = true;
|
||||
else if (m_settings->contains(QString("%1%2").arg(getUniqueIDString()).arg("Disabled")))
|
||||
result = true;
|
||||
|
||||
m_settings->endGroup();
|
||||
}
|
||||
@@ -1652,7 +1654,8 @@ bool InputDevice::elementsHaveNames()
|
||||
{
|
||||
JoyButton *button = tempSet->getJoyButton(i);
|
||||
|
||||
if ((button != nullptr) && !button->getButtonName().isEmpty()) result = true;
|
||||
if ((button != nullptr) && !button->getButtonName().isEmpty())
|
||||
result = true;
|
||||
}
|
||||
|
||||
for (int i = 0; (i < getNumberAxes()) && !result; i++)
|
||||
@@ -1661,15 +1664,18 @@ bool InputDevice::elementsHaveNames()
|
||||
|
||||
if (axis != nullptr)
|
||||
{
|
||||
if (!axis->getAxisName().isEmpty()) result = true;
|
||||
if (!axis->getAxisName().isEmpty())
|
||||
result = true;
|
||||
|
||||
JoyAxisButton *naxisbutton = axis->getNAxisButton();
|
||||
|
||||
if (!naxisbutton->getButtonName().isEmpty()) result = true;
|
||||
if (!naxisbutton->getButtonName().isEmpty())
|
||||
result = true;
|
||||
|
||||
JoyAxisButton *paxisbutton = axis->getPAxisButton();
|
||||
|
||||
if (!paxisbutton->getButtonName().isEmpty()) result = true;
|
||||
if (!paxisbutton->getButtonName().isEmpty())
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1679,16 +1685,18 @@ bool InputDevice::elementsHaveNames()
|
||||
|
||||
if (stick != nullptr)
|
||||
{
|
||||
if (!stick->getStickName().isEmpty()) result = true;
|
||||
if (!stick->getStickName().isEmpty())
|
||||
result = true;
|
||||
|
||||
QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton*> *buttons = stick->getButtons();
|
||||
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton*> iter(*buttons);
|
||||
QHash<JoyControlStick::JoyStickDirections, JoyControlStickButton *> *buttons = stick->getButtons();
|
||||
QHashIterator<JoyControlStick::JoyStickDirections, JoyControlStickButton *> iter(*buttons);
|
||||
|
||||
while (iter.hasNext() && !result)
|
||||
{
|
||||
JoyControlStickButton *button = iter.next().value();
|
||||
|
||||
if (button && !button->getButtonName().isEmpty()) result = true;
|
||||
if (button && !button->getButtonName().isEmpty())
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1699,16 +1707,18 @@ bool InputDevice::elementsHaveNames()
|
||||
|
||||
if (dpad != nullptr)
|
||||
{
|
||||
if (!dpad->getDpadName().isEmpty()) result = true;
|
||||
if (!dpad->getDpadName().isEmpty())
|
||||
result = true;
|
||||
|
||||
QHash<int, JoyDPadButton*> *temp = dpad->getButtons();
|
||||
QHashIterator<int, JoyDPadButton*> iter(*temp);
|
||||
QHash<int, JoyDPadButton *> *temp = dpad->getButtons();
|
||||
QHashIterator<int, JoyDPadButton *> iter(*temp);
|
||||
|
||||
while (iter.hasNext() && !result)
|
||||
{
|
||||
JoyDPadButton *button = iter.next().value();
|
||||
|
||||
if (button && !button->getButtonName().isEmpty()) result = true;
|
||||
if (button && !button->getButtonName().isEmpty())
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1719,16 +1729,18 @@ bool InputDevice::elementsHaveNames()
|
||||
|
||||
if (vdpad != nullptr)
|
||||
{
|
||||
if (!vdpad->getDpadName().isEmpty()) result = true;
|
||||
if (!vdpad->getDpadName().isEmpty())
|
||||
result = true;
|
||||
|
||||
QHash<int, JoyDPadButton*> *temp = vdpad->getButtons();
|
||||
QHashIterator<int, JoyDPadButton*> iter(*temp);
|
||||
QHash<int, JoyDPadButton *> *temp = vdpad->getButtons();
|
||||
QHashIterator<int, JoyDPadButton *> iter(*temp);
|
||||
|
||||
while (iter.hasNext() && !result)
|
||||
{
|
||||
JoyDPadButton *button = iter.next().value();
|
||||
|
||||
if ((button != nullptr) && !button->getButtonName().isEmpty()) result = true;
|
||||
if ((button != nullptr) && !button->getButtonName().isEmpty())
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1741,7 +1753,7 @@ bool InputDevice::elementsHaveNames()
|
||||
* @param GUID string
|
||||
* @return if GUID is considered empty.
|
||||
*/
|
||||
//bool InputDevice::isEmptyGUID(QString tempGUID)
|
||||
// bool InputDevice::isEmptyGUID(QString tempGUID)
|
||||
//{
|
||||
// qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -1758,7 +1770,8 @@ bool InputDevice::isEmptyUniqueID(QString tempUniqueID)
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (tempUniqueID.contains(GlobalVariables::InputDevice::emptyUniqueID)) result = true;
|
||||
if (tempUniqueID.contains(GlobalVariables::InputDevice::emptyUniqueID))
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1769,7 +1782,7 @@ bool InputDevice::isEmptyUniqueID(QString tempUniqueID)
|
||||
* @param GUID string
|
||||
* @return if GUID is considered a match.
|
||||
*/
|
||||
//bool InputDevice::isRelevantGUID(QString tempGUID)
|
||||
// bool InputDevice::isRelevantGUID(QString tempGUID)
|
||||
//{
|
||||
// qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -1780,19 +1793,18 @@ bool InputDevice::isEmptyUniqueID(QString tempUniqueID)
|
||||
// return result;
|
||||
//}
|
||||
|
||||
|
||||
bool InputDevice::isRelevantUniqueID(QString tempUniqueID)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (tempUniqueID == getUniqueIDString()) result = true;
|
||||
if (tempUniqueID == getUniqueIDString())
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString InputDevice::getRawGUIDString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -1800,7 +1812,6 @@ QString InputDevice::getRawGUIDString()
|
||||
return getGUIDString();
|
||||
}
|
||||
|
||||
|
||||
QString InputDevice::getRawVendorString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -1808,7 +1819,6 @@ QString InputDevice::getRawVendorString()
|
||||
return getVendorString();
|
||||
}
|
||||
|
||||
|
||||
QString InputDevice::getRawProductIDString()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -1816,11 +1826,7 @@ QString InputDevice::getRawProductIDString()
|
||||
return getProductIDString();
|
||||
}
|
||||
|
||||
QString InputDevice::getRawProductVersion()
|
||||
{
|
||||
return getProductVersion();
|
||||
}
|
||||
|
||||
QString InputDevice::getRawProductVersion() { return getProductVersion(); }
|
||||
|
||||
QString InputDevice::getRawUniqueIDString()
|
||||
{
|
||||
@@ -1829,7 +1835,6 @@ QString InputDevice::getRawUniqueIDString()
|
||||
return getUniqueIDString();
|
||||
}
|
||||
|
||||
|
||||
void InputDevice::haltServices()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -1852,8 +1857,7 @@ void InputDevice::setRawAxisDeadZone(int deadZone)
|
||||
if ((deadZone > 0) && (deadZone <= GlobalVariables::JoyAxis::AXISMAX))
|
||||
{
|
||||
this->rawAxisDeadZone = deadZone;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
this->rawAxisDeadZone = GlobalVariables::InputDevice::RAISEDDEADZONE;
|
||||
}
|
||||
@@ -1873,19 +1877,19 @@ void InputDevice::rawAxisEvent(int index, int value)
|
||||
emit rawAxisMoved(index, value);
|
||||
}
|
||||
|
||||
void InputDevice::convertToUniqueMappSett(QSettings* sett, QString gUIDmappGroupSett, QString uniqueIDGroupSett)
|
||||
void InputDevice::convertToUniqueMappSett(QSettings *sett, QString gUIDmappGroupSett, QString uniqueIDGroupSett)
|
||||
{
|
||||
if (sett->contains(gUIDmappGroupSett))
|
||||
{
|
||||
if (sett->contains(gUIDmappGroupSett) && (sett->value(gUIDmappGroupSett).toString().split(",").first() == getGUIDString()))
|
||||
if (sett->contains(gUIDmappGroupSett) &&
|
||||
(sett->value(gUIDmappGroupSett).toString().split(",").first() == getGUIDString()))
|
||||
{
|
||||
QStringList gg = sett->value(gUIDmappGroupSett).toString().split(",");
|
||||
gg.removeFirst();
|
||||
gg.prepend(uniqueIDGroupSett);
|
||||
sett->setValue(uniqueIDGroupSett, sett->value(gg.join(",")));
|
||||
sett->remove(gUIDmappGroupSett);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
sett->setValue(uniqueIDGroupSett, sett->value(gUIDmappGroupSett));
|
||||
sett->remove(gUIDmappGroupSett);
|
||||
@@ -1893,37 +1897,16 @@ void InputDevice::convertToUniqueMappSett(QSettings* sett, QString gUIDmappGroup
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, SetJoystick*>& InputDevice::getJoystick_sets() {
|
||||
QHash<int, SetJoystick *> &InputDevice::getJoystick_sets() { return joystick_sets; }
|
||||
|
||||
return joystick_sets;
|
||||
}
|
||||
QHash<int, JoyAxis::ThrottleTypes> &InputDevice::getCali() { return cali; }
|
||||
|
||||
QHash<int, JoyAxis::ThrottleTypes>& InputDevice::getCali() {
|
||||
SDL_JoystickID *InputDevice::getJoystickID() { return &joystickID; }
|
||||
|
||||
return cali;
|
||||
}
|
||||
QList<bool> &InputDevice::getButtonstatesLocal() { return buttonstates; }
|
||||
|
||||
SDL_JoystickID* InputDevice::getJoystickID() {
|
||||
QList<int> &InputDevice::getAxesstatesLocal() { return axesstates; }
|
||||
|
||||
return &joystickID;
|
||||
}
|
||||
QList<int> &InputDevice::getDpadstatesLocal() { return dpadstates; }
|
||||
|
||||
QList<bool>& InputDevice::getButtonstatesLocal() {
|
||||
|
||||
return buttonstates;
|
||||
}
|
||||
|
||||
QList<int>& InputDevice::getAxesstatesLocal() {
|
||||
|
||||
return axesstates;
|
||||
}
|
||||
|
||||
QList<int>& InputDevice::getDpadstatesLocal() {
|
||||
|
||||
return dpadstates;
|
||||
}
|
||||
|
||||
SDL_Joystick* InputDevice::getJoyHandle() const
|
||||
{
|
||||
return m_joyhandle;
|
||||
}
|
||||
SDL_Joystick *InputDevice::getJoyHandle() const { return m_joyhandle; }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INPUTDEVICE_H
|
||||
#define INPUTDEVICE_H
|
||||
|
||||
@@ -24,7 +23,6 @@
|
||||
|
||||
#include <SDL2/SDL_joystick.h>
|
||||
|
||||
|
||||
class AntiMicroSettings;
|
||||
class SetJoystick;
|
||||
class QXmlStreamReader;
|
||||
@@ -35,8 +33,8 @@ class InputDevice : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InputDevice(SDL_Joystick* joystick, int deviceIndex, AntiMicroSettings *settings, QObject *parent = nullptr);
|
||||
public:
|
||||
explicit InputDevice(SDL_Joystick *joystick, int deviceIndex, AntiMicroSettings *settings, QObject *parent = nullptr);
|
||||
virtual ~InputDevice();
|
||||
|
||||
virtual int getNumberButtons();
|
||||
@@ -48,8 +46,8 @@ public:
|
||||
int getJoyNumber();
|
||||
int getRealJoyNumber();
|
||||
int getActiveSetNumber();
|
||||
SetJoystick* getActiveSetJoystick();
|
||||
SetJoystick* getSetJoystick(int index);
|
||||
SetJoystick *getActiveSetJoystick();
|
||||
SetJoystick *getSetJoystick(int index);
|
||||
void removeControlStick(int index);
|
||||
bool isActive();
|
||||
int getButtonDownCount();
|
||||
@@ -123,11 +121,11 @@ public:
|
||||
void activatePossibleDPadEvents(); // InputDeviceHat class
|
||||
void activatePossibleVDPadEvents(); // InputDeviceVDPad class
|
||||
void activatePossibleButtonEvents(); // InputDeviceButton class
|
||||
void convertToUniqueMappSett(QSettings* sett, QString gUIDmappGroupSett, QString uniqueIDGroupSett);
|
||||
void convertToUniqueMappSett(QSettings *sett, QString gUIDmappGroupSett, QString uniqueIDGroupSett);
|
||||
|
||||
//bool isEmptyGUID(QString tempGUID);
|
||||
// bool isEmptyGUID(QString tempGUID);
|
||||
bool isEmptyUniqueID(QString tempUniqueID);
|
||||
//bool isRelevantGUID(QString tempGUID);
|
||||
// bool isRelevantGUID(QString tempGUID);
|
||||
bool isRelevantUniqueID(QString tempUniqueID);
|
||||
|
||||
void setRawAxisDeadZone(int deadZone); // InputDeviceAxis class
|
||||
@@ -135,21 +133,20 @@ public:
|
||||
void rawAxisEvent(int index, int value); // InputDeviceAxis class
|
||||
bool elementsHaveNames();
|
||||
|
||||
QHash<int, SetJoystick*>& getJoystick_sets();
|
||||
SDL_Joystick* getJoyHandle() const;
|
||||
QHash<int, SetJoystick *> &getJoystick_sets();
|
||||
SDL_Joystick *getJoyHandle() const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void enableSetConnections(SetJoystick *setstick);
|
||||
|
||||
QHash<int, JoyAxis::ThrottleTypes>& getCali();
|
||||
SDL_JoystickID* getJoystickID();
|
||||
QHash<int, JoyAxis::ThrottleTypes> &getCali();
|
||||
SDL_JoystickID *getJoystickID();
|
||||
|
||||
int rawAxisDeadZone;
|
||||
int keyPressTime; // unsigned
|
||||
QString profileName;
|
||||
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void setChangeActivated(int index);
|
||||
void setAxisThrottleActivated(int index); // InputDeviceAxis class
|
||||
void clicked(int index);
|
||||
@@ -170,17 +167,21 @@ signals:
|
||||
void requestProfileLoad(QString location);
|
||||
void requestWait();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void reset();
|
||||
void transferReset();
|
||||
void reInitButtons();
|
||||
void resetButtonDownCount();
|
||||
void setActiveSetNumber(int index);
|
||||
void changeSetButtonAssociation(int button_index, int originset, int newset, int mode); // InputDeviceButton class
|
||||
void changeSetAxisButtonAssociation(int button_index, int axis_index, int originset, int newset, int mode); // InputDeviceAxisBtn class
|
||||
void changeSetStickButtonAssociation(int button_index, int stick_index, int originset, int newset, int mode); // InputDeviceStick class
|
||||
void changeSetDPadButtonAssociation(int button_index, int dpad_index, int originset, int newset, int mode); // InputDeviceHat class
|
||||
void changeSetVDPadButtonAssociation(int button_index, int dpad_index, int originset, int newset, int mode); // InputDeviceVDPad class
|
||||
void changeSetAxisButtonAssociation(int button_index, int axis_index, int originset, int newset,
|
||||
int mode); // InputDeviceAxisBtn class
|
||||
void changeSetStickButtonAssociation(int button_index, int stick_index, int originset, int newset,
|
||||
int mode); // InputDeviceStick class
|
||||
void changeSetDPadButtonAssociation(int button_index, int dpad_index, int originset, int newset,
|
||||
int mode); // InputDeviceHat class
|
||||
void changeSetVDPadButtonAssociation(int button_index, int dpad_index, int originset, int newset,
|
||||
int mode); // InputDeviceVDPad class
|
||||
void setDeviceKeyPressTime(int newPressTime); // .., unsigned
|
||||
void profileEdited();
|
||||
void setProfileName(QString value);
|
||||
@@ -195,7 +196,7 @@ public slots:
|
||||
void establishPropertyUpdatedConnection();
|
||||
void disconnectPropertyUpdatedConnection();
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
void propogateSetChange(int index);
|
||||
void propogateSetAxisThrottleChange(int index, int originset);
|
||||
void buttonDownEvent(int setindex, int buttonindex); // InputDeviceButton class
|
||||
@@ -220,13 +221,13 @@ protected slots:
|
||||
void updateSetDPadNames(int dpadIndex); // InputDeviceHat class
|
||||
void updateSetVDPadNames(int vdpadIndex); // InputDeviceVDPad class
|
||||
|
||||
private:
|
||||
QList<bool>& getButtonstatesLocal();
|
||||
QList<int>& getAxesstatesLocal();
|
||||
QList<int>& getDpadstatesLocal();
|
||||
private:
|
||||
QList<bool> &getButtonstatesLocal();
|
||||
QList<int> &getAxesstatesLocal();
|
||||
QList<int> &getDpadstatesLocal();
|
||||
|
||||
SDL_Joystick* m_joyhandle;
|
||||
QHash<int, SetJoystick*> joystick_sets;
|
||||
SDL_Joystick *m_joyhandle;
|
||||
QHash<int, SetJoystick *> joystick_sets;
|
||||
QHash<int, JoyAxis::ThrottleTypes> cali;
|
||||
AntiMicroSettings *m_settings;
|
||||
int active_set;
|
||||
@@ -244,7 +245,7 @@ private:
|
||||
QList<int> dpadstates;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(InputDevice*)
|
||||
Q_DECLARE_METATYPE(InputDevice *)
|
||||
Q_DECLARE_METATYPE(SDL_JoystickID)
|
||||
|
||||
#endif // INPUTDEVICE_H
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
|
||||
#include "inputdevicebitarraystatus.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "inputdevice.h"
|
||||
#include "setjoystick.h"
|
||||
#include "joystick.h"
|
||||
#include "joydpad.h"
|
||||
#include "joybutton.h"
|
||||
#include "joydpad.h"
|
||||
#include "joystick.h"
|
||||
#include "messagehandler.h"
|
||||
#include "setjoystick.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
InputDeviceBitArrayStatus::InputDeviceBitArrayStatus(InputDevice *device, bool readCurrent, QObject *parent) :
|
||||
QObject(parent)
|
||||
InputDeviceBitArrayStatus::InputDeviceBitArrayStatus(InputDevice *device, bool readCurrent, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -40,8 +40,7 @@ InputDeviceBitArrayStatus::InputDeviceBitArrayStatus(InputDevice *device, bool r
|
||||
if ((axis != nullptr) && readCurrent)
|
||||
{
|
||||
axesStatus.append(!axis->inDeadZone(axis->getCurrentRawValue()) ? true : false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
axesStatus.append(false);
|
||||
}
|
||||
@@ -55,8 +54,7 @@ InputDeviceBitArrayStatus::InputDeviceBitArrayStatus(InputDevice *device, bool r
|
||||
if ((dpad != nullptr) && readCurrent)
|
||||
{
|
||||
hatButtonStatus.append(dpad->getCurrentDirection() != JoyDPadButton::DpadCentered ? true : false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
hatButtonStatus.append(false);
|
||||
}
|
||||
@@ -150,7 +148,4 @@ void InputDeviceBitArrayStatus::clearStatusValues()
|
||||
getButtonStatusLocal().fill(false);
|
||||
}
|
||||
|
||||
QBitArray& InputDeviceBitArrayStatus::getButtonStatusLocal() {
|
||||
|
||||
return buttonStatus;
|
||||
}
|
||||
QBitArray &InputDeviceBitArrayStatus::getButtonStatusLocal() { return buttonStatus; }
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INPUTDEVICESTATUSEVENT_H
|
||||
#define INPUTDEVICESTATUSEVENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QBitArray>
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
class InputDevice;
|
||||
|
||||
@@ -31,7 +29,7 @@ class InputDeviceBitArrayStatus : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit InputDeviceBitArrayStatus(InputDevice *device, bool readCurrent = true, QObject *parent = nullptr);
|
||||
|
||||
void changeAxesStatus(int axisIndex, bool value);
|
||||
@@ -41,13 +39,12 @@ public:
|
||||
QBitArray generateFinalBitArray();
|
||||
void clearStatusValues();
|
||||
|
||||
private:
|
||||
QBitArray& getButtonStatusLocal();
|
||||
private:
|
||||
QBitArray &getButtonStatusLocal();
|
||||
|
||||
QList<bool> axesStatus;
|
||||
QList<bool> hatButtonStatus;
|
||||
QBitArray buttonStatus;
|
||||
|
||||
};
|
||||
|
||||
#endif // INPUTDEVICESTATUSEVENT_H
|
||||
|
||||
182
src/joyaxis.cpp
182
src/joyaxis.cpp
@@ -18,26 +18,25 @@
|
||||
|
||||
#include "joyaxis.h"
|
||||
|
||||
#include "event.h"
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "setjoystick.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joyaxis.h"
|
||||
#include "event.h"
|
||||
#include "joycontrolstick.h"
|
||||
#include "messagehandler.h"
|
||||
#include "setjoystick.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
const JoyAxis::ThrottleTypes JoyAxis::DEFAULTTHROTTLE = JoyAxis::NormalThrottle;
|
||||
|
||||
JoyAxis::JoyAxis(int index, int originset, SetJoystick *parentSet,
|
||||
QObject *parent) :
|
||||
QObject(parent)
|
||||
JoyAxis::JoyAxis(int index, int originset, SetJoystick *parentSet, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -75,8 +74,7 @@ void JoyAxis::queuePendingEvent(int value, bool ignoresets, bool updateLastValue
|
||||
if (m_stick != nullptr)
|
||||
{
|
||||
stickPassEvent(value, ignoresets, updateLastValues);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
pendingEvent = true;
|
||||
pendingValue = value;
|
||||
@@ -135,15 +133,16 @@ void JoyAxis::stickPassEvent(int value, bool ignoresets, bool updateLastValues)
|
||||
{
|
||||
isActive = eventActive = true;
|
||||
emit active(value);
|
||||
}
|
||||
else if (!safezone && isActive)
|
||||
} else if (!safezone && isActive)
|
||||
{
|
||||
isActive = eventActive = false;
|
||||
emit released(value);
|
||||
}
|
||||
|
||||
if (!ignoresets) m_stick->queueJoyEvent(ignoresets);
|
||||
else m_stick->joyEvent(ignoresets);
|
||||
if (!ignoresets)
|
||||
m_stick->queueJoyEvent(ignoresets);
|
||||
else
|
||||
m_stick->joyEvent(ignoresets);
|
||||
|
||||
emit moved(currentRawValue);
|
||||
}
|
||||
@@ -156,8 +155,7 @@ void JoyAxis::joyEvent(int value, bool ignoresets, bool updateLastValues)
|
||||
if ((m_stick != nullptr) && !pendingEvent)
|
||||
{
|
||||
stickPassEvent(value, ignoresets, updateLastValues);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (updateLastValues)
|
||||
{
|
||||
@@ -187,14 +185,12 @@ void JoyAxis::joyEvent(int value, bool ignoresets, bool updateLastValues)
|
||||
isActive = eventActive = true;
|
||||
emit active(value);
|
||||
createDeskEvent(ignoresets);
|
||||
}
|
||||
else if (!safezone && isActive)
|
||||
} else if (!safezone && isActive)
|
||||
{
|
||||
isActive = eventActive = false;
|
||||
emit released(value);
|
||||
createDeskEvent(ignoresets);
|
||||
}
|
||||
else if (isActive)
|
||||
} else if (isActive)
|
||||
{
|
||||
createDeskEvent(ignoresets);
|
||||
}
|
||||
@@ -216,7 +212,8 @@ bool JoyAxis::inDeadZone(int value)
|
||||
|
||||
result = true;
|
||||
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
|
||||
qDebug() << "Value of throttle is not in (greater than) dead zone: " << abs(temp) << " > " << deadZone;
|
||||
}
|
||||
@@ -238,8 +235,7 @@ QString JoyAxis::getName(bool forceFullFormat, bool displayNames)
|
||||
if (!naxisbutton->getActionName().isEmpty() && displayNames)
|
||||
{
|
||||
label.append(naxisbutton->getActionName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(naxisbutton->getCalculatedActiveZoneSummary());
|
||||
}
|
||||
@@ -249,34 +245,29 @@ QString JoyAxis::getName(bool forceFullFormat, bool displayNames)
|
||||
if (!paxisbutton->getActionName().isEmpty() && displayNames)
|
||||
{
|
||||
label.append(paxisbutton->getActionName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(paxisbutton->getCalculatedActiveZoneSummary());
|
||||
}
|
||||
}
|
||||
else if ((throttle == static_cast<int>(PositiveThrottle)) || (throttle == static_cast<int>(PositiveHalfThrottle)))
|
||||
} else if ((throttle == static_cast<int>(PositiveThrottle)) || (throttle == static_cast<int>(PositiveHalfThrottle)))
|
||||
{
|
||||
label.append("+");
|
||||
|
||||
if (!paxisbutton->getActionName().isEmpty() && displayNames)
|
||||
{
|
||||
label.append(paxisbutton->getActionName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(paxisbutton->getCalculatedActiveZoneSummary());
|
||||
}
|
||||
}
|
||||
else if ((throttle == static_cast<int>(NegativeThrottle)) || (throttle == static_cast<int>(NegativeHalfThrottle)))
|
||||
} else if ((throttle == static_cast<int>(NegativeThrottle)) || (throttle == static_cast<int>(NegativeHalfThrottle)))
|
||||
{
|
||||
label.append("-");
|
||||
|
||||
if (!naxisbutton->getActionName().isEmpty() && displayNames)
|
||||
{
|
||||
label.append(naxisbutton->getActionName());
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(naxisbutton->getCalculatedActiveZoneSummary());
|
||||
}
|
||||
@@ -299,10 +290,7 @@ int JoyAxis::getCurrentThrottledValue()
|
||||
return currentThrottledValue;
|
||||
}
|
||||
|
||||
void JoyAxis::updateCurrentThrottledValue(int newValue)
|
||||
{
|
||||
currentThrottledValue = newValue;
|
||||
}
|
||||
void JoyAxis::updateCurrentThrottledValue(int newValue) { currentThrottledValue = newValue; }
|
||||
|
||||
int JoyAxis::calculateThrottledValue(int value)
|
||||
{
|
||||
@@ -312,7 +300,7 @@ int JoyAxis::calculateThrottledValue(int value)
|
||||
|
||||
int temp = value;
|
||||
|
||||
switch(throttle)
|
||||
switch (throttle)
|
||||
{
|
||||
|
||||
case -2:
|
||||
@@ -340,10 +328,8 @@ int JoyAxis::calculateThrottledValue(int value)
|
||||
value = (value >= 0) ? value : -value;
|
||||
temp = value;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Calculated value of throttle is: " << temp;
|
||||
|
||||
return temp;
|
||||
@@ -363,15 +349,16 @@ int JoyAxis::getIndex()
|
||||
return m_index;
|
||||
}
|
||||
|
||||
|
||||
void JoyAxis::createDeskEvent(bool ignoresets)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyAxisButton *eventbutton = nullptr;
|
||||
|
||||
if (currentThrottledValue > deadZone) eventbutton = paxisbutton;
|
||||
else if (currentThrottledValue < -deadZone) eventbutton = naxisbutton;
|
||||
if (currentThrottledValue > deadZone)
|
||||
eventbutton = paxisbutton;
|
||||
else if (currentThrottledValue < -deadZone)
|
||||
eventbutton = naxisbutton;
|
||||
|
||||
if ((eventbutton != nullptr) && !activeButton)
|
||||
{
|
||||
@@ -379,19 +366,16 @@ void JoyAxis::createDeskEvent(bool ignoresets)
|
||||
// button as active button
|
||||
eventbutton->joyEvent(eventActive, ignoresets);
|
||||
activeButton = eventbutton;
|
||||
}
|
||||
else if ((eventbutton == nullptr) && (activeButton != nullptr))
|
||||
} else if ((eventbutton == nullptr) && (activeButton != nullptr))
|
||||
{
|
||||
// Currently in deadzone. Disable currently active button.
|
||||
activeButton->joyEvent(eventActive, ignoresets);
|
||||
activeButton = nullptr;
|
||||
}
|
||||
else if ((eventbutton != nullptr) && (activeButton != nullptr) && (eventbutton == activeButton))
|
||||
} else if ((eventbutton != nullptr) && (activeButton != nullptr) && (eventbutton == activeButton))
|
||||
{
|
||||
//Button is currently active. Just pass current value
|
||||
// Button is currently active. Just pass current value
|
||||
eventbutton->joyEvent(eventActive, ignoresets);
|
||||
}
|
||||
else if ((eventbutton != nullptr) && (activeButton != nullptr) && (eventbutton != activeButton))
|
||||
} else if ((eventbutton != nullptr) && (activeButton != nullptr) && (eventbutton != activeButton))
|
||||
{
|
||||
// Deadzone skipped. Button for new event is not the currently
|
||||
// active button. Disable the active button before enabling
|
||||
@@ -423,12 +407,11 @@ void JoyAxis::setMaxZoneValue(int value)
|
||||
|
||||
value = abs(value);
|
||||
|
||||
if (value >=getAxisMaxCal())
|
||||
if (value >= getAxisMaxCal())
|
||||
{
|
||||
maxZoneValue = getAxisMaxCal();
|
||||
emit propertyUpdated();
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
maxZoneValue = value;
|
||||
emit propertyUpdated();
|
||||
@@ -452,7 +435,8 @@ void JoyAxis::setThrottle(int value)
|
||||
|
||||
qDebug() << "Value of throttle for axis in setThrottle is: " << value;
|
||||
|
||||
if ((value >= static_cast<int>(JoyAxis::NegativeHalfThrottle)) && (value <= static_cast<int>(JoyAxis::PositiveHalfThrottle)))
|
||||
if ((value >= static_cast<int>(JoyAxis::NegativeHalfThrottle)) &&
|
||||
(value <= static_cast<int>(JoyAxis::PositiveHalfThrottle)))
|
||||
{
|
||||
if (value != throttle)
|
||||
{
|
||||
@@ -475,8 +459,8 @@ void JoyAxis::setInitialThrottle(int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if ((value >= static_cast<int>(JoyAxis::NegativeHalfThrottle)) && (value <= static_cast<int>(JoyAxis::PositiveHalfThrottle))
|
||||
&& (value != throttle))
|
||||
if ((value >= static_cast<int>(JoyAxis::NegativeHalfThrottle)) &&
|
||||
(value <= static_cast<int>(JoyAxis::PositiveHalfThrottle)) && (value != throttle))
|
||||
{
|
||||
throttle = value;
|
||||
adjustRange();
|
||||
@@ -530,14 +514,14 @@ void JoyAxis::reset(int index)
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
JoyAxisButton* JoyAxis::getPAxisButton()
|
||||
JoyAxisButton *JoyAxis::getPAxisButton()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
return paxisbutton;
|
||||
}
|
||||
|
||||
JoyAxisButton* JoyAxis::getNAxisButton()
|
||||
JoyAxisButton *JoyAxis::getNAxisButton()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -558,14 +542,12 @@ void JoyAxis::adjustRange()
|
||||
if (throttle == static_cast<int>(JoyAxis::NegativeThrottle))
|
||||
{
|
||||
currentThrottledDeadValue = getAxisMaxCal();
|
||||
}
|
||||
else if ((throttle == static_cast<int>(JoyAxis::NormalThrottle)) ||
|
||||
} else if ((throttle == static_cast<int>(JoyAxis::NormalThrottle)) ||
|
||||
(throttle == static_cast<int>(JoyAxis::PositiveHalfThrottle)) ||
|
||||
(throttle == static_cast<int>(JoyAxis::NegativeHalfThrottle)))
|
||||
{
|
||||
currentThrottledDeadValue = 0;
|
||||
}
|
||||
else if (throttle == static_cast<int>(JoyAxis::PositiveThrottle))
|
||||
} else if (throttle == static_cast<int>(JoyAxis::PositiveThrottle))
|
||||
{
|
||||
currentThrottledDeadValue = getAxisMinCal();
|
||||
}
|
||||
@@ -595,11 +577,10 @@ double JoyAxis::getDistanceFromDeadZone(int value)
|
||||
|
||||
if (value >= deadZone)
|
||||
{
|
||||
distance = static_cast<double>(value - deadZone)/(maxZoneValue - deadZone);
|
||||
}
|
||||
else if (value <= -deadZone)
|
||||
distance = static_cast<double>(value - deadZone) / (maxZoneValue - deadZone);
|
||||
} else if (value <= -deadZone)
|
||||
{
|
||||
distance = static_cast<double>(value + deadZone)/( (-maxZoneValue) + deadZone);
|
||||
distance = static_cast<double>(value + deadZone) / ((-maxZoneValue) + deadZone);
|
||||
}
|
||||
|
||||
return qBound(0.0, distance, 1.0);
|
||||
@@ -649,7 +630,7 @@ bool JoyAxis::isPartControlStick()
|
||||
return (m_stick != nullptr);
|
||||
}
|
||||
|
||||
JoyControlStick* JoyAxis::getControlStick()
|
||||
JoyControlStick *JoyAxis::getControlStick()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -666,11 +647,10 @@ void JoyAxis::removeControlStick(bool performRelease)
|
||||
m_stick->releaseButtonEvents();
|
||||
|
||||
m_stick = nullptr;
|
||||
//emit propertyUpdated();
|
||||
// emit propertyUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool JoyAxis::hasControlOfButtons()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -729,14 +709,12 @@ void JoyAxis::setCurrentRawValue(int value)
|
||||
qDebug() << "Raw value is less than " << getAxisMaxCal() << " and greather than " << getAxisMinCal();
|
||||
|
||||
currentRawValue = value;
|
||||
}
|
||||
else if (value > getAxisMaxCal())
|
||||
} else if (value > getAxisMaxCal())
|
||||
{
|
||||
qDebug() << "Raw value is greather than " << getAxisMaxCal();
|
||||
|
||||
currentRawValue = getAxisMaxCal();
|
||||
}
|
||||
else if (value < getAxisMinCal())
|
||||
} else if (value < getAxisMinCal())
|
||||
{
|
||||
qDebug() << "Raw value is less than " << getAxisMinCal();
|
||||
|
||||
@@ -874,7 +852,7 @@ double JoyAxis::getButtonsPresetSensitivity()
|
||||
return presetSensitivity;
|
||||
}
|
||||
|
||||
JoyAxisButton* JoyAxis::getAxisButtonByValue(int value)
|
||||
JoyAxisButton *JoyAxis::getAxisButtonByValue(int value)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -888,8 +866,7 @@ JoyAxisButton* JoyAxis::getAxisButtonByValue(int value)
|
||||
qDebug() << "throtted value is positive";
|
||||
|
||||
eventbutton = paxisbutton;
|
||||
}
|
||||
else if (throttledValue < (-deadZone))
|
||||
} else if (throttledValue < (-deadZone))
|
||||
{
|
||||
qDebug() << "throtted value is negative";
|
||||
|
||||
@@ -962,8 +939,7 @@ QString JoyAxis::getPartialName(bool forceFullFormat, bool displayNames)
|
||||
}
|
||||
|
||||
label.append(axisName);
|
||||
}
|
||||
else if (!defaultAxisName.isEmpty())
|
||||
} else if (!defaultAxisName.isEmpty())
|
||||
{
|
||||
if (forceFullFormat)
|
||||
{
|
||||
@@ -971,8 +947,7 @@ QString JoyAxis::getPartialName(bool forceFullFormat, bool displayNames)
|
||||
}
|
||||
|
||||
label.append(defaultAxisName);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
label.append(tr("Axis")).append(" ");
|
||||
label.append(QString::number(getRealJoyIndex()));
|
||||
@@ -1009,7 +984,7 @@ JoyAxis::ThrottleTypes JoyAxis::getDefaultThrottle()
|
||||
return this->DEFAULTTHROTTLE;
|
||||
}
|
||||
|
||||
SetJoystick* JoyAxis::getParentSet()
|
||||
SetJoystick *JoyAxis::getParentSet()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -1060,12 +1035,10 @@ void JoyAxis::performCalibration(int value)
|
||||
{
|
||||
// Assume axis is a trigger. Set default throttle to Positive.
|
||||
device->setCalibrationThrottle(m_index, PositiveThrottle);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
// Ensure that default throttle is used when a device is reset.
|
||||
device->setCalibrationThrottle(m_index,
|
||||
static_cast<JoyAxis::ThrottleTypes>(throttle));
|
||||
device->setCalibrationThrottle(m_index, static_cast<JoyAxis::ThrottleTypes>(throttle));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1135,16 +1108,13 @@ int JoyAxis::getProperReleaseValue()
|
||||
if (throttle == static_cast<int>(NegativeHalfThrottle))
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
else if (throttle == static_cast<int>(NegativeThrottle))
|
||||
} else if (throttle == static_cast<int>(NegativeThrottle))
|
||||
{
|
||||
value = getAxisMaxCal();
|
||||
}
|
||||
else if (throttle == static_cast<int>(PositiveThrottle))
|
||||
} else if (throttle == static_cast<int>(PositiveThrottle))
|
||||
{
|
||||
value = getAxisMinCal();
|
||||
}
|
||||
else if (throttle == static_cast<int>(PositiveHalfThrottle))
|
||||
} else if (throttle == static_cast<int>(PositiveHalfThrottle))
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
@@ -1198,32 +1168,14 @@ void JoyAxis::eventReset()
|
||||
paxisbutton->eventReset();
|
||||
}
|
||||
|
||||
void JoyAxis::setAxisMinCal(int value) {
|
||||
void JoyAxis::setAxisMinCal(int value) { axis_min_cal = value; }
|
||||
|
||||
axis_min_cal = value;
|
||||
}
|
||||
int JoyAxis::getAxisMinCal() { return ((axis_min_cal != -1) ? axis_min_cal : GlobalVariables::JoyAxis::AXISMIN); }
|
||||
|
||||
int JoyAxis::getAxisMinCal() {
|
||||
void JoyAxis::setAxisMaxCal(int value) { axis_max_cal = value; }
|
||||
|
||||
return ((axis_min_cal != -1) ? axis_min_cal : GlobalVariables::JoyAxis::AXISMIN);
|
||||
}
|
||||
int JoyAxis::getAxisMaxCal() { return ((axis_max_cal != -1) ? axis_max_cal : GlobalVariables::JoyAxis::AXISMAX); }
|
||||
|
||||
void JoyAxis::setAxisMaxCal(int value) {
|
||||
void JoyAxis::setAxisCenterCal(int value) { axis_center_cal = value; }
|
||||
|
||||
axis_max_cal = value;
|
||||
}
|
||||
|
||||
int JoyAxis::getAxisMaxCal() {
|
||||
|
||||
return ((axis_max_cal != -1) ? axis_max_cal : GlobalVariables::JoyAxis::AXISMAX);
|
||||
}
|
||||
|
||||
void JoyAxis::setAxisCenterCal(int value) {
|
||||
|
||||
axis_center_cal = value;
|
||||
}
|
||||
|
||||
int JoyAxis::getAxisCenterCal() {
|
||||
|
||||
return((axis_center_cal != -1) ? axis_center_cal : 0);
|
||||
}
|
||||
int JoyAxis::getAxisCenterCal() { return ((axis_center_cal != -1) ? axis_center_cal : 0); }
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JOYAXIS_H
|
||||
#define JOYAXIS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
#include "joybuttontypes/joyaxisbutton.h"
|
||||
|
||||
@@ -32,16 +31,16 @@ class QXmlStreamReader;
|
||||
class QXmlStreamWriter;
|
||||
class JoyAxis;
|
||||
|
||||
|
||||
class JoyAxis : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JoyAxis(int index, int originset, SetJoystick *parentSet, QObject *parent=0);
|
||||
public:
|
||||
explicit JoyAxis(int index, int originset, SetJoystick *parentSet, QObject *parent = 0);
|
||||
~JoyAxis();
|
||||
|
||||
enum ThrottleTypes {
|
||||
enum ThrottleTypes
|
||||
{
|
||||
NegativeHalfThrottle = -2,
|
||||
NegativeThrottle = -1,
|
||||
NormalThrottle = 0,
|
||||
@@ -49,15 +48,15 @@ public:
|
||||
PositiveHalfThrottle = 2
|
||||
};
|
||||
|
||||
void joyEvent(int value, bool ignoresets=false, bool updateLastValues=true); // JoyAxisEvent class
|
||||
void queuePendingEvent(int value, bool ignoresets=false, bool updateLastValues=true); // JoyAxisEvent class
|
||||
void joyEvent(int value, bool ignoresets = false, bool updateLastValues = true); // JoyAxisEvent class
|
||||
void queuePendingEvent(int value, bool ignoresets = false, bool updateLastValues = true); // JoyAxisEvent class
|
||||
void activatePendingEvent(); // JoyAxisEvent class
|
||||
bool hasPendingEvent(); // JoyAxisEvent class
|
||||
void clearPendingEvent(); // JoyAxisEvent class
|
||||
bool inDeadZone(int value);
|
||||
|
||||
virtual QString getName(bool forceFullFormat=false, bool displayNames=false);
|
||||
virtual QString getPartialName(bool forceFullFormat=false, bool displayNames=false);
|
||||
virtual QString getName(bool forceFullFormat = false, bool displayNames = false);
|
||||
virtual QString getPartialName(bool forceFullFormat = false, bool displayNames = false);
|
||||
virtual QString getXmlName(); // JoyAxisXml class
|
||||
|
||||
void setIndex(int index);
|
||||
@@ -78,7 +77,7 @@ public:
|
||||
int getCurrentRawValue();
|
||||
int getCurrentThrottledDeadValue();
|
||||
int getCurrentlyAssignedSet();
|
||||
JoyAxisButton* getAxisButtonByValue(int value);
|
||||
JoyAxisButton *getAxisButtonByValue(int value);
|
||||
|
||||
double getDistanceFromDeadZone();
|
||||
double getDistanceFromDeadZone(int value);
|
||||
@@ -87,7 +86,7 @@ public:
|
||||
void setControlStick(JoyControlStick *stick);
|
||||
void removeControlStick(bool performRelease = true);
|
||||
bool isPartControlStick();
|
||||
JoyControlStick* getControlStick();
|
||||
JoyControlStick *getControlStick();
|
||||
bool hasControlOfButtons();
|
||||
void removeVDPads();
|
||||
|
||||
@@ -130,7 +129,7 @@ public:
|
||||
virtual void setDefaultAxisName(QString tempname);
|
||||
virtual QString getDefaultAxisName();
|
||||
|
||||
SetJoystick* getParentSet();
|
||||
SetJoystick *getParentSet();
|
||||
|
||||
virtual bool isDefault();
|
||||
|
||||
@@ -154,12 +153,12 @@ public:
|
||||
static const ThrottleTypes DEFAULTTHROTTLE;
|
||||
int calculateThrottledValue(int value);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void createDeskEvent(bool ignoresets = false); // JoyAxisEvent class
|
||||
void adjustRange();
|
||||
|
||||
void performCalibration(int value);
|
||||
void stickPassEvent(int value, bool ignoresets=false, bool updateLastValues=true); // JoyAxisEvent class
|
||||
void stickPassEvent(int value, bool ignoresets = false, bool updateLastValues = true); // JoyAxisEvent class
|
||||
|
||||
JoyAxisButton *paxisbutton;
|
||||
JoyAxisButton *naxisbutton;
|
||||
@@ -189,9 +188,9 @@ protected:
|
||||
JoyAxisButton *activeButton;
|
||||
|
||||
// TODO: CHECK IF PROPERTY IS NEEDED.
|
||||
//bool pendingUpdateLastValues;
|
||||
// bool pendingUpdateLastValues;
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void active(int value);
|
||||
void released(int value);
|
||||
void moved(int value);
|
||||
@@ -200,7 +199,7 @@ signals:
|
||||
void axisNameChanged();
|
||||
void propertyUpdated();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
virtual void reset();
|
||||
virtual void reset(int index);
|
||||
void propogateThrottleChange();
|
||||
@@ -214,15 +213,13 @@ public slots:
|
||||
void establishPropertyUpdatedConnection();
|
||||
void disconnectPropertyUpdatedConnection();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
int m_originset;
|
||||
|
||||
JoyControlStick *m_stick;
|
||||
|
||||
SetJoystick *m_parentSet;
|
||||
|
||||
|
||||
void resetPrivateVars();
|
||||
};
|
||||
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
|
||||
#include "joyaxiscontextmenu.h"
|
||||
|
||||
#include "antkeymapper.h"
|
||||
#include "common.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joyaxis.h"
|
||||
#include "messagehandler.h"
|
||||
#include "mousedialog/mouseaxissettingsdialog.h"
|
||||
#include "antkeymapper.h"
|
||||
#include "inputdevice.h"
|
||||
#include "common.h"
|
||||
#include "joyaxis.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
JoyAxisContextMenu::JoyAxisContextMenu(JoyAxis *axis, QWidget *parent) :
|
||||
QMenu(parent),
|
||||
helper(axis)
|
||||
JoyAxisContextMenu::JoyAxisContextMenu(JoyAxis *axis, QWidget *parent)
|
||||
: QMenu(parent)
|
||||
, helper(axis)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -56,8 +56,10 @@ void JoyAxisContextMenu::buildMenu()
|
||||
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
|
||||
if (actAsTrigger)buildTriggerMenu();
|
||||
else buildAxisMenu();
|
||||
if (actAsTrigger)
|
||||
buildTriggerMenu();
|
||||
else
|
||||
buildAxisMenu();
|
||||
}
|
||||
|
||||
void JoyAxisContextMenu::buildAxisMenu()
|
||||
@@ -70,131 +72,109 @@ void JoyAxisContextMenu::buildAxisMenu()
|
||||
|
||||
QAction *action = this->addAction(tr("Mouse (Horizontal)"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Mouse (Inverted Horizontal)"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Mouse (Vertical)"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Mouse (Inverted Vertical)"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Arrows: Up | Down"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Arrows: Left | Right"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Keys: W | S"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Keys: A | D"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("NumPad: KP_8 | KP_2"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
|
||||
presetMode++;
|
||||
action = this->addAction(tr("NumPad: KP_4 | KP_6"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("None"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setAxisPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setAxisPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
|
||||
@@ -212,67 +192,76 @@ int JoyAxisContextMenu::getPresetIndex()
|
||||
int result = 0;
|
||||
|
||||
JoyAxisButton *naxisbutton = axis->getNAxisButton();
|
||||
QList<JoyButtonSlot*> *naxisslots = naxisbutton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *naxisslots = naxisbutton->getAssignedSlots();
|
||||
JoyAxisButton *paxisbutton = axis->getPAxisButton();
|
||||
QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
|
||||
if ((naxisslots->length() == 1) && (paxisslots->length() == 1))
|
||||
{
|
||||
JoyButtonSlot *nslot = naxisslots->at(0);
|
||||
JoyButtonSlot *pslot = paxisslots->at(0);
|
||||
|
||||
if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseLeft) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseRight))
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseRight) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseLeft))
|
||||
{
|
||||
result = 2;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseDown))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseUp) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseDown))
|
||||
{
|
||||
result = 3;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (nslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) && (pslot->getSlotCode() == JoyButtonSlot::MouseUp))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(nslot->getSlotCode() == JoyButtonSlot::MouseDown) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyMouseMovement) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseUp))
|
||||
{
|
||||
result = 4;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down)))
|
||||
{
|
||||
result = 5;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right)))
|
||||
{
|
||||
result = 6;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S)))
|
||||
{
|
||||
result = 7;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D)))
|
||||
{
|
||||
result = 8;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2)))
|
||||
{
|
||||
result = 9;
|
||||
}
|
||||
else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) && (pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
} else if ((nslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(nslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4)) &&
|
||||
(pslot->getSlotMode() == JoyButtonSlot::JoyKeyboard) &&
|
||||
(pslot->getSlotCode() == AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6)))
|
||||
{
|
||||
result = 10;
|
||||
}
|
||||
}
|
||||
else if ((naxisslots->length() == 0) && (paxisslots->length() == 0))
|
||||
} else if ((naxisslots->length() == 0) && (paxisslots->length() == 0))
|
||||
{
|
||||
result = 11;
|
||||
}
|
||||
@@ -282,7 +271,7 @@ int JoyAxisContextMenu::getPresetIndex()
|
||||
return result;
|
||||
}
|
||||
|
||||
void JoyAxisContextMenu::setAxisPreset(QAction* action)
|
||||
void JoyAxisContextMenu::setAxisPreset(QAction *action)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -291,7 +280,7 @@ void JoyAxisContextMenu::setAxisPreset(QAction* action)
|
||||
JoyButtonSlot *nbuttonslot = nullptr;
|
||||
JoyButtonSlot *pbuttonslot = nullptr;
|
||||
|
||||
switch(item)
|
||||
switch (item)
|
||||
{
|
||||
case 0:
|
||||
nbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLeft, JoyButtonSlot::JoyMouseMovement, this);
|
||||
@@ -314,33 +303,45 @@ void JoyAxisContextMenu::setAxisPreset(QAction* action)
|
||||
break;
|
||||
|
||||
case 4:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Up), Qt::Key_Up,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Down), Qt::Key_Down,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Left), Qt::Key_Left,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_Right), Qt::Key_Right,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_W), Qt::Key_W,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_S), Qt::Key_S,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_A), Qt::Key_A,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(Qt::Key_D), Qt::Key_D,
|
||||
JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8), QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2), QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_8),
|
||||
QtKeyMapperBase::AntKey_KP_8, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_2),
|
||||
QtKeyMapperBase::AntKey_KP_2, JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4), QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6), QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
nbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_4),
|
||||
QtKeyMapperBase::AntKey_KP_4, JoyButtonSlot::JoyKeyboard, this);
|
||||
pbuttonslot = new JoyButtonSlot(AntKeyMapper::getInstance()->returnVirtualKey(QtKeyMapperBase::AntKey_KP_6),
|
||||
QtKeyMapperBase::AntKey_KP_6, JoyButtonSlot::JoyKeyboard, this);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
@@ -351,8 +352,7 @@ void JoyAxisContextMenu::setAxisPreset(QAction* action)
|
||||
if (nbuttonslot != nullptr)
|
||||
{
|
||||
QMetaObject::invokeMethod(&helper, "setNAssignedSlot", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, nbuttonslot->getSlotCode()),
|
||||
Q_ARG(int, nbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(int, nbuttonslot->getSlotCode()), Q_ARG(int, nbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode()));
|
||||
|
||||
nbuttonslot->deleteLater();
|
||||
@@ -361,8 +361,7 @@ void JoyAxisContextMenu::setAxisPreset(QAction* action)
|
||||
if (pbuttonslot != nullptr)
|
||||
{
|
||||
QMetaObject::invokeMethod(&helper, "setPAssignedSlot", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, nbuttonslot->getSlotCode()),
|
||||
Q_ARG(int, nbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(int, nbuttonslot->getSlotCode()), Q_ARG(int, nbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, nbuttonslot->getSlotMode()));
|
||||
|
||||
pbuttonslot->deleteLater();
|
||||
@@ -387,36 +386,30 @@ void JoyAxisContextMenu::buildTriggerMenu()
|
||||
|
||||
QAction *action = this->addAction(tr("Left Mouse Button"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setTriggerPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setTriggerPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("Right Mouse Button"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setTriggerPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setTriggerPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
presetMode++;
|
||||
|
||||
action = this->addAction(tr("None"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(currentPreset == presetMode+1);
|
||||
action->setChecked(currentPreset == presetMode + 1);
|
||||
action->setData(QVariant(presetMode));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
setTriggerPreset(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { setTriggerPreset(action); });
|
||||
|
||||
presetGroup->addAction(action);
|
||||
|
||||
@@ -436,24 +429,21 @@ int JoyAxisContextMenu::getTriggerPresetIndex()
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
JoyAxisButton *paxisbutton = axis->getPAxisButton();
|
||||
QList<JoyButtonSlot*> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
QList<JoyButtonSlot *> *paxisslots = paxisbutton->getAssignedSlots();
|
||||
|
||||
if (paxisslots->length() == 1)
|
||||
{
|
||||
JoyButtonSlot *pslot = paxisslots->at(0);
|
||||
|
||||
if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseLB))
|
||||
if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) && (pslot->getSlotCode() == JoyButtonSlot::MouseLB))
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
else if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) &&
|
||||
} else if ((pslot->getSlotMode() == JoyButtonSlot::JoyMouseButton) &&
|
||||
(pslot->getSlotCode() == JoyButtonSlot::MouseRB))
|
||||
{
|
||||
result = 2;
|
||||
}
|
||||
}
|
||||
else if (paxisslots->length() == 0)
|
||||
} else if (paxisslots->length() == 0)
|
||||
{
|
||||
result = 3;
|
||||
}
|
||||
@@ -463,7 +453,7 @@ int JoyAxisContextMenu::getTriggerPresetIndex()
|
||||
return result;
|
||||
}
|
||||
|
||||
void JoyAxisContextMenu::setTriggerPreset(QAction* action)
|
||||
void JoyAxisContextMenu::setTriggerPreset(QAction *action)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -471,7 +461,7 @@ void JoyAxisContextMenu::setTriggerPreset(QAction* action)
|
||||
|
||||
JoyButtonSlot *pbuttonslot = nullptr;
|
||||
|
||||
switch(item)
|
||||
switch (item)
|
||||
{
|
||||
case 0:
|
||||
pbuttonslot = new JoyButtonSlot(JoyButtonSlot::MouseLB, JoyButtonSlot::JoyMouseButton, this);
|
||||
@@ -487,19 +477,14 @@ void JoyAxisContextMenu::setTriggerPreset(QAction* action)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (pbuttonslot != nullptr)
|
||||
{
|
||||
QMetaObject::invokeMethod(&helper, "setPAssignedSlot", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(int, pbuttonslot->getSlotCode()),
|
||||
Q_ARG(int, pbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(int, pbuttonslot->getSlotCode()), Q_ARG(int, pbuttonslot->getSlotCodeAlias()),
|
||||
Q_ARG(JoyButtonSlot::JoySlotInputAction, pbuttonslot->getSlotMode()));
|
||||
|
||||
pbuttonslot->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
JoyAxisContextMenuHelper& JoyAxisContextMenu::getHelperLocal() {
|
||||
|
||||
return helper;
|
||||
}
|
||||
JoyAxisContextMenuHelper &JoyAxisContextMenu::getHelperLocal() { return helper; }
|
||||
|
||||
@@ -16,12 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JOYAXISCONTEXTMENU_H
|
||||
#define JOYAXISCONTEXTMENU_H
|
||||
|
||||
|
||||
|
||||
#include "uihelpers/joyaxiscontextmenuhelper.h"
|
||||
|
||||
#include <QMenu>
|
||||
@@ -33,23 +30,23 @@ class JoyAxisContextMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit JoyAxisContextMenu(JoyAxis *axis, QWidget *parent = nullptr);
|
||||
void buildMenu();
|
||||
void buildAxisMenu();
|
||||
void buildTriggerMenu();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int getPresetIndex();
|
||||
int getTriggerPresetIndex();
|
||||
|
||||
private slots:
|
||||
void setAxisPreset(QAction* action);
|
||||
void setTriggerPreset(QAction* action);
|
||||
private slots:
|
||||
void setAxisPreset(QAction *action);
|
||||
void setTriggerPreset(QAction *action);
|
||||
void openMouseSettingsDialog();
|
||||
|
||||
private:
|
||||
JoyAxisContextMenuHelper& getHelperLocal();
|
||||
private:
|
||||
JoyAxisContextMenuHelper &getHelperLocal();
|
||||
|
||||
JoyAxis *axis;
|
||||
JoyAxisContextMenuHelper helper;
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
#include "joyaxiswidget.h"
|
||||
|
||||
#include "messagehandler.h"
|
||||
#include "joyaxiscontextmenu.h"
|
||||
#include "joyaxis.h"
|
||||
#include "joyaxiscontextmenu.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
JoyAxisWidget::JoyAxisWidget(JoyAxis *axis, bool displayNames, QWidget *parent) :
|
||||
FlashButtonWidget(displayNames, parent)
|
||||
JoyAxisWidget::JoyAxisWidget(JoyAxis *axis, bool displayNames, QWidget *parent)
|
||||
: FlashButtonWidget(displayNames, parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -54,7 +54,7 @@ JoyAxisWidget::JoyAxisWidget(JoyAxis *axis, bool displayNames, QWidget *parent)
|
||||
pAxisButton->establishPropertyUpdatedConnections();
|
||||
}
|
||||
|
||||
JoyAxis* JoyAxisWidget::getAxis() const
|
||||
JoyAxis *JoyAxisWidget::getAxis() const
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JOYAXISWIDGET_H
|
||||
#define JOYAXISWIDGET_H
|
||||
|
||||
@@ -25,28 +24,27 @@
|
||||
class JoyAxis;
|
||||
class QWidget;
|
||||
|
||||
|
||||
class JoyAxisWidget : public FlashButtonWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JoyAxisWidget(JoyAxis *axis, bool displayNames, QWidget *parent=0);
|
||||
public:
|
||||
explicit JoyAxisWidget(JoyAxis *axis, bool displayNames, QWidget *parent = 0);
|
||||
|
||||
JoyAxis* getAxis() const;
|
||||
JoyAxis *getAxis() const;
|
||||
void tryFlash();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual QString generateLabel() override;
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void disableFlashes() override;
|
||||
void enableFlashes() override;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void showContextMenu(const QPoint &point);
|
||||
|
||||
private:
|
||||
private:
|
||||
JoyAxis *m_axis;
|
||||
};
|
||||
|
||||
|
||||
1273
src/joybutton.cpp
1273
src/joybutton.cpp
File diff suppressed because it is too large
Load Diff
326
src/joybutton.h
326
src/joybutton.h
@@ -16,51 +16,73 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JOYBUTTON_H
|
||||
#define JOYBUTTON_H
|
||||
|
||||
|
||||
#include "joybuttonslot.h"
|
||||
#include "globalvariables.h"
|
||||
#include "springmousemoveinfo.h"
|
||||
#include "joybuttonmousehelper.h"
|
||||
#include "joybuttonslot.h"
|
||||
#include "springmousemoveinfo.h"
|
||||
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QDeadlineTimer>
|
||||
#include <QQueue>
|
||||
#include <QReadWriteLock>
|
||||
#include <QRunnable>
|
||||
#include <QDeadlineTimer>
|
||||
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
class VDPad;
|
||||
class SetJoystick;
|
||||
class QXmlStreamReader;
|
||||
class QXmlStreamWriter;
|
||||
//class QThread;
|
||||
// class QThread;
|
||||
class QThreadPool;
|
||||
|
||||
|
||||
|
||||
class JoyButton : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JoyButton(int index, int originset, SetJoystick *parentSet, QObject *parent=0);
|
||||
public:
|
||||
explicit JoyButton(int index, int originset, SetJoystick *parentSet, QObject *parent = 0);
|
||||
~JoyButton();
|
||||
|
||||
enum SetChangeCondition {SetChangeDisabled=0, SetChangeOneWay,
|
||||
SetChangeTwoWay, SetChangeWhileHeld};
|
||||
enum SetChangeCondition
|
||||
{
|
||||
SetChangeDisabled = 0,
|
||||
SetChangeOneWay,
|
||||
SetChangeTwoWay,
|
||||
SetChangeWhileHeld
|
||||
};
|
||||
|
||||
enum JoyMouseMovementMode {MouseCursor=0, MouseSpring};
|
||||
enum JoyMouseCurve {EnhancedPrecisionCurve=0, LinearCurve, QuadraticCurve,
|
||||
CubicCurve, QuadraticExtremeCurve, PowerCurve,
|
||||
EasingQuadraticCurve, EasingCubicCurve};
|
||||
enum JoyExtraAccelerationCurve {LinearAccelCurve, EaseOutSineCurve,
|
||||
EaseOutQuadAccelCurve, EaseOutCubicAccelCurve};
|
||||
enum TurboMode {NormalTurbo=0, GradientTurbo, PulseTurbo};
|
||||
enum JoyMouseMovementMode
|
||||
{
|
||||
MouseCursor = 0,
|
||||
MouseSpring
|
||||
};
|
||||
enum JoyMouseCurve
|
||||
{
|
||||
EnhancedPrecisionCurve = 0,
|
||||
LinearCurve,
|
||||
QuadraticCurve,
|
||||
CubicCurve,
|
||||
QuadraticExtremeCurve,
|
||||
PowerCurve,
|
||||
EasingQuadraticCurve,
|
||||
EasingCubicCurve
|
||||
};
|
||||
enum JoyExtraAccelerationCurve
|
||||
{
|
||||
LinearAccelCurve,
|
||||
EaseOutSineCurve,
|
||||
EaseOutQuadAccelCurve,
|
||||
EaseOutCubicAccelCurve
|
||||
};
|
||||
enum TurboMode
|
||||
{
|
||||
NormalTurbo = 0,
|
||||
GradientTurbo,
|
||||
PulseTurbo
|
||||
};
|
||||
|
||||
typedef struct _mouseCursorInfo
|
||||
{
|
||||
@@ -68,8 +90,8 @@ public:
|
||||
double code;
|
||||
} mouseCursorInfo;
|
||||
|
||||
void joyEvent(bool pressed, bool ignoresets=false); // JoyButtonEvents class
|
||||
void queuePendingEvent(bool pressed, bool ignoresets=false); // JoyButtonEvents class
|
||||
void joyEvent(bool pressed, bool ignoresets = false); // JoyButtonEvents class
|
||||
void queuePendingEvent(bool pressed, bool ignoresets = false); // JoyButtonEvents class
|
||||
void activatePendingEvent(); // JoyButtonEvents class
|
||||
void setJoyNumber(int index);
|
||||
void clearPendingEvent(); // JoyButtonEvents class
|
||||
@@ -93,8 +115,8 @@ public:
|
||||
void setAccelExtraDuration(double value);
|
||||
void setStartAccelMultiplier(double value);
|
||||
void setMaxAccelThreshold(double value);
|
||||
void setChangeSetSelection(int index, bool updateActiveString=true);
|
||||
void activateMiniSlots(JoyButtonSlot* slot, JoyButtonSlot* mix);
|
||||
void setChangeSetSelection(int index, bool updateActiveString = true);
|
||||
void activateMiniSlots(JoyButtonSlot *slot, JoyButtonSlot *mix);
|
||||
|
||||
bool hasPendingEvent(); // JoyButtonEvents class
|
||||
bool getToggleState();
|
||||
@@ -136,8 +158,8 @@ public:
|
||||
QString getActionName();
|
||||
QString getButtonName();
|
||||
|
||||
QList<JoyButtonSlot*>* getAssignedSlots(); // JoyButtonSlots class
|
||||
QList<JoyButtonSlot*> const& getActiveSlots(); // JoyButtonSlots class
|
||||
QList<JoyButtonSlot *> *getAssignedSlots(); // JoyButtonSlots class
|
||||
QList<JoyButtonSlot *> const &getActiveSlots(); // JoyButtonSlots class
|
||||
|
||||
virtual bool isPartRealAxis();
|
||||
virtual bool isModifierButton();
|
||||
@@ -154,63 +176,77 @@ public:
|
||||
virtual void initializeDistanceValues();
|
||||
virtual void setTurboMode(TurboMode mode);
|
||||
virtual void setDefaultButtonName(QString tempname);
|
||||
virtual void copyLastMouseDistanceFromDeadZone(JoyButton *srcButton); // Don't use direct assignment but copying from a current button.
|
||||
virtual void copyLastMouseDistanceFromDeadZone(
|
||||
JoyButton *srcButton); // Don't use direct assignment but copying from a current button.
|
||||
virtual void copyLastAccelerationDistance(JoyButton *srcButton);
|
||||
virtual void setVDPad(VDPad *vdpad);
|
||||
virtual void setChangeSetCondition(SetChangeCondition condition,
|
||||
bool passive=false, bool updateActiveString=true);
|
||||
virtual void setChangeSetCondition(SetChangeCondition condition, bool passive = false, bool updateActiveString = true);
|
||||
|
||||
virtual QString getPartialName(bool forceFullFormat=false, bool displayNames=false) const;
|
||||
virtual QString getPartialName(bool forceFullFormat = false, bool displayNames = false) const;
|
||||
virtual QString getSlotsSummary(); // JoyButtonSlots class
|
||||
virtual QString getSlotsString(); // JoyButtonSlots class
|
||||
virtual QString getActiveZoneSummary();
|
||||
virtual QString getCalculatedActiveZoneSummary();
|
||||
virtual QString getName(bool forceFullFormat=false, bool displayNames=false);
|
||||
virtual QString getName(bool forceFullFormat = false, bool displayNames = false);
|
||||
virtual QString getXmlName(); // JoyButtonXml class
|
||||
virtual QString getDefaultButtonName();
|
||||
|
||||
virtual QList<JoyButtonSlot*> getActiveZoneList();
|
||||
|
||||
virtual QList<JoyButtonSlot *> getActiveZoneList();
|
||||
|
||||
SetChangeCondition getChangeSetCondition();
|
||||
|
||||
VDPad* getVDPad();
|
||||
VDPad *getVDPad();
|
||||
|
||||
JoyMouseMovementMode getMouseMode();
|
||||
|
||||
JoyMouseCurve getMouseCurve();
|
||||
|
||||
SetJoystick* getParentSet();
|
||||
SetJoystick *getParentSet();
|
||||
|
||||
TurboMode getTurboMode();
|
||||
|
||||
static int calculateFinalMouseSpeed(JoyMouseCurve curve, int value, const float joyspeed);
|
||||
|
||||
static bool hasCursorEvents(QList<JoyButton::mouseCursorInfo>* cursorXSpeedsList, QList<JoyButton::mouseCursorInfo>* cursorYSpeedsList); // JoyButtonEvents class
|
||||
static bool hasSpringEvents(QList<PadderCommon::springModeInfo>* springXSpeedsList, QList<PadderCommon::springModeInfo>* springYSpeedsList); // JoyButtonEvents class
|
||||
static bool shouldInvokeMouseEvents(QList<JoyButton*>* pendingMouseButtons, QTimer* staticMouseEventTimer, QTime* testOldMouseTime); // JoyButtonEvents class
|
||||
static bool hasCursorEvents(QList<JoyButton::mouseCursorInfo> *cursorXSpeedsList,
|
||||
QList<JoyButton::mouseCursorInfo> *cursorYSpeedsList); // JoyButtonEvents class
|
||||
static bool hasSpringEvents(QList<PadderCommon::springModeInfo> *springXSpeedsList,
|
||||
QList<PadderCommon::springModeInfo> *springYSpeedsList); // JoyButtonEvents class
|
||||
static bool shouldInvokeMouseEvents(QList<JoyButton *> *pendingMouseButtons, QTimer *staticMouseEventTimer,
|
||||
QTime *testOldMouseTime); // JoyButtonEvents class
|
||||
|
||||
static void setWeightModifier(double modifier, double maxWeightModifier, double& weightModifier);
|
||||
static void moveMouseCursor(int &movedX, int &movedY, int &movedElapsed, QList<double>* mouseHistoryX, QList<double>* mouseHistoryY, QTime* testOldMouseTime, QTimer* staticMouseEventTimer, int mouseRefreshRate, int mouseHistorySize, QList<JoyButton::mouseCursorInfo>* cursorXSpeeds, QList<JoyButton::mouseCursorInfo>* cursorYSpeeds, double& cursorRemainderX, double& cursorRemainderY, double weightModifier, int idleMouseRefrRate, QList<JoyButton*>* pendingMouseButtonse);
|
||||
static void moveSpringMouse(int &movedX, int &movedY, bool &hasMoved, int springModeScreen, QList<PadderCommon::springModeInfo>* springXSpeeds, QList<PadderCommon::springModeInfo>* springYSpeeds, QList<JoyButton*>* pendingMouseButtons, int mouseRefreshRate, int idleMouseRefrRate, QTimer* staticMouseEventTimer);
|
||||
static void setMouseHistorySize(int size, int maxMouseHistSize, int& mouseHistSize, QList<double>* mouseHistoryX, QList<double>* mouseHistoryY);
|
||||
static void setMouseRefreshRate(int refresh, int& mouseRefreshRate, int idleMouseRefrRate, JoyButtonMouseHelper* mouseHelper, QList<double>* mouseHistoryX, QList<double>* mouseHistoryY, QTime* testOldMouseTime, QTimer* staticMouseEventTimer);
|
||||
static void setSpringModeScreen(int screen, int& springModeScreen);
|
||||
static void resetActiveButtonMouseDistances(JoyButtonMouseHelper* mouseHelper);
|
||||
static void setGamepadRefreshRate(int refresh, int& gamepadRefreshRate, JoyButtonMouseHelper* mouseHelper);
|
||||
static void restartLastMouseTime(QTime* testOldMouseTime);
|
||||
static void setStaticMouseThread(QThread *thread, QTimer* staticMouseEventTimer, QTime* testOldMouseTime, int idleMouseRefrRate, JoyButtonMouseHelper* mouseHelper);
|
||||
static void indirectStaticMouseThread(QThread *thread, QTimer* staticMouseEventTimer, JoyButtonMouseHelper* mouseHelper);
|
||||
static void invokeMouseEvents(JoyButtonMouseHelper* mouseHelper); // JoyButtonEvents class
|
||||
static void setWeightModifier(double modifier, double maxWeightModifier, double &weightModifier);
|
||||
static void moveMouseCursor(int &movedX, int &movedY, int &movedElapsed, QList<double> *mouseHistoryX,
|
||||
QList<double> *mouseHistoryY, QTime *testOldMouseTime, QTimer *staticMouseEventTimer,
|
||||
int mouseRefreshRate, int mouseHistorySize, QList<JoyButton::mouseCursorInfo> *cursorXSpeeds,
|
||||
QList<JoyButton::mouseCursorInfo> *cursorYSpeeds, double &cursorRemainderX,
|
||||
double &cursorRemainderY, double weightModifier, int idleMouseRefrRate,
|
||||
QList<JoyButton *> *pendingMouseButtonse);
|
||||
static void moveSpringMouse(int &movedX, int &movedY, bool &hasMoved, int springModeScreen,
|
||||
QList<PadderCommon::springModeInfo> *springXSpeeds,
|
||||
QList<PadderCommon::springModeInfo> *springYSpeeds, QList<JoyButton *> *pendingMouseButtons,
|
||||
int mouseRefreshRate, int idleMouseRefrRate, QTimer *staticMouseEventTimer);
|
||||
static void setMouseHistorySize(int size, int maxMouseHistSize, int &mouseHistSize, QList<double> *mouseHistoryX,
|
||||
QList<double> *mouseHistoryY);
|
||||
static void setMouseRefreshRate(int refresh, int &mouseRefreshRate, int idleMouseRefrRate,
|
||||
JoyButtonMouseHelper *mouseHelper, QList<double> *mouseHistoryX,
|
||||
QList<double> *mouseHistoryY, QTime *testOldMouseTime, QTimer *staticMouseEventTimer);
|
||||
static void setSpringModeScreen(int screen, int &springModeScreen);
|
||||
static void resetActiveButtonMouseDistances(JoyButtonMouseHelper *mouseHelper);
|
||||
static void setGamepadRefreshRate(int refresh, int &gamepadRefreshRate, JoyButtonMouseHelper *mouseHelper);
|
||||
static void restartLastMouseTime(QTime *testOldMouseTime);
|
||||
static void setStaticMouseThread(QThread *thread, QTimer *staticMouseEventTimer, QTime *testOldMouseTime,
|
||||
int idleMouseRefrRate, JoyButtonMouseHelper *mouseHelper);
|
||||
static void indirectStaticMouseThread(QThread *thread, QTimer *staticMouseEventTimer, JoyButtonMouseHelper *mouseHelper);
|
||||
static void invokeMouseEvents(JoyButtonMouseHelper *mouseHelper); // JoyButtonEvents class
|
||||
|
||||
static JoyButtonMouseHelper* getMouseHelper();
|
||||
static QList<JoyButton*>* getPendingMouseButtons();
|
||||
static QList<JoyButton::mouseCursorInfo>* getCursorXSpeeds();
|
||||
static QList<JoyButton::mouseCursorInfo>* getCursorYSpeeds();
|
||||
static QList<PadderCommon::springModeInfo>* getSpringXSpeeds();
|
||||
static QList<PadderCommon::springModeInfo>* getSpringYSpeeds();
|
||||
static QTimer* getStaticMouseEventTimer(); // JoyButtonEvents class
|
||||
static QTime* getTestOldMouseTime();
|
||||
static JoyButtonMouseHelper *getMouseHelper();
|
||||
static QList<JoyButton *> *getPendingMouseButtons();
|
||||
static QList<JoyButton::mouseCursorInfo> *getCursorXSpeeds();
|
||||
static QList<JoyButton::mouseCursorInfo> *getCursorYSpeeds();
|
||||
static QList<PadderCommon::springModeInfo> *getSpringXSpeeds();
|
||||
static QList<PadderCommon::springModeInfo> *getSpringYSpeeds();
|
||||
static QTimer *getStaticMouseEventTimer(); // JoyButtonEvents class
|
||||
static QTime *getTestOldMouseTime();
|
||||
|
||||
JoyExtraAccelerationCurve getExtraAccelerationCurve();
|
||||
|
||||
@@ -220,25 +256,25 @@ public:
|
||||
static const TurboMode DEFAULTTURBOMODE;
|
||||
static const JoyExtraAccelerationCurve DEFAULTEXTRAACCELCURVE;
|
||||
|
||||
bool insertAssignedSlot(JoyButtonSlot *slot, bool updateActiveString=true); // JoyButtonSlots class
|
||||
bool insertAssignedSlot(JoyButtonSlot *newSlot, int index, bool updateActiveString=true);
|
||||
bool insertAssignedSlot(JoyButtonSlot *slot, bool updateActiveString = true); // JoyButtonSlots class
|
||||
bool insertAssignedSlot(JoyButtonSlot *newSlot, int index, bool updateActiveString = true);
|
||||
bool containsJoyMixSlot();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int getPreferredKeyPressTime(); // unsigned
|
||||
|
||||
double getTotalSlotDistance(JoyButtonSlot *slot);
|
||||
|
||||
bool distanceEvent(); // JoyButtonEvents class
|
||||
bool checkForDelaySequence();
|
||||
void clearAssignedSlots(bool signalEmit=true); // JoyButtonSlots class
|
||||
void clearAssignedSlots(bool signalEmit = true); // JoyButtonSlots class
|
||||
void releaseSlotEvent(); // JoyButtonEvents class
|
||||
void checkForPressedSetChange();
|
||||
void checkTurboCondition(JoyButtonSlot *slot);
|
||||
void vdpadPassEvent(bool pressed, bool ignoresets=false); // JoyButtonEvents class
|
||||
void vdpadPassEvent(bool pressed, bool ignoresets = false); // JoyButtonEvents class
|
||||
void localBuildActiveZoneSummaryString();
|
||||
|
||||
static bool hasFutureSpringEvents(QList<JoyButton*>* pendingMouseButtons);
|
||||
static bool hasFutureSpringEvents(QList<JoyButton *> *pendingMouseButtons);
|
||||
static int timeBetweenMiniSlots;
|
||||
static int allSlotTimeBetweenSlots;
|
||||
|
||||
@@ -246,14 +282,14 @@ protected:
|
||||
|
||||
TurboMode currentTurboMode;
|
||||
|
||||
QString buildActiveZoneSummary(QList<JoyButtonSlot*> &tempList);
|
||||
QString buildActiveZoneSummary(QList<JoyButtonSlot *> &tempList);
|
||||
|
||||
static QList<JoyButtonSlot*> mouseSpeedModList; // JoyButtonSlots class
|
||||
static QList<JoyButtonSlot *> mouseSpeedModList; // JoyButtonSlots class
|
||||
static QList<mouseCursorInfo> cursorXSpeeds;
|
||||
static QList<mouseCursorInfo> cursorYSpeeds;
|
||||
static QList<PadderCommon::springModeInfo> springXSpeeds;
|
||||
static QList<PadderCommon::springModeInfo> springYSpeeds;
|
||||
static QList<JoyButton*> pendingMouseButtons;
|
||||
static QList<JoyButton *> pendingMouseButtons;
|
||||
static JoyButtonSlot *lastActiveKey; // JoyButtonSlots class
|
||||
static JoyButtonMouseHelper mouseHelper;
|
||||
|
||||
@@ -287,15 +323,15 @@ protected:
|
||||
|
||||
QQueue<bool> ignoreSetQueue;
|
||||
QQueue<bool> isButtonPressedQueue;
|
||||
QQueue<JoyButtonSlot*> mouseWheelVerticalEventQueue; // JoyButtonEvents class
|
||||
QQueue<JoyButtonSlot*> mouseWheelHorizontalEventQueue; // JoyButtonEvents class
|
||||
QQueue<JoyButtonSlot *> mouseWheelVerticalEventQueue; // JoyButtonEvents class
|
||||
QQueue<JoyButtonSlot *> mouseWheelHorizontalEventQueue; // JoyButtonEvents class
|
||||
|
||||
QString buttonName; // User specified button name
|
||||
QString defaultButtonName; // Name used by the system
|
||||
|
||||
signals:
|
||||
void clicked (int index);
|
||||
void released (int index);
|
||||
signals:
|
||||
void clicked(int index);
|
||||
void released(int index);
|
||||
void keyChanged(int keycode);
|
||||
void mouseChanged(int mousecode);
|
||||
void setChangeActivated(int index);
|
||||
@@ -310,9 +346,9 @@ signals:
|
||||
void propertyUpdated();
|
||||
void activeZoneChanged();
|
||||
|
||||
public slots:
|
||||
void setTurboInterval (int interval);
|
||||
void setToggle (bool toggle);
|
||||
public slots:
|
||||
void setTurboInterval(int interval);
|
||||
void setToggle(bool toggle);
|
||||
void setUseTurbo(bool useTurbo);
|
||||
void setMouseSpeedX(int speed);
|
||||
void setMouseSpeedY(int speed);
|
||||
@@ -331,38 +367,37 @@ public slots:
|
||||
virtual void reset();
|
||||
virtual void reset(int index);
|
||||
virtual void resetProperties();
|
||||
virtual void clearSlotsEventReset(bool clearSignalEmit=true); // JoyButtonEvents class
|
||||
virtual void clearSlotsEventReset(bool clearSignalEmit = true); // JoyButtonEvents class
|
||||
virtual void eventReset(); // JoyButtonEvents class
|
||||
virtual void mouseEvent(); // JoyButtonEvents class
|
||||
|
||||
static void establishMouseTimerConnections();
|
||||
|
||||
bool setAssignedSlot(int code, int alias, int index,
|
||||
JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
JoyButtonSlot::JoySlotInputAction mode = JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
|
||||
bool setAssignedSlot(int code,
|
||||
JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
JoyButtonSlot::JoySlotInputAction mode = JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
|
||||
bool setAssignedSlot(int code, int alias,
|
||||
JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
JoyButtonSlot::JoySlotInputAction mode = JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
|
||||
bool setAssignedSlot(JoyButtonSlot *otherSlot, int index); // JoyButtonSlots class
|
||||
|
||||
bool insertAssignedSlot(int code, int alias, int index,
|
||||
JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
JoyButtonSlot::JoySlotInputAction mode = JoyButtonSlot::JoyKeyboard); // JoyButtonSlots class
|
||||
|
||||
void buildActiveZoneSummaryString();
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
virtual void turboEvent(); // JoyButtonEvents class
|
||||
virtual void wheelEventVertical(); // JoyButtonEvents class
|
||||
virtual void wheelEventHorizontal(); // JoyButtonEvents class
|
||||
|
||||
void createDeskEvent(); // JoyButtonEvents class
|
||||
void releaseDeskEvent(bool skipsetchange=false); // JoyButtonEvents class
|
||||
void releaseDeskEvent(bool skipsetchange = false); // JoyButtonEvents class
|
||||
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void releaseActiveSlots(); // JoyButtonSlots class
|
||||
void activateSlots(); // JoyButtonSlots class
|
||||
void waitForDeskEvent(); // JoyButtonEvents class
|
||||
@@ -374,8 +409,7 @@ private slots:
|
||||
void keyPressEvent(); // JoyButtonEvents class
|
||||
void slotSetChange();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
inline void updatePendingParams(bool isEvent, bool isPressed, bool areIgnoredSets)
|
||||
{
|
||||
pendingEvent = isEvent;
|
||||
@@ -404,7 +438,8 @@ private:
|
||||
currentWheelHorizontalEvent = nullptr;
|
||||
currentKeyPress = nullptr;
|
||||
currentDelay = nullptr;
|
||||
if (currentChangedSlot) currentSetChangeSlot = nullptr;
|
||||
if (currentChangedSlot)
|
||||
currentSetChangeSlot = nullptr;
|
||||
|
||||
isKeyPressed = isButtonPressed = false;
|
||||
quitEvent = true;
|
||||
@@ -412,7 +447,8 @@ private:
|
||||
|
||||
inline void stopTimers(bool restartedActiveZoneTimer, bool stoppedActiveZoneTimer, bool stoppedSlotSetTimer)
|
||||
{
|
||||
if (restartedActiveZoneTimer) activeZoneTimer.start();
|
||||
if (restartedActiveZoneTimer)
|
||||
activeZoneTimer.start();
|
||||
|
||||
turboTimer.stop();
|
||||
pauseWaitTimer.stop();
|
||||
@@ -425,9 +461,11 @@ private:
|
||||
keyPressTimer.stop();
|
||||
delayTimer.stop();
|
||||
|
||||
if (stoppedActiveZoneTimer) activeZoneTimer.stop();
|
||||
if (stoppedActiveZoneTimer)
|
||||
activeZoneTimer.stop();
|
||||
|
||||
if (stoppedSlotSetTimer) slotSetChangeTimer.stop();
|
||||
if (stoppedSlotSetTimer)
|
||||
slotSetChangeTimer.stop();
|
||||
|
||||
if (slotiter != nullptr)
|
||||
{
|
||||
@@ -452,11 +490,14 @@ private:
|
||||
currentAccelerationDistance = 0.0;
|
||||
startingAccelerationDistance = 0.0;
|
||||
|
||||
if (updatedOldAccel) oldAccelMulti = updateOldAccelMulti = 0.0;
|
||||
else oldAccelMulti = 0.0;
|
||||
if (updatedOldAccel)
|
||||
oldAccelMulti = updateOldAccelMulti = 0.0;
|
||||
else
|
||||
oldAccelMulti = 0.0;
|
||||
|
||||
accelTravel = 0.0;
|
||||
if (restartedAccelDurTimer) accelExtraDurationTime.restart();
|
||||
if (restartedAccelDurTimer)
|
||||
accelExtraDurationTime.restart();
|
||||
|
||||
if (restartedRestParams)
|
||||
{
|
||||
@@ -471,35 +512,45 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
inline void lockForWritedString(QString& param, QString value)
|
||||
inline void lockForWritedString(QString ¶m, QString value)
|
||||
{
|
||||
activeZoneStringLock.lockForWrite();
|
||||
param = value;
|
||||
activeZoneStringLock.unlock();
|
||||
}
|
||||
|
||||
void releaseEachSlot(bool &changeRepeatState, int &references, int tempcode, JoyButtonSlot::JoySlotInputAction mode, JoyButtonSlot *slot);
|
||||
void releaseEachSlot(bool &changeRepeatState, int &references, int tempcode, JoyButtonSlot::JoySlotInputAction mode,
|
||||
JoyButtonSlot *slot);
|
||||
void resetAllProperties();
|
||||
void resetPrivVars();
|
||||
void restartAllForSetChange();
|
||||
void startTimerOverrun(int slotCode, QElapsedTimer* currSlotTime, QTimer* currSlotTimer, bool releasedDeskTimer = false);
|
||||
void findJoySlotsEnd(QListIterator<JoyButtonSlot*> *slotiter);
|
||||
void startTimerOverrun(int slotCode, QElapsedTimer *currSlotTime, QTimer *currSlotTimer, bool releasedDeskTimer = false);
|
||||
void findJoySlotsEnd(QListIterator<JoyButtonSlot *> *slotiter);
|
||||
void changeStatesQueue(bool currentReleased);
|
||||
void countActiveSlots(int tempcode, int& references, JoyButtonSlot* slot, QHash<int, int>& activeSlotsHash, bool& changeRepeatState, bool activeSlotHashWindows = false); // JoyButtonSlots class
|
||||
void releaseMoveSlots(QList<JoyButton::mouseCursorInfo>& cursorSpeeds, JoyButtonSlot *slot, QList<int>& indexesToRemove); // JoyButtonSlots class
|
||||
void setSpringDeadCircle(double& springDeadCircle, int mouseDirection);
|
||||
void checkSpringDeadCircle(int tempcode, double& springDeadCircle, int mouseSlot1, int mouseSlot2);
|
||||
static void distanceForMovingAx(double& finalAx, mouseCursorInfo infoAx);
|
||||
static void adjustAxForCursor(QList<double>* mouseHistoryList, double& adjustedAx, double& cursorRemainder, double weightModifier);
|
||||
void setDistanceForSpring(JoyButtonMouseHelper& mouseHelper, double& mouseFirstAx, double& mouseSecondAx, double distanceFromDeadZone);
|
||||
void countActiveSlots(int tempcode, int &references, JoyButtonSlot *slot, QHash<int, int> &activeSlotsHash,
|
||||
bool &changeRepeatState, bool activeSlotHashWindows = false); // JoyButtonSlots class
|
||||
void releaseMoveSlots(QList<JoyButton::mouseCursorInfo> &cursorSpeeds, JoyButtonSlot *slot,
|
||||
QList<int> &indexesToRemove); // JoyButtonSlots class
|
||||
void setSpringDeadCircle(double &springDeadCircle, int mouseDirection);
|
||||
void checkSpringDeadCircle(int tempcode, double &springDeadCircle, int mouseSlot1, int mouseSlot2);
|
||||
static void distanceForMovingAx(double &finalAx, mouseCursorInfo infoAx);
|
||||
static void adjustAxForCursor(QList<double> *mouseHistoryList, double &adjustedAx, double &cursorRemainder,
|
||||
double weightModifier);
|
||||
void setDistanceForSpring(JoyButtonMouseHelper &mouseHelper, double &mouseFirstAx, double &mouseSecondAx,
|
||||
double distanceFromDeadZone);
|
||||
void changeTurboParams(bool _isKeyPressed, bool isButtonPressed);
|
||||
void updateParamsAfterDistEvent(); // JoyButtonEvents class
|
||||
void startSequenceOfPressActive(bool isTurbo, QString debugText);
|
||||
QList<JoyButtonSlot*>& getAssignmentsLocal();
|
||||
QList<JoyButtonSlot*>& getActiveSlotsLocal(); // JoyButtonSlots class
|
||||
void updateMouseProperties(double newAxisValue, double newSpringDead, int newSpringWidth, int newSpringHeight, bool relatived, int modeScreen, QList<PadderCommon::springModeInfo>& springSpeeds, QChar axis, double newAxisValueY = 0, double newSpringDeadY = 0);
|
||||
//void getActiveZoneWithAppend(JoyButtonSlot::JoySlotInputAction mode, QList<JoyButtonSlot *>& tempSlotList, QListIterator<JoyButtonSlot *> *iter, JoyButtonSlot *slot);
|
||||
void buildActiveZoneSummarySwitchSlots(JoyButtonSlot::JoySlotInputAction mode, JoyButtonSlot *slot, bool& behindHold, QStringList* stringlist, int& i, QListIterator<JoyButtonSlot*>* iter, bool slotsActive);
|
||||
QList<JoyButtonSlot *> &getAssignmentsLocal();
|
||||
QList<JoyButtonSlot *> &getActiveSlotsLocal(); // JoyButtonSlots class
|
||||
void updateMouseProperties(double newAxisValue, double newSpringDead, int newSpringWidth, int newSpringHeight,
|
||||
bool relatived, int modeScreen, QList<PadderCommon::springModeInfo> &springSpeeds, QChar axis,
|
||||
double newAxisValueY = 0, double newSpringDeadY = 0);
|
||||
// void getActiveZoneWithAppend(JoyButtonSlot::JoySlotInputAction mode, QList<JoyButtonSlot *>& tempSlotList,
|
||||
// QListIterator<JoyButtonSlot *> *iter, JoyButtonSlot *slot);
|
||||
void buildActiveZoneSummarySwitchSlots(JoyButtonSlot::JoySlotInputAction mode, JoyButtonSlot *slot, bool &behindHold,
|
||||
QStringList *stringlist, int &i, QListIterator<JoyButtonSlot *> *iter,
|
||||
bool slotsActive);
|
||||
|
||||
bool m_toggle;
|
||||
bool quitEvent; // JoyButtonEvents class
|
||||
@@ -511,7 +562,8 @@ private:
|
||||
bool ignoreEvents; // JoyButtonEvents class
|
||||
bool whileHeldStatus;
|
||||
bool updateLastMouseDistance; // Should lastMouseDistance be updated. Set after mouse event.
|
||||
bool updateStartingMouseDistance; // Should startingMouseDistance be updated. Set after acceleration has finally been applied.
|
||||
bool updateStartingMouseDistance; // Should startingMouseDistance be updated. Set after acceleration has finally been
|
||||
// applied.
|
||||
bool relativeSpring;
|
||||
bool pendingPress;
|
||||
bool pendingEvent; // JoyButtonEvents class
|
||||
@@ -536,8 +588,10 @@ private:
|
||||
double oldAccelMulti;
|
||||
double accelTravel; // Track travel when accel started
|
||||
double updateOldAccelMulti;
|
||||
double currentMouseDistance; // Keep track of the current mouse distance after a poll. Used to update lastMouseDistance later.
|
||||
double currentAccelerationDistance; // Keep track of the current mouse distance after a poll. Used to update lastMouseDistance later.
|
||||
double currentMouseDistance; // Keep track of the current mouse distance after a poll. Used to update lastMouseDistance
|
||||
// later.
|
||||
double currentAccelerationDistance; // Keep track of the current mouse distance after a poll. Used to update
|
||||
// lastMouseDistance later.
|
||||
double startingAccelerationDistance; // Take into account when mouse acceleration started
|
||||
double minMouseDistanceAccelThreshold;
|
||||
double maxMouseDistanceAccelThreshold;
|
||||
@@ -561,10 +615,10 @@ private:
|
||||
QString actionName;
|
||||
QString activeZoneString;
|
||||
|
||||
QList<JoyButtonSlot*> assignments;
|
||||
QList<JoyButtonSlot*> activeSlots;
|
||||
QListIterator<JoyButtonSlot*> *slotiter;
|
||||
QQueue<JoyButtonSlot*> mouseEventQueue; // JoyButtonEvents class
|
||||
QList<JoyButtonSlot *> assignments;
|
||||
QList<JoyButtonSlot *> activeSlots;
|
||||
QListIterator<JoyButtonSlot *> *slotiter;
|
||||
QQueue<JoyButtonSlot *> mouseEventQueue; // JoyButtonEvents class
|
||||
JoyButtonSlot *currentPause;
|
||||
JoyButtonSlot *currentHold;
|
||||
JoyButtonSlot *currentCycle;
|
||||
@@ -586,7 +640,6 @@ private:
|
||||
QElapsedTimer cycleResetHold;
|
||||
static QTime testOldMouseTime;
|
||||
|
||||
|
||||
VDPad *m_vdpad;
|
||||
JoyMouseMovementMode mouseMode;
|
||||
JoyMouseCurve mouseCurve;
|
||||
@@ -597,29 +650,25 @@ private:
|
||||
QReadWriteLock activeZoneStringLock;
|
||||
QThreadPool *threadPool;
|
||||
|
||||
|
||||
void addEachSlotToActives(JoyButtonSlot *slot, int &i, bool &delaySequence, bool &exit, QListIterator<JoyButtonSlot *> *slotiter);
|
||||
void addEachSlotToActives(JoyButtonSlot *slot, int &i, bool &delaySequence, bool &exit,
|
||||
QListIterator<JoyButtonSlot *> *slotiter);
|
||||
};
|
||||
|
||||
|
||||
class MiniSlotRun : public QRunnable, public QObject
|
||||
{
|
||||
|
||||
public:
|
||||
MiniSlotRun(JoyButtonSlot *slot, JoyButtonSlot* slotmini, JoyButton* btn, int milisec) :
|
||||
QObject(btn),
|
||||
m_slot(slot),
|
||||
m_slotmini(slotmini),
|
||||
m_btn(btn),
|
||||
m_miliseconds(milisec)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~MiniSlotRun()
|
||||
public:
|
||||
MiniSlotRun(JoyButtonSlot *slot, JoyButtonSlot *slotmini, JoyButton *btn, int milisec)
|
||||
: QObject(btn)
|
||||
, m_slot(slot)
|
||||
, m_slotmini(slotmini)
|
||||
, m_btn(btn)
|
||||
, m_miliseconds(milisec)
|
||||
{
|
||||
}
|
||||
|
||||
~MiniSlotRun() {}
|
||||
|
||||
void run()
|
||||
{
|
||||
this->thread()->wait(m_miliseconds);
|
||||
@@ -627,12 +676,11 @@ public:
|
||||
m_btn->activateMiniSlots(m_slotmini, m_slot);
|
||||
}
|
||||
|
||||
private:
|
||||
JoyButtonSlot* m_slot;
|
||||
JoyButtonSlot* m_slotmini;
|
||||
JoyButton* m_btn;
|
||||
private:
|
||||
JoyButtonSlot *m_slot;
|
||||
JoyButtonSlot *m_slotmini;
|
||||
JoyButton *m_btn;
|
||||
int m_miliseconds;
|
||||
};
|
||||
|
||||
|
||||
#endif // JOYBUTTON_H
|
||||
|
||||
@@ -18,19 +18,18 @@
|
||||
|
||||
#include "joybuttoncontextmenu.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "inputdevice.h"
|
||||
#include "common.h"
|
||||
#include "globalvariables.h"
|
||||
#include "inputdevice.h"
|
||||
#include "joybutton.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QActionGroup>
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
JoyButtonContextMenu::JoyButtonContextMenu(JoyButton *button, QWidget *parent) :
|
||||
QMenu(parent)
|
||||
JoyButtonContextMenu::JoyButtonContextMenu(JoyButton *button, QWidget *parent)
|
||||
: QMenu(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -77,7 +76,7 @@ void JoyButtonContextMenu::buildMenu()
|
||||
|
||||
for (int i = 0; i < GlobalVariables::InputDevice::NUMBER_JOYSETS; i++)
|
||||
{
|
||||
QMenu *tempSetMenu = setSectionMenu->addMenu(tr("Set %1").arg(i+1));
|
||||
QMenu *tempSetMenu = setSectionMenu->addMenu(tr("Set %1").arg(i + 1));
|
||||
int setSelection = i * 3;
|
||||
|
||||
if (i == button->getSetSelection())
|
||||
@@ -99,8 +98,9 @@ void JoyButtonContextMenu::buildMenu()
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
void JoyButtonContextMenu::createActionForGroup(QActionGroup *tempGroup, QString actionText, QAction *action, QMenu *tempSetMenu, int setSelection, int currentSelection, int setDataInc, int setCondition)
|
||||
void JoyButtonContextMenu::createActionForGroup(QActionGroup *tempGroup, QString actionText, QAction *action,
|
||||
QMenu *tempSetMenu, int setSelection, int currentSelection, int setDataInc,
|
||||
int setCondition)
|
||||
{
|
||||
action = tempSetMenu->addAction(actionText.arg(currentSelection + 1));
|
||||
action->setData(QVariant(setSelection + setDataInc));
|
||||
@@ -112,14 +112,11 @@ void JoyButtonContextMenu::createActionForGroup(QActionGroup *tempGroup, QString
|
||||
action->setChecked(true);
|
||||
}
|
||||
|
||||
connect(action, &QAction::triggered, this, [this, action]() {
|
||||
switchSetMode(action);
|
||||
});
|
||||
connect(action, &QAction::triggered, this, [this, action]() { switchSetMode(action); });
|
||||
|
||||
tempGroup->addAction(action);
|
||||
}
|
||||
|
||||
|
||||
void JoyButtonContextMenu::switchToggle()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
@@ -138,7 +135,7 @@ void JoyButtonContextMenu::switchTurbo()
|
||||
PadderCommon::inputDaemonMutex.unlock();
|
||||
}
|
||||
|
||||
void JoyButtonContextMenu::switchSetMode(QAction* action)
|
||||
void JoyButtonContextMenu::switchSetMode(QAction *action)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -147,7 +144,7 @@ void JoyButtonContextMenu::switchSetMode(QAction* action)
|
||||
int setChangeCondition = item % 3;
|
||||
JoyButton::SetChangeCondition temp = JoyButton::SetChangeOneWay;
|
||||
|
||||
switch(setChangeCondition)
|
||||
switch (setChangeCondition)
|
||||
{
|
||||
case 0:
|
||||
temp = JoyButton::SetChangeOneWay;
|
||||
@@ -162,7 +159,6 @@ void JoyButtonContextMenu::switchSetMode(QAction* action)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
PadderCommon::inputDaemonMutex.lock();
|
||||
|
||||
// First, remove old condition for the button in both sets.
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
class JoyButton;
|
||||
class QWidget;
|
||||
|
||||
@@ -29,20 +28,21 @@ class JoyButtonContextMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit JoyButtonContextMenu(JoyButton *button, QWidget *parent = nullptr);
|
||||
void buildMenu();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
JoyButton *button;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void switchToggle();
|
||||
void switchTurbo();
|
||||
void switchSetMode(QAction* action);
|
||||
void switchSetMode(QAction *action);
|
||||
void disableSetMode();
|
||||
void clearButton();
|
||||
void createActionForGroup(QActionGroup *tempGroup, QString actionText, QAction *action, QMenu *tempSetMenu, int setSelection, int currentSelection, int setDataInc, int setCondition);
|
||||
void createActionForGroup(QActionGroup *tempGroup, QString actionText, QAction *action, QMenu *tempSetMenu,
|
||||
int setSelection, int currentSelection, int setDataInc, int setCondition);
|
||||
};
|
||||
|
||||
#endif // JOYBUTTONCONTEXTMENU_H
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
#include "joybuttonmousehelper.h"
|
||||
|
||||
#include "globalvariables.h"
|
||||
#include "messagehandler.h"
|
||||
#include "joybutton.h"
|
||||
#include "messagehandler.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
#include <QThread>
|
||||
|
||||
JoyButtonMouseHelper::JoyButtonMouseHelper(QObject *parent) :
|
||||
QObject(parent)
|
||||
JoyButtonMouseHelper::JoyButtonMouseHelper(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
@@ -44,7 +44,13 @@ void JoyButtonMouseHelper::moveMouseCursor()
|
||||
int finalx = 0;
|
||||
int finaly = 0;
|
||||
int elapsedTime = 5;
|
||||
JoyButton::moveMouseCursor(finalx, finaly, elapsedTime, &GlobalVariables::JoyButton::mouseHistoryX, &GlobalVariables::JoyButton::mouseHistoryY, JoyButton::getTestOldMouseTime(), JoyButton::getStaticMouseEventTimer(), GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::mouseHistorySize, JoyButton::getCursorXSpeeds(), JoyButton::getCursorYSpeeds(), GlobalVariables::JoyButton::cursorRemainderX, GlobalVariables::JoyButton::cursorRemainderY, GlobalVariables::JoyButton::weightModifier, GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getPendingMouseButtons());
|
||||
JoyButton::moveMouseCursor(finalx, finaly, elapsedTime, &GlobalVariables::JoyButton::mouseHistoryX,
|
||||
&GlobalVariables::JoyButton::mouseHistoryY, JoyButton::getTestOldMouseTime(),
|
||||
JoyButton::getStaticMouseEventTimer(), GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::mouseHistorySize, JoyButton::getCursorXSpeeds(),
|
||||
JoyButton::getCursorYSpeeds(), GlobalVariables::JoyButton::cursorRemainderX,
|
||||
GlobalVariables::JoyButton::cursorRemainderY, GlobalVariables::JoyButton::weightModifier,
|
||||
GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getPendingMouseButtons());
|
||||
|
||||
if ((finalx != 0) || (finaly != 0))
|
||||
emit mouseCursorMoved(finalx, finaly, elapsedTime);
|
||||
@@ -60,7 +66,10 @@ void JoyButtonMouseHelper::moveSpringMouse()
|
||||
int finalx = 0;
|
||||
int finaly = 0;
|
||||
bool hasMoved = false;
|
||||
JoyButton::moveSpringMouse(finalx, finaly, hasMoved, GlobalVariables::JoyButton::springModeScreen, JoyButton::getSpringXSpeeds(), JoyButton::getSpringYSpeeds(), JoyButton::getPendingMouseButtons(), GlobalVariables::JoyButton::mouseRefreshRate, GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getStaticMouseEventTimer());
|
||||
JoyButton::moveSpringMouse(finalx, finaly, hasMoved, GlobalVariables::JoyButton::springModeScreen,
|
||||
JoyButton::getSpringXSpeeds(), JoyButton::getSpringYSpeeds(),
|
||||
JoyButton::getPendingMouseButtons(), GlobalVariables::JoyButton::mouseRefreshRate,
|
||||
GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getStaticMouseEventTimer());
|
||||
|
||||
if (hasMoved)
|
||||
emit mouseSpringMoved(finalx, finaly);
|
||||
@@ -73,10 +82,11 @@ void JoyButtonMouseHelper::mouseEvent()
|
||||
{
|
||||
// qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
if (!JoyButton::hasCursorEvents(JoyButton::getCursorXSpeeds(), JoyButton::getCursorYSpeeds()) && !JoyButton::hasSpringEvents(JoyButton::getSpringXSpeeds(), JoyButton::getSpringYSpeeds()))
|
||||
if (!JoyButton::hasCursorEvents(JoyButton::getCursorXSpeeds(), JoyButton::getCursorYSpeeds()) &&
|
||||
!JoyButton::hasSpringEvents(JoyButton::getSpringXSpeeds(), JoyButton::getSpringYSpeeds()))
|
||||
{
|
||||
QList<JoyButton*> *buttonList = JoyButton::getPendingMouseButtons();
|
||||
QListIterator<JoyButton*> iter(*buttonList);
|
||||
QList<JoyButton *> *buttonList = JoyButton::getPendingMouseButtons();
|
||||
QListIterator<JoyButton *> iter(*buttonList);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -100,8 +110,8 @@ void JoyButtonMouseHelper::resetButtonMouseDistances()
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
QList<JoyButton*> *buttonList = JoyButton::getPendingMouseButtons();
|
||||
QListIterator<JoyButton*> iter(*buttonList);
|
||||
QList<JoyButton *> *buttonList = JoyButton::getPendingMouseButtons();
|
||||
QListIterator<JoyButton *> iter(*buttonList);
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
@@ -142,5 +152,6 @@ void JoyButtonMouseHelper::changeThread(QThread *thread)
|
||||
{
|
||||
qInstallMessageHandler(MessageHandler::myMessageOutput);
|
||||
|
||||
JoyButton::setStaticMouseThread(thread, JoyButton::getStaticMouseEventTimer(), JoyButton::getTestOldMouseTime(), GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getMouseHelper());
|
||||
JoyButton::setStaticMouseThread(thread, JoyButton::getStaticMouseEventTimer(), JoyButton::getTestOldMouseTime(),
|
||||
GlobalVariables::JoyButton::IDLEMOUSEREFRESHRATE, JoyButton::getMouseHelper());
|
||||
}
|
||||
|
||||
@@ -16,20 +16,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef JOYBUTTONMOUSEHELPER_H
|
||||
#define JOYBUTTONMOUSEHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class QThread;
|
||||
|
||||
class JoyButtonMouseHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit JoyButtonMouseHelper(QObject *parent = nullptr);
|
||||
void resetButtonMouseDistances();
|
||||
void setFirstSpringStatus(bool status);
|
||||
@@ -37,19 +35,19 @@ public:
|
||||
void carryGamePollRateUpdate(int pollRate);
|
||||
void carryMouseRefreshRateUpdate(int refreshRate);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void mouseCursorMoved(int mouseX, int mouseY, int elapsed);
|
||||
void mouseSpringMoved(int mouseX, int mouseY);
|
||||
void gamepadRefreshRateUpdated(int pollRate);
|
||||
void mouseRefreshRateUpdated(int refreshRate);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void moveMouseCursor();
|
||||
void moveSpringMouse();
|
||||
void mouseEvent();
|
||||
void changeThread(QThread *thread);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool firstSpringEvent;
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user