diff --git a/src/duckstation-qt/controllerglobalsettingswidget.cpp b/src/duckstation-qt/controllerglobalsettingswidget.cpp index 58bfba912..5d21ccc93 100644 --- a/src/duckstation-qt/controllerglobalsettingswidget.cpp +++ b/src/duckstation-qt/controllerglobalsettingswidget.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "controllerglobalsettingswidget.h" @@ -23,15 +23,31 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent, &ControllerGlobalSettingsWidget::updateSDLOptionsEnabled); connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked); +#ifdef __APPLE__ + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLIOKitDriver, "InputSources", "SDLIOKitDriver", true); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLMFIDriver, "InputSources", "SDLMFIDriver", true); +#else + m_ui.sdlGridLayout->removeWidget(m_ui.enableSDLIOKitDriver); + m_ui.enableSDLIOKitDriver->deleteLater(); + m_ui.enableSDLIOKitDriver = nullptr; + m_ui.sdlGridLayout->removeWidget(m_ui.enableSDLMFIDriver); + m_ui.enableSDLMFIDriver->deleteLater(); + m_ui.enableSDLMFIDriver = nullptr; +#endif + #ifdef _WIN32 SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableDInputSource, "InputSources", "DInput", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableXInputSource, "InputSources", "XInput", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableRawInput, "InputSources", "RawInput", false); #else - m_ui.enableDInputSource->setEnabled(false); - m_ui.enableXInputSource->setEnabled(false); - m_ui.enableRawInput->setEnabled(false); + m_ui.mainLayout->removeWidget(m_ui.xinputGroup); + m_ui.xinputGroup->deleteLater(); + m_ui.xinputGroup = nullptr; + m_ui.mainLayout->removeWidget(m_ui.dinputGroup); + m_ui.dinputGroup->deleteLater(); + m_ui.dinputGroup = nullptr; #endif + ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableMouseMapping, "UI", "EnableMouseMapping", false); SettingWidgetBinder::BindWidgetToEnumSetting(sif, m_ui.multitapMode, "ControllerPorts", "MultitapMode", diff --git a/src/duckstation-qt/controllerglobalsettingswidget.ui b/src/duckstation-qt/controllerglobalsettingswidget.ui index 55a224a60..749d0b844 100644 --- a/src/duckstation-qt/controllerglobalsettingswidget.ui +++ b/src/duckstation-qt/controllerglobalsettingswidget.ui @@ -7,7 +7,7 @@ 0 0 902 - 673 + 800 @@ -129,7 +129,7 @@ SDL Input Source - + @@ -163,13 +163,26 @@ - .. - + .. + + + + Enable IOKit Driver + + + + + + + Enable MFI Driver + + + diff --git a/src/util/sdl_input_source.cpp b/src/util/sdl_input_source.cpp index 4db534bbe..1e401e89e 100644 --- a/src/util/sdl_input_source.cpp +++ b/src/util/sdl_input_source.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #include "sdl_input_source.h" @@ -172,9 +172,21 @@ void SDLInputSource::UpdateSettings(SettingsInterface& si, std::unique_lockgame_controller, color); } + + m_controller_enhanced_mode = si.GetBoolValue("InputSources", "SDLControllerEnhancedMode", false); + m_sdl_hints = si.GetKeyValueList("SDLHints"); + +#ifdef __APPLE__ + m_enable_iokit_driver = si.GetBoolValue("InputSources", "SDLIOKitDriver", true); + m_enable_mfi_driver = si.GetBoolValue("InputSources", "SDLMFIDriver", true); +#endif } u32 SDLInputSource::GetRGBForPlayerId(SettingsInterface& si, u32 player_id) @@ -256,14 +273,14 @@ void SDLInputSource::SetHints() SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, m_controller_enhanced_mode ? "1" : "0"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, m_controller_enhanced_mode ? "1" : "0"); - // Enable Wii U Pro Controller support - // New as of SDL 2.26, so use string - SDL_SetHint("SDL_JOYSTICK_HIDAPI_WII", "1"); -#ifndef _WIN32 - // Gets us pressure sensitive button support on Linux - // Apparently doesn't work on Windows, so leave it off there - // New as of SDL 2.26, so use string - SDL_SetHint("SDL_JOYSTICK_HIDAPI_PS3", "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); + +#ifdef __APPLE__ + Log_InfoFmt("IOKit is {}, MFI is {}.", m_enable_iokit_driver ? "enabled" : "disabled", + m_enable_mfi_driver ? "enabled" : "disabled"); + SDL_SetHint(SDL_HINT_JOYSTICK_IOKIT, m_enable_iokit_driver ? "1" : "0"); + SDL_SetHint(SDL_HINT_JOYSTICK_MFI, m_enable_mfi_driver ? "1" : "0"); #endif for (const std::pair& hint : m_sdl_hints) @@ -842,7 +859,7 @@ bool SDLInputSource::HandleJoystickButtonEvent(const SDL_JoyButtonEvent* ev) if (it == m_controllers.end()) return false; if (ev->button < it->joy_button_used_in_gc.size() && it->joy_button_used_in_gc[ev->button]) - return false; // Will get handled by GC event + return false; // Will get handled by GC event const u32 button = ev->button + static_cast(std::size(s_sdl_button_names)); // Ensure we don't conflict with GC buttons const InputBindingKey key(MakeGenericControllerButtonKey(InputSourceType::SDL, it->player_id, button)); diff --git a/src/util/sdl_input_source.h b/src/util/sdl_input_source.h index 3c8aebab8..7ed6185d1 100644 --- a/src/util/sdl_input_source.h +++ b/src/util/sdl_input_source.h @@ -1,9 +1,11 @@ -// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once -#include "SDL.h" #include "input_source.h" + +#include + #include #include #include @@ -86,8 +88,14 @@ private: ControllerDataVector m_controllers; - bool m_sdl_subsystem_initialized = false; - bool m_controller_enhanced_mode = false; std::array m_led_colors{}; std::vector> m_sdl_hints; + + bool m_sdl_subsystem_initialized = false; + bool m_controller_enhanced_mode = false; + +#ifdef __APPLE__ + bool m_enable_iokit_driver = false; + bool m_enable_mfi_driver = false; +#endif };