summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/settings.h1
-rw-r--r--src/input_common/drivers/joycon.cpp49
-rw-r--r--src/input_common/drivers/joycon.h1
-rw-r--r--src/input_common/drivers/sdl_driver.cpp18
-rw-r--r--src/input_common/helpers/joycon_driver.cpp3
-rw-r--r--src/yuzu/configuration/config.cpp2
-rw-r--r--src/yuzu/configuration/configure_input_advanced.cpp2
-rw-r--r--src/yuzu/configuration/configure_input_advanced.ui22
-rw-r--r--src/yuzu_cmd/config.cpp1
9 files changed, 92 insertions, 7 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index 64db66f37..6d27dd5ee 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -488,6 +488,7 @@ struct Values {
488 Setting<bool> enable_raw_input{false, "enable_raw_input"}; 488 Setting<bool> enable_raw_input{false, "enable_raw_input"};
489 Setting<bool> controller_navigation{true, "controller_navigation"}; 489 Setting<bool> controller_navigation{true, "controller_navigation"};
490 Setting<bool> enable_joycon_driver{true, "enable_joycon_driver"}; 490 Setting<bool> enable_joycon_driver{true, "enable_joycon_driver"};
491 Setting<bool> enable_procon_driver{false, "enable_procon_driver"};
491 492
492 SwitchableSetting<bool> vibration_enabled{true, "vibration_enabled"}; 493 SwitchableSetting<bool> vibration_enabled{true, "vibration_enabled"};
493 SwitchableSetting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"}; 494 SwitchableSetting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index 4fcfb4510..afc33db57 100644
--- a/src/input_common/drivers/joycon.cpp
+++ b/src/input_common/drivers/joycon.cpp
@@ -16,7 +16,7 @@ namespace InputCommon {
16 16
17Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_) { 17Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_) {
18 // Avoid conflicting with SDL driver 18 // Avoid conflicting with SDL driver
19 if (!Settings::values.enable_joycon_driver) { 19 if (!Settings::values.enable_joycon_driver && !Settings::values.enable_procon_driver) {
20 return; 20 return;
21 } 21 }
22 LOG_INFO(Input, "Joycon driver Initialization started"); 22 LOG_INFO(Input, "Joycon driver Initialization started");
@@ -46,6 +46,12 @@ void Joycons::Reset() {
46 } 46 }
47 device->Stop(); 47 device->Stop();
48 } 48 }
49 for (const auto& device : pro_controller) {
50 if (!device) {
51 continue;
52 }
53 device->Stop();
54 }
49 SDL_hid_exit(); 55 SDL_hid_exit();
50} 56}
51 57
@@ -61,6 +67,11 @@ void Joycons::Setup() {
61 PreSetController(GetIdentifier(port, Joycon::ControllerType::Right)); 67 PreSetController(GetIdentifier(port, Joycon::ControllerType::Right));
62 device = std::make_shared<Joycon::JoyconDriver>(port++); 68 device = std::make_shared<Joycon::JoyconDriver>(port++);
63 } 69 }
70 port = 0;
71 for (auto& device : pro_controller) {
72 PreSetController(GetIdentifier(port, Joycon::ControllerType::Pro));
73 device = std::make_shared<Joycon::JoyconDriver>(port++);
74 }
64 75
65 scan_thread = std::jthread([this](std::stop_token stop_token) { ScanThread(stop_token); }); 76 scan_thread = std::jthread([this](std::stop_token stop_token) { ScanThread(stop_token); });
66} 77}
@@ -116,6 +127,9 @@ bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const {
116 // Check if device already exist 127 // Check if device already exist
117 switch (type) { 128 switch (type) {
118 case Joycon::ControllerType::Left: 129 case Joycon::ControllerType::Left:
130 if (!Settings::values.enable_joycon_driver) {
131 return false;
132 }
119 for (const auto& device : left_joycons) { 133 for (const auto& device : left_joycons) {
120 if (is_handle_identical(device)) { 134 if (is_handle_identical(device)) {
121 return false; 135 return false;
@@ -123,12 +137,25 @@ bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const {
123 } 137 }
124 break; 138 break;
125 case Joycon::ControllerType::Right: 139 case Joycon::ControllerType::Right:
140 if (!Settings::values.enable_joycon_driver) {
141 return false;
142 }
126 for (const auto& device : right_joycons) { 143 for (const auto& device : right_joycons) {
127 if (is_handle_identical(device)) { 144 if (is_handle_identical(device)) {
128 return false; 145 return false;
129 } 146 }
130 } 147 }
131 break; 148 break;
149 case Joycon::ControllerType::Pro:
150 if (!Settings::values.enable_procon_driver) {
151 return false;
152 }
153 for (const auto& device : pro_controller) {
154 if (is_handle_identical(device)) {
155 return false;
156 }
157 }
158 break;
132 default: 159 default:
133 return false; 160 return false;
134 } 161 }
@@ -199,6 +226,14 @@ std::shared_ptr<Joycon::JoyconDriver> Joycons::GetNextFreeHandle(
199 return *unconnected_device; 226 return *unconnected_device;
200 } 227 }
201 } 228 }
229 if (type == Joycon::ControllerType::Pro) {
230 const auto unconnected_device = std::ranges::find_if(
231 pro_controller, [](auto& device) { return !device->IsConnected(); });
232
233 if (unconnected_device != pro_controller.end()) {
234 return *unconnected_device;
235 }
236 }
202 return nullptr; 237 return nullptr;
203} 238}
204 239
@@ -409,6 +444,15 @@ std::shared_ptr<Joycon::JoyconDriver> Joycons::GetHandle(PadIdentifier identifie
409 } 444 }
410 } 445 }
411 446
447 if (type == Joycon::ControllerType::Pro) {
448 const auto matching_device = std::ranges::find_if(
449 pro_controller, [is_handle_active](auto& device) { return is_handle_active(device); });
450
451 if (matching_device != pro_controller.end()) {
452 return *matching_device;
453 }
454 }
455
412 return nullptr; 456 return nullptr;
413} 457}
414 458
@@ -455,6 +499,9 @@ std::vector<Common::ParamPackage> Joycons::GetInputDevices() const {
455 for (const auto& controller : right_joycons) { 499 for (const auto& controller : right_joycons) {
456 add_entry(controller); 500 add_entry(controller);
457 } 501 }
502 for (const auto& controller : pro_controller) {
503 add_entry(controller);
504 }
458 505
459 // List dual joycon pairs 506 // List dual joycon pairs
460 for (std::size_t i = 0; i < MaxSupportedControllers; i++) { 507 for (std::size_t i = 0; i < MaxSupportedControllers; i++) {
diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h
index 2149ab7fd..473ba1b9e 100644
--- a/src/input_common/drivers/joycon.h
+++ b/src/input_common/drivers/joycon.h
@@ -106,6 +106,7 @@ private:
106 // Joycon types are split by type to ease supporting dualjoycon configurations 106 // Joycon types are split by type to ease supporting dualjoycon configurations
107 std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> left_joycons{}; 107 std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> left_joycons{};
108 std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> right_joycons{}; 108 std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> right_joycons{};
109 std::array<std::shared_ptr<Joycon::JoyconDriver>, MaxSupportedControllers> pro_controller{};
109}; 110};
110 111
111} // namespace InputCommon 112} // namespace InputCommon
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index d975eb815..88cacd615 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -343,6 +343,14 @@ void SDLDriver::InitJoystick(int joystick_index) {
343 } 343 }
344 } 344 }
345 345
346 if (Settings::values.enable_procon_driver) {
347 if (guid.uuid[5] == 0x05 && guid.uuid[4] == 0x7e && guid.uuid[8] == 0x09) {
348 LOG_WARNING(Input, "Preferring joycon driver for device index {}", joystick_index);
349 SDL_JoystickClose(sdl_joystick);
350 return;
351 }
352 }
353
346 std::scoped_lock lock{joystick_map_mutex}; 354 std::scoped_lock lock{joystick_map_mutex};
347 if (joystick_map.find(guid) == joystick_map.end()) { 355 if (joystick_map.find(guid) == joystick_map.end()) {
348 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller); 356 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
@@ -465,13 +473,19 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
465 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); 473 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
466 SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); 474 SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
467 475
468 // Disable hidapi drivers for switch controllers when the custom joycon driver is enabled 476 // Disable hidapi drivers for joycon controllers when the custom joycon driver is enabled
469 if (Settings::values.enable_joycon_driver) { 477 if (Settings::values.enable_joycon_driver) {
470 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0"); 478 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0");
471 } else { 479 } else {
472 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); 480 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
473 } 481 }
474 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1"); 482
483 // Disable hidapi drivers for pro controllers when the custom joycon driver is enabled
484 if (Settings::values.enable_procon_driver) {
485 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "0");
486 } else {
487 SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1");
488 }
475 489
476 // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native 490 // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
477 // driver on Linux. 491 // driver on Linux.
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp
index 8f94c9f45..e65b6b845 100644
--- a/src/input_common/helpers/joycon_driver.cpp
+++ b/src/input_common/helpers/joycon_driver.cpp
@@ -543,9 +543,10 @@ void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) {
543 543
544DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, 544DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info,
545 ControllerType& controller_type) { 545 ControllerType& controller_type) {
546 static constexpr std::array<std::pair<u32, ControllerType>, 2> supported_devices{ 546 static constexpr std::array<std::pair<u32, ControllerType>, 6> supported_devices{
547 std::pair<u32, ControllerType>{0x2006, ControllerType::Left}, 547 std::pair<u32, ControllerType>{0x2006, ControllerType::Left},
548 {0x2007, ControllerType::Right}, 548 {0x2007, ControllerType::Right},
549 {0x2009, ControllerType::Pro},
549 }; 550 };
550 constexpr u16 nintendo_vendor_id = 0x057e; 551 constexpr u16 nintendo_vendor_id = 0x057e;
551 552
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 35fef506a..31209fb2e 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -441,6 +441,7 @@ void Config::ReadControlValues() {
441 Settings::values.mouse_panning = false; 441 Settings::values.mouse_panning = false;
442 ReadBasicSetting(Settings::values.mouse_panning_sensitivity); 442 ReadBasicSetting(Settings::values.mouse_panning_sensitivity);
443 ReadBasicSetting(Settings::values.enable_joycon_driver); 443 ReadBasicSetting(Settings::values.enable_joycon_driver);
444 ReadBasicSetting(Settings::values.enable_procon_driver);
444 445
445 ReadBasicSetting(Settings::values.tas_enable); 446 ReadBasicSetting(Settings::values.tas_enable);
446 ReadBasicSetting(Settings::values.tas_loop); 447 ReadBasicSetting(Settings::values.tas_loop);
@@ -1141,6 +1142,7 @@ void Config::SaveControlValues() {
1141 WriteGlobalSetting(Settings::values.motion_enabled); 1142 WriteGlobalSetting(Settings::values.motion_enabled);
1142 WriteBasicSetting(Settings::values.enable_raw_input); 1143 WriteBasicSetting(Settings::values.enable_raw_input);
1143 WriteBasicSetting(Settings::values.enable_joycon_driver); 1144 WriteBasicSetting(Settings::values.enable_joycon_driver);
1145 WriteBasicSetting(Settings::values.enable_procon_driver);
1144 WriteBasicSetting(Settings::values.keyboard_enabled); 1146 WriteBasicSetting(Settings::values.keyboard_enabled);
1145 WriteBasicSetting(Settings::values.emulate_analog_keyboard); 1147 WriteBasicSetting(Settings::values.emulate_analog_keyboard);
1146 WriteBasicSetting(Settings::values.mouse_panning_sensitivity); 1148 WriteBasicSetting(Settings::values.mouse_panning_sensitivity);
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp
index 77b976e74..8d81322f3 100644
--- a/src/yuzu/configuration/configure_input_advanced.cpp
+++ b/src/yuzu/configuration/configure_input_advanced.cpp
@@ -139,6 +139,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
139 Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked(); 139 Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked();
140 Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked(); 140 Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked();
141 Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked(); 141 Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked();
142 Settings::values.enable_procon_driver = ui->enable_procon_driver->isChecked();
142} 143}
143 144
144void ConfigureInputAdvanced::LoadConfiguration() { 145void ConfigureInputAdvanced::LoadConfiguration() {
@@ -174,6 +175,7 @@ void ConfigureInputAdvanced::LoadConfiguration() {
174 ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue()); 175 ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue());
175 ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue()); 176 ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue());
176 ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue()); 177 ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue());
178 ui->enable_procon_driver->setChecked(Settings::values.enable_procon_driver.GetValue());
177 179
178 UpdateUIEnabled(); 180 UpdateUIEnabled();
179} 181}
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui
index 75d96d3ab..0eb2b34bc 100644
--- a/src/yuzu/configuration/configure_input_advanced.ui
+++ b/src/yuzu/configuration/configure_input_advanced.ui
@@ -2712,6 +2712,22 @@
2712 </widget> 2712 </widget>
2713 </item> 2713 </item>
2714 <item row="6" column="0"> 2714 <item row="6" column="0">
2715 <widget class="QCheckBox" name="enable_procon_driver">
2716 <property name="toolTip">
2717 <string>Requires restarting yuzu</string>
2718 </property>
2719 <property name="minimumSize">
2720 <size>
2721 <width>0</width>
2722 <height>23</height>
2723 </size>
2724 </property>
2725 <property name="text">
2726 <string>Enable direct Pro Controller driver [EXPERIMENTAL]</string>
2727 </property>
2728 </widget>
2729 </item>
2730 <item row="7" column="0">
2715 <widget class="QCheckBox" name="mouse_panning"> 2731 <widget class="QCheckBox" name="mouse_panning">
2716 <property name="minimumSize"> 2732 <property name="minimumSize">
2717 <size> 2733 <size>
@@ -2724,7 +2740,7 @@
2724 </property> 2740 </property>
2725 </widget> 2741 </widget>
2726 </item> 2742 </item>
2727 <item row="6" column="2"> 2743 <item row="7" column="2">
2728 <widget class="QSpinBox" name="mouse_panning_sensitivity"> 2744 <widget class="QSpinBox" name="mouse_panning_sensitivity">
2729 <property name="toolTip"> 2745 <property name="toolTip">
2730 <string>Mouse sensitivity</string> 2746 <string>Mouse sensitivity</string>
@@ -2746,14 +2762,14 @@
2746 </property> 2762 </property>
2747 </widget> 2763 </widget>
2748 </item> 2764 </item>
2749 <item row="7" column="0"> 2765 <item row="8" column="0">
2750 <widget class="QLabel" name="motion_touch"> 2766 <widget class="QLabel" name="motion_touch">
2751 <property name="text"> 2767 <property name="text">
2752 <string>Motion / Touch</string> 2768 <string>Motion / Touch</string>
2753 </property> 2769 </property>
2754 </widget> 2770 </widget>
2755 </item> 2771 </item>
2756 <item row="7" column="2"> 2772 <item row="8" column="2">
2757 <widget class="QPushButton" name="buttonMotionTouch"> 2773 <widget class="QPushButton" name="buttonMotionTouch">
2758 <property name="text"> 2774 <property name="text">
2759 <string>Configure</string> 2775 <string>Configure</string>
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 9c34cdc6e..3b6dce296 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -178,6 +178,7 @@ void Config::ReadValues() {
178 178
179 ReadSetting("ControlsGeneral", Settings::values.enable_raw_input); 179 ReadSetting("ControlsGeneral", Settings::values.enable_raw_input);
180 ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver); 180 ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver);
181 ReadSetting("ControlsGeneral", Settings::values.enable_procon_driver);
181 ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard); 182 ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard);
182 ReadSetting("ControlsGeneral", Settings::values.vibration_enabled); 183 ReadSetting("ControlsGeneral", Settings::values.vibration_enabled);
183 ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations); 184 ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations);