mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-19 23:05:38 +00:00
SDLInputSource: Expose IOKit/MFI toggles
This commit is contained in:
parent
29b5afecae
commit
73bb2e77af
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// 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",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>902</width>
|
||||
<height>673</height>
|
||||
<height>800</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="mainLayout" columnstretch="1,0">
|
||||
|
@ -129,7 +129,7 @@
|
|||
<property name="title">
|
||||
<string>SDL Input Source</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout" name="sdlGridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
|
@ -163,13 +163,26 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="lightbulb-line">
|
||||
<normaloff>.</normaloff>.
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="enableSDLIOKitDriver">
|
||||
<property name="text">
|
||||
<string>Enable IOKit Driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="enableSDLMFIDriver">
|
||||
<property name="text">
|
||||
<string>Enable MFI Driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// 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_lock<std:
|
|||
{
|
||||
const bool old_controller_enhanced_mode = m_controller_enhanced_mode;
|
||||
|
||||
#ifdef __APPLE__
|
||||
const bool old_enable_iokit_driver = m_enable_iokit_driver;
|
||||
const bool old_enable_mfi_driver = m_enable_mfi_driver;
|
||||
#endif
|
||||
|
||||
LoadSettings(si);
|
||||
|
||||
if (m_controller_enhanced_mode != old_controller_enhanced_mode)
|
||||
#ifdef __APPLE__
|
||||
const bool drivers_changed =
|
||||
(m_enable_iokit_driver != old_enable_iokit_driver || m_enable_mfi_driver != old_enable_mfi_driver);
|
||||
#else
|
||||
constexpr bool drivers_changed = false;
|
||||
#endif
|
||||
|
||||
if (m_controller_enhanced_mode != old_controller_enhanced_mode || drivers_changed)
|
||||
{
|
||||
settings_lock.unlock();
|
||||
ShutdownSubsystem();
|
||||
|
@ -198,9 +210,6 @@ void SDLInputSource::Shutdown()
|
|||
|
||||
void SDLInputSource::LoadSettings(SettingsInterface& si)
|
||||
{
|
||||
m_controller_enhanced_mode = si.GetBoolValue("InputSources", "SDLControllerEnhancedMode", false);
|
||||
m_sdl_hints = si.GetKeyValueList("SDLHints");
|
||||
|
||||
for (u32 i = 0; i < MAX_LED_COLORS; i++)
|
||||
{
|
||||
const u32 color = GetRGBForPlayerId(si, i);
|
||||
|
@ -215,6 +224,14 @@ void SDLInputSource::LoadSettings(SettingsInterface& si)
|
|||
|
||||
SetControllerRGBLED(it->game_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<std::string, std::string>& 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<u32>(std::size(s_sdl_button_names)); // Ensure we don't conflict with GC buttons
|
||||
const InputBindingKey key(MakeGenericControllerButtonKey(InputSourceType::SDL, it->player_id, button));
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#pragma once
|
||||
#include "SDL.h"
|
||||
#include "input_source.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
@ -86,8 +88,14 @@ private:
|
|||
|
||||
ControllerDataVector m_controllers;
|
||||
|
||||
bool m_sdl_subsystem_initialized = false;
|
||||
bool m_controller_enhanced_mode = false;
|
||||
std::array<u32, MAX_LED_COLORS> m_led_colors{};
|
||||
std::vector<std::pair<std::string, std::string>> 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
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue