diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/param_package.cpp | 18 | ||||
| -rw-r--r-- | src/common/param_package.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_port.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/client_port.h | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/server_port.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/sm/sm.h | 19 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input.cpp | 87 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input.h | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input.ui | 28 |
10 files changed, 146 insertions, 19 deletions
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index 9526ca0c6..b916b4866 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp | |||
| @@ -20,7 +20,15 @@ constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0"; | |||
| 20 | constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1"; | 20 | constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1"; |
| 21 | constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2"; | 21 | constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2"; |
| 22 | 22 | ||
| 23 | /// A placeholder for empty param packages to avoid empty strings | ||
| 24 | /// (they may be recognized as "not set" by some frontend libraries like qt) | ||
| 25 | constexpr char EMPTY_PLACEHOLDER[] = "[empty]"; | ||
| 26 | |||
| 23 | ParamPackage::ParamPackage(const std::string& serialized) { | 27 | ParamPackage::ParamPackage(const std::string& serialized) { |
| 28 | if (serialized == EMPTY_PLACEHOLDER) { | ||
| 29 | return; | ||
| 30 | } | ||
| 31 | |||
| 24 | std::vector<std::string> pairs; | 32 | std::vector<std::string> pairs; |
| 25 | Common::SplitString(serialized, PARAM_SEPARATOR, pairs); | 33 | Common::SplitString(serialized, PARAM_SEPARATOR, pairs); |
| 26 | 34 | ||
| @@ -46,7 +54,7 @@ ParamPackage::ParamPackage(std::initializer_list<DataType::value_type> list) : d | |||
| 46 | 54 | ||
| 47 | std::string ParamPackage::Serialize() const { | 55 | std::string ParamPackage::Serialize() const { |
| 48 | if (data.empty()) | 56 | if (data.empty()) |
| 49 | return ""; | 57 | return EMPTY_PLACEHOLDER; |
| 50 | 58 | ||
| 51 | std::string result; | 59 | std::string result; |
| 52 | 60 | ||
| @@ -120,4 +128,12 @@ bool ParamPackage::Has(const std::string& key) const { | |||
| 120 | return data.find(key) != data.end(); | 128 | return data.find(key) != data.end(); |
| 121 | } | 129 | } |
| 122 | 130 | ||
| 131 | void ParamPackage::Erase(const std::string& key) { | ||
| 132 | data.erase(key); | ||
| 133 | } | ||
| 134 | |||
| 135 | void ParamPackage::Clear() { | ||
| 136 | data.clear(); | ||
| 137 | } | ||
| 138 | |||
| 123 | } // namespace Common | 139 | } // namespace Common |
diff --git a/src/common/param_package.h b/src/common/param_package.h index 7842cd4ef..6a0a9b656 100644 --- a/src/common/param_package.h +++ b/src/common/param_package.h | |||
| @@ -32,6 +32,8 @@ public: | |||
| 32 | void Set(const std::string& key, int value); | 32 | void Set(const std::string& key, int value); |
| 33 | void Set(const std::string& key, float value); | 33 | void Set(const std::string& key, float value); |
| 34 | bool Has(const std::string& key) const; | 34 | bool Has(const std::string& key) const; |
| 35 | void Erase(const std::string& key); | ||
| 36 | void Clear(); | ||
| 35 | 37 | ||
| 36 | private: | 38 | private: |
| 37 | DataType data; | 39 | DataType data; |
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index 873d6c516..d4c91d529 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp | |||
| @@ -17,6 +17,10 @@ namespace Kernel { | |||
| 17 | ClientPort::ClientPort(KernelCore& kernel) : Object{kernel} {} | 17 | ClientPort::ClientPort(KernelCore& kernel) : Object{kernel} {} |
| 18 | ClientPort::~ClientPort() = default; | 18 | ClientPort::~ClientPort() = default; |
| 19 | 19 | ||
| 20 | SharedPtr<ServerPort> ClientPort::GetServerPort() const { | ||
| 21 | return server_port; | ||
| 22 | } | ||
| 23 | |||
| 20 | ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() { | 24 | ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() { |
| 21 | // Note: Threads do not wait for the server endpoint to call | 25 | // Note: Threads do not wait for the server endpoint to call |
| 22 | // AcceptSession before returning from this call. | 26 | // AcceptSession before returning from this call. |
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index f3dfebbb1..6cd607206 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h | |||
| @@ -30,6 +30,8 @@ public: | |||
| 30 | return HANDLE_TYPE; | 30 | return HANDLE_TYPE; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | SharedPtr<ServerPort> GetServerPort() const; | ||
| 34 | |||
| 33 | /** | 35 | /** |
| 34 | * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's | 36 | * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's |
| 35 | * list of pending sessions, and signals the ServerPort, causing any threads | 37 | * list of pending sessions, and signals the ServerPort, causing any threads |
diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 62fb51349..e52f8245f 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "core/hle/kernel/object.h" | 12 | #include "core/hle/kernel/object.h" |
| 13 | #include "core/hle/kernel/wait_object.h" | 13 | #include "core/hle/kernel/wait_object.h" |
| 14 | #include "core/hle/result.h" | ||
| 14 | 15 | ||
| 15 | namespace Kernel { | 16 | namespace Kernel { |
| 16 | 17 | ||
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index da2c51082..4f8145dda 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h | |||
| @@ -6,9 +6,12 @@ | |||
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include <type_traits> | ||
| 9 | #include <unordered_map> | 10 | #include <unordered_map> |
| 10 | 11 | ||
| 12 | #include "core/hle/kernel/client_port.h" | ||
| 11 | #include "core/hle/kernel/object.h" | 13 | #include "core/hle/kernel/object.h" |
| 14 | #include "core/hle/kernel/server_port.h" | ||
| 12 | #include "core/hle/result.h" | 15 | #include "core/hle/result.h" |
| 13 | #include "core/hle/service/service.h" | 16 | #include "core/hle/service/service.h" |
| 14 | 17 | ||
| @@ -48,6 +51,22 @@ public: | |||
| 48 | ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name); | 51 | ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name); |
| 49 | ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ConnectToService(const std::string& name); | 52 | ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ConnectToService(const std::string& name); |
| 50 | 53 | ||
| 54 | template <typename T> | ||
| 55 | std::shared_ptr<T> GetService(const std::string& service_name) const { | ||
| 56 | static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>, | ||
| 57 | "Not a base of ServiceFrameworkBase"); | ||
| 58 | auto service = registered_services.find(service_name); | ||
| 59 | if (service == registered_services.end()) { | ||
| 60 | LOG_DEBUG(Service, "Can't find service: {}", service_name); | ||
| 61 | return nullptr; | ||
| 62 | } | ||
| 63 | auto port = service->second->GetServerPort(); | ||
| 64 | if (port == nullptr) { | ||
| 65 | return nullptr; | ||
| 66 | } | ||
| 67 | return std::static_pointer_cast<T>(port->hle_handler); | ||
| 68 | } | ||
| 69 | |||
| 51 | void InvokeControlRequest(Kernel::HLERequestContext& context); | 70 | void InvokeControlRequest(Kernel::HLERequestContext& context); |
| 52 | 71 | ||
| 53 | private: | 72 | private: |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 60dcdc184..a91bc6dee 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -252,6 +252,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() { | |||
| 252 | params.count = regs.vertex_buffer.count; | 252 | params.count = regs.vertex_buffer.count; |
| 253 | params.vertex_first = regs.vertex_buffer.first; | 253 | params.vertex_first = regs.vertex_buffer.first; |
| 254 | } | 254 | } |
| 255 | return params; | ||
| 255 | } | 256 | } |
| 256 | 257 | ||
| 257 | void RasterizerOpenGL::SetupShaders() { | 258 | void RasterizerOpenGL::SetupShaders() { |
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 473937ea9..94789c064 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | #include <QMenu> | ||
| 8 | #include <QMessageBox> | 9 | #include <QMessageBox> |
| 9 | #include <QTimer> | 10 | #include <QTimer> |
| 10 | #include "common/param_package.h" | 11 | #include "common/param_package.h" |
| @@ -128,28 +129,63 @@ ConfigureInput::ConfigureInput(QWidget* parent) | |||
| 128 | analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; | 129 | analog_map_stick = {ui->buttonLStickAnalog, ui->buttonRStickAnalog}; |
| 129 | 130 | ||
| 130 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { | 131 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { |
| 131 | if (button_map[button_id]) | 132 | if (!button_map[button_id]) |
| 132 | connect(button_map[button_id], &QPushButton::released, [=]() { | 133 | continue; |
| 133 | handleClick( | 134 | button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); |
| 134 | button_map[button_id], | 135 | connect(button_map[button_id], &QPushButton::released, [=]() { |
| 135 | [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, | 136 | handleClick( |
| 136 | InputCommon::Polling::DeviceType::Button); | 137 | button_map[button_id], |
| 137 | }); | 138 | [=](const Common::ParamPackage& params) { buttons_param[button_id] = params; }, |
| 139 | InputCommon::Polling::DeviceType::Button); | ||
| 140 | }); | ||
| 141 | connect(button_map[button_id], &QPushButton::customContextMenuRequested, | ||
| 142 | [=](const QPoint& menu_location) { | ||
| 143 | QMenu context_menu; | ||
| 144 | context_menu.addAction(tr("Clear"), [&] { | ||
| 145 | buttons_param[button_id].Clear(); | ||
| 146 | button_map[button_id]->setText(tr("[not set]")); | ||
| 147 | }); | ||
| 148 | context_menu.addAction(tr("Restore Default"), [&] { | ||
| 149 | buttons_param[button_id] = Common::ParamPackage{ | ||
| 150 | InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])}; | ||
| 151 | button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); | ||
| 152 | }); | ||
| 153 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); | ||
| 154 | }); | ||
| 138 | } | 155 | } |
| 139 | 156 | ||
| 140 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { | 157 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { |
| 141 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { | 158 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { |
| 142 | if (analog_map_buttons[analog_id][sub_button_id] != nullptr) { | 159 | if (!analog_map_buttons[analog_id][sub_button_id]) |
| 143 | connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, | 160 | continue; |
| 144 | [=]() { | 161 | analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy( |
| 145 | handleClick(analog_map_buttons[analog_id][sub_button_id], | 162 | Qt::CustomContextMenu); |
| 146 | [=](const Common::ParamPackage& params) { | 163 | connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() { |
| 147 | SetAnalogButton(params, analogs_param[analog_id], | 164 | handleClick(analog_map_buttons[analog_id][sub_button_id], |
| 148 | analog_sub_buttons[sub_button_id]); | 165 | [=](const Common::ParamPackage& params) { |
| 149 | }, | 166 | SetAnalogButton(params, analogs_param[analog_id], |
| 150 | InputCommon::Polling::DeviceType::Button); | 167 | analog_sub_buttons[sub_button_id]); |
| 168 | }, | ||
| 169 | InputCommon::Polling::DeviceType::Button); | ||
| 170 | }); | ||
| 171 | connect(analog_map_buttons[analog_id][sub_button_id], | ||
| 172 | &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) { | ||
| 173 | QMenu context_menu; | ||
| 174 | context_menu.addAction(tr("Clear"), [&] { | ||
| 175 | analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); | ||
| 176 | analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]")); | ||
| 151 | }); | 177 | }); |
| 152 | } | 178 | context_menu.addAction(tr("Restore Default"), [&] { |
| 179 | Common::ParamPackage params{InputCommon::GenerateKeyboardParam( | ||
| 180 | Config::default_analogs[analog_id][sub_button_id])}; | ||
| 181 | SetAnalogButton(params, analogs_param[analog_id], | ||
| 182 | analog_sub_buttons[sub_button_id]); | ||
| 183 | analog_map_buttons[analog_id][sub_button_id]->setText(AnalogToText( | ||
| 184 | analogs_param[analog_id], analog_sub_buttons[sub_button_id])); | ||
| 185 | }); | ||
| 186 | context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal( | ||
| 187 | menu_location)); | ||
| 188 | }); | ||
| 153 | } | 189 | } |
| 154 | connect(analog_map_stick[analog_id], &QPushButton::released, [=]() { | 190 | connect(analog_map_stick[analog_id], &QPushButton::released, [=]() { |
| 155 | QMessageBox::information(this, tr("Information"), | 191 | QMessageBox::information(this, tr("Information"), |
| @@ -162,6 +198,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) | |||
| 162 | }); | 198 | }); |
| 163 | } | 199 | } |
| 164 | 200 | ||
| 201 | connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); }); | ||
| 165 | connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); }); | 202 | connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); }); |
| 166 | 203 | ||
| 167 | timeout_timer->setSingleShot(true); | 204 | timeout_timer->setSingleShot(true); |
| @@ -215,7 +252,21 @@ void ConfigureInput::restoreDefaults() { | |||
| 215 | } | 252 | } |
| 216 | } | 253 | } |
| 217 | updateButtonLabels(); | 254 | updateButtonLabels(); |
| 218 | applyConfiguration(); | 255 | } |
| 256 | |||
| 257 | void ConfigureInput::ClearAll() { | ||
| 258 | for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) { | ||
| 259 | if (button_map[button_id] && button_map[button_id]->isEnabled()) | ||
| 260 | buttons_param[button_id].Clear(); | ||
| 261 | } | ||
| 262 | for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { | ||
| 263 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) { | ||
| 264 | if (analog_map_buttons[analog_id][sub_button_id] && | ||
| 265 | analog_map_buttons[analog_id][sub_button_id]->isEnabled()) | ||
| 266 | analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); | ||
| 267 | } | ||
| 268 | } | ||
| 269 | updateButtonLabels(); | ||
| 219 | } | 270 | } |
| 220 | 271 | ||
| 221 | void ConfigureInput::updateButtonLabels() { | 272 | void ConfigureInput::updateButtonLabels() { |
diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h index a0bef86d5..d1198db81 100644 --- a/src/yuzu/configuration/configure_input.h +++ b/src/yuzu/configuration/configure_input.h | |||
| @@ -72,6 +72,9 @@ private: | |||
| 72 | void loadConfiguration(); | 72 | void loadConfiguration(); |
| 73 | /// Restore all buttons to their default values. | 73 | /// Restore all buttons to their default values. |
| 74 | void restoreDefaults(); | 74 | void restoreDefaults(); |
| 75 | /// Clear all input configuration | ||
| 76 | void ClearAll(); | ||
| 77 | |||
| 75 | /// Update UI to reflect current configuration. | 78 | /// Update UI to reflect current configuration. |
| 76 | void updateButtonLabels(); | 79 | void updateButtonLabels(); |
| 77 | 80 | ||
diff --git a/src/yuzu/configuration/configure_input.ui b/src/yuzu/configuration/configure_input.ui index 8bfa5df62..8a019a693 100644 --- a/src/yuzu/configuration/configure_input.ui +++ b/src/yuzu/configuration/configure_input.ui | |||
| @@ -695,6 +695,34 @@ Capture:</string> | |||
| 695 | </spacer> | 695 | </spacer> |
| 696 | </item> | 696 | </item> |
| 697 | <item> | 697 | <item> |
| 698 | <widget class="QPushButton" name="buttonClearAll"> | ||
| 699 | <property name="sizePolicy"> | ||
| 700 | <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> | ||
| 701 | <horstretch>0</horstretch> | ||
| 702 | <verstretch>0</verstretch> | ||
| 703 | </sizepolicy> | ||
| 704 | </property> | ||
| 705 | <property name="sizeIncrement"> | ||
| 706 | <size> | ||
| 707 | <width>0</width> | ||
| 708 | <height>0</height> | ||
| 709 | </size> | ||
| 710 | </property> | ||
| 711 | <property name="baseSize"> | ||
| 712 | <size> | ||
| 713 | <width>0</width> | ||
| 714 | <height>0</height> | ||
| 715 | </size> | ||
| 716 | </property> | ||
| 717 | <property name="layoutDirection"> | ||
| 718 | <enum>Qt::LeftToRight</enum> | ||
| 719 | </property> | ||
| 720 | <property name="text"> | ||
| 721 | <string>Clear All</string> | ||
| 722 | </property> | ||
| 723 | </widget> | ||
| 724 | </item> | ||
| 725 | <item> | ||
| 698 | <widget class="QPushButton" name="buttonRestoreDefaults"> | 726 | <widget class="QPushButton" name="buttonRestoreDefaults"> |
| 699 | <property name="sizePolicy"> | 727 | <property name="sizePolicy"> |
| 700 | <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> | 728 | <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |