diff options
| author | 2022-12-26 12:49:49 -0600 | |
|---|---|---|
| committer | 2023-01-19 18:05:22 -0600 | |
| commit | 5cb437703fa441a08db295f8a916caedc3a581f2 (patch) | |
| tree | 148c35e47d18462f0b8f8e116e2247b4cbfdbde2 /src | |
| parent | input_common: Use DriverResult on all engines (diff) | |
| download | yuzu-5cb437703fa441a08db295f8a916caedc3a581f2.tar.gz yuzu-5cb437703fa441a08db295f8a916caedc3a581f2.tar.xz yuzu-5cb437703fa441a08db295f8a916caedc3a581f2.zip | |
yuzu: Add ring controller test button
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 10 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nfc/nfc_device.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp_device.cpp | 3 | ||||
| -rw-r--r-- | src/input_common/drivers/virtual_amiibo.cpp | 9 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 38 | ||||
| -rw-r--r-- | src/input_common/helpers/joycon_driver.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_ringcon.cpp | 69 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_ringcon.h | 10 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_ringcon.ui | 396 |
10 files changed, 370 insertions, 174 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 62da5be6c..915ffa490 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -1200,7 +1200,8 @@ bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { | |||
| 1200 | return output_devices[device_index]->IsVibrationEnabled(); | 1200 | return output_devices[device_index]->IsVibrationEnabled(); |
| 1201 | } | 1201 | } |
| 1202 | 1202 | ||
| 1203 | bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode) { | 1203 | Common::Input::DriverResult EmulatedController::SetPollingMode( |
| 1204 | Common::Input::PollingMode polling_mode) { | ||
| 1204 | LOG_INFO(Service_HID, "Set polling mode {}", polling_mode); | 1205 | LOG_INFO(Service_HID, "Set polling mode {}", polling_mode); |
| 1205 | auto& output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; | 1206 | auto& output_device = output_devices[static_cast<std::size_t>(DeviceIndex::Right)]; |
| 1206 | auto& nfc_output_device = output_devices[3]; | 1207 | auto& nfc_output_device = output_devices[3]; |
| @@ -1208,8 +1209,11 @@ bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode) | |||
| 1208 | const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode); | 1209 | const auto virtual_nfc_result = nfc_output_device->SetPollingMode(polling_mode); |
| 1209 | const auto mapped_nfc_result = output_device->SetPollingMode(polling_mode); | 1210 | const auto mapped_nfc_result = output_device->SetPollingMode(polling_mode); |
| 1210 | 1211 | ||
| 1211 | return virtual_nfc_result == Common::Input::DriverResult::Success || | 1212 | if (virtual_nfc_result == Common::Input::DriverResult::Success) { |
| 1212 | mapped_nfc_result == Common::Input::DriverResult::Success; | 1213 | return virtual_nfc_result; |
| 1214 | } | ||
| 1215 | |||
| 1216 | return mapped_nfc_result; | ||
| 1213 | } | 1217 | } |
| 1214 | 1218 | ||
| 1215 | bool EmulatedController::SetCameraFormat( | 1219 | bool EmulatedController::SetCameraFormat( |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index c517aa5d7..fb931fc0a 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -363,9 +363,9 @@ public: | |||
| 363 | /** | 363 | /** |
| 364 | * Sets the desired data to be polled from a controller | 364 | * Sets the desired data to be polled from a controller |
| 365 | * @param polling_mode type of input desired buttons, gyro, nfc, ir, etc. | 365 | * @param polling_mode type of input desired buttons, gyro, nfc, ir, etc. |
| 366 | * @return true if SetPollingMode was successfull | 366 | * @return driver result from this command |
| 367 | */ | 367 | */ |
| 368 | bool SetPollingMode(Common::Input::PollingMode polling_mode); | 368 | Common::Input::DriverResult SetPollingMode(Common::Input::PollingMode polling_mode); |
| 369 | 369 | ||
| 370 | /** | 370 | /** |
| 371 | * Sets the desired camera format to be polled from a controller | 371 | * Sets the desired camera format to be polled from a controller |
diff --git a/src/core/hle/service/nfc/nfc_device.cpp b/src/core/hle/service/nfc/nfc_device.cpp index 78578f723..c9815edbc 100644 --- a/src/core/hle/service/nfc/nfc_device.cpp +++ b/src/core/hle/service/nfc/nfc_device.cpp | |||
| @@ -130,7 +130,8 @@ Result NfcDevice::StartDetection(NFP::TagProtocol allowed_protocol) { | |||
| 130 | return WrongDeviceState; | 130 | return WrongDeviceState; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | if (!npad_device->SetPollingMode(Common::Input::PollingMode::NFC)) { | 133 | if (npad_device->SetPollingMode(Common::Input::PollingMode::NFC) != |
| 134 | Common::Input::DriverResult::Success) { | ||
| 134 | LOG_ERROR(Service_NFC, "Nfc not supported"); | 135 | LOG_ERROR(Service_NFC, "Nfc not supported"); |
| 135 | return NfcDisabled; | 136 | return NfcDisabled; |
| 136 | } | 137 | } |
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp index c860fd1a1..7b8013961 100644 --- a/src/core/hle/service/nfp/nfp_device.cpp +++ b/src/core/hle/service/nfp/nfp_device.cpp | |||
| @@ -152,7 +152,8 @@ Result NfpDevice::StartDetection(TagProtocol allowed_protocol) { | |||
| 152 | return WrongDeviceState; | 152 | return WrongDeviceState; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | if (!npad_device->SetPollingMode(Common::Input::PollingMode::NFC)) { | 155 | if (npad_device->SetPollingMode(Common::Input::PollingMode::NFC) != |
| 156 | Common::Input::DriverResult::Success) { | ||
| 156 | LOG_ERROR(Service_NFP, "Nfc not supported"); | 157 | LOG_ERROR(Service_NFP, "Nfc not supported"); |
| 157 | return NfcDisabled; | 158 | return NfcDisabled; |
| 158 | } | 159 | } |
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 29e129d3c..4a0268a4d 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp | |||
| @@ -27,17 +27,18 @@ Common::Input::DriverResult VirtualAmiibo::SetPollingMode( | |||
| 27 | const Common::Input::PollingMode polling_mode_) { | 27 | const Common::Input::PollingMode polling_mode_) { |
| 28 | polling_mode = polling_mode_; | 28 | polling_mode = polling_mode_; |
| 29 | 29 | ||
| 30 | if (polling_mode == Common::Input::PollingMode::NFC) { | 30 | switch (polling_mode) { |
| 31 | case Common::Input::PollingMode::NFC: | ||
| 31 | if (state == State::Initialized) { | 32 | if (state == State::Initialized) { |
| 32 | state = State::WaitingForAmiibo; | 33 | state = State::WaitingForAmiibo; |
| 33 | } | 34 | } |
| 34 | } else { | 35 | return Common::Input::DriverResult::Success; |
| 36 | default: | ||
| 35 | if (state == State::AmiiboIsOpen) { | 37 | if (state == State::AmiiboIsOpen) { |
| 36 | CloseAmiibo(); | 38 | CloseAmiibo(); |
| 37 | } | 39 | } |
| 40 | return Common::Input::DriverResult::NotSupported; | ||
| 38 | } | 41 | } |
| 39 | |||
| 40 | return Common::Input::DriverResult::Success; | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | Common::Input::NfcState VirtualAmiibo::SupportsNfc( | 44 | Common::Input::NfcState VirtualAmiibo::SupportsNfc( |
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index b00b6110b..8217ba7f6 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp | |||
| @@ -238,7 +238,7 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) { | |||
| 238 | } | 238 | } |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | void JoyconDriver::SetPollingMode() { | 241 | DriverResult JoyconDriver::SetPollingMode() { |
| 242 | disable_input_thread = true; | 242 | disable_input_thread = true; |
| 243 | 243 | ||
| 244 | rumble_protocol->EnableRumble(vibration_enabled && supported_features.vibration); | 244 | rumble_protocol->EnableRumble(vibration_enabled && supported_features.vibration); |
| @@ -263,7 +263,7 @@ void JoyconDriver::SetPollingMode() { | |||
| 263 | } | 263 | } |
| 264 | if (result == DriverResult::Success) { | 264 | if (result == DriverResult::Success) { |
| 265 | disable_input_thread = false; | 265 | disable_input_thread = false; |
| 266 | return; | 266 | return result; |
| 267 | } | 267 | } |
| 268 | nfc_protocol->DisableNfc(); | 268 | nfc_protocol->DisableNfc(); |
| 269 | LOG_ERROR(Input, "Error enabling NFC"); | 269 | LOG_ERROR(Input, "Error enabling NFC"); |
| @@ -282,7 +282,7 @@ void JoyconDriver::SetPollingMode() { | |||
| 282 | if (result == DriverResult::Success) { | 282 | if (result == DriverResult::Success) { |
| 283 | ring_connected = true; | 283 | ring_connected = true; |
| 284 | disable_input_thread = false; | 284 | disable_input_thread = false; |
| 285 | return; | 285 | return result; |
| 286 | } | 286 | } |
| 287 | ring_connected = false; | 287 | ring_connected = false; |
| 288 | ring_protocol->DisableRingCon(); | 288 | ring_protocol->DisableRingCon(); |
| @@ -293,7 +293,7 @@ void JoyconDriver::SetPollingMode() { | |||
| 293 | const auto result = generic_protocol->EnablePassiveMode(); | 293 | const auto result = generic_protocol->EnablePassiveMode(); |
| 294 | if (result == DriverResult::Success) { | 294 | if (result == DriverResult::Success) { |
| 295 | disable_input_thread = false; | 295 | disable_input_thread = false; |
| 296 | return; | 296 | return result; |
| 297 | } | 297 | } |
| 298 | LOG_ERROR(Input, "Error enabling passive mode"); | 298 | LOG_ERROR(Input, "Error enabling passive mode"); |
| 299 | } | 299 | } |
| @@ -305,6 +305,7 @@ void JoyconDriver::SetPollingMode() { | |||
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | disable_input_thread = false; | 307 | disable_input_thread = false; |
| 308 | return result; | ||
| 308 | } | 309 | } |
| 309 | 310 | ||
| 310 | JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() { | 311 | JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() { |
| @@ -380,8 +381,7 @@ DriverResult JoyconDriver::SetPasiveMode() { | |||
| 380 | hidbus_enabled = false; | 381 | hidbus_enabled = false; |
| 381 | nfc_enabled = false; | 382 | nfc_enabled = false; |
| 382 | passive_enabled = true; | 383 | passive_enabled = true; |
| 383 | SetPollingMode(); | 384 | return SetPollingMode(); |
| 384 | return DriverResult::Success; | ||
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | DriverResult JoyconDriver::SetActiveMode() { | 387 | DriverResult JoyconDriver::SetActiveMode() { |
| @@ -390,28 +390,42 @@ DriverResult JoyconDriver::SetActiveMode() { | |||
| 390 | hidbus_enabled = false; | 390 | hidbus_enabled = false; |
| 391 | nfc_enabled = false; | 391 | nfc_enabled = false; |
| 392 | passive_enabled = false; | 392 | passive_enabled = false; |
| 393 | SetPollingMode(); | 393 | return SetPollingMode(); |
| 394 | return DriverResult::Success; | ||
| 395 | } | 394 | } |
| 396 | 395 | ||
| 397 | DriverResult JoyconDriver::SetNfcMode() { | 396 | DriverResult JoyconDriver::SetNfcMode() { |
| 398 | std::scoped_lock lock{mutex}; | 397 | std::scoped_lock lock{mutex}; |
| 398 | |||
| 399 | if (!supported_features.nfc) { | ||
| 400 | return DriverResult::NotSupported; | ||
| 401 | } | ||
| 402 | |||
| 399 | motion_enabled = true; | 403 | motion_enabled = true; |
| 400 | hidbus_enabled = false; | 404 | hidbus_enabled = false; |
| 401 | nfc_enabled = true; | 405 | nfc_enabled = true; |
| 402 | passive_enabled = false; | 406 | passive_enabled = false; |
| 403 | SetPollingMode(); | 407 | return SetPollingMode(); |
| 404 | return DriverResult::Success; | ||
| 405 | } | 408 | } |
| 406 | 409 | ||
| 407 | DriverResult JoyconDriver::SetRingConMode() { | 410 | DriverResult JoyconDriver::SetRingConMode() { |
| 408 | std::scoped_lock lock{mutex}; | 411 | std::scoped_lock lock{mutex}; |
| 412 | |||
| 413 | if (!supported_features.hidbus) { | ||
| 414 | return DriverResult::NotSupported; | ||
| 415 | } | ||
| 416 | |||
| 409 | motion_enabled = true; | 417 | motion_enabled = true; |
| 410 | hidbus_enabled = true; | 418 | hidbus_enabled = true; |
| 411 | nfc_enabled = false; | 419 | nfc_enabled = false; |
| 412 | passive_enabled = false; | 420 | passive_enabled = false; |
| 413 | SetPollingMode(); | 421 | |
| 414 | return DriverResult::Success; | 422 | const auto result = SetPollingMode(); |
| 423 | |||
| 424 | if (!ring_connected) { | ||
| 425 | return DriverResult::NoDeviceDetected; | ||
| 426 | } | ||
| 427 | |||
| 428 | return result; | ||
| 415 | } | 429 | } |
| 416 | 430 | ||
| 417 | bool JoyconDriver::IsConnected() const { | 431 | bool JoyconDriver::IsConnected() const { |
diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index bf38a3009..5ff15c784 100644 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h | |||
| @@ -73,7 +73,7 @@ private: | |||
| 73 | void OnNewData(std::span<u8> buffer); | 73 | void OnNewData(std::span<u8> buffer); |
| 74 | 74 | ||
| 75 | /// Updates device configuration to enable or disable features | 75 | /// Updates device configuration to enable or disable features |
| 76 | void SetPollingMode(); | 76 | DriverResult SetPollingMode(); |
| 77 | 77 | ||
| 78 | /// Returns true if input thread is valid and doesn't need to be stopped | 78 | /// Returns true if input thread is valid and doesn't need to be stopped |
| 79 | bool IsInputThreadValid() const; | 79 | bool IsInputThreadValid() const; |
diff --git a/src/yuzu/configuration/configure_ringcon.cpp b/src/yuzu/configuration/configure_ringcon.cpp index 0cfe3b60e..697c36fb4 100644 --- a/src/yuzu/configuration/configure_ringcon.cpp +++ b/src/yuzu/configuration/configure_ringcon.cpp | |||
| @@ -4,7 +4,9 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | #include <QKeyEvent> | 5 | #include <QKeyEvent> |
| 6 | #include <QMenu> | 6 | #include <QMenu> |
| 7 | #include <QMessageBox> | ||
| 7 | #include <QTimer> | 8 | #include <QTimer> |
| 9 | #include <fmt/format.h> | ||
| 8 | 10 | ||
| 9 | #include "core/hid/emulated_controller.h" | 11 | #include "core/hid/emulated_controller.h" |
| 10 | #include "core/hid/hid_core.h" | 12 | #include "core/hid/hid_core.h" |
| @@ -130,6 +132,13 @@ ConfigureRingController::ConfigureRingController(QWidget* parent, | |||
| 130 | emulated_controller->SaveCurrentConfig(); | 132 | emulated_controller->SaveCurrentConfig(); |
| 131 | emulated_controller->EnableConfiguration(); | 133 | emulated_controller->EnableConfiguration(); |
| 132 | 134 | ||
| 135 | Core::HID::ControllerUpdateCallback engine_callback{ | ||
| 136 | .on_change = [this](Core::HID::ControllerTriggerType type) { ControllerUpdate(type); }, | ||
| 137 | .is_npad_service = false, | ||
| 138 | }; | ||
| 139 | callback_key = emulated_controller->SetCallback(engine_callback); | ||
| 140 | is_controller_set = true; | ||
| 141 | |||
| 133 | LoadConfiguration(); | 142 | LoadConfiguration(); |
| 134 | 143 | ||
| 135 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { | 144 | for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { |
| @@ -187,6 +196,9 @@ ConfigureRingController::ConfigureRingController(QWidget* parent, | |||
| 187 | connect(ui->restore_defaults_button, &QPushButton::clicked, this, | 196 | connect(ui->restore_defaults_button, &QPushButton::clicked, this, |
| 188 | &ConfigureRingController::RestoreDefaults); | 197 | &ConfigureRingController::RestoreDefaults); |
| 189 | 198 | ||
| 199 | connect(ui->enable_ring_controller_button, &QPushButton::clicked, this, | ||
| 200 | &ConfigureRingController::EnableRingController); | ||
| 201 | |||
| 190 | timeout_timer->setSingleShot(true); | 202 | timeout_timer->setSingleShot(true); |
| 191 | connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); }); | 203 | connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); }); |
| 192 | 204 | ||
| @@ -202,7 +214,13 @@ ConfigureRingController::ConfigureRingController(QWidget* parent, | |||
| 202 | } | 214 | } |
| 203 | 215 | ||
| 204 | ConfigureRingController::~ConfigureRingController() { | 216 | ConfigureRingController::~ConfigureRingController() { |
| 217 | emulated_controller->SetPollingMode(Common::Input::PollingMode::Active); | ||
| 205 | emulated_controller->DisableConfiguration(); | 218 | emulated_controller->DisableConfiguration(); |
| 219 | |||
| 220 | if (is_controller_set) { | ||
| 221 | emulated_controller->DeleteCallback(callback_key); | ||
| 222 | is_controller_set = false; | ||
| 223 | } | ||
| 206 | }; | 224 | }; |
| 207 | 225 | ||
| 208 | void ConfigureRingController::changeEvent(QEvent* event) { | 226 | void ConfigureRingController::changeEvent(QEvent* event) { |
| @@ -256,6 +274,57 @@ void ConfigureRingController::RestoreDefaults() { | |||
| 256 | UpdateUI(); | 274 | UpdateUI(); |
| 257 | } | 275 | } |
| 258 | 276 | ||
| 277 | void ConfigureRingController::EnableRingController() { | ||
| 278 | const auto dialog_title = tr("Error enabling ring input"); | ||
| 279 | |||
| 280 | is_ring_enabled = false; | ||
| 281 | ui->ring_controller_sensor_value->setText(tr("Not connected")); | ||
| 282 | |||
| 283 | if (!Settings::values.enable_joycon_driver) { | ||
| 284 | QMessageBox::warning(this, dialog_title, tr("Direct Joycon driver is not enabled")); | ||
| 285 | return; | ||
| 286 | } | ||
| 287 | |||
| 288 | ui->enable_ring_controller_button->setEnabled(false); | ||
| 289 | ui->enable_ring_controller_button->setText(tr("Configuring")); | ||
| 290 | // SetPollingMode is blocking. Allow to update the button status before calling the command | ||
| 291 | repaint(); | ||
| 292 | |||
| 293 | const auto result = emulated_controller->SetPollingMode(Common::Input::PollingMode::Ring); | ||
| 294 | switch (result) { | ||
| 295 | case Common::Input::DriverResult::Success: | ||
| 296 | is_ring_enabled = true; | ||
| 297 | break; | ||
| 298 | case Common::Input::DriverResult::NotSupported: | ||
| 299 | QMessageBox::warning(this, dialog_title, | ||
| 300 | tr("The current mapped device doesn't support the ring controller")); | ||
| 301 | break; | ||
| 302 | case Common::Input::DriverResult::NoDeviceDetected: | ||
| 303 | QMessageBox::warning(this, dialog_title, | ||
| 304 | tr("The current mapped device doesn't have a ring attached")); | ||
| 305 | break; | ||
| 306 | default: | ||
| 307 | QMessageBox::warning(this, dialog_title, | ||
| 308 | tr("Unexpected driver result %1").arg(static_cast<int>(result))); | ||
| 309 | break; | ||
| 310 | } | ||
| 311 | ui->enable_ring_controller_button->setEnabled(true); | ||
| 312 | ui->enable_ring_controller_button->setText(tr("Enable")); | ||
| 313 | } | ||
| 314 | |||
| 315 | void ConfigureRingController::ControllerUpdate(Core::HID::ControllerTriggerType type) { | ||
| 316 | if (!is_ring_enabled) { | ||
| 317 | return; | ||
| 318 | } | ||
| 319 | if (type != Core::HID::ControllerTriggerType::RingController) { | ||
| 320 | return; | ||
| 321 | } | ||
| 322 | |||
| 323 | const auto value = emulated_controller->GetRingSensorValues(); | ||
| 324 | const auto tex_value = QString::fromStdString(fmt::format("{:.3f}", value.raw_value)); | ||
| 325 | ui->ring_controller_sensor_value->setText(tex_value); | ||
| 326 | } | ||
| 327 | |||
| 259 | void ConfigureRingController::HandleClick( | 328 | void ConfigureRingController::HandleClick( |
| 260 | QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter, | 329 | QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter, |
| 261 | InputCommon::Polling::InputType type) { | 330 | InputCommon::Polling::InputType type) { |
diff --git a/src/yuzu/configuration/configure_ringcon.h b/src/yuzu/configuration/configure_ringcon.h index 6e693e0dd..b23c27906 100644 --- a/src/yuzu/configuration/configure_ringcon.h +++ b/src/yuzu/configuration/configure_ringcon.h | |||
| @@ -42,6 +42,12 @@ private: | |||
| 42 | /// Restore all buttons to their default values. | 42 | /// Restore all buttons to their default values. |
| 43 | void RestoreDefaults(); | 43 | void RestoreDefaults(); |
| 44 | 44 | ||
| 45 | /// Sets current polling mode to ring input | ||
| 46 | void EnableRingController(); | ||
| 47 | |||
| 48 | // Handles emulated controller events | ||
| 49 | void ControllerUpdate(Core::HID::ControllerTriggerType type); | ||
| 50 | |||
| 45 | /// Called when the button was pressed. | 51 | /// Called when the button was pressed. |
| 46 | void HandleClick(QPushButton* button, | 52 | void HandleClick(QPushButton* button, |
| 47 | std::function<void(const Common::ParamPackage&)> new_input_setter, | 53 | std::function<void(const Common::ParamPackage&)> new_input_setter, |
| @@ -80,5 +86,9 @@ private: | |||
| 80 | InputCommon::InputSubsystem* input_subsystem; | 86 | InputCommon::InputSubsystem* input_subsystem; |
| 81 | Core::HID::EmulatedController* emulated_controller; | 87 | Core::HID::EmulatedController* emulated_controller; |
| 82 | 88 | ||
| 89 | bool is_ring_enabled{}; | ||
| 90 | bool is_controller_set{}; | ||
| 91 | int callback_key; | ||
| 92 | |||
| 83 | std::unique_ptr<Ui::ConfigureRingController> ui; | 93 | std::unique_ptr<Ui::ConfigureRingController> ui; |
| 84 | }; | 94 | }; |
diff --git a/src/yuzu/configuration/configure_ringcon.ui b/src/yuzu/configuration/configure_ringcon.ui index 9ec634dd4..514dff372 100644 --- a/src/yuzu/configuration/configure_ringcon.ui +++ b/src/yuzu/configuration/configure_ringcon.ui | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>298</width> | 9 | <width>315</width> |
| 10 | <height>339</height> | 10 | <height>400</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
| @@ -46,187 +46,283 @@ | |||
| 46 | </property> | 46 | </property> |
| 47 | </spacer> | 47 | </spacer> |
| 48 | </item> | 48 | </item> |
| 49 | <item> | 49 | <item> |
| 50 | <widget class="QGroupBox" name="RingAnalog"> | 50 | <widget class="QGroupBox" name="RingAnalog"> |
| 51 | <property name="title"> | 51 | <property name="title"> |
| 52 | <string>Ring Sensor Parameters</string> | 52 | <string>Virtual Ring Sensor Parameters</string> |
| 53 | </property> | 53 | </property> |
| 54 | <property name="alignment"> | 54 | <property name="alignment"> |
| 55 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | 55 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> |
| 56 | </property> | 56 | </property> |
| 57 | <layout class="QVBoxLayout" name="verticalLayout_3"> | 57 | <layout class="QVBoxLayout" name="verticalLayout_1"> |
| 58 | <property name="spacing"> | ||
| 59 | <number>0</number> | ||
| 60 | </property> | ||
| 61 | <property name="sizeConstraint"> | ||
| 62 | <enum>QLayout::SetDefaultConstraint</enum> | ||
| 63 | </property> | ||
| 64 | <property name="leftMargin"> | ||
| 65 | <number>3</number> | ||
| 66 | </property> | ||
| 67 | <property name="topMargin"> | ||
| 68 | <number>6</number> | ||
| 69 | </property> | ||
| 70 | <property name="rightMargin"> | ||
| 71 | <number>3</number> | ||
| 72 | </property> | ||
| 73 | <property name="bottomMargin"> | ||
| 74 | <number>0</number> | ||
| 75 | </property> | ||
| 76 | <item> | ||
| 77 | <layout class="QHBoxLayout" name="buttonRingAnalogPullHorizontaLayout"> | ||
| 78 | <property name="spacing"> | 58 | <property name="spacing"> |
| 79 | <number>3</number> | 59 | <number>0</number> |
| 80 | </property> | 60 | </property> |
| 81 | <item alignment="Qt::AlignHCenter"> | 61 | <property name="sizeConstraint"> |
| 82 | <widget class="QGroupBox" name="buttonRingAnalogPullGroup"> | 62 | <enum>QLayout::SetDefaultConstraint</enum> |
| 83 | <property name="title"> | 63 | </property> |
| 84 | <string>Pull</string> | 64 | <property name="leftMargin"> |
| 85 | </property> | 65 | <number>3</number> |
| 86 | <property name="alignment"> | 66 | </property> |
| 87 | <set>Qt::AlignCenter</set> | 67 | <property name="topMargin"> |
| 68 | <number>6</number> | ||
| 69 | </property> | ||
| 70 | <property name="rightMargin"> | ||
| 71 | <number>3</number> | ||
| 72 | </property> | ||
| 73 | <property name="bottomMargin"> | ||
| 74 | <number>0</number> | ||
| 75 | </property> | ||
| 76 | <item> | ||
| 77 | <layout class="QHBoxLayout" name="buttonRingAnalogPullHorizontaLayout"> | ||
| 78 | <property name="spacing"> | ||
| 79 | <number>3</number> | ||
| 88 | </property> | 80 | </property> |
| 89 | <layout class="QVBoxLayout" name="buttonRingAnalogPullVerticalLayout"> | 81 | <item alignment="Qt::AlignHCenter"> |
| 90 | <property name="spacing"> | 82 | <widget class="QGroupBox" name="buttonRingAnalogPullGroup"> |
| 91 | <number>3</number> | 83 | <property name="title"> |
| 84 | <string>Pull</string> | ||
| 92 | </property> | 85 | </property> |
| 93 | <property name="leftMargin"> | 86 | <property name="alignment"> |
| 94 | <number>3</number> | 87 | <set>Qt::AlignCenter</set> |
| 95 | </property> | ||
| 96 | <property name="topMargin"> | ||
| 97 | <number>3</number> | ||
| 98 | </property> | 88 | </property> |
| 99 | <property name="rightMargin"> | 89 | <layout class="QVBoxLayout" name="buttonRingAnalogPullVerticalLayout"> |
| 100 | <number>3</number> | 90 | <property name="spacing"> |
| 91 | <number>3</number> | ||
| 92 | </property> | ||
| 93 | <property name="leftMargin"> | ||
| 94 | <number>3</number> | ||
| 95 | </property> | ||
| 96 | <property name="topMargin"> | ||
| 97 | <number>3</number> | ||
| 98 | </property> | ||
| 99 | <property name="rightMargin"> | ||
| 100 | <number>3</number> | ||
| 101 | </property> | ||
| 102 | <property name="bottomMargin"> | ||
| 103 | <number>3</number> | ||
| 104 | </property> | ||
| 105 | <item> | ||
| 106 | <widget class="QPushButton" name="buttonRingAnalogPull"> | ||
| 107 | <property name="minimumSize"> | ||
| 108 | <size> | ||
| 109 | <width>70</width> | ||
| 110 | <height>0</height> | ||
| 111 | </size> | ||
| 112 | </property> | ||
| 113 | <property name="maximumSize"> | ||
| 114 | <size> | ||
| 115 | <width>68</width> | ||
| 116 | <height>16777215</height> | ||
| 117 | </size> | ||
| 118 | </property> | ||
| 119 | <property name="styleSheet"> | ||
| 120 | <string notr="true">min-width: 68px;</string> | ||
| 121 | </property> | ||
| 122 | <property name="text"> | ||
| 123 | <string>Pull</string> | ||
| 124 | </property> | ||
| 125 | </widget> | ||
| 126 | </item> | ||
| 127 | </layout> | ||
| 128 | </widget> | ||
| 129 | </item> | ||
| 130 | <item alignment="Qt::AlignHCenter"> | ||
| 131 | <widget class="QGroupBox" name="buttonRingAnalogPushGroup"> | ||
| 132 | <property name="title"> | ||
| 133 | <string>Push</string> | ||
| 101 | </property> | 134 | </property> |
| 102 | <property name="bottomMargin"> | 135 | <property name="alignment"> |
| 103 | <number>3</number> | 136 | <set>Qt::AlignCenter</set> |
| 104 | </property> | 137 | </property> |
| 105 | <item> | 138 | <layout class="QVBoxLayout" name="buttonRingAnalogPushVerticalLayout"> |
| 106 | <widget class="QPushButton" name="buttonRingAnalogPull"> | 139 | <property name="spacing"> |
| 107 | <property name="minimumSize"> | 140 | <number>3</number> |
| 108 | <size> | 141 | </property> |
| 109 | <width>68</width> | 142 | <property name="leftMargin"> |
| 110 | <height>0</height> | 143 | <number>3</number> |
| 111 | </size> | 144 | </property> |
| 112 | </property> | 145 | <property name="topMargin"> |
| 113 | <property name="maximumSize"> | 146 | <number>3</number> |
| 114 | <size> | 147 | </property> |
| 115 | <width>68</width> | 148 | <property name="rightMargin"> |
| 116 | <height>16777215</height> | 149 | <number>3</number> |
| 117 | </size> | 150 | </property> |
| 118 | </property> | 151 | <property name="bottomMargin"> |
| 119 | <property name="styleSheet"> | 152 | <number>3</number> |
| 120 | <string notr="true">min-width: 68px;</string> | 153 | </property> |
| 121 | </property> | 154 | <item> |
| 122 | <property name="text"> | 155 | <widget class="QPushButton" name="buttonRingAnalogPush"> |
| 123 | <string>Pull</string> | 156 | <property name="minimumSize"> |
| 124 | </property> | 157 | <size> |
| 125 | </widget> | 158 | <width>70</width> |
| 126 | </item> | 159 | <height>0</height> |
| 127 | </layout> | 160 | </size> |
| 128 | </widget> | 161 | </property> |
| 162 | <property name="maximumSize"> | ||
| 163 | <size> | ||
| 164 | <width>68</width> | ||
| 165 | <height>16777215</height> | ||
| 166 | </size> | ||
| 167 | </property> | ||
| 168 | <property name="styleSheet"> | ||
| 169 | <string notr="true">min-width: 68px;</string> | ||
| 170 | </property> | ||
| 171 | <property name="text"> | ||
| 172 | <string>Push</string> | ||
| 173 | </property> | ||
| 174 | </widget> | ||
| 175 | </item> | ||
| 176 | </layout> | ||
| 177 | </widget> | ||
| 178 | </item> | ||
| 179 | </layout> | ||
| 129 | </item> | 180 | </item> |
| 130 | <item alignment="Qt::AlignHCenter"> | 181 | <item> |
| 131 | <widget class="QGroupBox" name="buttonRingAnalogPushGroup"> | 182 | <layout class="QVBoxLayout" name="sliderRingAnalogDeadzoneVerticalLayout"> |
| 132 | <property name="title"> | 183 | <property name="spacing"> |
| 133 | <string>Push</string> | 184 | <number>3</number> |
| 134 | </property> | 185 | </property> |
| 135 | <property name="alignment"> | 186 | <property name="sizeConstraint"> |
| 136 | <set>Qt::AlignCenter</set> | 187 | <enum>QLayout::SetDefaultConstraint</enum> |
| 137 | </property> | 188 | </property> |
| 138 | <layout class="QVBoxLayout" name="buttonRingAnalogPushVerticalLayout"> | 189 | <property name="leftMargin"> |
| 139 | <property name="spacing"> | 190 | <number>0</number> |
| 140 | <number>3</number> | 191 | </property> |
| 141 | </property> | 192 | <property name="topMargin"> |
| 142 | <property name="leftMargin"> | 193 | <number>10</number> |
| 143 | <number>3</number> | 194 | </property> |
| 144 | </property> | 195 | <property name="rightMargin"> |
| 145 | <property name="topMargin"> | 196 | <number>0</number> |
| 146 | <number>3</number> | 197 | </property> |
| 147 | </property> | 198 | <property name="bottomMargin"> |
| 148 | <property name="rightMargin"> | 199 | <number>3</number> |
| 149 | <number>3</number> | 200 | </property> |
| 150 | </property> | 201 | <item> |
| 151 | <property name="bottomMargin"> | 202 | <layout class="QHBoxLayout" name="sliderRingAnalogDeadzoneHorizontalLayout"> |
| 152 | <number>3</number> | ||
| 153 | </property> | ||
| 154 | <item> | 203 | <item> |
| 155 | <widget class="QPushButton" name="buttonRingAnalogPush"> | 204 | <widget class="QLabel" name="labelRingAnalogDeadzone"> |
| 156 | <property name="minimumSize"> | ||
| 157 | <size> | ||
| 158 | <width>68</width> | ||
| 159 | <height>0</height> | ||
| 160 | </size> | ||
| 161 | </property> | ||
| 162 | <property name="maximumSize"> | ||
| 163 | <size> | ||
| 164 | <width>68</width> | ||
| 165 | <height>16777215</height> | ||
| 166 | </size> | ||
| 167 | </property> | ||
| 168 | <property name="styleSheet"> | ||
| 169 | <string notr="true">min-width: 68px;</string> | ||
| 170 | </property> | ||
| 171 | <property name="text"> | 205 | <property name="text"> |
| 172 | <string>Push</string> | 206 | <string>Deadzone: 0%</string> |
| 207 | </property> | ||
| 208 | <property name="alignment"> | ||
| 209 | <set>Qt::AlignHCenter</set> | ||
| 173 | </property> | 210 | </property> |
| 174 | </widget> | 211 | </widget> |
| 175 | </item> | 212 | </item> |
| 176 | </layout> | 213 | </layout> |
| 177 | </widget> | 214 | </item> |
| 215 | <item> | ||
| 216 | <widget class="QSlider" name="sliderRingAnalogDeadzone"> | ||
| 217 | <property name="maximum"> | ||
| 218 | <number>100</number> | ||
| 219 | </property> | ||
| 220 | <property name="orientation"> | ||
| 221 | <enum>Qt::Horizontal</enum> | ||
| 222 | </property> | ||
| 223 | </widget> | ||
| 224 | </item> | ||
| 225 | </layout> | ||
| 178 | </item> | 226 | </item> |
| 179 | </layout> | 227 | </layout> |
| 180 | </item> | 228 | </widget> |
| 181 | <item> | 229 | </item> |
| 182 | <layout class="QVBoxLayout" name="sliderRingAnalogDeadzoneVerticalLayout"> | 230 | <item> |
| 231 | <widget class="QGroupBox" name="RingDriver"> | ||
| 232 | <property name="title"> | ||
| 233 | <string>Direct Joycon Driver</string> | ||
| 234 | </property> | ||
| 235 | <property name="alignment"> | ||
| 236 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | ||
| 237 | </property> | ||
| 238 | <layout class="QVBoxLayout" name="verticalLayout_2"> | ||
| 183 | <property name="spacing"> | 239 | <property name="spacing"> |
| 184 | <number>3</number> | 240 | <number>0</number> |
| 185 | </property> | 241 | </property> |
| 186 | <property name="sizeConstraint"> | 242 | <property name="sizeConstraint"> |
| 187 | <enum>QLayout::SetDefaultConstraint</enum> | 243 | <enum>QLayout::SetDefaultConstraint</enum> |
| 188 | </property> | 244 | </property> |
| 189 | <property name="leftMargin"> | 245 | <property name="leftMargin"> |
| 190 | <number>0</number> | 246 | <number>3</number> |
| 191 | </property> | 247 | </property> |
| 192 | <property name="topMargin"> | 248 | <property name="topMargin"> |
| 193 | <number>10</number> | 249 | <number>6</number> |
| 194 | </property> | 250 | </property> |
| 195 | <property name="rightMargin"> | 251 | <property name="rightMargin"> |
| 196 | <number>0</number> | 252 | <number>3</number> |
| 197 | </property> | 253 | </property> |
| 198 | <property name="bottomMargin"> | 254 | <property name="bottomMargin"> |
| 199 | <number>3</number> | 255 | <number>10</number> |
| 200 | </property> | 256 | </property> |
| 201 | <item> | 257 | <item> |
| 202 | <layout class="QHBoxLayout" name="sliderRingAnalogDeadzoneHorizontalLayout"> | 258 | <layout class="QGridLayout" name="gridLayout"> |
| 203 | <item> | 259 | <property name="leftMargin"> |
| 204 | <widget class="QLabel" name="labelRingAnalogDeadzone"> | 260 | <number>10</number> |
| 261 | </property> | ||
| 262 | <property name="topMargin"> | ||
| 263 | <number>6</number> | ||
| 264 | </property> | ||
| 265 | <property name="rightMargin"> | ||
| 266 | <number>10</number> | ||
| 267 | </property> | ||
| 268 | <property name="bottomMargin"> | ||
| 269 | <number>10</number> | ||
| 270 | </property> | ||
| 271 | <property name="verticalSpacing"> | ||
| 272 | <number>10</number> | ||
| 273 | </property> | ||
| 274 | <item row="0" column="1"> | ||
| 275 | <spacer name="horizontalSpacer"> | ||
| 276 | <property name="orientation"> | ||
| 277 | <enum>Qt::Horizontal</enum> | ||
| 278 | </property> | ||
| 279 | <property name="sizeType"> | ||
| 280 | <enum>QSizePolicy::Fixed</enum> | ||
| 281 | </property> | ||
| 282 | <property name="sizeHint" stdset="0"> | ||
| 283 | <size> | ||
| 284 | <width>76</width> | ||
| 285 | <height>20</height> | ||
| 286 | </size> | ||
| 287 | </property> | ||
| 288 | </spacer> | ||
| 289 | </item> | ||
| 290 | <item row="0" column="0"> | ||
| 291 | <widget class="QLabel" name="enable_ring_controller_label"> | ||
| 292 | <property name="text"> | ||
| 293 | <string>Enable Ring Input</string> | ||
| 294 | </property> | ||
| 295 | </widget> | ||
| 296 | </item> | ||
| 297 | <item row="0" column="2"> | ||
| 298 | <widget class="QPushButton" name="enable_ring_controller_button"> | ||
| 205 | <property name="text"> | 299 | <property name="text"> |
| 206 | <string>Deadzone: 0%</string> | 300 | <string>Enable</string> |
| 301 | </property> | ||
| 302 | </widget> | ||
| 303 | </item> | ||
| 304 | <item row="1" column="0"> | ||
| 305 | <widget class="QLabel" name="ring_controller_sensor_label"> | ||
| 306 | <property name="text"> | ||
| 307 | <string>Ring Sensor Value</string> | ||
| 308 | </property> | ||
| 309 | </widget> | ||
| 310 | </item> | ||
| 311 | <item row="1" column="2"> | ||
| 312 | <widget class="QLabel" name="ring_controller_sensor_value"> | ||
| 313 | <property name="text"> | ||
| 314 | <string>Not connected</string> | ||
| 207 | </property> | 315 | </property> |
| 208 | <property name="alignment"> | 316 | <property name="alignment"> |
| 209 | <set>Qt::AlignHCenter</set> | 317 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
| 210 | </property> | 318 | </property> |
| 211 | </widget> | 319 | </widget> |
| 212 | </item> | 320 | </item> |
| 213 | </layout> | 321 | </layout> |
| 214 | </item> | ||
| 215 | <item> | ||
| 216 | <widget class="QSlider" name="sliderRingAnalogDeadzone"> | ||
| 217 | <property name="maximum"> | ||
| 218 | <number>100</number> | ||
| 219 | </property> | ||
| 220 | <property name="orientation"> | ||
| 221 | <enum>Qt::Horizontal</enum> | ||
| 222 | </property> | ||
| 223 | </widget> | ||
| 224 | </item> | 322 | </item> |
| 225 | </layout> | 323 | </layout> |
| 226 | </item> | 324 | </widget> |
| 227 | </layout> | 325 | </item> |
| 228 | </widget> | ||
| 229 | </item> | ||
| 230 | <item> | 326 | <item> |
| 231 | <spacer name="verticalSpacer"> | 327 | <spacer name="verticalSpacer"> |
| 232 | <property name="orientation"> | 328 | <property name="orientation"> |
| @@ -273,6 +369,6 @@ | |||
| 273 | <signal>rejected()</signal> | 369 | <signal>rejected()</signal> |
| 274 | <receiver>ConfigureRingController</receiver> | 370 | <receiver>ConfigureRingController</receiver> |
| 275 | <slot>reject()</slot> | 371 | <slot>reject()</slot> |
| 276 | </connection> | 372 | </connection> |
| 277 | </connections> | 373 | </connections> |
| 278 | </ui> | 374 | </ui> |