This commit is contained in:
Steven Cherry 2016-07-07 19:42:35 -05:00 committed by Anon
parent 82c1cf5f69
commit 87041056be
3 changed files with 13 additions and 28 deletions

View File

@ -1,8 +1,9 @@
// Copyright 2014 Citra Emulator Project
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <string>
#include <QVariant>

View File

@ -10,12 +10,6 @@
<height>501</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>441</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Citra Configuration</string>
</property>

View File

@ -1,4 +1,4 @@
// Copyright 2016 Citra Emulator Project
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -9,8 +9,7 @@
ConfigureInput::ConfigureInput(QWidget* parent) :
QWidget(parent),
ui(new Ui::ConfigureInput)
{
ui(new Ui::ConfigureInput){
ui->setupUi(this);
// Initialize mapping of input enum to UI button.
@ -52,13 +51,11 @@ ConfigureInput::ConfigureInput(QWidget* parent) :
this->setConfiguration();
}
ConfigureInput::~ConfigureInput()
{
ConfigureInput::~ConfigureInput(){
}
/// Event handler for all button released() event.
void ConfigureInput::handleClick()
{
void ConfigureInput::handleClick(){
QPushButton* sender = qobject_cast<QPushButton*>(QObject::sender());
previous_mapping = sender->text();
sender->setText(tr("[waiting]"));
@ -70,8 +67,7 @@ void ConfigureInput::handleClick()
}
/// Save all button configurations to settings file
void ConfigureInput::applyConfiguration()
{
void ConfigureInput::applyConfiguration(){
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS - 1; ++i) {
int value = getKeyValue(input_mapping[Settings::NativeInput::Values(i)]->text());
Settings::values.input_mappings[Settings::NativeInput::All[i]] = value;
@ -80,8 +76,7 @@ void ConfigureInput::applyConfiguration()
}
/// Load configuration settings into button text
void ConfigureInput::setConfiguration()
{
void ConfigureInput::setConfiguration(){
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS - 1; ++i) {
QString keyValue = getKeyName(Settings::values.input_mappings[i]);
input_mapping[Settings::NativeInput::Values(i)]->setText(keyValue);
@ -89,8 +84,7 @@ void ConfigureInput::setConfiguration()
}
/// Handle key press event for input tab when a button is 'waiting'.
void ConfigureInput::keyPressEvent(QKeyEvent* event)
{
void ConfigureInput::keyPressEvent(QKeyEvent* event){
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
{
key_pressed = event->key();
@ -100,8 +94,7 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
}
/// Set button text to name of key pressed.
void ConfigureInput::setKey()
{
void ConfigureInput::setKey(){
QString key_value = getKeyName(key_pressed);
if (key_pressed == Qt::Key_Escape)
changing_button->setText(previous_mapping);
@ -116,8 +109,7 @@ void ConfigureInput::setKey()
}
/// Convert key ASCII value to its' letter/name
QString ConfigureInput::getKeyName(int key_code) const
{
QString ConfigureInput::getKeyName(int key_code) const{
if (key_code == Qt::Key_Shift)
return tr("Shift");
@ -137,8 +129,7 @@ QString ConfigureInput::getKeyName(int key_code) const
}
/// Convert letter/name of key to its ASCII value.
Qt::Key ConfigureInput::getKeyValue(const QString& text) const
{
Qt::Key ConfigureInput::getKeyValue(const QString& text) const{
if (text == "Shift")
return Qt::Key_Shift;
if (text == "Ctrl")
@ -153,8 +144,7 @@ Qt::Key ConfigureInput::getKeyValue(const QString& text) const
}
/// Check all inputs for duplicate keys. Clears out any other button with same key as new button.
void ConfigureInput::removeDuplicates(const QString& newValue)
{
void ConfigureInput::removeDuplicates(const QString& newValue){
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS - 1; ++i) {
if (changing_button != input_mapping[Settings::NativeInput::Values(i)]) {
QString oldValue = input_mapping[Settings::NativeInput::Values(i)]->text();