diff options
Diffstat (limited to 'src/citra_qt')
| -rw-r--r-- | src/citra_qt/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 25 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.h | 6 | ||||
| -rw-r--r-- | src/citra_qt/config.cpp | 35 | ||||
| -rw-r--r-- | src/citra_qt/config.h | 3 | ||||
| -rw-r--r-- | src/citra_qt/configure_input.cpp | 9 |
6 files changed, 33 insertions, 47 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 15a6ccf9a..2b1c59a92 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt | |||
| @@ -97,7 +97,7 @@ if (APPLE) | |||
| 97 | else() | 97 | else() |
| 98 | add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) | 98 | add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) |
| 99 | endif() | 99 | endif() |
| 100 | target_link_libraries(citra-qt core video_core audio_core common) | 100 | target_link_libraries(citra-qt core video_core audio_core common input_common) |
| 101 | target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS}) | 101 | target_link_libraries(citra-qt ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS}) |
| 102 | target_link_libraries(citra-qt ${PLATFORM_LIBRARIES} Threads::Threads) | 102 | target_link_libraries(citra-qt ${PLATFORM_LIBRARIES} Threads::Threads) |
| 103 | 103 | ||
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 69d18cf0c..66c883d9a 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -13,7 +13,8 @@ | |||
| 13 | #include "common/scm_rev.h" | 13 | #include "common/scm_rev.h" |
| 14 | #include "common/string_util.h" | 14 | #include "common/string_util.h" |
| 15 | #include "core/core.h" | 15 | #include "core/core.h" |
| 16 | #include "core/frontend/key_map.h" | 16 | #include "input_common/keyboard.h" |
| 17 | #include "input_common/main.h" | ||
| 17 | #include "video_core/debug_utils/debug_utils.h" | 18 | #include "video_core/debug_utils/debug_utils.h" |
| 18 | #include "video_core/video_core.h" | 19 | #include "video_core/video_core.h" |
| 19 | 20 | ||
| @@ -99,14 +100,17 @@ private: | |||
| 99 | }; | 100 | }; |
| 100 | 101 | ||
| 101 | GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) | 102 | GRenderWindow::GRenderWindow(QWidget* parent, EmuThread* emu_thread) |
| 102 | : QWidget(parent), child(nullptr), keyboard_id(0), emu_thread(emu_thread) { | 103 | : QWidget(parent), child(nullptr), emu_thread(emu_thread) { |
| 103 | 104 | ||
| 104 | std::string window_title = Common::StringFromFormat("Citra %s| %s-%s", Common::g_build_name, | 105 | std::string window_title = Common::StringFromFormat("Citra %s| %s-%s", Common::g_build_name, |
| 105 | Common::g_scm_branch, Common::g_scm_desc); | 106 | Common::g_scm_branch, Common::g_scm_desc); |
| 106 | setWindowTitle(QString::fromStdString(window_title)); | 107 | setWindowTitle(QString::fromStdString(window_title)); |
| 107 | 108 | ||
| 108 | keyboard_id = KeyMap::NewDeviceId(); | 109 | InputCommon::Init(); |
| 109 | ReloadSetKeymaps(); | 110 | } |
| 111 | |||
| 112 | GRenderWindow::~GRenderWindow() { | ||
| 113 | InputCommon::Shutdown(); | ||
| 110 | } | 114 | } |
| 111 | 115 | ||
| 112 | void GRenderWindow::moveContext() { | 116 | void GRenderWindow::moveContext() { |
| @@ -197,11 +201,11 @@ void GRenderWindow::closeEvent(QCloseEvent* event) { | |||
| 197 | } | 201 | } |
| 198 | 202 | ||
| 199 | void GRenderWindow::keyPressEvent(QKeyEvent* event) { | 203 | void GRenderWindow::keyPressEvent(QKeyEvent* event) { |
| 200 | KeyMap::PressKey(*this, {event->key(), keyboard_id}); | 204 | InputCommon::GetKeyboard()->PressKey(event->key()); |
| 201 | } | 205 | } |
| 202 | 206 | ||
| 203 | void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { | 207 | void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { |
| 204 | KeyMap::ReleaseKey(*this, {event->key(), keyboard_id}); | 208 | InputCommon::GetKeyboard()->ReleaseKey(event->key()); |
| 205 | } | 209 | } |
| 206 | 210 | ||
| 207 | void GRenderWindow::mousePressEvent(QMouseEvent* event) { | 211 | void GRenderWindow::mousePressEvent(QMouseEvent* event) { |
| @@ -230,14 +234,7 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { | |||
| 230 | motion_emu->EndTilt(); | 234 | motion_emu->EndTilt(); |
| 231 | } | 235 | } |
| 232 | 236 | ||
| 233 | void GRenderWindow::ReloadSetKeymaps() { | 237 | void GRenderWindow::ReloadSetKeymaps() {} |
| 234 | KeyMap::ClearKeyMapping(keyboard_id); | ||
| 235 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | ||
| 236 | KeyMap::SetKeyMapping( | ||
| 237 | {Settings::values.input_mappings[Settings::NativeInput::All[i]], keyboard_id}, | ||
| 238 | KeyMap::mapping_targets[i]); | ||
| 239 | } | ||
| 240 | } | ||
| 241 | 238 | ||
| 242 | void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) { | 239 | void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) { |
| 243 | NotifyClientAreaSizeChanged(std::make_pair(width, height)); | 240 | NotifyClientAreaSizeChanged(std::make_pair(width, height)); |
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 7dac1c480..923a5b456 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h | |||
| @@ -104,6 +104,7 @@ class GRenderWindow : public QWidget, public EmuWindow { | |||
| 104 | 104 | ||
| 105 | public: | 105 | public: |
| 106 | GRenderWindow(QWidget* parent, EmuThread* emu_thread); | 106 | GRenderWindow(QWidget* parent, EmuThread* emu_thread); |
| 107 | ~GRenderWindow(); | ||
| 107 | 108 | ||
| 108 | // EmuWindow implementation | 109 | // EmuWindow implementation |
| 109 | void SwapBuffers() override; | 110 | void SwapBuffers() override; |
| @@ -127,7 +128,7 @@ public: | |||
| 127 | void mouseMoveEvent(QMouseEvent* event) override; | 128 | void mouseMoveEvent(QMouseEvent* event) override; |
| 128 | void mouseReleaseEvent(QMouseEvent* event) override; | 129 | void mouseReleaseEvent(QMouseEvent* event) override; |
| 129 | 130 | ||
| 130 | void ReloadSetKeymaps() override; | 131 | void ReloadSetKeymaps(); |
| 131 | 132 | ||
| 132 | void OnClientAreaResized(unsigned width, unsigned height); | 133 | void OnClientAreaResized(unsigned width, unsigned height); |
| 133 | 134 | ||
| @@ -152,9 +153,6 @@ private: | |||
| 152 | 153 | ||
| 153 | QByteArray geometry; | 154 | QByteArray geometry; |
| 154 | 155 | ||
| 155 | /// Device id of keyboard for use with KeyMap | ||
| 156 | int keyboard_id; | ||
| 157 | |||
| 158 | EmuThread* emu_thread; | 156 | EmuThread* emu_thread; |
| 159 | 157 | ||
| 160 | /// Motion sensors emulation | 158 | /// Motion sensors emulation |
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 5fe57dfa2..5855c7105 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "citra_qt/config.h" | 6 | #include "citra_qt/config.h" |
| 7 | #include "citra_qt/ui_settings.h" | 7 | #include "citra_qt/ui_settings.h" |
| 8 | #include "common/file_util.h" | 8 | #include "common/file_util.h" |
| 9 | #include "input_common/main.h" | ||
| 9 | 10 | ||
| 10 | Config::Config() { | 11 | Config::Config() { |
| 11 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | 12 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. |
| @@ -16,25 +17,23 @@ Config::Config() { | |||
| 16 | Reload(); | 17 | Reload(); |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> Config::defaults = { | 20 | const std::array<int, Settings::NativeButton::NumButtons> Config::default_buttons = { |
| 20 | // directly mapped keys | 21 | Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, |
| 21 | Qt::Key_A, Qt::Key_S, Qt::Key_Z, Qt::Key_X, Qt::Key_Q, Qt::Key_W, Qt::Key_1, Qt::Key_2, | 22 | Qt::Key_Q, Qt::Key_W, Qt::Key_M, Qt::Key_N, Qt::Key_1, Qt::Key_2, Qt::Key_B, |
| 22 | Qt::Key_M, Qt::Key_N, Qt::Key_B, Qt::Key_T, Qt::Key_G, Qt::Key_F, Qt::Key_H, Qt::Key_I, | ||
| 23 | Qt::Key_K, Qt::Key_J, Qt::Key_L, | ||
| 24 | |||
| 25 | // indirectly mapped keys | ||
| 26 | Qt::Key_Up, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_D, | ||
| 27 | }; | 23 | }; |
| 28 | 24 | ||
| 29 | void Config::ReadValues() { | 25 | void Config::ReadValues() { |
| 30 | qt_config->beginGroup("Controls"); | 26 | qt_config->beginGroup("Controls"); |
| 31 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | 27 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 32 | Settings::values.input_mappings[Settings::NativeInput::All[i]] = | 28 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| 33 | qt_config->value(QString::fromStdString(Settings::NativeInput::Mapping[i]), defaults[i]) | 29 | Settings::values.buttons[i] = |
| 34 | .toInt(); | 30 | qt_config |
| 31 | ->value(Settings::NativeButton::mapping[i], QString::fromStdString(default_param)) | ||
| 32 | .toString() | ||
| 33 | .toStdString(); | ||
| 34 | if (Settings::values.buttons[i].empty()) | ||
| 35 | Settings::values.buttons[i] = default_param; | ||
| 35 | } | 36 | } |
| 36 | Settings::values.pad_circle_modifier_scale = | ||
| 37 | qt_config->value("pad_circle_modifier_scale", 0.5).toFloat(); | ||
| 38 | qt_config->endGroup(); | 37 | qt_config->endGroup(); |
| 39 | 38 | ||
| 40 | qt_config->beginGroup("Core"); | 39 | qt_config->beginGroup("Core"); |
| @@ -155,12 +154,10 @@ void Config::ReadValues() { | |||
| 155 | 154 | ||
| 156 | void Config::SaveValues() { | 155 | void Config::SaveValues() { |
| 157 | qt_config->beginGroup("Controls"); | 156 | qt_config->beginGroup("Controls"); |
| 158 | for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { | 157 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 159 | qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]), | 158 | qt_config->setValue(QString::fromStdString(Settings::NativeButton::mapping[i]), |
| 160 | Settings::values.input_mappings[Settings::NativeInput::All[i]]); | 159 | QString::fromStdString(Settings::values.buttons[i])); |
| 161 | } | 160 | } |
| 162 | qt_config->setValue("pad_circle_modifier_scale", | ||
| 163 | (double)Settings::values.pad_circle_modifier_scale); | ||
| 164 | qt_config->endGroup(); | 161 | qt_config->endGroup(); |
| 165 | 162 | ||
| 166 | qt_config->beginGroup("Core"); | 163 | qt_config->beginGroup("Core"); |
diff --git a/src/citra_qt/config.h b/src/citra_qt/config.h index 79c901804..d7bf99442 100644 --- a/src/citra_qt/config.h +++ b/src/citra_qt/config.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <string> | 8 | #include <string> |
| 8 | #include <QVariant> | 9 | #include <QVariant> |
| 9 | #include "core/settings.h" | 10 | #include "core/settings.h" |
| @@ -23,5 +24,5 @@ public: | |||
| 23 | 24 | ||
| 24 | void Reload(); | 25 | void Reload(); |
| 25 | void Save(); | 26 | void Save(); |
| 26 | static const std::array<QVariant, Settings::NativeInput::NUM_INPUTS> defaults; | 27 | static const std::array<int, Settings::NativeButton::NumButtons> default_buttons; |
| 27 | }; | 28 | }; |
diff --git a/src/citra_qt/configure_input.cpp b/src/citra_qt/configure_input.cpp index c29652f32..8846a68b2 100644 --- a/src/citra_qt/configure_input.cpp +++ b/src/citra_qt/configure_input.cpp | |||
| @@ -92,14 +92,7 @@ void ConfigureInput::loadConfiguration() { | |||
| 92 | updateButtonLabels(); | 92 | updateButtonLabels(); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | void ConfigureInput::restoreDefaults() { | 95 | void ConfigureInput::restoreDefaults() {} |
| 96 | for (const auto& input_id : Settings::NativeInput::All) { | ||
| 97 | const size_t index = static_cast<size_t>(input_id); | ||
| 98 | key_map[input_id] = static_cast<Qt::Key>(Config::defaults[index].toInt()); | ||
| 99 | } | ||
| 100 | updateButtonLabels(); | ||
| 101 | applyConfiguration(); | ||
| 102 | } | ||
| 103 | 96 | ||
| 104 | void ConfigureInput::updateButtonLabels() { | 97 | void ConfigureInput::updateButtonLabels() { |
| 105 | for (const auto& input_id : Settings::NativeInput::All) { | 98 | for (const auto& input_id : Settings::NativeInput::All) { |