mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 12:50:14 +00:00
Merge fix
This commit is contained in:
parent
3740f03ef9
commit
005b9ce06f
@ -18,7 +18,7 @@ Config::Config() {
|
||||
Reload();
|
||||
}
|
||||
|
||||
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults = {
|
||||
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> Config::defaults = {
|
||||
// directly mapped keys
|
||||
Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X,
|
||||
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,
|
||||
};
|
||||
|
||||
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS>& Config::getDefaultInput()
|
||||
{
|
||||
return defaults;
|
||||
}
|
||||
|
||||
void Config::ReadValues() {
|
||||
qt_config->beginGroup("Controls");
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
|
@ -3,9 +3,10 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <QVariant>
|
||||
|
||||
#include "core/settings.h"
|
||||
#include <QVariant>
|
||||
|
||||
class QSettings;
|
||||
|
||||
@ -13,6 +14,8 @@ class Config {
|
||||
QSettings* qt_config;
|
||||
std::string qt_config_loc;
|
||||
|
||||
static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults;
|
||||
|
||||
void ReadValues();
|
||||
void SaveValues();
|
||||
public:
|
||||
@ -21,5 +24,5 @@ public:
|
||||
|
||||
void Reload();
|
||||
void Save();
|
||||
static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS>& getDefaultInput();
|
||||
};
|
||||
extern const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults;
|
||||
|
@ -30,6 +30,7 @@ void ConfigureDialog::setConfiguration() {
|
||||
void ConfigureDialog::applyConfiguration() {
|
||||
ui->generalTab->applyConfiguration();
|
||||
ui->systemTab->applyConfiguration();
|
||||
ui->inputTab->applyConfiguration();
|
||||
ui->audioTab->applyConfiguration();
|
||||
ui->debugTab->applyConfiguration();
|
||||
ui->inputTab->applyConfiguration();
|
||||
|
@ -1,7 +1,10 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
#include "configure_input.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "citra_qt/configure_input.h"
|
||||
|
||||
ConfigureInput::ConfigureInput(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
@ -53,6 +56,7 @@ ConfigureInput::~ConfigureInput()
|
||||
void ConfigureInput::handleClick()
|
||||
{
|
||||
QPushButton* sender = qobject_cast<QPushButton*>(QObject::sender());
|
||||
previous_mapping = sender->text();
|
||||
sender->setText(tr("[waiting]"));
|
||||
sender->setFocus();
|
||||
grabKeyboard();
|
||||
@ -84,21 +88,7 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
|
||||
{
|
||||
keys_pressed.push_back(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*/
|
||||
key_pressed = event->key();
|
||||
setKey();
|
||||
}
|
||||
}
|
||||
@ -106,18 +96,17 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
|
||||
/// Set button text to name of key pressed.
|
||||
void ConfigureInput::setKey()
|
||||
{
|
||||
QString key_value = "";
|
||||
for (int i : keys_pressed) // Will only contain one key until settings refactor
|
||||
{
|
||||
key_value += getKeyName(i);
|
||||
}
|
||||
// RemoveDuplicates(keyValue);
|
||||
QString key_value = getKeyName(key_pressed);
|
||||
if (key_pressed == Qt::Key_Escape)
|
||||
changing_button->setText(previous_mapping);
|
||||
else
|
||||
changing_button->setText(key_value);
|
||||
|
||||
keys_pressed.clear();
|
||||
key_pressed = Qt::Key_unknown;
|
||||
releaseKeyboard();
|
||||
releaseMouse();
|
||||
changing_button = nullptr;
|
||||
previous_mapping = nullptr;
|
||||
}
|
||||
|
||||
/// 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)
|
||||
return "";
|
||||
|
||||
if (key_code == -1)
|
||||
return "";
|
||||
|
||||
@ -171,7 +161,7 @@ void ConfigureInput::removeDuplicates(const QString& newValue)
|
||||
/// Restore all buttons to their default values.
|
||||
void ConfigureInput::restoreDefaults() {
|
||||
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);
|
||||
}
|
||||
}
|
@ -3,17 +3,17 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "citra_qt/config.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_input.h"
|
||||
|
||||
class QObject;
|
||||
class QPushButton;
|
||||
class QString;
|
||||
class QWidget;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureInput;
|
||||
@ -34,8 +34,9 @@ public:
|
||||
private:
|
||||
std::unique_ptr<Ui::ConfigureInput> ui;
|
||||
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.
|
||||
QString previous_mapping;
|
||||
|
||||
void setConfiguration();
|
||||
void setKey();
|
||||
|
Loading…
Reference in New Issue
Block a user