mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
DolphinQt: DualSense Player LED toggle
This commit is contained in:
parent
53ede795a2
commit
7b2b6d7a32
@ -487,6 +487,7 @@ const Info<bool> MAIN_MOVIE_SHOW_RERECORD{{System::Main, "Movie", "ShowRerecord"
|
|||||||
// Main.Input
|
// Main.Input
|
||||||
|
|
||||||
const Info<bool> MAIN_INPUT_BACKGROUND_INPUT{{System::Main, "Input", "BackgroundInput"}, false};
|
const Info<bool> MAIN_INPUT_BACKGROUND_INPUT{{System::Main, "Input", "BackgroundInput"}, false};
|
||||||
|
const Info<bool> MAIN_INPUT_SDL_PS5_PLAYER_LED{{System::Main, "Input", "SDLPS5PlayerLED"}, false};
|
||||||
|
|
||||||
// Main.Debug
|
// Main.Debug
|
||||||
|
|
||||||
|
@ -320,6 +320,7 @@ extern const Info<bool> MAIN_MOVIE_SHOW_RERECORD;
|
|||||||
// Main.Input
|
// Main.Input
|
||||||
|
|
||||||
extern const Info<bool> MAIN_INPUT_BACKGROUND_INPUT;
|
extern const Info<bool> MAIN_INPUT_BACKGROUND_INPUT;
|
||||||
|
extern const Info<bool> MAIN_INPUT_SDL_PS5_PLAYER_LED;
|
||||||
|
|
||||||
// Main.Debug
|
// Main.Debug
|
||||||
|
|
||||||
|
@ -33,10 +33,12 @@ void CommonControllersWidget::CreateLayout()
|
|||||||
m_common_box = new QGroupBox(tr("Common"));
|
m_common_box = new QGroupBox(tr("Common"));
|
||||||
m_common_layout = new QVBoxLayout();
|
m_common_layout = new QVBoxLayout();
|
||||||
m_common_bg_input = new QCheckBox(tr("Background Input"));
|
m_common_bg_input = new QCheckBox(tr("Background Input"));
|
||||||
|
m_common_sdl_ps5_player_led = new QCheckBox(tr("Enable DualSense Player LED"));
|
||||||
m_common_configure_controller_interface =
|
m_common_configure_controller_interface =
|
||||||
new NonDefaultQPushButton(tr("Alternate Input Sources"));
|
new NonDefaultQPushButton(tr("Alternate Input Sources"));
|
||||||
|
|
||||||
m_common_layout->addWidget(m_common_bg_input);
|
m_common_layout->addWidget(m_common_bg_input);
|
||||||
|
m_common_layout->addWidget(m_common_sdl_ps5_player_led);
|
||||||
m_common_layout->addWidget(m_common_configure_controller_interface);
|
m_common_layout->addWidget(m_common_configure_controller_interface);
|
||||||
|
|
||||||
m_common_box->setLayout(m_common_layout);
|
m_common_box->setLayout(m_common_layout);
|
||||||
@ -51,6 +53,8 @@ void CommonControllersWidget::CreateLayout()
|
|||||||
void CommonControllersWidget::ConnectWidgets()
|
void CommonControllersWidget::ConnectWidgets()
|
||||||
{
|
{
|
||||||
connect(m_common_bg_input, &QCheckBox::toggled, this, &CommonControllersWidget::SaveSettings);
|
connect(m_common_bg_input, &QCheckBox::toggled, this, &CommonControllersWidget::SaveSettings);
|
||||||
|
connect(m_common_sdl_ps5_player_led, &QCheckBox::toggled, this,
|
||||||
|
&CommonControllersWidget::SaveSettings);
|
||||||
connect(m_common_configure_controller_interface, &QPushButton::clicked, this,
|
connect(m_common_configure_controller_interface, &QPushButton::clicked, this,
|
||||||
&CommonControllersWidget::OnControllerInterfaceConfigure);
|
&CommonControllersWidget::OnControllerInterfaceConfigure);
|
||||||
}
|
}
|
||||||
@ -67,10 +71,14 @@ void CommonControllersWidget::OnControllerInterfaceConfigure()
|
|||||||
void CommonControllersWidget::LoadSettings()
|
void CommonControllersWidget::LoadSettings()
|
||||||
{
|
{
|
||||||
SignalBlocking(m_common_bg_input)->setChecked(Config::Get(Config::MAIN_INPUT_BACKGROUND_INPUT));
|
SignalBlocking(m_common_bg_input)->setChecked(Config::Get(Config::MAIN_INPUT_BACKGROUND_INPUT));
|
||||||
|
SignalBlocking(m_common_sdl_ps5_player_led)
|
||||||
|
->setChecked(Config::Get(Config::MAIN_INPUT_SDL_PS5_PLAYER_LED));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonControllersWidget::SaveSettings()
|
void CommonControllersWidget::SaveSettings()
|
||||||
{
|
{
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_INPUT_BACKGROUND_INPUT, m_common_bg_input->isChecked());
|
Config::SetBaseOrCurrent(Config::MAIN_INPUT_BACKGROUND_INPUT, m_common_bg_input->isChecked());
|
||||||
|
Config::SetBaseOrCurrent(Config::MAIN_INPUT_SDL_PS5_PLAYER_LED,
|
||||||
|
m_common_sdl_ps5_player_led->isChecked());
|
||||||
Config::Save();
|
Config::Save();
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,6 @@ private:
|
|||||||
QGroupBox* m_common_box;
|
QGroupBox* m_common_box;
|
||||||
QVBoxLayout* m_common_layout;
|
QVBoxLayout* m_common_layout;
|
||||||
QCheckBox* m_common_bg_input;
|
QCheckBox* m_common_bg_input;
|
||||||
|
QCheckBox* m_common_sdl_ps5_player_led;
|
||||||
QPushButton* m_common_configure_controller_interface;
|
QPushButton* m_common_configure_controller_interface;
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "Common/ScopeGuard.h"
|
#include "Common/ScopeGuard.h"
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -287,6 +288,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void OpenAndAddDevice(int index);
|
void OpenAndAddDevice(int index);
|
||||||
|
void SetPS5PlayerLED();
|
||||||
|
|
||||||
bool HandleEventAndContinue(const SDL_Event& e);
|
bool HandleEventAndContinue(const SDL_Event& e);
|
||||||
|
|
||||||
@ -294,6 +296,7 @@ private:
|
|||||||
Uint32 m_stop_event_type;
|
Uint32 m_stop_event_type;
|
||||||
Uint32 m_populate_event_type;
|
Uint32 m_populate_event_type;
|
||||||
std::thread m_hotplug_thread;
|
std::thread m_hotplug_thread;
|
||||||
|
Config::ConfigChangedCallbackID m_config_changed_callback_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
|
std::unique_ptr<ciface::InputBackend> CreateInputBackend(ControllerInterface* controller_interface)
|
||||||
@ -435,8 +438,8 @@ InputBackend::InputBackend(ControllerInterface* controller_interface)
|
|||||||
// We want buttons to come in as positions, not labels
|
// We want buttons to come in as positions, not labels
|
||||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0");
|
SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0");
|
||||||
|
|
||||||
// Disable DualSense Player LEDs; We already colorize the Primary LED
|
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { SetPS5PlayerLED(); });
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, "0");
|
SetPS5PlayerLED();
|
||||||
|
|
||||||
m_hotplug_thread = std::thread([this] {
|
m_hotplug_thread = std::thread([this] {
|
||||||
Common::ScopeGuard quit_guard([] {
|
Common::ScopeGuard quit_guard([] {
|
||||||
@ -513,6 +516,7 @@ InputBackend::~InputBackend()
|
|||||||
if (!m_hotplug_thread.joinable())
|
if (!m_hotplug_thread.joinable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Config::RemoveConfigChangedCallback(m_config_changed_callback_id);
|
||||||
SDL_Event stop_event{m_stop_event_type};
|
SDL_Event stop_event{m_stop_event_type};
|
||||||
SDL_PushEvent(&stop_event);
|
SDL_PushEvent(&stop_event);
|
||||||
|
|
||||||
@ -528,6 +532,12 @@ void InputBackend::PopulateDevices()
|
|||||||
SDL_PushEvent(&populate_event);
|
SDL_PushEvent(&populate_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputBackend::SetPS5PlayerLED()
|
||||||
|
{
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED,
|
||||||
|
Config::Get(Config::MAIN_INPUT_SDL_PS5_PLAYER_LED) ? "1" : "0");
|
||||||
|
}
|
||||||
|
|
||||||
struct SDLMotionAxis
|
struct SDLMotionAxis
|
||||||
{
|
{
|
||||||
std::string_view name;
|
std::string_view name;
|
||||||
|
Loading…
Reference in New Issue
Block a user