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 | 54 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.hxx | 3 | ||||
| -rw-r--r-- | src/citra_qt/config.cpp | 79 | ||||
| -rw-r--r-- | src/citra_qt/config.h | 23 | ||||
| -rw-r--r-- | src/citra_qt/main.cpp | 5 |
6 files changed, 135 insertions, 31 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 426e4ef99..98a48a69a 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt | |||
| @@ -4,6 +4,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) | |||
| 4 | set(SRCS | 4 | set(SRCS |
| 5 | config/controller_config.cpp | 5 | config/controller_config.cpp |
| 6 | config/controller_config_util.cpp | 6 | config/controller_config_util.cpp |
| 7 | config.cpp | ||
| 7 | debugger/callstack.cpp | 8 | debugger/callstack.cpp |
| 8 | debugger/disassembler.cpp | 9 | debugger/disassembler.cpp |
| 9 | debugger/graphics.cpp | 10 | debugger/graphics.cpp |
| @@ -18,6 +19,7 @@ set(SRCS | |||
| 18 | set(HEADERS | 19 | set(HEADERS |
| 19 | config/controller_config.hxx | 20 | config/controller_config.hxx |
| 20 | config/controller_config_util.hxx | 21 | config/controller_config_util.hxx |
| 22 | config.h | ||
| 21 | debugger/callstack.hxx | 23 | debugger/callstack.hxx |
| 22 | debugger/disassembler.hxx | 24 | debugger/disassembler.hxx |
| 23 | debugger/graphics.hxx | 25 | debugger/graphics.hxx |
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index cf4d8b32b..5dce9e570 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp | |||
| @@ -6,12 +6,11 @@ | |||
| 6 | #include "bootmanager.hxx" | 6 | #include "bootmanager.hxx" |
| 7 | 7 | ||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/loader/loader.h" | 9 | #include "core/settings.h" |
| 10 | #include "core/hw/hw.h" | ||
| 11 | 10 | ||
| 12 | #include "video_core/video_core.h" | 11 | #include "video_core/video_core.h" |
| 13 | 12 | ||
| 14 | #include "version.h" | 13 | #include "citra_qt/version.h" |
| 15 | 14 | ||
| 16 | #define APP_NAME "citra" | 15 | #define APP_NAME "citra" |
| 17 | #define APP_VERSION "0.1-" VERSION | 16 | #define APP_VERSION "0.1-" VERSION |
| @@ -102,40 +101,15 @@ private: | |||
| 102 | GRenderWindow* parent_; | 101 | GRenderWindow* parent_; |
| 103 | }; | 102 | }; |
| 104 | 103 | ||
| 105 | |||
| 106 | EmuThread& GRenderWindow::GetEmuThread() | 104 | EmuThread& GRenderWindow::GetEmuThread() |
| 107 | { | 105 | { |
| 108 | return emu_thread; | 106 | return emu_thread; |
| 109 | } | 107 | } |
| 110 | 108 | ||
| 111 | static const std::pair<int, HID_User::PadState> default_key_map[] = { | 109 | GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this), keyboard_id(0) |
| 112 | { Qt::Key_A, HID_User::PAD_A }, | ||
| 113 | { Qt::Key_B, HID_User::PAD_B }, | ||
| 114 | { Qt::Key_Backslash, HID_User::PAD_SELECT }, | ||
| 115 | { Qt::Key_Enter, HID_User::PAD_START }, | ||
| 116 | { Qt::Key_Right, HID_User::PAD_RIGHT }, | ||
| 117 | { Qt::Key_Left, HID_User::PAD_LEFT }, | ||
| 118 | { Qt::Key_Up, HID_User::PAD_UP }, | ||
| 119 | { Qt::Key_Down, HID_User::PAD_DOWN }, | ||
| 120 | { Qt::Key_R, HID_User::PAD_R }, | ||
| 121 | { Qt::Key_L, HID_User::PAD_L }, | ||
| 122 | { Qt::Key_X, HID_User::PAD_X }, | ||
| 123 | { Qt::Key_Y, HID_User::PAD_Y }, | ||
| 124 | { Qt::Key_H, HID_User::PAD_CIRCLE_RIGHT }, | ||
| 125 | { Qt::Key_F, HID_User::PAD_CIRCLE_LEFT }, | ||
| 126 | { Qt::Key_T, HID_User::PAD_CIRCLE_UP }, | ||
| 127 | { Qt::Key_G, HID_User::PAD_CIRCLE_DOWN }, | ||
| 128 | }; | ||
| 129 | |||
| 130 | GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this) | ||
| 131 | { | 110 | { |
| 132 | // Register a new ID for the default keyboard | ||
| 133 | keyboard_id = KeyMap::NewDeviceId(); | 111 | keyboard_id = KeyMap::NewDeviceId(); |
| 134 | 112 | ReloadSetKeymaps(); | |
| 135 | // Set default key mappings for keyboard | ||
| 136 | for (auto mapping : default_key_map) { | ||
| 137 | KeyMap::SetKeyMapping({mapping.first, keyboard_id}, mapping.second); | ||
| 138 | } | ||
| 139 | 113 | ||
| 140 | // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose | 114 | // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose |
| 141 | QGLFormat fmt; | 115 | QGLFormat fmt; |
| @@ -245,3 +219,23 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event) | |||
| 245 | HID_User::PadUpdateComplete(); | 219 | HID_User::PadUpdateComplete(); |
| 246 | } | 220 | } |
| 247 | 221 | ||
| 222 | void GRenderWindow::ReloadSetKeymaps() | ||
| 223 | { | ||
| 224 | KeyMap::SetKeyMapping({Settings::values.pad_a_key, keyboard_id}, HID_User::PAD_A); | ||
| 225 | KeyMap::SetKeyMapping({Settings::values.pad_b_key, keyboard_id}, HID_User::PAD_B); | ||
| 226 | KeyMap::SetKeyMapping({Settings::values.pad_select_key, keyboard_id}, HID_User::PAD_SELECT); | ||
| 227 | KeyMap::SetKeyMapping({Settings::values.pad_start_key, keyboard_id}, HID_User::PAD_START); | ||
| 228 | KeyMap::SetKeyMapping({Settings::values.pad_dright_key, keyboard_id}, HID_User::PAD_RIGHT); | ||
| 229 | KeyMap::SetKeyMapping({Settings::values.pad_dleft_key, keyboard_id}, HID_User::PAD_LEFT); | ||
| 230 | KeyMap::SetKeyMapping({Settings::values.pad_dup_key, keyboard_id}, HID_User::PAD_UP); | ||
| 231 | KeyMap::SetKeyMapping({Settings::values.pad_ddown_key, keyboard_id}, HID_User::PAD_DOWN); | ||
| 232 | KeyMap::SetKeyMapping({Settings::values.pad_r_key, keyboard_id}, HID_User::PAD_R); | ||
| 233 | KeyMap::SetKeyMapping({Settings::values.pad_l_key, keyboard_id}, HID_User::PAD_L); | ||
| 234 | KeyMap::SetKeyMapping({Settings::values.pad_x_key, keyboard_id}, HID_User::PAD_X); | ||
| 235 | KeyMap::SetKeyMapping({Settings::values.pad_y_key, keyboard_id}, HID_User::PAD_Y); | ||
| 236 | KeyMap::SetKeyMapping({Settings::values.pad_sright_key, keyboard_id}, HID_User::PAD_CIRCLE_RIGHT); | ||
| 237 | KeyMap::SetKeyMapping({Settings::values.pad_sleft_key, keyboard_id}, HID_User::PAD_CIRCLE_LEFT); | ||
| 238 | KeyMap::SetKeyMapping({Settings::values.pad_sup_key, keyboard_id}, HID_User::PAD_CIRCLE_UP); | ||
| 239 | KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); | ||
| 240 | } | ||
| 241 | |||
diff --git a/src/citra_qt/bootmanager.hxx b/src/citra_qt/bootmanager.hxx index eedf19471..816ffed2e 100644 --- a/src/citra_qt/bootmanager.hxx +++ b/src/citra_qt/bootmanager.hxx | |||
| @@ -107,6 +107,8 @@ public: | |||
| 107 | void keyPressEvent(QKeyEvent* event); | 107 | void keyPressEvent(QKeyEvent* event); |
| 108 | void keyReleaseEvent(QKeyEvent* event); | 108 | void keyReleaseEvent(QKeyEvent* event); |
| 109 | 109 | ||
| 110 | void ReloadSetKeymaps() override; | ||
| 111 | |||
| 110 | public slots: | 112 | public slots: |
| 111 | void moveContext(); | 113 | void moveContext(); |
| 112 | 114 | ||
| @@ -117,5 +119,6 @@ private: | |||
| 117 | 119 | ||
| 118 | QByteArray geometry; | 120 | QByteArray geometry; |
| 119 | 121 | ||
| 122 | /// Device id of keyboard for use with KeyMap | ||
| 120 | int keyboard_id; | 123 | int keyboard_id; |
| 121 | }; | 124 | }; |
diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp new file mode 100644 index 000000000..1b116edc5 --- /dev/null +++ b/src/citra_qt/config.cpp | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <QString> | ||
| 6 | #include <QStringList> | ||
| 7 | |||
| 8 | #include "core/settings.h" | ||
| 9 | #include "common/file_util.h" | ||
| 10 | |||
| 11 | #include "config.h" | ||
| 12 | |||
| 13 | Config::Config() { | ||
| 14 | |||
| 15 | // TODO: Don't hardcode the path; let the frontend decide where to put the config files. | ||
| 16 | qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; | ||
| 17 | FileUtil::CreateFullPath(qt_config_loc); | ||
| 18 | qt_config = new QSettings(QString::fromStdString(qt_config_loc), QSettings::IniFormat); | ||
| 19 | |||
| 20 | Reload(); | ||
| 21 | } | ||
| 22 | |||
| 23 | void Config::ReadControls() { | ||
| 24 | qt_config->beginGroup("Controls"); | ||
| 25 | Settings::values.pad_a_key = qt_config->value("pad_a", Qt::Key_A).toInt(); | ||
| 26 | Settings::values.pad_b_key = qt_config->value("pad_b", Qt::Key_S).toInt(); | ||
| 27 | Settings::values.pad_x_key = qt_config->value("pad_x", Qt::Key_Z).toInt(); | ||
| 28 | Settings::values.pad_y_key = qt_config->value("pad_y", Qt::Key_X).toInt(); | ||
| 29 | Settings::values.pad_l_key = qt_config->value("pad_l", Qt::Key_Q).toInt(); | ||
| 30 | Settings::values.pad_r_key = qt_config->value("pad_r", Qt::Key_W).toInt(); | ||
| 31 | Settings::values.pad_start_key = qt_config->value("pad_start", Qt::Key_M).toInt(); | ||
| 32 | Settings::values.pad_select_key = qt_config->value("pad_select", Qt::Key_N).toInt(); | ||
| 33 | Settings::values.pad_home_key = qt_config->value("pad_home", Qt::Key_B).toInt(); | ||
| 34 | Settings::values.pad_dup_key = qt_config->value("pad_dup", Qt::Key_T).toInt(); | ||
| 35 | Settings::values.pad_ddown_key = qt_config->value("pad_ddown", Qt::Key_G).toInt(); | ||
| 36 | Settings::values.pad_dleft_key = qt_config->value("pad_dleft", Qt::Key_F).toInt(); | ||
| 37 | Settings::values.pad_dright_key = qt_config->value("pad_dright", Qt::Key_H).toInt(); | ||
| 38 | Settings::values.pad_sup_key = qt_config->value("pad_sup", Qt::Key_Up).toInt(); | ||
| 39 | Settings::values.pad_sdown_key = qt_config->value("pad_sdown", Qt::Key_Down).toInt(); | ||
| 40 | Settings::values.pad_sleft_key = qt_config->value("pad_sleft", Qt::Key_Left).toInt(); | ||
| 41 | Settings::values.pad_sright_key = qt_config->value("pad_sright", Qt::Key_Right).toInt(); | ||
| 42 | qt_config->endGroup(); | ||
| 43 | } | ||
| 44 | |||
| 45 | void Config::SaveControls() { | ||
| 46 | qt_config->beginGroup("Controls"); | ||
| 47 | qt_config->setValue("pad_a", Settings::values.pad_a_key); | ||
| 48 | qt_config->setValue("pad_b", Settings::values.pad_b_key); | ||
| 49 | qt_config->setValue("pad_x", Settings::values.pad_x_key); | ||
| 50 | qt_config->setValue("pad_y", Settings::values.pad_y_key); | ||
| 51 | qt_config->setValue("pad_l", Settings::values.pad_l_key); | ||
| 52 | qt_config->setValue("pad_r", Settings::values.pad_r_key); | ||
| 53 | qt_config->setValue("pad_start", Settings::values.pad_start_key); | ||
| 54 | qt_config->setValue("pad_select", Settings::values.pad_select_key); | ||
| 55 | qt_config->setValue("pad_home", Settings::values.pad_home_key); | ||
| 56 | qt_config->setValue("pad_dup", Settings::values.pad_dup_key); | ||
| 57 | qt_config->setValue("pad_ddown", Settings::values.pad_ddown_key); | ||
| 58 | qt_config->setValue("pad_dleft", Settings::values.pad_dleft_key); | ||
| 59 | qt_config->setValue("pad_dright", Settings::values.pad_dright_key); | ||
| 60 | qt_config->setValue("pad_sup", Settings::values.pad_sup_key); | ||
| 61 | qt_config->setValue("pad_sdown", Settings::values.pad_sdown_key); | ||
| 62 | qt_config->setValue("pad_sleft", Settings::values.pad_sleft_key); | ||
| 63 | qt_config->setValue("pad_sright", Settings::values.pad_sright_key); | ||
| 64 | qt_config->endGroup(); | ||
| 65 | } | ||
| 66 | |||
| 67 | void Config::Reload() { | ||
| 68 | ReadControls(); | ||
| 69 | } | ||
| 70 | |||
| 71 | void Config::Save() { | ||
| 72 | SaveControls(); | ||
| 73 | } | ||
| 74 | |||
| 75 | Config::~Config() { | ||
| 76 | Save(); | ||
| 77 | |||
| 78 | delete qt_config; | ||
| 79 | } | ||
diff --git a/src/citra_qt/config.h b/src/citra_qt/config.h new file mode 100644 index 000000000..ae390be6b --- /dev/null +++ b/src/citra_qt/config.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <QSettings> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | class Config { | ||
| 12 | QSettings* qt_config; | ||
| 13 | std::string qt_config_loc; | ||
| 14 | |||
| 15 | void ReadControls(); | ||
| 16 | void SaveControls(); | ||
| 17 | public: | ||
| 18 | Config(); | ||
| 19 | ~Config(); | ||
| 20 | |||
| 21 | void Reload(); | ||
| 22 | void Save(); | ||
| 23 | }; | ||
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 1bf9bc53c..bac6a6bb8 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -26,12 +26,16 @@ | |||
| 26 | #include "core/core.h" | 26 | #include "core/core.h" |
| 27 | #include "core/loader/loader.h" | 27 | #include "core/loader/loader.h" |
| 28 | #include "core/arm/disassembler/load_symbol_map.h" | 28 | #include "core/arm/disassembler/load_symbol_map.h" |
| 29 | #include "citra_qt/config.h" | ||
| 29 | 30 | ||
| 30 | #include "version.h" | 31 | #include "version.h" |
| 31 | 32 | ||
| 32 | 33 | ||
| 33 | GMainWindow::GMainWindow() | 34 | GMainWindow::GMainWindow() |
| 34 | { | 35 | { |
| 36 | LogManager::Init(); | ||
| 37 | Config config; | ||
| 38 | |||
| 35 | ui.setupUi(this); | 39 | ui.setupUi(this); |
| 36 | statusBar()->hide(); | 40 | statusBar()->hide(); |
| 37 | 41 | ||
| @@ -112,7 +116,6 @@ GMainWindow::GMainWindow() | |||
| 112 | 116 | ||
| 113 | show(); | 117 | show(); |
| 114 | 118 | ||
| 115 | LogManager::Init(); | ||
| 116 | System::Init(render_window); | 119 | System::Init(render_window); |
| 117 | } | 120 | } |
| 118 | 121 | ||