summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/yuzu/configuration/config.cpp348
-rw-r--r--src/yuzu/configuration/config.h4
2 files changed, 331 insertions, 21 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index be69fb831..c931c7cd6 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -47,39 +47,283 @@ const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> Config:
},
}};
+const std::array<int, Settings::NativeMouseButton::NumMouseButtons> Config::default_mouse_buttons =
+ {
+ Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_Apostrophe, Qt::Key_Minus, Qt::Key_Equal,
+};
+
+const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> Config::default_keyboard_keys = {
+ 0,
+ 0,
+ 0,
+ 0,
+ Qt::Key_A,
+ Qt::Key_B,
+ Qt::Key_C,
+ Qt::Key_D,
+ Qt::Key_E,
+ Qt::Key_F,
+ Qt::Key_G,
+ Qt::Key_H,
+ Qt::Key_I,
+ Qt::Key_J,
+ Qt::Key_K,
+ Qt::Key_L,
+ Qt::Key_M,
+ Qt::Key_N,
+ Qt::Key_O,
+ Qt::Key_P,
+ Qt::Key_Q,
+ Qt::Key_R,
+ Qt::Key_S,
+ Qt::Key_T,
+ Qt::Key_U,
+ Qt::Key_V,
+ Qt::Key_W,
+ Qt::Key_X,
+ Qt::Key_Y,
+ Qt::Key_Z,
+ Qt::Key_1,
+ Qt::Key_2,
+ Qt::Key_3,
+ Qt::Key_4,
+ Qt::Key_5,
+ Qt::Key_6,
+ Qt::Key_7,
+ Qt::Key_8,
+ Qt::Key_9,
+ Qt::Key_0,
+ Qt::Key_Enter,
+ Qt::Key_Escape,
+ Qt::Key_Backspace,
+ Qt::Key_Tab,
+ Qt::Key_Space,
+ Qt::Key_Minus,
+ Qt::Key_Equal,
+ Qt::Key_BracketLeft,
+ Qt::Key_BracketRight,
+ Qt::Key_Backslash,
+ Qt::Key_Dead_Tilde,
+ Qt::Key_Semicolon,
+ Qt::Key_Apostrophe,
+ Qt::Key_Dead_Grave,
+ Qt::Key_Comma,
+ Qt::Key_Period,
+ Qt::Key_Slash,
+ Qt::Key_CapsLock,
+
+ Qt::Key_F1,
+ Qt::Key_F2,
+ Qt::Key_F3,
+ Qt::Key_F4,
+ Qt::Key_F5,
+ Qt::Key_F6,
+ Qt::Key_F7,
+ Qt::Key_F8,
+ Qt::Key_F9,
+ Qt::Key_F10,
+ Qt::Key_F11,
+ Qt::Key_F12,
+
+ Qt::Key_SysReq,
+ Qt::Key_ScrollLock,
+ Qt::Key_Pause,
+ Qt::Key_Insert,
+ Qt::Key_Home,
+ Qt::Key_PageUp,
+ Qt::Key_Delete,
+ Qt::Key_End,
+ Qt::Key_PageDown,
+ Qt::Key_Right,
+ Qt::Key_Left,
+ Qt::Key_Down,
+ Qt::Key_Up,
+
+ Qt::Key_NumLock,
+ Qt::Key_Slash,
+ Qt::Key_Asterisk,
+ Qt::Key_Minus,
+ Qt::Key_Plus,
+ Qt::Key_Enter,
+ Qt::Key_1,
+ Qt::Key_2,
+ Qt::Key_3,
+ Qt::Key_4,
+ Qt::Key_5,
+ Qt::Key_6,
+ Qt::Key_7,
+ Qt::Key_8,
+ Qt::Key_9,
+ Qt::Key_0,
+ Qt::Key_Period,
+
+ 0,
+ 0,
+ Qt::Key_PowerOff,
+ Qt::Key_Equal,
+
+ Qt::Key_F13,
+ Qt::Key_F14,
+ Qt::Key_F15,
+ Qt::Key_F16,
+ Qt::Key_F17,
+ Qt::Key_F18,
+ Qt::Key_F19,
+ Qt::Key_F20,
+ Qt::Key_F21,
+ Qt::Key_F22,
+ Qt::Key_F23,
+ Qt::Key_F24,
+
+ Qt::Key_Open,
+ Qt::Key_Help,
+ Qt::Key_Menu,
+ 0,
+ Qt::Key_Stop,
+ Qt::Key_AudioRepeat,
+ Qt::Key_Undo,
+ Qt::Key_Cut,
+ Qt::Key_Copy,
+ Qt::Key_Paste,
+ Qt::Key_Find,
+ Qt::Key_VolumeMute,
+ Qt::Key_VolumeUp,
+ Qt::Key_VolumeDown,
+ Qt::Key_CapsLock,
+ Qt::Key_NumLock,
+ Qt::Key_ScrollLock,
+ Qt::Key_Comma,
+
+ Qt::Key_ParenLeft,
+ Qt::Key_ParenRight,
+};
+
+const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default_keyboard_mods = {
+ Qt::Key_Control, Qt::Key_Shift, Qt::Key_Alt, Qt::Key_ApplicationLeft,
+ Qt::Key_Control, Qt::Key_Shift, Qt::Key_AltGr, Qt::Key_ApplicationRight,
+};
+
void Config::ReadValues() {
qt_config->beginGroup("Controls");
+ for (std::size_t p = 0; p < 10; ++p) {
+ Settings::values.players[p].connected =
+ qt_config->value(QString("player_%1_connected").arg(p), false).toBool();
+
+ Settings::values.players[p].type = static_cast<Settings::ControllerType>(
+ qt_config
+ ->value(QString("player_%1_type").arg(p),
+ static_cast<u8>(Settings::ControllerType::DualJoycon))
+ .toUInt());
+
+ Settings::values.players[p].body_color_left =
+ qt_config
+ ->value(QString("player_%1_body_color_left").arg(p),
+ Settings::JOYCON_BODY_NEON_BLUE)
+ .toUInt();
+ Settings::values.players[p].body_color_right =
+ qt_config
+ ->value(QString("player_%1_body_color_right").arg(p),
+ Settings::JOYCON_BODY_NEON_RED)
+ .toUInt();
+ Settings::values.players[p].button_color_left =
+ qt_config
+ ->value(QString("player_%1_button_color_left").arg(p),
+ Settings::JOYCON_BUTTONS_NEON_BLUE)
+ .toUInt();
+ Settings::values.players[p].button_color_right =
+ qt_config
+ ->value(QString("player_%1_button_color_right").arg(p),
+ Settings::JOYCON_BUTTONS_NEON_RED)
+ .toUInt();
+
+ for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
+ std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
+ Settings::values.players[p].buttons[i] =
+ qt_config
+ ->value(QString("player_%1_").arg(p) + Settings::NativeButton::mapping[i],
+ QString::fromStdString(default_param))
+ .toString()
+ .toStdString();
+ if (Settings::values.players[p].buttons[i].empty())
+ Settings::values.players[p].buttons[i] = default_param;
+ }
+
+ for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
+ std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
+ default_analogs[i][0], default_analogs[i][1], default_analogs[i][2],
+ default_analogs[i][3], default_analogs[i][4], 0.5f);
+ Settings::values.players[p].analogs[i] =
+ qt_config
+ ->value(QString("player_%1_").arg(p) + Settings::NativeAnalog::mapping[i],
+ QString::fromStdString(default_param))
+ .toString()
+ .toStdString();
+ if (Settings::values.players[p].analogs[i].empty())
+ Settings::values.players[p].analogs[i] = default_param;
+ }
+ }
+
+ std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(),
+ [](const auto& player) { return player.connected; });
+
+ Settings::values.motion_device =
+ qt_config->value("motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01")
+ .toString()
+ .toStdString();
+
+ Settings::values.mouse_enabled = qt_config->value("mouse_enabled", false).toBool();
+
+ for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
+ std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]);
+ Settings::values.mouse_buttons[i] =
+ qt_config
+ ->value(QString("mouse_") + Settings::NativeMouseButton::mapping[i],
+ QString::fromStdString(default_param))
+ .toString()
+ .toStdString();
+ if (Settings::values.mouse_buttons[i].empty())
+ Settings::values.mouse_buttons[i] = default_param;
+ }
+
+ Settings::values.keyboard_enabled = qt_config->value("keyboard_enabled", false).toBool();
+
+ Settings::values.debug_pad_enabled = qt_config->value("debug_pad_enabled", false).toBool();
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]);
- Settings::values.buttons[i] =
+ Settings::values.debug_pad_buttons[i] =
qt_config
- ->value(Settings::NativeButton::mapping[i], QString::fromStdString(default_param))
+ ->value(QString("debug_pad_") + Settings::NativeButton::mapping[i],
+ QString::fromStdString(default_param))
.toString()
.toStdString();
- if (Settings::values.buttons[i].empty())
- Settings::values.buttons[i] = default_param;
+ if (Settings::values.debug_pad_buttons[i].empty())
+ Settings::values.debug_pad_buttons[i] = default_param;
}
for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
std::string default_param = InputCommon::GenerateAnalogParamFromKeys(
default_analogs[i][0], default_analogs[i][1], default_analogs[i][2],
default_analogs[i][3], default_analogs[i][4], 0.5f);
- Settings::values.analogs[i] =
+ Settings::values.debug_pad_analogs[i] =
qt_config
- ->value(Settings::NativeAnalog::mapping[i], QString::fromStdString(default_param))
+ ->value(QString("debug_pad_") + Settings::NativeAnalog::mapping[i],
+ QString::fromStdString(default_param))
.toString()
.toStdString();
- if (Settings::values.analogs[i].empty())
- Settings::values.analogs[i] = default_param;
+ if (Settings::values.debug_pad_analogs[i].empty())
+ Settings::values.debug_pad_analogs[i] = default_param;
}
- Settings::values.motion_device =
- qt_config->value("motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01")
- .toString()
- .toStdString();
- Settings::values.touch_device =
- qt_config->value("touch_device", "engine:emu_window").toString().toStdString();
+ Settings::values.touchscreen.enabled = qt_config->value("touchscreen_enabled", true).toBool();
+ Settings::values.touchscreen.device =
+ qt_config->value("touchscreen_device", "engine:emu_window").toString().toStdString();
+ Settings::values.touchscreen.finger = qt_config->value("touchscreen_finger", 0).toUInt();
+ Settings::values.touchscreen.rotation_angle = qt_config->value("touchscreen_angle", 0).toUInt();
+ Settings::values.touchscreen.diameter_x =
+ qt_config->value("touchscreen_diameter_x", 15).toUInt();
+ Settings::values.touchscreen.diameter_y =
+ qt_config->value("touchscreen_diameter_y", 15).toUInt();
qt_config->endGroup();
qt_config->beginGroup("Core");
@@ -126,6 +370,20 @@ void Config::ReadValues() {
.toStdString());
qt_config->endGroup();
+ std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(),
+ Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam);
+ std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(),
+ Settings::values.keyboard_keys.begin() +
+ Settings::NativeKeyboard::LeftControlKey,
+ InputCommon::GenerateKeyboardParam);
+ std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(),
+ Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam);
+
+ qt_config->beginGroup("Core");
+ Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool();
+ Settings::values.use_multi_core = qt_config->value("use_multi_core", false).toBool();
+ qt_config->endGroup();
+
qt_config->beginGroup("System");
Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool();
Settings::values.enable_nfc = qt_config->value("enable_nfc", true).toBool();
@@ -232,16 +490,65 @@ void Config::ReadValues() {
void Config::SaveValues() {
qt_config->beginGroup("Controls");
+ for (int p = 0; p < 10; ++p) {
+ qt_config->setValue(QString("player_%1_connected").arg(p),
+ Settings::values.players[p].connected);
+ qt_config->setValue(QString("player_%1_type").arg(p),
+ static_cast<u8>(Settings::values.players[p].type));
+
+ qt_config->setValue(QString("player_%1_body_color_left").arg(p),
+ Settings::values.players[p].body_color_left);
+ qt_config->setValue(QString("player_%1_body_color_right").arg(p),
+ Settings::values.players[p].body_color_right);
+ qt_config->setValue(QString("player_%1_button_color_left").arg(p),
+ Settings::values.players[p].button_color_left);
+ qt_config->setValue(QString("player_%1_button_color_right").arg(p),
+ Settings::values.players[p].button_color_right);
+
+ for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
+ qt_config->setValue(QString("player_%1_").arg(p) +
+ QString::fromStdString(Settings::NativeButton::mapping[i]),
+ QString::fromStdString(Settings::values.players[p].buttons[i]));
+ }
+ for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
+ qt_config->setValue(QString("player_%1_").arg(p) +
+ QString::fromStdString(Settings::NativeAnalog::mapping[i]),
+ QString::fromStdString(Settings::values.players[p].analogs[i]));
+ }
+ }
+
+ qt_config->setValue("motion_device", QString::fromStdString(Settings::values.motion_device));
+
+ qt_config->setValue("mouse_enabled", Settings::values.mouse_enabled);
+
+ for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) {
+ qt_config->setValue(QString("mouse_") +
+ QString::fromStdString(Settings::NativeMouseButton::mapping[i]),
+ QString::fromStdString(Settings::values.mouse_buttons[i]));
+ }
+
+ qt_config->setValue("keyboard_enabled", Settings::values.keyboard_enabled);
+
+ qt_config->setValue("debug_pad_enabled", Settings::values.debug_pad_enabled);
for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) {
- qt_config->setValue(QString::fromStdString(Settings::NativeButton::mapping[i]),
- QString::fromStdString(Settings::values.buttons[i]));
+ qt_config->setValue(QString("debug_pad_") +
+ QString::fromStdString(Settings::NativeButton::mapping[i]),
+ QString::fromStdString(Settings::values.debug_pad_buttons[i]));
}
for (int i = 0; i < Settings::NativeAnalog::NumAnalogs; ++i) {
- qt_config->setValue(QString::fromStdString(Settings::NativeAnalog::mapping[i]),
- QString::fromStdString(Settings::values.analogs[i]));
+ qt_config->setValue(QString("debug_pad_") +
+ QString::fromStdString(Settings::NativeAnalog::mapping[i]),
+ QString::fromStdString(Settings::values.debug_pad_analogs[i]));
}
- qt_config->setValue("motion_device", QString::fromStdString(Settings::values.motion_device));
- qt_config->setValue("touch_device", QString::fromStdString(Settings::values.touch_device));
+
+ qt_config->setValue("touchscreen_enabled", Settings::values.touchscreen.enabled);
+ qt_config->setValue("touchscreen_device",
+ QString::fromStdString(Settings::values.touchscreen.device));
+
+ qt_config->setValue("touchscreen_finger", Settings::values.touchscreen.finger);
+ qt_config->setValue("touchscreen_angle", Settings::values.touchscreen.rotation_angle);
+ qt_config->setValue("touchscreen_diameter_x", Settings::values.touchscreen.diameter_x);
+ qt_config->setValue("touchscreen_diameter_y", Settings::values.touchscreen.diameter_y);
qt_config->endGroup();
qt_config->beginGroup("Core");
@@ -280,7 +587,6 @@ void Config::SaveValues() {
qt_config->setValue("use_docked_mode", Settings::values.use_docked_mode);
qt_config->setValue("enable_nfc", Settings::values.enable_nfc);
qt_config->setValue("current_user", Settings::values.current_user);
-
qt_config->setValue("language_index", Settings::values.language_index);
qt_config->setValue("rng_seed_enabled", Settings::values.rng_seed.has_value());
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h
index 9c99c1b75..1facd6b55 100644
--- a/src/yuzu/configuration/config.h
+++ b/src/yuzu/configuration/config.h
@@ -22,6 +22,10 @@ public:
static const std::array<int, Settings::NativeButton::NumButtons> default_buttons;
static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> default_analogs;
+ static const std::array<int, Settings::NativeMouseButton::NumMouseButtons>
+ default_mouse_buttons;
+ static const std::array<int, Settings::NativeKeyboard::NumKeyboardKeys> default_keyboard_keys;
+ static const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> default_keyboard_mods;
private:
void ReadValues();