mirror of https://git.suyu.dev/suyu/suyu
input_common: Disable SDL driver with switch controllers
This commit is contained in:
parent
d80e6c399b
commit
2d802893e7
|
@ -483,6 +483,7 @@ struct Values {
|
||||||
|
|
||||||
Setting<bool> enable_raw_input{false, "enable_raw_input"};
|
Setting<bool> enable_raw_input{false, "enable_raw_input"};
|
||||||
Setting<bool> controller_navigation{true, "controller_navigation"};
|
Setting<bool> controller_navigation{true, "controller_navigation"};
|
||||||
|
Setting<bool> enable_joycon_driver{true, "enable_joycon_driver"};
|
||||||
|
|
||||||
SwitchableSetting<bool> vibration_enabled{true, "vibration_enabled"};
|
SwitchableSetting<bool> vibration_enabled{true, "vibration_enabled"};
|
||||||
SwitchableSetting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};
|
SwitchableSetting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_) {
|
Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_) {
|
||||||
|
// Avoid conflicting with SDL driver
|
||||||
|
if (!Settings::values.enable_joycon_driver) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
LOG_INFO(Input, "Joycon driver Initialization started");
|
LOG_INFO(Input, "Joycon driver Initialization started");
|
||||||
const int init_res = SDL_hid_init();
|
const int init_res = SDL_hid_init();
|
||||||
if (init_res == 0) {
|
if (init_res == 0) {
|
||||||
|
|
|
@ -318,6 +318,14 @@ void SDLDriver::InitJoystick(int joystick_index) {
|
||||||
|
|
||||||
const auto guid = GetGUID(sdl_joystick);
|
const auto guid = GetGUID(sdl_joystick);
|
||||||
|
|
||||||
|
if (Settings::values.enable_joycon_driver) {
|
||||||
|
if (guid.uuid[5] == 0x05 && guid.uuid[4] == 0x7e) {
|
||||||
|
LOG_ERROR(Input, "Device black listed {}", joystick_index);
|
||||||
|
SDL_JoystickClose(sdl_joystick);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::scoped_lock lock{joystick_map_mutex};
|
std::scoped_lock lock{joystick_map_mutex};
|
||||||
if (joystick_map.find(guid) == joystick_map.end()) {
|
if (joystick_map.find(guid) == joystick_map.end()) {
|
||||||
auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
|
auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
|
||||||
|
@ -440,9 +448,14 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
|
||||||
// Use hidapi driver for joycons. This will allow joycons to be detected as a GameController and
|
// Disable hidapi drivers for switch controllers when the custom joycon driver is enabled
|
||||||
// not a generic one
|
if (Settings::values.enable_joycon_driver) {
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0");
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "0");
|
||||||
|
} else {
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1");
|
||||||
|
}
|
||||||
|
|
||||||
// Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
|
// Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
|
||||||
// driver on Linux.
|
// driver on Linux.
|
||||||
|
|
|
@ -440,6 +440,7 @@ void Config::ReadControlValues() {
|
||||||
ReadBasicSetting(Settings::values.emulate_analog_keyboard);
|
ReadBasicSetting(Settings::values.emulate_analog_keyboard);
|
||||||
Settings::values.mouse_panning = false;
|
Settings::values.mouse_panning = false;
|
||||||
ReadBasicSetting(Settings::values.mouse_panning_sensitivity);
|
ReadBasicSetting(Settings::values.mouse_panning_sensitivity);
|
||||||
|
ReadBasicSetting(Settings::values.enable_joycon_driver);
|
||||||
|
|
||||||
ReadBasicSetting(Settings::values.tas_enable);
|
ReadBasicSetting(Settings::values.tas_enable);
|
||||||
ReadBasicSetting(Settings::values.tas_loop);
|
ReadBasicSetting(Settings::values.tas_loop);
|
||||||
|
@ -1139,6 +1140,7 @@ void Config::SaveControlValues() {
|
||||||
WriteGlobalSetting(Settings::values.enable_accurate_vibrations);
|
WriteGlobalSetting(Settings::values.enable_accurate_vibrations);
|
||||||
WriteGlobalSetting(Settings::values.motion_enabled);
|
WriteGlobalSetting(Settings::values.motion_enabled);
|
||||||
WriteBasicSetting(Settings::values.enable_raw_input);
|
WriteBasicSetting(Settings::values.enable_raw_input);
|
||||||
|
WriteBasicSetting(Settings::values.enable_joycon_driver);
|
||||||
WriteBasicSetting(Settings::values.keyboard_enabled);
|
WriteBasicSetting(Settings::values.keyboard_enabled);
|
||||||
WriteBasicSetting(Settings::values.emulate_analog_keyboard);
|
WriteBasicSetting(Settings::values.emulate_analog_keyboard);
|
||||||
WriteBasicSetting(Settings::values.mouse_panning_sensitivity);
|
WriteBasicSetting(Settings::values.mouse_panning_sensitivity);
|
||||||
|
|
|
@ -138,6 +138,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
|
||||||
Settings::values.controller_navigation = ui->controller_navigation->isChecked();
|
Settings::values.controller_navigation = ui->controller_navigation->isChecked();
|
||||||
Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked();
|
Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked();
|
||||||
Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked();
|
Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked();
|
||||||
|
Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureInputAdvanced::LoadConfiguration() {
|
void ConfigureInputAdvanced::LoadConfiguration() {
|
||||||
|
@ -172,6 +173,7 @@ void ConfigureInputAdvanced::LoadConfiguration() {
|
||||||
ui->controller_navigation->setChecked(Settings::values.controller_navigation.GetValue());
|
ui->controller_navigation->setChecked(Settings::values.controller_navigation.GetValue());
|
||||||
ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue());
|
ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue());
|
||||||
ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue());
|
ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue());
|
||||||
|
ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue());
|
||||||
|
|
||||||
UpdateUIEnabled();
|
UpdateUIEnabled();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2696,6 +2696,22 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="enable_joycon_driver">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Requires restarting yuzu</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>23</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable direct JoyCon driver</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
<widget class="QCheckBox" name="mouse_panning">
|
<widget class="QCheckBox" name="mouse_panning">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -2708,7 +2724,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="2">
|
<item row="6" column="2">
|
||||||
<widget class="QSpinBox" name="mouse_panning_sensitivity">
|
<widget class="QSpinBox" name="mouse_panning_sensitivity">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Mouse sensitivity</string>
|
<string>Mouse sensitivity</string>
|
||||||
|
@ -2730,14 +2746,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="motion_touch">
|
<widget class="QLabel" name="motion_touch">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Motion / Touch</string>
|
<string>Motion / Touch</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2">
|
<item row="7" column="2">
|
||||||
<widget class="QPushButton" name="buttonMotionTouch">
|
<widget class="QPushButton" name="buttonMotionTouch">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Configure</string>
|
<string>Configure</string>
|
||||||
|
|
Loading…
Reference in New Issue