From 4014ed63c13b9857b43462064b7e6e7411c1ce4e Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 30 Dec 2022 22:42:54 +0100 Subject: [PATCH] early-access version 3267 --- README.md | 2 +- src/core/hle/service/hid/irs.cpp | 13 ++-- src/input_common/drivers/joycon.cpp | 3 +- src/input_common/helpers/joycon_driver.cpp | 76 +++++++++++++++++---- src/input_common/helpers/joycon_driver.h | 2 + src/yuzu/configuration/configure_system.cpp | 36 ++++++++++ src/yuzu/configuration/configure_system.ui | 12 +++- 7 files changed, 123 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0f6e98e52..98348cbc6 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3266. +This is the source code for early-access 3267. ## Legal Notice diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cpp index 8625b7e11..b9052e497 100755 --- a/src/core/hle/service/hid/irs.cpp +++ b/src/core/hle/service/hid/irs.cpp @@ -63,8 +63,6 @@ void IRS::ActivateIrsensor(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}", applet_resource_user_id); - npad_device->SetPollingMode(Common::Input::PollingMode::IR); - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } @@ -112,6 +110,7 @@ void IRS::StopImageProcessor(Kernel::HLERequestContext& ctx) { auto result = IsIrCameraHandleValid(parameters.camera_handle); if (result.IsSuccess()) { // TODO: Stop Image processor + npad_device->SetPollingMode(Common::Input::PollingMode::Active); result = ResultSuccess; } @@ -143,6 +142,7 @@ void IRS::RunMomentProcessor(Kernel::HLERequestContext& ctx) { MakeProcessor(parameters.camera_handle, device); auto& image_transfer_processor = GetProcessor(parameters.camera_handle); image_transfer_processor.SetConfig(parameters.processor_config); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -174,6 +174,7 @@ void IRS::RunClusteringProcessor(Kernel::HLERequestContext& ctx) { auto& image_transfer_processor = GetProcessor(parameters.camera_handle); image_transfer_processor.SetConfig(parameters.processor_config); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -223,6 +224,7 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) { GetProcessor(parameters.camera_handle); image_transfer_processor.SetConfig(parameters.processor_config); image_transfer_processor.SetTransferMemoryPointer(transfer_memory); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -298,6 +300,7 @@ void IRS::RunTeraPluginProcessor(Kernel::HLERequestContext& ctx) { auto& image_transfer_processor = GetProcessor(parameters.camera_handle); image_transfer_processor.SetConfig(parameters.processor_config); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -347,6 +350,7 @@ void IRS::RunPointingProcessor(Kernel::HLERequestContext& ctx) { MakeProcessor(camera_handle, device); auto& image_transfer_processor = GetProcessor(camera_handle); image_transfer_processor.SetConfig(processor_config); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -457,6 +461,7 @@ void IRS::RunImageTransferExProcessor(Kernel::HLERequestContext& ctx) { GetProcessor(parameters.camera_handle); image_transfer_processor.SetConfig(parameters.processor_config); image_transfer_processor.SetTransferMemoryPointer(transfer_memory); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -483,6 +488,7 @@ void IRS::RunIrLedProcessor(Kernel::HLERequestContext& ctx) { MakeProcessor(camera_handle, device); auto& image_transfer_processor = GetProcessor(camera_handle); image_transfer_processor.SetConfig(processor_config); + npad_device->SetPollingMode(Common::Input::PollingMode::IR); } IPC::ResponseBuilder rb{ctx, 2}; @@ -508,6 +514,7 @@ void IRS::StopImageProcessorAsync(Kernel::HLERequestContext& ctx) { auto result = IsIrCameraHandleValid(parameters.camera_handle); if (result.IsSuccess()) { // TODO: Stop image processor async + npad_device->SetPollingMode(Common::Input::PollingMode::IR); result = ResultSuccess; } @@ -529,8 +536,6 @@ void IRS::ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_IRS, "(STUBBED) called, function_level={}, applet_resource_user_id={}", parameters.function_level.function_level, parameters.applet_resource_user_id); - npad_device->SetPollingMode(Common::Input::PollingMode::IR); - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index 6c03e0953..3b0e81531 100755 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -77,11 +77,10 @@ void Joycons::Setup() { } void Joycons::ScanThread(std::stop_token stop_token) { - constexpr u16 nintendo_vendor_id = 0x057e; Common::SetCurrentThreadName("yuzu:input:JoyconScanThread"); scan_thread_running = true; while (!stop_token.stop_requested()) { - SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); + SDL_hid_device_info* devs = SDL_hid_enumerate(0x0, 0x0); SDL_hid_device_info* cur_dev = devs; while (cur_dev) { diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 040832a4b..f6bb67e90 100755 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -28,6 +28,7 @@ void JoyconDriver::Stop() { } DriverResult JoyconDriver::RequestDeviceAccess(SDL_hid_device_info* device_info) { + constexpr u16 nintendo_vendor_id = 0x057e; std::scoped_lock lock{mutex}; handle_device_type = ControllerType::None; @@ -35,6 +36,7 @@ DriverResult JoyconDriver::RequestDeviceAccess(SDL_hid_device_info* device_info) if (handle_device_type == ControllerType::None) { return DriverResult::UnsupportedControllerType; } + is_third_party = nintendo_vendor_id != device_info->vendor_id; hidapi_handle->handle = SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); @@ -334,8 +336,15 @@ JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() { .passive = true, .motion = true, .vibration = true, + .home_led = true, }; + if (is_third_party) { + features.passive = false; + features.home_led = false; + return features; + } + if (device_type == ControllerType::Right) { features.nfc = true; features.irs = true; @@ -345,6 +354,7 @@ JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() { if (device_type == ControllerType::Pro) { features.nfc = true; } + return features; } @@ -530,25 +540,65 @@ void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) { DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, ControllerType& controller_type) { - static constexpr std::array, 4> supported_devices{ - std::pair{0x2006, ControllerType::Left}, - {0x2007, ControllerType::Right}, - {0x2009, ControllerType::Pro}, - {0x200E, ControllerType::Grip}, - }; constexpr u16 nintendo_vendor_id = 0x057e; + constexpr u16 hori_vendor_id = 0x0f0d; + constexpr u16 pdp_vendor_id = 0x0e6f; + constexpr u16 powera_vendor_id = 0x20d6; controller_type = ControllerType::None; - if (device_info->vendor_id != nintendo_vendor_id) { - return DriverResult::UnsupportedControllerType; - } - - for (const auto& [product_id, type] : supported_devices) { - if (device_info->product_id == static_cast(product_id)) { - controller_type = type; + if (nintendo_vendor_id == device_info->vendor_id) { + switch (device_info->product_id) { + case 0x2006: // Nintendo Switch Joy-Con (Left) + controller_type = ControllerType::Left; + return Joycon::DriverResult::Success; + case 0x2007: // Nintendo Switch Joy-Con (Right) + controller_type = ControllerType::Right; + return Joycon::DriverResult::Success; + case 0x2008: // Nintendo Switch Joy-Con (Left+Right Combined) + case 0x2009: // Nintendo Switch Pro Controller + controller_type = ControllerType::Pro; + return Joycon::DriverResult::Success; + case 0x200E: // Nintendo Switch Grip Controller + controller_type = ControllerType::Grip; return Joycon::DriverResult::Success; } } + if (hori_vendor_id == device_info->vendor_id) { + switch (device_info->product_id) { + case 0x00c1: // HORIPAD for Nintendo Switch + case 0x0092: // HORI Pokken Tournament DX Pro Pad + case 0x00f6: // HORI Wireless Switch Pad + case 0x00aa: // HORI Real Arcade Pro V Hayabusa in Switch Mode + controller_type = ControllerType::Pro; + return Joycon::DriverResult::Success; + } + } + if (pdp_vendor_id == device_info->vendor_id) { + switch (device_info->product_id) { + case 0x0180: // PDP Faceoff Wired Pro Controller for Nintendo Switch + case 0x0181: // PDP Faceoff Deluxe Wired Pro Controller for Nintendo Switch + case 0x0184: // PDP Faceoff Wired Deluxe+ Audio Controller + case 0x0185: // PDP Wired Fight Pad Pro for Nintendo Switch + case 0x0186: // PDP Afterglow Wireless Switch Controller + case 0x0187: // PDP Rockcandy Wired Controller + case 0x0188: // PDP Afterglow Wired Deluxe+ Audio Controller + controller_type = ControllerType::Pro; + return Joycon::DriverResult::Success; + } + } + if (powera_vendor_id == device_info->vendor_id) { + switch (device_info->product_id) { + case 0xa711: // PowerA Wired Controller Plus/PowerA Wired Controller Nintendo + case 0xa712: // PowerA Nintendo Switch Fusion Fight Pad + case 0xa713: // PowerA Super Mario Controller + case 0xa714: // PowerA Nintendo Switch Spectra Controller + case 0xa715: // Power A Fusion Wireless Arcade Stick (USB Mode) + case 0xa716: // PowerA Nintendo Switch Fusion Pro Controller + controller_type = ControllerType::Pro; + return Joycon::DriverResult::Success; + } + } + return Joycon::DriverResult::UnsupportedControllerType; } diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h index 61ecf4a6c..f79eb4ee3 100755 --- a/src/input_common/helpers/joycon_driver.h +++ b/src/input_common/helpers/joycon_driver.h @@ -67,6 +67,7 @@ private: bool motion{}; bool nfc{}; bool vibration{}; + bool home_led{}; }; /// Main thread, actively request new data from the handle @@ -129,6 +130,7 @@ private: RingCalibration ring_calibration{}; // Fixed joycon info + bool is_third_party{}; FirmwareVersion version{}; Color color{}; std::size_t port{}; diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index cf0d902b7..b2967d37f 100755 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -14,6 +14,26 @@ #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_system.h" +constexpr std::array LOCALE_BLOCKLIST{ + // pzzefezrpnkzeidfej + // thhsrnhutlohsternp + // BHH4CG U + // Raa1AB S + // nn9 + // ts + 0b0100011100001100000, // Japan + 0b0000001101001100100, // Americas + 0b0100110100001000010, // Europe + 0b0100110100001000010, // Australia + 0b0000000000000000000, // China + 0b0100111100001000000, // Korea + 0b0100111100001000000, // Taiwan +}; + +static bool IsValidLocale(u32 region_index, u32 language_index) { + return ((LOCALE_BLOCKLIST.at(region_index) >> language_index) & 1) == 0; +} + ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) : QWidget(parent), ui{std::make_unique()}, system{system_} { ui->setupUi(this); @@ -34,6 +54,22 @@ ConfigureSystem::ConfigureSystem(Core::System& system_, QWidget* parent) } }); + const auto locale_check = [this](int index) { + const bool valid_locale = + IsValidLocale(ui->combo_region->currentIndex(), ui->combo_language->currentIndex()); + ui->label_warn_invalid_locale->setVisible(!valid_locale); + if (!valid_locale) { + ui->label_warn_invalid_locale->setText( + tr("Warning: \"%1\" is not a valid language for region \"%2\"") + .arg(ui->combo_language->currentText()) + .arg(ui->combo_region->currentText())); + } + }; + + connect(ui->combo_language, qOverload(&QComboBox::currentIndexChanged), this, + locale_check); + connect(ui->combo_region, qOverload(&QComboBox::currentIndexChanged), this, locale_check); + ui->label_console_id->setVisible(Settings::IsConfiguringGlobal()); ui->button_regenerate_console_id->setVisible(Settings::IsConfiguringGlobal()); diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui index c36060ef8..767ddacc1 100755 --- a/src/yuzu/configuration/configure_system.ui +++ b/src/yuzu/configuration/configure_system.ui @@ -326,7 +326,7 @@ - English + American English @@ -545,6 +545,16 @@ + + + + + + + true + + +