diff --git a/NXController.pro b/NXController.pro
index e825f36..caa5b8b 100644
--- a/NXController.pro
+++ b/NXController.pro
@@ -14,10 +14,12 @@ DEFINES += QT_DEPRECATED_WARNINGS
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
-RC_ICONS = icons/NXController.ico
-ICON = icons/NXController.icns
+RC_ICONS = images/NXController.ico
+ICON = images/NXController.icns
SOURCES += \
+ UI/Control/qlineedithotkey.cpp \
+ UI/buttonconfig.cpp \
UI/inputtable.cpp \
UI/main.cpp \
UI/mainwindow.cpp \
@@ -25,15 +27,21 @@ SOURCES += \
nxcontroller_cfw.cpp
HEADERS += \
+ UI/Control/qlineedithotkey.h \
+ UI/buttonconfig.h \
UI/inputtable.h \
UI/mainwindow.h \
nxcontroller.h \
nxcontroller_cfw.h
FORMS += \
+ UI/buttonconfig.ui \
UI/mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
+
+RESOURCES += \
+ resource.qrc
diff --git a/README.md b/README.md
index a6c7095..334e824 100644
--- a/README.md
+++ b/README.md
@@ -11,16 +11,17 @@
- Via serial port: [Switch-Fightstick](https://github.com/wwwwwwzx/Switch-Fightstick)
- Arduino UNO R3 or other boards, check [here](https://github.com/shinyquagsire23/Switch-Fightstick/blob/master/README.md)
- USB to TTL/Serial module (FT232RL)
-![](https://i.imgur.com/dOYtwCx.png)
+![](https://imgur.com/l5hwBk4.png)
- Via wifi connection: [sys-botbase](https://github.com/olliz0r/sys-botbase)
- Modified console only
- Read and write memory
- ![](https://i.imgur.com/axVMUc9.png)
+ ![img](https://i.imgur.com/7xM4CQu.png)
-Default configuration is the same as yuzu:
- ![](https://imgur.com/7CS52T7.png)
+
+## Customize your button settings
+Default button configuration is the same as yuzu:
+ ![](https://i.imgur.com/chgS50t.png)
## To do
- Add scripts for botting
-- Allow user to change configuration
diff --git a/UI/Control/qlineedithotkey.cpp b/UI/Control/qlineedithotkey.cpp
new file mode 100644
index 0000000..d806f0a
--- /dev/null
+++ b/UI/Control/qlineedithotkey.cpp
@@ -0,0 +1,27 @@
+/*
+ * This file is part of NXController
+ * Copyright (C) 2020 by wwwwwwzx
+ *
+ * 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; either 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see .
+ */
+
+#include "qlineedithotkey.h"
+#include
+
+QLineEditHotKey::QLineEditHotKey(QWidget* pParent) : QLineEdit(pParent) {}
+
+void QLineEditHotKey::keyPressEvent(QKeyEvent* event) {
+ int keyInt = event->key();
+ setText(QKeySequence(keyInt).toString(QKeySequence::NativeText));
+}
diff --git a/UI/Control/qlineedithotkey.h b/UI/Control/qlineedithotkey.h
new file mode 100644
index 0000000..1f8ab4f
--- /dev/null
+++ b/UI/Control/qlineedithotkey.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of NXController
+ * Copyright (C) 2020 by wwwwwwzx
+ *
+ * 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; either 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see .
+ */
+
+#ifndef QLINEEDITHOTKEY_H
+#define QLINEEDITHOTKEY_H
+
+#include
+
+class QLineEditHotKey : public QLineEdit {
+ public:
+ QLineEditHotKey(QWidget* pParent = NULL);
+ ~QLineEditHotKey() {}
+
+ protected:
+ void keyPressEvent(QKeyEvent* event);
+};
+
+#endif // QLINEEDITHOTKEY_H
diff --git a/UI/buttonconfig.cpp b/UI/buttonconfig.cpp
new file mode 100644
index 0000000..5deaf93
--- /dev/null
+++ b/UI/buttonconfig.cpp
@@ -0,0 +1,147 @@
+/*
+ * This file is part of NXController
+ * Copyright (C) 2020 by wwwwwwzx
+ *
+ * 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; either 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see .
+ */
+
+#include "buttonconfig.h"
+#include "ui_buttonconfig.h"
+#include "inputtable.h"
+#include
+#include
+
+buttonconfig::buttonconfig(QWidget* parent) : QDialog(parent), ui(new Ui::buttonconfig) {
+ ui->setupUi(this);
+ QSettings setting("config.ini", QSettings::IniFormat);
+ auto table = setting.value("settings/keyconfig", qVariantFromValue(config));
+ if (table.isValid())
+ config = table.value();
+ ui->K_A->setText(QKeySequence(config.A).toString(QKeySequence::NativeText));
+ ui->K_B->setText(QKeySequence(config.B).toString(QKeySequence::NativeText));
+ ui->K_X->setText(QKeySequence(config.X).toString(QKeySequence::NativeText));
+ ui->K_Y->setText(QKeySequence(config.Y).toString(QKeySequence::NativeText));
+ ui->K_L->setText(QKeySequence(config.L).toString(QKeySequence::NativeText));
+ ui->K_R->setText(QKeySequence(config.R).toString(QKeySequence::NativeText));
+ ui->K_ZL->setText(QKeySequence(config.ZL).toString(QKeySequence::NativeText));
+ ui->K_ZR->setText(QKeySequence(config.ZR).toString(QKeySequence::NativeText));
+ ui->K_LS->setText(QKeySequence(config.LS).toString(QKeySequence::NativeText));
+ ui->K_RS->setText(QKeySequence(config.RS).toString(QKeySequence::NativeText));
+ ui->K_Home->setText(QKeySequence(config.Home).toString(QKeySequence::NativeText));
+ ui->K_Capture->setText(QKeySequence(config.Capture).toString(QKeySequence::NativeText));
+ ui->K_Plus->setText(QKeySequence(config.Plus).toString(QKeySequence::NativeText));
+ ui->K_Minus->setText(QKeySequence(config.Minus).toString(QKeySequence::NativeText));
+
+ ui->K_D_Up->setText(QKeySequence(config.D_Up).toString(QKeySequence::NativeText));
+ ui->K_D_Down->setText(QKeySequence(config.D_Down).toString(QKeySequence::NativeText));
+ ui->K_D_Left->setText(QKeySequence(config.D_Left).toString(QKeySequence::NativeText));
+ ui->K_D_Right->setText(QKeySequence(config.D_Right).toString(QKeySequence::NativeText));
+ ui->K_LS_Up->setText(QKeySequence(config.LS_Up).toString(QKeySequence::NativeText));
+ ui->K_LS_Down->setText(QKeySequence(config.LS_Down).toString(QKeySequence::NativeText));
+ ui->K_LS_Left->setText(QKeySequence(config.LS_Left).toString(QKeySequence::NativeText));
+ ui->K_LS_Right->setText(QKeySequence(config.LS_Right).toString(QKeySequence::NativeText));
+ ui->K_RS_Up->setText(QKeySequence(config.RS_Up).toString(QKeySequence::NativeText));
+ ui->K_RS_Down->setText(QKeySequence(config.RS_Down).toString(QKeySequence::NativeText));
+ ui->K_RS_Left->setText(QKeySequence(config.RS_Left).toString(QKeySequence::NativeText));
+ ui->K_RS_Right->setText(QKeySequence(config.RS_Right).toString(QKeySequence::NativeText));
+}
+
+buttonconfig::~buttonconfig() {
+ delete ui;
+}
+
+void buttonconfig::on_buttonBox_accepted() {
+ QSettings setting("config.ini", QSettings::IniFormat);
+ setting.setValue("settings/keyconfig", qVariantFromValue(config));
+}
+
+void buttonconfig::on_K_A_textChanged(const QString& newtext) {
+ config.A = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_B_textChanged(const QString& newtext) {
+ config.B = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_X_textChanged(const QString& newtext) {
+ config.X = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_Y_textChanged(const QString& newtext) {
+ config.Y = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_L_textChanged(const QString& newtext) {
+ config.L = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_R_textChanged(const QString& newtext) {
+ config.R = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_ZL_textChanged(const QString& newtext) {
+ config.ZL = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_ZR_textChanged(const QString& newtext) {
+ config.ZR = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_LS_textChanged(const QString& newtext) {
+ config.LS = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_RS_textChanged(const QString& newtext) {
+ config.RS = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_Home_textChanged(const QString& newtext) {
+ config.Home = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_Capture_textChanged(const QString& newtext) {
+ config.Capture = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_Plus_textChanged(const QString& newtext) {
+ config.Plus = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_Minus_textChanged(const QString& newtext) {
+ config.Minus = QKeySequence(newtext)[0];
+}
+
+void buttonconfig::on_K_D_Up_textChanged(const QString& newtext) {
+ config.D_Up = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_D_Down_textChanged(const QString& newtext) {
+ config.D_Down = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_D_Left_textChanged(const QString& newtext) {
+ config.D_Left = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_D_Right_textChanged(const QString& newtext) {
+ config.D_Right = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_LS_Up_textChanged(const QString& newtext) {
+ config.LS_Up = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_LS_Down_textChanged(const QString& newtext) {
+ config.LS_Down = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_LS_Left_textChanged(const QString& newtext) {
+ config.LS_Left = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_LS_Right_textChanged(const QString& newtext) {
+ config.LS_Right = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_RS_Up_textChanged(const QString& newtext) {
+ config.RS_Up = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_RS_Down_textChanged(const QString& newtext) {
+ config.RS_Down = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_RS_Left_textChanged(const QString& newtext) {
+ config.RS_Left = QKeySequence(newtext)[0];
+}
+void buttonconfig::on_K_RS_Right_textChanged(const QString& newtext) {
+ config.RS_Right = QKeySequence(newtext)[0];
+}
diff --git a/UI/buttonconfig.h b/UI/buttonconfig.h
new file mode 100644
index 0000000..9c6b716
--- /dev/null
+++ b/UI/buttonconfig.h
@@ -0,0 +1,72 @@
+/*
+ * This file is part of NXController
+ * Copyright (C) 2020 by wwwwwwzx
+ *
+ * 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; either 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see .
+ */
+
+#ifndef BUTTONCONFIG_H
+#define BUTTONCONFIG_H
+
+#include
+#include "inputtable.h"
+
+namespace Ui {
+ class buttonconfig;
+}
+
+class buttonconfig : public QDialog {
+ Q_OBJECT
+
+ public:
+ explicit buttonconfig(QWidget* parent = nullptr);
+ ~buttonconfig();
+
+ private slots:
+ void on_buttonBox_accepted();
+
+ void on_K_A_textChanged(const QString& newtext);
+ void on_K_B_textChanged(const QString& newtext);
+ void on_K_X_textChanged(const QString& newtext);
+ void on_K_Y_textChanged(const QString& newtext);
+ void on_K_L_textChanged(const QString& newtext);
+ void on_K_R_textChanged(const QString& newtext);
+ void on_K_ZL_textChanged(const QString& newtext);
+ void on_K_ZR_textChanged(const QString& newtext);
+ void on_K_LS_textChanged(const QString& newtext);
+ void on_K_RS_textChanged(const QString& newtext);
+ void on_K_Home_textChanged(const QString& newtext);
+ void on_K_Capture_textChanged(const QString& newtext);
+ void on_K_Plus_textChanged(const QString& newtext);
+ void on_K_Minus_textChanged(const QString& newtext);
+
+ void on_K_D_Left_textChanged(const QString& newtext);
+ void on_K_D_Right_textChanged(const QString& newtext);
+ void on_K_D_Up_textChanged(const QString& newtext);
+ void on_K_D_Down_textChanged(const QString& newtext);
+ void on_K_LS_Left_textChanged(const QString& newtext);
+ void on_K_LS_Right_textChanged(const QString& newtext);
+ void on_K_LS_Up_textChanged(const QString& newtext);
+ void on_K_LS_Down_textChanged(const QString& newtext);
+ void on_K_RS_Left_textChanged(const QString& newtext);
+ void on_K_RS_Right_textChanged(const QString& newtext);
+ void on_K_RS_Up_textChanged(const QString& newtext);
+ void on_K_RS_Down_textChanged(const QString& newtext);
+
+ private:
+ Ui::buttonconfig* ui;
+ inputtable config;
+};
+
+#endif // BUTTONCONFIG_H
diff --git a/UI/buttonconfig.ui b/UI/buttonconfig.ui
new file mode 100644
index 0000000..7dcfb93
--- /dev/null
+++ b/UI/buttonconfig.ui
@@ -0,0 +1,552 @@
+
+
+ buttonconfig
+
+
+
+ 0
+ 0
+ 720
+ 560
+
+
+
+ Button Settings
+
+
+
+
+ 290
+ 510
+ 161
+ 32
+
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+ 0
+ 0
+ 720
+ 560
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 720
+ 560
+
+
+
+
+
+
+ :/images/pro.png
+
+
+ true
+
+
+
+
+
+ 580
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 525
+ 245
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 525
+ 145
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 470
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 495
+ 292
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 432
+ 350
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 370
+ 292
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 432
+ 240
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 190
+ 290
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 230
+ 330
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 270
+ 290
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 230
+ 260
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 80
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 210
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 145
+ 140
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 145
+ 250
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 432
+ 292
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 145
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 390
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 290
+ 195
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 427
+ 139
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 253
+ 139
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 150
+ 70
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 550
+ 70
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 590
+ 50
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ 110
+ 50
+ 40
+ 20
+
+
+
+ Qt::ClickFocus
+
+
+ Qt::AlignCenter
+
+
+ L_pro
+ buttonBox
+ K_A
+ K_B
+ K_X
+ K_Y
+ K_RS_Right
+ K_RS_Down
+ K_RS_Left
+ K_RS_Up
+ K_D_Left
+ K_D_Down
+ K_D_Right
+ K_D_Up
+ K_LS_Left
+ K_LS_Right
+ K_LS_Up
+ K_LS_Down
+ K_RS
+ K_LS
+ K_Home
+ K_Capture
+ K_Plus
+ K_Minus
+ K_L
+ K_R
+ K_ZR
+ K_ZL
+
+
+
+ QLineEditHotKey
+ QLineEdit
+ UI/Control/qlineedithotkey.h
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ buttonconfig
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ buttonconfig
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/UI/inputtable.cpp b/UI/inputtable.cpp
index 9bfe931..a61d9a0 100644
--- a/UI/inputtable.cpp
+++ b/UI/inputtable.cpp
@@ -18,4 +18,18 @@
#include "inputtable.h"
-inputtable::inputtable() {}
+QDataStream& operator<<(QDataStream& out, const inputtable& v) {
+ out << v.A << v.B << v.X << v.Y << v.L << v.R << v.ZL << v.ZR << v.LS << v.RS << v.Home << v.Capture << v.Plus << v.Minus;
+ out << v.D_Up << v.D_Down << v.D_Left << v.D_Right;
+ out << v.LS_Up << v.LS_Down << v.LS_Left << v.LS_Right;
+ out << v.RS_Up << v.RS_Down << v.RS_Left << v.RS_Right;
+ return out;
+}
+
+QDataStream& operator>>(QDataStream& in, inputtable& v) {
+ in >> v.A >> v.B >> v.X >> v.Y >> v.L >> v.R >> v.ZL >> v.ZR >> v.LS >> v.RS >> v.Home >> v.Capture >> v.Plus >> v.Minus;
+ in >> v.D_Up >> v.D_Down >> v.D_Left >> v.D_Right;
+ in >> v.LS_Up >> v.LS_Down >> v.LS_Left >> v.LS_Right;
+ in >> v.RS_Up >> v.RS_Down >> v.RS_Left >> v.RS_Right;
+ return in;
+}
diff --git a/UI/inputtable.h b/UI/inputtable.h
index e14dbca..efb9076 100644
--- a/UI/inputtable.h
+++ b/UI/inputtable.h
@@ -20,36 +20,37 @@
#define INPUTTABLE_H
#include
-class inputtable {
- public:
- inputtable();
- Qt::Key A = Qt::Key_A;
- Qt::Key B = Qt::Key_S;
- Qt::Key X = Qt::Key_Z;
- Qt::Key Y = Qt::Key_X;
- Qt::Key L = Qt::Key_Q;
- Qt::Key R = Qt::Key_W;
- Qt::Key ZL = Qt::Key_1;
- Qt::Key ZR = Qt::Key_2;
- Qt::Key LS = Qt::Key_3;
- Qt::Key RS = Qt::Key_4;
- Qt::Key Home = Qt::Key_B;
- Qt::Key Capture = Qt::Key_V;
- Qt::Key Plus = Qt::Key_N;
- Qt::Key Minus = Qt::Key_M;
+struct inputtable {
+ int A = Qt::Key_A;
+ int B = Qt::Key_S;
+ int X = Qt::Key_Z;
+ int Y = Qt::Key_X;
+ int L = Qt::Key_Q;
+ int R = Qt::Key_W;
+ int ZL = Qt::Key_1;
+ int ZR = Qt::Key_2;
+ int LS = Qt::Key_3;
+ int RS = Qt::Key_4;
+ int Home = Qt::Key_B;
+ int Capture = Qt::Key_V;
+ int Plus = Qt::Key_N;
+ int Minus = Qt::Key_M;
- Qt::Key D_Up = Qt::Key_T;
- Qt::Key D_Down = Qt::Key_G;
- Qt::Key D_Left = Qt::Key_F;
- Qt::Key D_Right = Qt::Key_H;
- Qt::Key LS_Left = Qt::Key_Left;
- Qt::Key LS_Right = Qt::Key_Right;
- Qt::Key LS_Up = Qt::Key_Up;
- Qt::Key LS_Down = Qt::Key_Down;
- Qt::Key RS_Left = Qt::Key_J;
- Qt::Key RS_Right = Qt::Key_L;
- Qt::Key RS_Up = Qt::Key_I;
- Qt::Key RS_Down = Qt::Key_K;
+ int D_Left = Qt::Key_F;
+ int D_Right = Qt::Key_H;
+ int D_Up = Qt::Key_T;
+ int D_Down = Qt::Key_G;
+ int LS_Left = Qt::Key_Left;
+ int LS_Right = Qt::Key_Right;
+ int LS_Up = Qt::Key_Up;
+ int LS_Down = Qt::Key_Down;
+ int RS_Left = Qt::Key_J;
+ int RS_Right = Qt::Key_L;
+ int RS_Up = Qt::Key_I;
+ int RS_Down = Qt::Key_K;
};
+Q_DECLARE_METATYPE(inputtable)
+QDataStream& operator<<(QDataStream& out, const inputtable& v);
+QDataStream& operator>>(QDataStream& in, inputtable& v);
#endif // INPUTTABLE_H
diff --git a/UI/mainwindow.cpp b/UI/mainwindow.cpp
index bb13b1d..73954eb 100644
--- a/UI/mainwindow.cpp
+++ b/UI/mainwindow.cpp
@@ -18,26 +18,24 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
+#include "buttonconfig.h"
#include
#include
#include
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
- QSettings setting;
- RefreshDeviceList();
- connect(ui->B_Refresh, SIGNAL(released()), this, SLOT(RefreshDeviceList()));
- connect(ui->B_Connect, SIGNAL(released()), this, SLOT(Connect()));
- connect(ui->B_Disconnect, SIGNAL(released()), this, SLOT(Disconnect()));
- connect(ui->B_Read, SIGNAL(released()), this, SLOT(Read()));
- connect(ui->B_Write, SIGNAL(released()), this, SLOT(Write()));
+ qRegisterMetaTypeStreamOperators("inputtable");
+ QSettings setting("config.ini", QSettings::IniFormat);
+ on_B_Refresh_clicked();
ui->B_Disconnect->setEnabled(false);
setMinimumHeight(135);
setMaximumHeight(135);
ui->ipaddress->setText(setting.value("settings/ip", "192.168.0.1").toString());
ui->ramaddress->setText(setting.value("settings/ramaddress", "0").toString());
ui->datasize->setText(setting.value("settings/datasize", "8").toString());
- Connect();
+ loadbuttonconfig();
+ on_B_Connect_clicked();
if (ui->B_Connect->isEnabled())
ui->RB_Socket->setChecked(true);
}
@@ -45,9 +43,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
MainWindow::~MainWindow() {
delete ui;
}
-
-void MainWindow::RefreshDeviceList() {
- QSettings setting;
+void MainWindow::on_B_Refresh_clicked() {
+ QSettings setting("config.ini", QSettings::IniFormat);
QString last_device = setting.value("settings/serialport", "").toString();
ui->devicelist->clear();
Q_FOREACH (QSerialPortInfo port, QSerialPortInfo::availablePorts())
@@ -58,8 +55,8 @@ void MainWindow::RefreshDeviceList() {
}
}
-void MainWindow::Connect() {
- QSettings setting;
+void MainWindow::on_B_Connect_clicked() {
+ QSettings setting("config.ini", QSettings::IniFormat);
if (ui->RB_Serial->isChecked()) {
if (!c.connect(ui->devicelist->currentText()))
return;
@@ -79,7 +76,7 @@ void MainWindow::Connect() {
ui->RB_Socket->setEnabled(false);
}
-void MainWindow::Disconnect() {
+void MainWindow::on_B_Disconnect_clicked() {
if (ui->RB_Serial->isChecked())
c.close();
else
@@ -95,18 +92,18 @@ void MainWindow::Disconnect() {
ui->RB_Socket->setEnabled(true);
}
-void MainWindow::Read() {
+void MainWindow::on_B_Read_clicked() {
if (ui->B_Connect->isEnabled() || ui->RB_Serial->isChecked())
return;
- QSettings setting;
+ QSettings setting("config.ini", QSettings::IniFormat);
ui->data->setText(b.peek(ui->ramaddress->text(), ui->datasize->text()));
setting.setValue("settings/ramaddress", ui->ramaddress->text());
}
-void MainWindow::Write() {
+void MainWindow::on_B_Write_clicked() {
if (ui->B_Connect->isEnabled() || ui->RB_Serial->isChecked())
return;
- QSettings setting;
+ QSettings setting("config.ini", QSettings::IniFormat);
b.poke(ui->ramaddress->text(), ui->data->text());
setting.setValue("settings/datasize", ui->datasize->text());
}
@@ -116,7 +113,7 @@ void MainWindow::keyPressEvent(QKeyEvent* event) {
return;
if (event->isAutoRepeat())
return;
- Qt::Key key = (Qt::Key)event->key();
+ int key = event->key();
if (ui->RB_Serial->isChecked()) {
if (key == keytable.A)
c.A(-1);
@@ -231,7 +228,7 @@ void MainWindow::keyReleaseEvent(QKeyEvent* event) {
return;
if (event->isAutoRepeat())
return;
- Qt::Key key = (Qt::Key)event->key();
+ int key = event->key();
if (ui->RB_Serial->isChecked()) {
if (key == keytable.A)
c.A(-1);
@@ -316,3 +313,16 @@ void MainWindow::keyReleaseEvent(QKeyEvent* event) {
b.RStick(b.RS_X, 0);
}
}
+
+void MainWindow::on_B_Settings_clicked() {
+ auto* setting = new buttonconfig();
+ setting->show();
+ loadbuttonconfig();
+}
+
+void MainWindow::loadbuttonconfig() {
+ QSettings setting("config.ini", QSettings::IniFormat);
+ auto table = setting.value("settings/keyconfig", qVariantFromValue(keytable));
+ if (table.isValid())
+ keytable = table.value();
+}
diff --git a/UI/mainwindow.h b/UI/mainwindow.h
index d3906df..c1936ac 100644
--- a/UI/mainwindow.h
+++ b/UI/mainwindow.h
@@ -43,13 +43,15 @@ class MainWindow : public QMainWindow {
inputtable keytable;
private slots:
- void RefreshDeviceList();
- void Connect();
- void Disconnect();
- void Write();
- void Read();
+ void on_B_Refresh_clicked();
+ void on_B_Connect_clicked();
+ void on_B_Disconnect_clicked();
+ void on_B_Write_clicked();
+ void on_B_Read_clicked();
+ void on_B_Settings_clicked();
private:
+ void loadbuttonconfig();
Ui::MainWindow* ui;
};
#endif // MAINWINDOW_H
diff --git a/UI/mainwindow.ui b/UI/mainwindow.ui
index a1d2df8..6099fdd 100644
--- a/UI/mainwindow.ui
+++ b/UI/mainwindow.ui
@@ -54,7 +54,7 @@
- 60
+ 10
100
110
25
@@ -86,7 +86,7 @@
- 220
+ 130
100
110
25
@@ -260,6 +260,22 @@
8
+
+
+
+ 250
+ 100
+ 110
+ 25
+
+
+
+ Qt::ClickFocus
+
+
+ Settings
+
+
diff --git a/icons/NXController.icns b/images/NXController.icns
similarity index 100%
rename from icons/NXController.icns
rename to images/NXController.icns
diff --git a/icons/NXController.ico b/images/NXController.ico
similarity index 100%
rename from icons/NXController.ico
rename to images/NXController.ico
diff --git a/images/pro.png b/images/pro.png
new file mode 100644
index 0000000..e8a262a
Binary files /dev/null and b/images/pro.png differ
diff --git a/resource.qrc b/resource.qrc
new file mode 100644
index 0000000..7da02f2
--- /dev/null
+++ b/resource.qrc
@@ -0,0 +1,5 @@
+
+
+ images/pro.png
+
+