Skip to content

Commit

Permalink
Allow user to change button configuration (#1)
Browse files Browse the repository at this point in the history
* Override native button clicked event

* Impl controls for button settings

* Update images
  • Loading branch information
wwwwwwzx authored Feb 3, 2020
1 parent 8693a52 commit 38630c8
Show file tree
Hide file tree
Showing 16 changed files with 952 additions and 64 deletions.
12 changes: 10 additions & 2 deletions NXController.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,34 @@ 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 \
nxcontroller.cpp \
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
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 27 additions & 0 deletions UI/Control/qlineedithotkey.cpp
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#include "qlineedithotkey.h"
#include <QKeyEvent>

QLineEditHotKey::QLineEditHotKey(QWidget* pParent) : QLineEdit(pParent) {}

void QLineEditHotKey::keyPressEvent(QKeyEvent* event) {
int keyInt = event->key();
setText(QKeySequence(keyInt).toString(QKeySequence::NativeText));
}
33 changes: 33 additions & 0 deletions UI/Control/qlineedithotkey.h
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#ifndef QLINEEDITHOTKEY_H
#define QLINEEDITHOTKEY_H

#include <QLineEdit>

class QLineEditHotKey : public QLineEdit {
public:
QLineEditHotKey(QWidget* pParent = NULL);
~QLineEditHotKey() {}

protected:
void keyPressEvent(QKeyEvent* event);
};

#endif // QLINEEDITHOTKEY_H
147 changes: 147 additions & 0 deletions UI/buttonconfig.cpp
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#include "buttonconfig.h"
#include "ui_buttonconfig.h"
#include "inputtable.h"
#include <QSettings>
#include <QKeyEvent>

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<inputtable>();
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];
}
72 changes: 72 additions & 0 deletions UI/buttonconfig.h
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

#ifndef BUTTONCONFIG_H
#define BUTTONCONFIG_H

#include <QDialog>
#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
Loading

0 comments on commit 38630c8

Please sign in to comment.