InputCommon: Add setting to enable GCAdapter ControllerInterface backend.

This commit is contained in:
Jordan Woyak 2022-10-09 22:26:49 -05:00
parent 1af21fbd65
commit 0f6b26e3fe
6 changed files with 25 additions and 3 deletions

View File

@ -186,6 +186,8 @@ const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING{
const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER{{System::Main, "Core", "WiimoteEnableSpeaker"}, false};
const Info<bool> MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE{
{System::Main, "Core", "WiimoteControllerInterface"}, false};
const Info<bool> MAIN_USE_GC_ADAPTER_FOR_CONTROLLER_INTERFACE{
{System::Main, "Core", "GCAdapterControllerInterface"}, false};
const Info<bool> MAIN_MMU{{System::Main, "Core", "MMU"}, false};
const Info<bool> MAIN_PAUSE_ON_PANIC{{System::Main, "Core", "PauseOnPanic"}, false};
const Info<int> MAIN_BB_DUMP_PORT{{System::Main, "Core", "BBDumpPort"}, -1};

View File

@ -106,6 +106,7 @@ extern const Info<bool> MAIN_WII_KEYBOARD;
extern const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING;
extern const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER;
extern const Info<bool> MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE;
extern const Info<bool> MAIN_USE_GC_ADAPTER_FOR_CONTROLLER_INTERFACE;
extern const Info<bool> MAIN_MMU;
extern const Info<bool> MAIN_PAUSE_ON_PANIC;
extern const Info<int> MAIN_BB_DUMP_PORT;

View File

@ -3,6 +3,7 @@
#include "DolphinQt/Config/GamecubeControllersWidget.h"
#include <QCheckBox>
#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
@ -95,6 +96,10 @@ void GamecubeControllersWidget::CreateLayout()
m_gc_layout->addWidget(gc_box, controller_row, 1);
m_gc_layout->addWidget(gc_button, controller_row, 2);
}
m_gcpad_ciface = new QCheckBox(tr("Use Wii-U Adapter for Emulated Controllers"));
m_gc_layout->addWidget(m_gcpad_ciface, m_gc_layout->rowCount(), 0, 1, -1);
m_gc_box->setLayout(m_gc_layout);
auto* layout = new QVBoxLayout;
@ -114,6 +119,8 @@ void GamecubeControllersWidget::ConnectWidgets()
});
connect(m_gc_buttons[i], &QPushButton::clicked, this, [this, i] { OnGCPadConfigure(i); });
}
connect(m_gcpad_ciface, &QCheckBox::toggled, this, &GamecubeControllersWidget::SaveSettings);
}
void GamecubeControllersWidget::OnGCTypeChanged(size_t index)
@ -184,6 +191,9 @@ void GamecubeControllersWidget::LoadSettings(Core::State state)
OnGCTypeChanged(i);
}
}
SignalBlocking(m_gcpad_ciface)
->setChecked(Config::Get(Config::MAIN_USE_GC_ADAPTER_FOR_CONTROLLER_INTERFACE));
}
void GamecubeControllersWidget::SaveSettings()
@ -203,11 +213,15 @@ void GamecubeControllersWidget::SaveSettings()
static_cast<s32>(i));
}
}
Config::SetBaseOrCurrent(Config::MAIN_USE_GC_ADAPTER_FOR_CONTROLLER_INTERFACE,
m_gcpad_ciface->isChecked());
}
SConfig::GetInstance().SaveSettings();
if (GCAdapter::UseAdapter())
GCAdapter::StartScanThread();
else
GCAdapter::StopScanThread();
SConfig::GetInstance().SaveSettings();
}

View File

@ -7,6 +7,7 @@
#include <array>
class QCheckBox;
class QComboBox;
class QHBoxLayout;
class QGridLayout;
@ -40,4 +41,5 @@ private:
std::array<QComboBox*, 4> m_gc_controller_boxes;
std::array<QPushButton*, 4> m_gc_buttons;
std::array<QHBoxLayout*, 4> m_gc_groups;
QCheckBox* m_gcpad_ciface;
};

View File

@ -87,6 +87,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi)
m_input_backends.emplace_back(ciface::SteamDeck::CreateInputBackend(this));
#endif
// TODO: obey Config::Get(Config::MAIN_USE_GC_ADAPTER_FOR_CONTROLLER_INTERFACE)
m_input_backends.emplace_back(ciface::WiiUAdapter::CreateInputBackend(this));
// Don't allow backends to add devices before the first RefreshDevices() as they will be cleaned

View File

@ -415,12 +415,14 @@ void SetAdapterCallback(std::function<void(void)> func)
static void RefreshConfig()
{
s_is_adapter_wanted = false;
s_is_adapter_wanted = Config::Get(Config::MAIN_USE_GC_ADAPTER_FOR_CONTROLLER_INTERFACE);
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
{
s_is_adapter_wanted |= Config::Get(Config::GetInfoForSIDevice(i)) ==
SerialInterface::SIDevices::SIDEVICE_WIIU_ADAPTER;
// TODO: ControllerInterface shouldn't obey this setting.
s_config_rumble_enabled[i] = Config::Get(Config::GetInfoForAdapterRumble(i));
}
}