SDLInputSource: SDL raw input as config option.

This commit is contained in:
Stuart Kenny 2023-03-31 14:49:41 +01:00 committed by refractionpcsx2
parent e95d75e01f
commit 8a9df89bf6
5 changed files with 25 additions and 8 deletions

View File

@ -37,11 +37,13 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
#ifdef SDL_BUILD
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableSDLRawInput, "InputSources", "SDLRawInput", false);
connect(m_ui.enableSDLSource, &QCheckBox::stateChanged, this, &ControllerGlobalSettingsWidget::updateSDLOptionsEnabled);
connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked);
#else
m_ui.enableSDLSource->setEnabled(false);
m_ui.ledSettings->setEnabled(false);
m_ui.enableSDLRawInput->setEnabled(false);
#endif
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableMouseMapping, "UI", "EnableMouseMapping", false);
@ -113,6 +115,7 @@ void ControllerGlobalSettingsWidget::updateSDLOptionsEnabled()
const bool enabled = m_ui.enableSDLSource->isChecked();
m_ui.enableSDLEnhancedMode->setEnabled(enabled);
m_ui.ledSettings->setEnabled(enabled);
m_ui.enableSDLRawInput->setEnabled(enabled);
}
void ControllerGlobalSettingsWidget::ledSettingsClicked()

View File

@ -58,6 +58,13 @@
<string>SDL Input Source</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="enableSDLSource">
<property name="text">
<string>Enable SDL Input Source</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
@ -68,13 +75,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="enableSDLSource">
<property name="text">
<string>Enable SDL Input Source</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
@ -97,6 +97,13 @@
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="enableSDLRawInput">
<property name="text">
<string>Enable SDL Raw Input</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -3741,6 +3741,9 @@ void FullscreenUI::DrawControllerSettingsPage()
DrawToggleSetting(bsi, ICON_FA_WIFI " SDL DualShock 4 / DualSense Enhanced Mode",
"Provides vibration and LED control support over Bluetooth.", "InputSources", "SDLControllerEnhancedMode", false,
bsi->GetBoolValue("InputSources", "SDL", true), false);
DrawToggleSetting(bsi, ICON_FA_COG " SDL Raw Input",
"Allow SDL to use raw access to input devices.", "InputSources", "SDLRawInput", false,
bsi->GetBoolValue("InputSources", "SDL", true), false);
#endif
#ifdef _WIN32
DrawToggleSetting(bsi, ICON_FA_COG " Enable XInput Input Source",

View File

@ -142,10 +142,11 @@ bool SDLInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mut
void SDLInputSource::UpdateSettings(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock)
{
const bool old_controller_enhanced_mode = m_controller_enhanced_mode;
const bool old_controller_raw_mode = m_controller_raw_mode;
LoadSettings(si);
if (m_controller_enhanced_mode != old_controller_enhanced_mode)
if (m_controller_enhanced_mode != old_controller_enhanced_mode || m_controller_raw_mode != old_controller_raw_mode)
{
settings_lock.unlock();
ShutdownSubsystem();
@ -170,6 +171,7 @@ void SDLInputSource::Shutdown()
void SDLInputSource::LoadSettings(SettingsInterface& si)
{
m_controller_enhanced_mode = si.GetBoolValue("InputSources", "SDLControllerEnhancedMode", false);
m_controller_raw_mode = si.GetBoolValue("InputSources", "SDLRawInput", false);
m_sdl_hints = si.GetKeyValueList("SDLHints");
for (u32 i = 0; i < MAX_LED_COLORS; i++)
@ -208,6 +210,7 @@ u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view& str, u32 player_
void SDLInputSource::SetHints()
{
SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, m_controller_raw_mode ? "1" : "0");
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

View File

@ -97,6 +97,7 @@ private:
bool m_sdl_subsystem_initialized = false;
bool m_controller_enhanced_mode = false;
bool m_controller_raw_mode = false;
std::array<u32, MAX_LED_COLORS> m_led_colors{};
std::vector<std::pair<std::string, std::string>> m_sdl_hints;
};