From 7b3617fef26e11f2cc5f1ef4cf07185fa135964e Mon Sep 17 00:00:00 2001 From: Chin Date: Sat, 31 Jan 2015 20:55:32 -0500 Subject: [PATCH] Settings: Create the input config dialog, add it to the menu, display the current key settings. --- src/citra_qt/CMakeLists.txt | 5 + src/citra_qt/KeyPressEater.cpp | 20 ++ src/citra_qt/KeyPressEater.h | 10 + src/citra_qt/inputs.cpp | 54 +++ src/citra_qt/inputs.h | 17 + src/citra_qt/inputs.ui | 594 +++++++++++++++++++++++++++++++++ src/citra_qt/main.cpp | 8 + src/citra_qt/main.h | 1 + src/citra_qt/main.ui | 9 + 9 files changed, 718 insertions(+) create mode 100644 src/citra_qt/KeyPressEater.cpp create mode 100644 src/citra_qt/KeyPressEater.h create mode 100644 src/citra_qt/inputs.cpp create mode 100644 src/citra_qt/inputs.h create mode 100644 src/citra_qt/inputs.ui diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 47aaeca24..e5b12bf57 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -20,6 +20,8 @@ set(SRCS util/spinbox.cpp bootmanager.cpp hotkeys.cpp + inputs.cpp + KeyPressEater.cpp main.cpp citra-qt.rc ) @@ -44,6 +46,8 @@ set(HEADERS util/spinbox.h bootmanager.h hotkeys.h + inputs.h + KeyPressEater.h main.h version.h ) @@ -55,6 +59,7 @@ set(UIS debugger/profiler.ui debugger/registers.ui hotkeys.ui + inputs.ui main.ui ) diff --git a/src/citra_qt/KeyPressEater.cpp b/src/citra_qt/KeyPressEater.cpp new file mode 100644 index 000000000..6510f22d5 --- /dev/null +++ b/src/citra_qt/KeyPressEater.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +KeyPressEater::KeyPressEater(QObject* parent) : QObject(parent) {} + +bool KeyPressEater::eventFilter(QObject *obj, QEvent *event) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + auto keyName = QKeySequence(keyEvent->key()).toString(); + + QLineEdit* lineEdit = static_cast(obj); + lineEdit->setText(keyName); + return true; + } + else { + // standard event processing + return QObject::eventFilter(obj, event); + } +} \ No newline at end of file diff --git a/src/citra_qt/KeyPressEater.h b/src/citra_qt/KeyPressEater.h new file mode 100644 index 000000000..9c5021574 --- /dev/null +++ b/src/citra_qt/KeyPressEater.h @@ -0,0 +1,10 @@ +#include +#include + +class KeyPressEater : public QObject +{ + Q_OBJECT +public: + KeyPressEater(QObject* parent); + bool eventFilter(QObject *obj, QEvent *event); +}; \ No newline at end of file diff --git a/src/citra_qt/inputs.cpp b/src/citra_qt/inputs.cpp new file mode 100644 index 000000000..32b848bdb --- /dev/null +++ b/src/citra_qt/inputs.cpp @@ -0,0 +1,54 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include +#include "core/settings.h" +#include "inputs.h" +#include "KeyPressEater.h" +#include + +GInputsDialog::GInputsDialog(QWidget* parent) : QDialog(parent) +{ + ui.setupUi(this); + KeyPressEater *keyPressEater = new KeyPressEater(this); + + // display current key settings + this->ui.lineEdit_A->setText(QKeySequence(Settings::values.pad_a_key).toString()); + this->ui.lineEdit_B->setText(QKeySequence(Settings::values.pad_b_key).toString()); + this->ui.lineEdit_X->setText(QKeySequence(Settings::values.pad_x_key).toString()); + this->ui.lineEdit_Y->setText(QKeySequence(Settings::values.pad_y_key).toString()); + this->ui.lineEdit_L->setText(QKeySequence(Settings::values.pad_l_key).toString()); + this->ui.lineEdit_R->setText(QKeySequence(Settings::values.pad_r_key).toString()); + this->ui.lineEdit_Start->setText(QKeySequence(Settings::values.pad_start_key).toString()); + this->ui.lineEdit_Select->setText(QKeySequence(Settings::values.pad_select_key).toString()); + this->ui.lineEdit_dUp->setText(QKeySequence(Settings::values.pad_dup_key).toString()); + this->ui.lineEdit_dDown->setText(QKeySequence(Settings::values.pad_ddown_key).toString()); + this->ui.lineEdit_dLeft->setText(QKeySequence(Settings::values.pad_dleft_key).toString()); + this->ui.lineEdit_dRight->setText(QKeySequence(Settings::values.pad_dright_key).toString()); + this->ui.lineEdit_sUp->setText(QKeySequence(Settings::values.pad_sup_key).toString()); + this->ui.lineEdit_sDown->setText(QKeySequence(Settings::values.pad_sdown_key).toString()); + this->ui.lineEdit_sLeft->setText(QKeySequence(Settings::values.pad_sleft_key).toString()); + this->ui.lineEdit_sRight->setText(QKeySequence(Settings::values.pad_sright_key).toString()); + this->ui.lineEdit_Home->setText(QKeySequence(Settings::values.pad_home_key).toString()); + + // setup event filters for the LineEdits + this->ui.lineEdit_A->installEventFilter(keyPressEater); + this->ui.lineEdit_B->installEventFilter(keyPressEater); + this->ui.lineEdit_X->installEventFilter(keyPressEater); + this->ui.lineEdit_Y->installEventFilter(keyPressEater); + this->ui.lineEdit_L->installEventFilter(keyPressEater); + this->ui.lineEdit_R->installEventFilter(keyPressEater); + this->ui.lineEdit_Start->installEventFilter(keyPressEater); + this->ui.lineEdit_Select->installEventFilter(keyPressEater); + this->ui.lineEdit_dUp->installEventFilter(keyPressEater); + this->ui.lineEdit_dDown->installEventFilter(keyPressEater); + this->ui.lineEdit_dLeft->installEventFilter(keyPressEater); + this->ui.lineEdit_dRight->installEventFilter(keyPressEater); + this->ui.lineEdit_sUp->installEventFilter(keyPressEater); + this->ui.lineEdit_sDown->installEventFilter(keyPressEater); + this->ui.lineEdit_sLeft->installEventFilter(keyPressEater); + this->ui.lineEdit_sRight->installEventFilter(keyPressEater); + this->ui.lineEdit_Home->installEventFilter(keyPressEater); +} diff --git a/src/citra_qt/inputs.h b/src/citra_qt/inputs.h new file mode 100644 index 000000000..1e64c23ac --- /dev/null +++ b/src/citra_qt/inputs.h @@ -0,0 +1,17 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include "ui_inputs.h" + +class GInputsDialog : public QDialog +{ + Q_OBJECT + +public: + GInputsDialog(QWidget* parent = NULL); + +private: + Ui::inputs ui; +}; diff --git a/src/citra_qt/inputs.ui b/src/citra_qt/inputs.ui new file mode 100644 index 000000000..b8b4d69f4 --- /dev/null +++ b/src/citra_qt/inputs.ui @@ -0,0 +1,594 @@ + + + inputs + + + + 0 + 0 + 512 + 402 + + + + Input setting + + + + + 10 + 360 + 491 + 23 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset + + + + + + 10 + 70 + 241 + 101 + + + + C-Pad + + + + + 160 + 40 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 10 + 40 + 29 + 20 + + + + Left + + + + + + 110 + 70 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 40 + 40 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 70 + 70 + 37 + 20 + + + + Down + + + + + + 127 + 40 + 35 + 20 + + + + Right + + + + + + 110 + 10 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 80 + 10 + 23 + 20 + + + + Up + + + + + + + 10 + 180 + 241 + 101 + + + + D-Pad + + + + + 110 + 70 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 40 + 40 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 80 + 10 + 24 + 20 + + + + Up + + + + + + 160 + 40 + 71 + 20 + + + + + + + Qt::AlignCenter + + + + + + 70 + 70 + 38 + 20 + + + + Down + + + + + + 110 + 10 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 10 + 40 + 30 + 20 + + + + Left + + + + + + 130 + 40 + 36 + 20 + + + + Right + + + + + + + 260 + 70 + 241 + 101 + + + + Main + + + + + 90 + 70 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 20 + 40 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 7 + 40 + 16 + 20 + + + + Y + + + + + + 140 + 40 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 70 + 70 + 16 + 20 + + + + B + + + + + + 70 + 10 + 16 + 20 + + + + X + + + + + + 120 + 40 + 16 + 20 + + + + A + + + + + + 90 + 10 + 71 + 20 + + + + Qt::AlignCenter + + + lineEdit_B + label_Y + lineEdit_Y + lineEdit_A + label_X + label_B + label_A + lineEdit_X + lineEdit_B + lineEdit_Y + label_Y + lineEdit_A + label_B + label_X + label_A + lineEdit_X + + + + + 10 + 290 + 491 + 51 + + + + Others + + + + + 360 + 20 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 330 + 20 + 24 + 20 + + + + Start + + + + + + 47 + 20 + 29 + 20 + + + + Select + + + + + + 90 + 20 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 230 + 20 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 186 + 20 + 27 + 20 + + + + Home + + + + + + + 10 + 10 + 491 + 51 + + + + Shoulder + + + + + 340 + 20 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 110 + 20 + 71 + 20 + + + + Qt::AlignCenter + + + + + + 310 + 20 + 16 + 20 + + + + R + + + + + + 86 + 20 + 16 + 20 + + + + L + + + + + + + + buttonBox + accepted() + inputs + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + inputs + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 6b030c178..2b654f3e1 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -22,6 +22,7 @@ #include "bootmanager.h" #include "hotkeys.h" +#include "inputs.h" //debugger #include "debugger/disassembler.h" @@ -146,6 +147,8 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) connect(ui.action_Use_Hardware_Renderer, SIGNAL(triggered(bool)), this, SLOT(SetHardwareRendererEnabled(bool))); connect(ui.action_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode())); connect(ui.action_Hotkeys, SIGNAL(triggered()), this, SLOT(OnOpenHotkeysDialog())); + connect(ui.action_Inputs, SIGNAL(triggered()), this, SLOT(OnOpenInputsDialog())); + connect(this, SIGNAL(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*))); connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping())); @@ -331,6 +334,11 @@ void GMainWindow::SetHardwareRendererEnabled(bool enabled) { VideoCore::g_hw_renderer_enabled = enabled; } +void GMainWindow::OnOpenInputsDialog() { + GInputsDialog dialog(this); + dialog.exec(); +} + void GMainWindow::ToggleWindowMode() { if (ui.action_Single_Window_Mode->isChecked()) { // Render in the main window... diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 9fe9e0c9c..ca7c9e5fa 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -67,6 +67,7 @@ private slots: void OnMenuLoadFile(); void OnMenuLoadSymbolMap(); void OnOpenHotkeysDialog(); + void OnOpenInputsDialog(); void OnConfigure(); void OnDisplayTitleBars(bool); void SetHardwareRendererEnabled(bool); diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 9a809ee6c..ff4942318 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -75,6 +75,7 @@ + @@ -166,6 +167,14 @@ Display Dock Widget Headers + + + Configure &Inputs + + + Configure Inputs + +