mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 14:20:14 +00:00
Input-GUI: More cleanup
This commit is contained in:
parent
61144d2ab1
commit
ce0cc37045
@ -18,7 +18,7 @@ Config::Config() {
|
|||||||
Reload();
|
Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults = {
|
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> Config::defaults = {
|
||||||
// directly mapped keys
|
// directly mapped keys
|
||||||
Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X,
|
Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X,
|
||||||
Qt::Key_Q, Qt::Key_W, Qt::Key_1, Qt::Key_2,
|
Qt::Key_Q, Qt::Key_W, Qt::Key_1, Qt::Key_2,
|
||||||
@ -31,6 +31,11 @@ const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults = {
|
|||||||
Qt::Key_D,
|
Qt::Key_D,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS>& Config::getDefaultInput()
|
||||||
|
{
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
|
||||||
void Config::ReadValues() {
|
void Config::ReadValues() {
|
||||||
qt_config->beginGroup("Controls");
|
qt_config->beginGroup("Controls");
|
||||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
|
||||||
@ -13,6 +14,8 @@ class Config {
|
|||||||
QSettings* qt_config;
|
QSettings* qt_config;
|
||||||
std::string qt_config_loc;
|
std::string qt_config_loc;
|
||||||
|
|
||||||
|
static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults;
|
||||||
|
|
||||||
void ReadValues();
|
void ReadValues();
|
||||||
void SaveValues();
|
void SaveValues();
|
||||||
public:
|
public:
|
||||||
@ -21,5 +24,5 @@ public:
|
|||||||
|
|
||||||
void Reload();
|
void Reload();
|
||||||
void Save();
|
void Save();
|
||||||
|
static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS>& getDefaultInput();
|
||||||
};
|
};
|
||||||
extern const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults;
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
// Copyright 2016 Citra Emulator Project
|
// Copyright 2016 Citra Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "citra_qt/config.h"
|
#include "citra_qt/config.h"
|
||||||
#include "citra_qt/configure_dialog.h"
|
#include "citra_qt/configure_dialog.h"
|
||||||
#include "ui_configure.h"
|
#include "ui_configure.h"
|
||||||
|
|
||||||
|
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
ConfigureDialog::ConfigureDialog(QWidget *parent) :
|
ConfigureDialog::ConfigureDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ConfigureDialog)
|
ui(new Ui::ConfigureDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setConfiguration();
|
this->setConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureDialog::~ConfigureDialog() {
|
ConfigureDialog::~ConfigureDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureDialog::setConfiguration() {
|
void ConfigureDialog::setConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureDialog::applyConfiguration() {
|
void ConfigureDialog::applyConfiguration() {
|
||||||
ui->generalTab->applyConfiguration();
|
ui->generalTab->applyConfiguration();
|
||||||
ui->audioTab->applyConfiguration();
|
ui->inputTab->applyConfiguration();
|
||||||
ui->debugTab->applyConfiguration();
|
ui->audioTab->applyConfiguration();
|
||||||
ui->inputTab->applyConfiguration();
|
ui->debugTab->applyConfiguration();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
// Copyright 2016 Citra Emulator Project
|
// Copyright 2016 Citra Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
#include "configure_input.h"
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "citra_qt/configure_input.h"
|
||||||
|
|
||||||
ConfigureInput::ConfigureInput(QWidget* parent) :
|
ConfigureInput::ConfigureInput(QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -53,6 +56,7 @@ ConfigureInput::~ConfigureInput()
|
|||||||
void ConfigureInput::handleClick()
|
void ConfigureInput::handleClick()
|
||||||
{
|
{
|
||||||
QPushButton* sender = qobject_cast<QPushButton*>(QObject::sender());
|
QPushButton* sender = qobject_cast<QPushButton*>(QObject::sender());
|
||||||
|
previous_mapping = sender->text();
|
||||||
sender->setText(tr("[waiting]"));
|
sender->setText(tr("[waiting]"));
|
||||||
sender->setFocus();
|
sender->setFocus();
|
||||||
grabKeyboard();
|
grabKeyboard();
|
||||||
@ -84,21 +88,7 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
|
|||||||
{
|
{
|
||||||
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
|
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
|
||||||
{
|
{
|
||||||
keys_pressed.push_back(event->key());
|
key_pressed = event->key();
|
||||||
|
|
||||||
// Can't save Modifier + Keys yet as input. Will re-enable after settings refactor
|
|
||||||
/*if (event->key() == Qt::Key_Shift)
|
|
||||||
return;
|
|
||||||
|
|
||||||
else if (event->key() == Qt::Key_Control)
|
|
||||||
return;
|
|
||||||
|
|
||||||
else if (event->key() == Qt::Key_Alt)
|
|
||||||
return;
|
|
||||||
|
|
||||||
else if (event->key() == Qt::Key_Meta)
|
|
||||||
return;
|
|
||||||
else*/
|
|
||||||
setKey();
|
setKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,18 +96,17 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
|
|||||||
/// Set button text to name of key pressed.
|
/// Set button text to name of key pressed.
|
||||||
void ConfigureInput::setKey()
|
void ConfigureInput::setKey()
|
||||||
{
|
{
|
||||||
QString key_value = "";
|
QString key_value = getKeyName(key_pressed);
|
||||||
for (int i : keys_pressed) // Will only contain one key until settings refactor
|
if (key_pressed == Qt::Key_Escape)
|
||||||
{
|
changing_button->setText(previous_mapping);
|
||||||
key_value += getKeyName(i);
|
else
|
||||||
}
|
changing_button->setText(key_value);
|
||||||
// RemoveDuplicates(keyValue);
|
|
||||||
changing_button->setText(key_value);
|
|
||||||
|
|
||||||
keys_pressed.clear();
|
key_pressed = Qt::Key_unknown;
|
||||||
releaseKeyboard();
|
releaseKeyboard();
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
changing_button = nullptr;
|
changing_button = nullptr;
|
||||||
|
previous_mapping = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert key ASCII value to its' letter/name
|
/// Convert key ASCII value to its' letter/name
|
||||||
@ -134,6 +123,7 @@ QString ConfigureInput::getKeyName(int key_code) const
|
|||||||
|
|
||||||
if (key_code == Qt::Key_Meta)
|
if (key_code == Qt::Key_Meta)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (key_code == -1)
|
if (key_code == -1)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@ -171,7 +161,7 @@ void ConfigureInput::removeDuplicates(const QString& newValue)
|
|||||||
/// Restore all buttons to their default values.
|
/// Restore all buttons to their default values.
|
||||||
void ConfigureInput::restoreDefaults() {
|
void ConfigureInput::restoreDefaults() {
|
||||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS - 1; ++i) {
|
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS - 1; ++i) {
|
||||||
QString keyValue = getKeyName(defaults[i].toInt());
|
QString keyValue = getKeyName(Config::getDefaultInput()[i].toInt());
|
||||||
input_mapping[Settings::NativeInput::Values(i)]->setText(keyValue);
|
input_mapping[Settings::NativeInput::Values(i)]->setText(keyValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,17 +3,17 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <QWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
#include "citra_qt/config.h"
|
#include "citra_qt/config.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "ui_configure_input.h"
|
#include "ui_configure_input.h"
|
||||||
|
|
||||||
class QObject;
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QString;
|
class QString;
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureInput;
|
class ConfigureInput;
|
||||||
@ -34,8 +34,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::ConfigureInput> ui;
|
std::unique_ptr<Ui::ConfigureInput> ui;
|
||||||
std::map<Settings::NativeInput::Values, QPushButton*> input_mapping;
|
std::map<Settings::NativeInput::Values, QPushButton*> input_mapping;
|
||||||
std::vector<int> keys_pressed;
|
int key_pressed;
|
||||||
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
||||||
|
QString previous_mapping;
|
||||||
|
|
||||||
void setConfiguration();
|
void setConfiguration();
|
||||||
void setKey();
|
void setKey();
|
||||||
|
Loading…
Reference in New Issue
Block a user