11 changed files with 463 additions and 17 deletions
@ -0,0 +1,139 @@
@@ -0,0 +1,139 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QGamepadManager> |
||||
#include <QGamepad> |
||||
|
||||
#include "gamepadconfigurationdialog.h" |
||||
|
||||
GamepadConfigurationDialog::GamepadConfigurationDialog(QGamepad *gamepad, QWidget* parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::GamepadConfigurationDialog), |
||||
m_gamepad(gamepad) |
||||
{ |
||||
ui->setupUi(this); |
||||
connect(m_gamepad, &QGamepad::axisRightXChanged, this, &GamepadConfigurationDialog::axisRightXChanged); |
||||
connect(m_gamepad, &QGamepad::axisRightYChanged, this, &GamepadConfigurationDialog::axisRightYChanged); |
||||
connect(m_gamepad, &QGamepad::axisLeftXChanged, this, &GamepadConfigurationDialog::axisLeftXChanged); |
||||
connect(m_gamepad, &QGamepad::axisLeftYChanged, this, &GamepadConfigurationDialog::axisLeftYChanged); |
||||
} |
||||
|
||||
GamepadConfigurationDialog::~GamepadConfigurationDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::accept() |
||||
{ |
||||
QDialog::accept(); |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::on_config0_clicked() |
||||
{ |
||||
if (ui->config0->text() == "Configure") |
||||
{ |
||||
ui->config0->setText("Done"); |
||||
ui->config1->setEnabled(false); |
||||
ui->config2->setEnabled(false); |
||||
ui->config3->setEnabled(false); |
||||
QGamepadManager::instance()->configureAxis(m_gamepad->deviceId(), QGamepadManager ::AxisRightX); |
||||
} |
||||
else |
||||
{ |
||||
ui->config0->setText("Configure"); |
||||
ui->config1->setEnabled(true); |
||||
ui->config2->setEnabled(true); |
||||
ui->config3->setEnabled(true); |
||||
} |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::on_config1_clicked() |
||||
{ |
||||
if (ui->config1->text() == "Configure") |
||||
{ |
||||
ui->config1->setText("Done"); |
||||
ui->config0->setEnabled(false); |
||||
ui->config2->setEnabled(false); |
||||
ui->config3->setEnabled(false); |
||||
QGamepadManager::instance()->configureAxis(m_gamepad->deviceId(), QGamepadManager ::AxisRightY); |
||||
} |
||||
else |
||||
{ |
||||
ui->config1->setText("Configure"); |
||||
ui->config0->setEnabled(true); |
||||
ui->config2->setEnabled(true); |
||||
ui->config3->setEnabled(true); |
||||
} |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::on_config2_clicked() |
||||
{ |
||||
if (ui->config2->text() == "Configure") |
||||
{ |
||||
ui->config2->setText("Done"); |
||||
ui->config0->setEnabled(false); |
||||
ui->config1->setEnabled(false); |
||||
ui->config3->setEnabled(false); |
||||
QGamepadManager::instance()->configureAxis(m_gamepad->deviceId(), QGamepadManager ::AxisLeftX); |
||||
} |
||||
else |
||||
{ |
||||
ui->config2->setText("Configure"); |
||||
ui->config0->setEnabled(true); |
||||
ui->config1->setEnabled(true); |
||||
ui->config3->setEnabled(true); |
||||
} |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::on_config3_clicked() |
||||
{ |
||||
if (ui->config3->text() == "Configure") |
||||
{ |
||||
ui->config3->setText("Done"); |
||||
ui->config0->setEnabled(false); |
||||
ui->config1->setEnabled(false); |
||||
ui->config2->setEnabled(false); |
||||
QGamepadManager::instance()->configureAxis(m_gamepad->deviceId(), QGamepadManager ::AxisLeftY); |
||||
} |
||||
else |
||||
{ |
||||
ui->config3->setText("Configure"); |
||||
ui->config0->setEnabled(true); |
||||
ui->config1->setEnabled(true); |
||||
ui->config2->setEnabled(true); |
||||
} |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::axisRightXChanged(double value) |
||||
{ |
||||
ui->value0->setText(QString::number(value)); |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::axisRightYChanged(double value) |
||||
{ |
||||
ui->value1->setText(QString::number(value)); |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::axisLeftXChanged(double value) |
||||
{ |
||||
ui->value2->setText(QString::number(value)); |
||||
} |
||||
|
||||
void GamepadConfigurationDialog::axisLeftYChanged(double value) |
||||
{ |
||||
ui->value3->setText(QString::number(value)); |
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2023 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_GAMEPADCONFIGURATIONDIALOG_H |
||||
#define INCLUDE_GAMEPADCONFIGURATIONDIALOG_H |
||||
|
||||
#include "ui_gamepadconfigurationdialog.h" |
||||
|
||||
class QGamepad; |
||||
|
||||
class GamepadConfigurationDialog : public QDialog { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit GamepadConfigurationDialog(QGamepad *gamepad, QWidget* parent = 0); |
||||
~GamepadConfigurationDialog(); |
||||
|
||||
private slots: |
||||
void accept(); |
||||
void on_config0_clicked(); |
||||
void on_config1_clicked(); |
||||
void on_config2_clicked(); |
||||
void on_config3_clicked(); |
||||
void axisRightXChanged(double value); |
||||
void axisRightYChanged(double value); |
||||
void axisLeftXChanged(double value); |
||||
void axisLeftYChanged(double value); |
||||
|
||||
private: |
||||
Ui::GamepadConfigurationDialog* ui; |
||||
QGamepad *m_gamepad; |
||||
}; |
||||
|
||||
#endif // INCLUDE_GAMEPADCONFIGURATIONDIALOG_H
|
||||
|
||||
@ -0,0 +1,196 @@
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>GamepadConfigurationDialog</class> |
||||
<widget class="QDialog" name="GamepadConfigurationDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>380</width> |
||||
<height>309</height> |
||||
</rect> |
||||
</property> |
||||
<property name="font"> |
||||
<font> |
||||
<family>Liberation Sans</family> |
||||
<pointsize>9</pointsize> |
||||
</font> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Gamepad Configuration</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="groupBox"> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="1" column="2"> |
||||
<widget class="QLabel" name="value0"> |
||||
<property name="text"> |
||||
<string>0</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="1"> |
||||
<widget class="QPushButton" name="config3"> |
||||
<property name="text"> |
||||
<string>Configure</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="2"> |
||||
<widget class="QLabel" name="value1"> |
||||
<property name="text"> |
||||
<string>0</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QPushButton" name="config1"> |
||||
<property name="text"> |
||||
<string>Configure</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="config3Label"> |
||||
<property name="text"> |
||||
<string>Azimuth Offset Axis</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="2"> |
||||
<widget class="QLabel" name="value3"> |
||||
<property name="text"> |
||||
<string>0</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QPushButton" name="config2"> |
||||
<property name="text"> |
||||
<string>Configure</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="config2Label"> |
||||
<property name="text"> |
||||
<string>Elevation Offset Axis</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="config1Label"> |
||||
<property name="text"> |
||||
<string>Target Elevation/Y Axis</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="7" column="2"> |
||||
<spacer name="verticalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>20</width> |
||||
<height>40</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="config0Label"> |
||||
<property name="text"> |
||||
<string>Target Aziumth/X Axis</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="2"> |
||||
<widget class="QLabel" name="value2"> |
||||
<property name="text"> |
||||
<string>0</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="instructions"> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>0</width> |
||||
<height>80</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>To configure a controller axis: |
||||
|
||||
- press the Configure button, |
||||
- move the controller axis, |
||||
- then press Done</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QPushButton" name="config0"> |
||||
<property name="text"> |
||||
<string>Configure</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="standardButtons"> |
||||
<set>QDialogButtonBox::Close</set> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<tabstops> |
||||
<tabstop>config0</tabstop> |
||||
<tabstop>config1</tabstop> |
||||
<tabstop>config2</tabstop> |
||||
<tabstop>config3</tabstop> |
||||
</tabstops> |
||||
<resources/> |
||||
<connections> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>accepted()</signal> |
||||
<receiver>GamepadConfigurationDialog</receiver> |
||||
<slot>accept()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>248</x> |
||||
<y>254</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>157</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
<connection> |
||||
<sender>buttonBox</sender> |
||||
<signal>rejected()</signal> |
||||
<receiver>GamepadConfigurationDialog</receiver> |
||||
<slot>reject()</slot> |
||||
<hints> |
||||
<hint type="sourcelabel"> |
||||
<x>316</x> |
||||
<y>260</y> |
||||
</hint> |
||||
<hint type="destinationlabel"> |
||||
<x>286</x> |
||||
<y>274</y> |
||||
</hint> |
||||
</hints> |
||||
</connection> |
||||
</connections> |
||||
</ui> |
||||
Loading…
Reference in new issue