Settings: Create the input config dialog, add it to the menu, display the current key settings.

This commit is contained in:
Chin 2015-01-31 20:55:32 -05:00 committed by chinhodado
parent b6c241d667
commit 7b3617fef2
9 changed files with 718 additions and 0 deletions

View File

@ -20,6 +20,8 @@ set(SRCS
util/spinbox.cpp util/spinbox.cpp
bootmanager.cpp bootmanager.cpp
hotkeys.cpp hotkeys.cpp
inputs.cpp
KeyPressEater.cpp
main.cpp main.cpp
citra-qt.rc citra-qt.rc
) )
@ -44,6 +46,8 @@ set(HEADERS
util/spinbox.h util/spinbox.h
bootmanager.h bootmanager.h
hotkeys.h hotkeys.h
inputs.h
KeyPressEater.h
main.h main.h
version.h version.h
) )
@ -55,6 +59,7 @@ set(UIS
debugger/profiler.ui debugger/profiler.ui
debugger/registers.ui debugger/registers.ui
hotkeys.ui hotkeys.ui
inputs.ui
main.ui main.ui
) )

View File

@ -0,0 +1,20 @@
#include <KeyPressEater.h>
#include <QKeyEvent>
#include <QLineEdit>
KeyPressEater::KeyPressEater(QObject* parent) : QObject(parent) {}
bool KeyPressEater::eventFilter(QObject *obj, QEvent *event) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
auto keyName = QKeySequence(keyEvent->key()).toString();
QLineEdit* lineEdit = static_cast<QLineEdit*>(obj);
lineEdit->setText(keyName);
return true;
}
else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}

View File

@ -0,0 +1,10 @@
#include <QObject>
#include <QEvent>
class KeyPressEater : public QObject
{
Q_OBJECT
public:
KeyPressEater(QObject* parent);
bool eventFilter(QObject *obj, QEvent *event);
};

54
src/citra_qt/inputs.cpp Normal file
View File

@ -0,0 +1,54 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <QKeySequence>
#include <QSettings>
#include "core/settings.h"
#include "inputs.h"
#include "KeyPressEater.h"
#include <map>
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);
}

17
src/citra_qt/inputs.h Normal file
View File

@ -0,0 +1,17 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <QDialog>
#include "ui_inputs.h"
class GInputsDialog : public QDialog
{
Q_OBJECT
public:
GInputsDialog(QWidget* parent = NULL);
private:
Ui::inputs ui;
};

594
src/citra_qt/inputs.ui Normal file
View File

@ -0,0 +1,594 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>inputs</class>
<widget class="QDialog" name="inputs">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>512</width>
<height>402</height>
</rect>
</property>
<property name="windowTitle">
<string>Input setting</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>10</x>
<y>360</y>
<width>491</width>
<height>23</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>241</width>
<height>101</height>
</rect>
</property>
<property name="title">
<string>C-Pad</string>
</property>
<widget class="QLineEdit" name="lineEdit_sRight">
<property name="geometry">
<rect>
<x>160</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_sLeft">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>29</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Left</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_sDown">
<property name="geometry">
<rect>
<x>110</x>
<y>70</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_sLeft">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_sDown">
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>37</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Down</string>
</property>
</widget>
<widget class="QLabel" name="label_sRight">
<property name="geometry">
<rect>
<x>127</x>
<y>40</y>
<width>35</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Right</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_sUp">
<property name="geometry">
<rect>
<x>110</x>
<y>10</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_sUp">
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>23</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Up</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>241</width>
<height>101</height>
</rect>
</property>
<property name="title">
<string>D-Pad</string>
</property>
<widget class="QLineEdit" name="lineEdit_dDown">
<property name="geometry">
<rect>
<x>110</x>
<y>70</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_dLeft">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_dUp">
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>24</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Up</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_dRight">
<property name="geometry">
<rect>
<x>160</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_dDown">
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>38</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Down</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_dUp">
<property name="geometry">
<rect>
<x>110</x>
<y>10</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_dLeft">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>30</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Left</string>
</property>
</widget>
<widget class="QLabel" name="label_dRight">
<property name="geometry">
<rect>
<x>130</x>
<y>40</y>
<width>36</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Right</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>260</x>
<y>70</y>
<width>241</width>
<height>101</height>
</rect>
</property>
<property name="title">
<string>Main</string>
</property>
<widget class="QLineEdit" name="lineEdit_B">
<property name="geometry">
<rect>
<x>90</x>
<y>70</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Y">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_Y">
<property name="geometry">
<rect>
<x>7</x>
<y>40</y>
<width>16</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Y</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_A">
<property name="geometry">
<rect>
<x>140</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_B">
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>16</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>B</string>
</property>
</widget>
<widget class="QLabel" name="label_X">
<property name="geometry">
<rect>
<x>70</x>
<y>10</y>
<width>16</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
<widget class="QLabel" name="label_A">
<property name="geometry">
<rect>
<x>120</x>
<y>40</y>
<width>16</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>A</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_X">
<property name="geometry">
<rect>
<x>90</x>
<y>10</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<zorder>lineEdit_B</zorder>
<zorder>label_Y</zorder>
<zorder>lineEdit_Y</zorder>
<zorder>lineEdit_A</zorder>
<zorder>label_X</zorder>
<zorder>label_B</zorder>
<zorder>label_A</zorder>
<zorder>lineEdit_X</zorder>
<zorder>lineEdit_B</zorder>
<zorder>lineEdit_Y</zorder>
<zorder>label_Y</zorder>
<zorder>lineEdit_A</zorder>
<zorder>label_B</zorder>
<zorder>label_X</zorder>
<zorder>label_A</zorder>
<zorder>lineEdit_X</zorder>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>10</x>
<y>290</y>
<width>491</width>
<height>51</height>
</rect>
</property>
<property name="title">
<string>Others</string>
</property>
<widget class="QLineEdit" name="lineEdit_Start">
<property name="geometry">
<rect>
<x>360</x>
<y>20</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_Start">
<property name="geometry">
<rect>
<x>330</x>
<y>20</y>
<width>24</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
<widget class="QLabel" name="label_Select">
<property name="geometry">
<rect>
<x>47</x>
<y>20</y>
<width>29</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Select</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Select">
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_Home">
<property name="geometry">
<rect>
<x>230</x>
<y>20</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_Home">
<property name="geometry">
<rect>
<x>186</x>
<y>20</y>
<width>27</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Home</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>491</width>
<height>51</height>
</rect>
</property>
<property name="title">
<string>Shoulder</string>
</property>
<widget class="QLineEdit" name="lineEdit_R">
<property name="geometry">
<rect>
<x>340</x>
<y>20</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_L">
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_R">
<property name="geometry">
<rect>
<x>310</x>
<y>20</y>
<width>16</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>R</string>
</property>
</widget>
<widget class="QLabel" name="label_L">
<property name="geometry">
<rect>
<x>86</x>
<y>20</y>
<width>16</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>L</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>inputs</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>inputs</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>

View File

@ -22,6 +22,7 @@
#include "bootmanager.h" #include "bootmanager.h"
#include "hotkeys.h" #include "hotkeys.h"
#include "inputs.h"
//debugger //debugger
#include "debugger/disassembler.h" #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_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_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode()));
connect(ui.action_Hotkeys, SIGNAL(triggered()), this, SLOT(OnOpenHotkeysDialog())); 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(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*)));
connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping())); connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping()));
@ -331,6 +334,11 @@ void GMainWindow::SetHardwareRendererEnabled(bool enabled) {
VideoCore::g_hw_renderer_enabled = enabled; VideoCore::g_hw_renderer_enabled = enabled;
} }
void GMainWindow::OnOpenInputsDialog() {
GInputsDialog dialog(this);
dialog.exec();
}
void GMainWindow::ToggleWindowMode() { void GMainWindow::ToggleWindowMode() {
if (ui.action_Single_Window_Mode->isChecked()) { if (ui.action_Single_Window_Mode->isChecked()) {
// Render in the main window... // Render in the main window...

View File

@ -67,6 +67,7 @@ private slots:
void OnMenuLoadFile(); void OnMenuLoadFile();
void OnMenuLoadSymbolMap(); void OnMenuLoadSymbolMap();
void OnOpenHotkeysDialog(); void OnOpenHotkeysDialog();
void OnOpenInputsDialog();
void OnConfigure(); void OnConfigure();
void OnDisplayTitleBars(bool); void OnDisplayTitleBars(bool);
void SetHardwareRendererEnabled(bool); void SetHardwareRendererEnabled(bool);

View File

@ -75,6 +75,7 @@
<addaction name="action_Single_Window_Mode"/> <addaction name="action_Single_Window_Mode"/>
<addaction name="actionDisplay_widget_title_bars"/> <addaction name="actionDisplay_widget_title_bars"/>
<addaction name="action_Hotkeys"/> <addaction name="action_Hotkeys"/>
<addaction name="action_Inputs"/>
</widget> </widget>
<widget class="QMenu" name="menu_Help"> <widget class="QMenu" name="menu_Help">
<property name="title"> <property name="title">
@ -166,6 +167,14 @@
<string>Display Dock Widget Headers</string> <string>Display Dock Widget Headers</string>
</property> </property>
</action> </action>
<action name="action_Inputs">
<property name="text">
<string>Configure &amp;Inputs</string>
</property>
<property name="toolTip">
<string>Configure Inputs</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections> <connections>