fixup: Comments, input order, casts closer to variables
This commit is contained in:
parent
77a68e0607
commit
166e9d7400
4 changed files with 27 additions and 27 deletions
|
@ -43,9 +43,9 @@ bool Config::LoadINI(INIReader* config, const char* location, const std::string&
|
|||
static const std::array<int, Settings::NativeInput::NUM_INPUTS> defaults = {
|
||||
GLFW_KEY_X, GLFW_KEY_Z, GLFW_KEY_S, GLFW_KEY_A,
|
||||
GLFW_KEY_Q, GLFW_KEY_W, GLFW_KEY_1, GLFW_KEY_2,
|
||||
GLFW_KEY_I, GLFW_KEY_K, GLFW_KEY_J, GLFW_KEY_L,
|
||||
GLFW_KEY_T, GLFW_KEY_G, GLFW_KEY_F, GLFW_KEY_H,
|
||||
GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_LEFT, GLFW_KEY_RIGHT,
|
||||
GLFW_KEY_J, GLFW_KEY_L, GLFW_KEY_I, GLFW_KEY_K,
|
||||
GLFW_KEY_F, GLFW_KEY_H, GLFW_KEY_T, GLFW_KEY_G,
|
||||
GLFW_KEY_LEFT, GLFW_KEY_RIGHT, GLFW_KEY_UP, GLFW_KEY_DOWN,
|
||||
GLFW_KEY_M, GLFW_KEY_N, GLFW_KEY_B
|
||||
};
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ Config::Config() {
|
|||
const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> Config::defaults = {
|
||||
Qt::Key_X, Qt::Key_Z, Qt::Key_S, Qt::Key_A,
|
||||
Qt::Key_Q, Qt::Key_W, Qt::Key_1, Qt::Key_2,
|
||||
Qt::Key_I, Qt::Key_K, Qt::Key_J, Qt::Key_L,
|
||||
Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H,
|
||||
Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right,
|
||||
Qt::Key_J, Qt::Key_L, Qt::Key_I, Qt::Key_K,
|
||||
Qt::Key_F, Qt::Key_H, Qt::Key_T, Qt::Key_G,
|
||||
Qt::Key_Left, Qt::Key_Right, Qt::Key_Up, Qt::Key_Down,
|
||||
Qt::Key_M, Qt::Key_N, Qt::Key_B
|
||||
};
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
#include "common/logging/log.h"
|
||||
|
||||
InputsDialog::InputsDialog(QWidget* parent) : QDialog(parent) {
|
||||
// create a copy of the current settings
|
||||
// Create a copy of the current settings
|
||||
temp_settings = Settings::Values(Settings::values);
|
||||
signal_mapper = new QSignalMapper(this);
|
||||
|
||||
// create the QPushButtons
|
||||
// Create the QPushButtons
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
push_buttons[i] = new QPushButton(this);
|
||||
push_buttons[i]->setCheckable(true);
|
||||
|
@ -50,8 +50,8 @@ InputsDialog::InputsDialog(QWidget* parent) : QDialog(parent) {
|
|||
QGridLayout* box = new QGridLayout;
|
||||
for (int x = 0; x <= (Settings::NativeInput::NUM_INPUTS / ARRAY_SIZE(group_names)); ++x) {
|
||||
QLabel* label = new QLabel(tr(label_array[id].c_str()));
|
||||
box->addWidget(label, (int) x / 2 * 2, (int) x % 2 * 2);
|
||||
box->addWidget(push_buttons[id], (int) x / 2 * 2 + 1, (int) x % 2 * 2);
|
||||
box->addWidget(label, (int)x / 2 * 2, (int)x % 2 * 2);
|
||||
box->addWidget(push_buttons[id], (int)x / 2 * 2 + 1, (int)x % 2 * 2);
|
||||
signal_mapper->setMapping(push_buttons[id], id);
|
||||
connect(push_buttons[id], SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
||||
++id;
|
||||
|
@ -59,12 +59,12 @@ InputsDialog::InputsDialog(QWidget* parent) : QDialog(parent) {
|
|||
break;
|
||||
}
|
||||
group->setLayout(box);
|
||||
grid->addWidget(group, (int) i % 3, (int) i / 3 * 2);
|
||||
grid->addWidget(group, (int)i % 3, (int)i / 3 * 2);
|
||||
}
|
||||
|
||||
connect(signal_mapper, SIGNAL(mapped(int)), this, SLOT(ChangeValue(int)));
|
||||
|
||||
// the button box that contains the restore default/ok/cancel buttons
|
||||
// The button box that contains the restore default/ok/cancel buttons
|
||||
QVBoxLayout* verticalLayout = new QVBoxLayout();
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox();
|
||||
buttonBox->setOrientation(Qt::Horizontal);
|
||||
|
@ -79,11 +79,11 @@ InputsDialog::InputsDialog(QWidget* parent) : QDialog(parent) {
|
|||
setLayout(verticalLayout);
|
||||
setWindowTitle(tr("Input Settings"));
|
||||
|
||||
// set up event handlers for the buttons
|
||||
// Set up event handlers for the buttons
|
||||
QPushButton* defaultButton = buttonBox->button(QDialogButtonBox::RestoreDefaults);
|
||||
connect(defaultButton, SIGNAL(clicked()), this, SLOT(RestoreDefaultSettings()));
|
||||
|
||||
// display current key settings
|
||||
// Display current key settings
|
||||
UpdateKeyLabels();
|
||||
}
|
||||
|
||||
|
@ -137,25 +137,25 @@ QString InputsDialog::GetKeyName(int key_code) {
|
|||
}
|
||||
|
||||
void InputsDialog::RestoreDefaultSettings() {
|
||||
// load the default button settings into temp_settings
|
||||
// Load the default button settings into temp_settings
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
temp_settings.input_mappings[Settings::NativeInput::All[i]] = Config::defaults[i].toInt();
|
||||
}
|
||||
|
||||
// then display it
|
||||
// Then display it
|
||||
UpdateKeyLabels();
|
||||
}
|
||||
|
||||
void InputsDialog::SaveSettings() {
|
||||
Config config;
|
||||
|
||||
// load the temporary settings into our real settings
|
||||
// Load the temporary settings into our real settings
|
||||
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
|
||||
Settings::values.input_mappings[Settings::NativeInput::All[i]] =
|
||||
temp_settings.input_mappings[Settings::NativeInput::All[i]];
|
||||
}
|
||||
|
||||
// then save it
|
||||
// Then save it
|
||||
config.Save();
|
||||
|
||||
// Close the dialog after save the bindings
|
||||
|
|
|
@ -13,26 +13,26 @@ namespace NativeInput {
|
|||
enum Values {
|
||||
Y, X, B, A,
|
||||
L, R, ZL, ZR,
|
||||
CUP, CDOWN, CLEFT, CRIGHT,
|
||||
DUP, DDOWN, DLEFT, DRIGHT,
|
||||
SUP, SDOWN, SLEFT, SRIGHT,
|
||||
CLEFT, CRIGHT, CUP, CDOWN,
|
||||
DLEFT, DRIGHT, DUP, DDOWN,
|
||||
SLEFT, SRIGHT, SUP, SDOWN,
|
||||
START, SELECT, HOME,
|
||||
NUM_INPUTS
|
||||
};
|
||||
static const std::array<const char*, NUM_INPUTS> Mapping = {{
|
||||
"pad_y", "pad_x", "pad_b", "pad_a",
|
||||
"pad_l", "pad_r", "pad_zl", "pad_zr",
|
||||
"pad_cup", "pad_cdown", "pad_cleft", "pad_cright",
|
||||
"pad_dup", "pad_ddown", "pad_dleft", "pad_dright",
|
||||
"pad_sup", "pad_sdown", "pad_sleft", "pad_sright",
|
||||
"pad_cleft", "pad_cright", "pad_cup", "pad_cdown",
|
||||
"pad_dleft", "pad_dright", "pad_dup", "pad_ddown",
|
||||
"pad_sleft", "pad_sright", "pad_sup", "pad_sdown",
|
||||
"pad_start", "pad_select", "pad_home"
|
||||
}};
|
||||
static const std::array<Values, NUM_INPUTS> All = {{
|
||||
Y, X, B, A,
|
||||
L, R, ZL, ZR,
|
||||
CUP, CDOWN, CLEFT, CRIGHT,
|
||||
DUP, DDOWN, DLEFT, DRIGHT,
|
||||
SUP, SDOWN, SLEFT, SRIGHT,
|
||||
CLEFT, CRIGHT, CUP, CDOWN,
|
||||
DLEFT, DRIGHT, DUP, DDOWN,
|
||||
SLEFT, SRIGHT, SUP, SDOWN,
|
||||
START, SELECT, HOME
|
||||
}};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue