Qt: GBA Pad config
This commit is contained in:
parent
d0f0b4c0e0
commit
9b80fb7deb
|
@ -124,6 +124,8 @@ add_executable(dolphin-emu
|
||||||
Config/Mapping/FreeLookGeneral.h
|
Config/Mapping/FreeLookGeneral.h
|
||||||
Config/Mapping/FreeLookRotation.cpp
|
Config/Mapping/FreeLookRotation.cpp
|
||||||
Config/Mapping/FreeLookRotation.h
|
Config/Mapping/FreeLookRotation.h
|
||||||
|
Config/Mapping/GBAPadEmu.cpp
|
||||||
|
Config/Mapping/GBAPadEmu.h
|
||||||
Config/Mapping/GCKeyboardEmu.cpp
|
Config/Mapping/GCKeyboardEmu.cpp
|
||||||
Config/Mapping/GCKeyboardEmu.h
|
Config/Mapping/GCKeyboardEmu.h
|
||||||
Config/Mapping/GCMicrophone.cpp
|
Config/Mapping/GCMicrophone.cpp
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
@ -24,23 +25,37 @@
|
||||||
|
|
||||||
#include "InputCommon/GCAdapter.h"
|
#include "InputCommon/GCAdapter.h"
|
||||||
|
|
||||||
static const std::map<SerialInterface::SIDevices, int> s_gc_types = {
|
static const std::vector<std::pair<SerialInterface::SIDevices, const char*>> s_gc_types = {
|
||||||
{SerialInterface::SIDEVICE_NONE, 0}, {SerialInterface::SIDEVICE_GC_CONTROLLER, 1},
|
{SerialInterface::SIDEVICE_NONE, _trans("None")},
|
||||||
{SerialInterface::SIDEVICE_WIIU_ADAPTER, 2}, {SerialInterface::SIDEVICE_GC_STEERING, 3},
|
{SerialInterface::SIDEVICE_GC_CONTROLLER, _trans("Standard Controller")},
|
||||||
{SerialInterface::SIDEVICE_DANCEMAT, 4}, {SerialInterface::SIDEVICE_GC_TARUKONGA, 5},
|
{SerialInterface::SIDEVICE_WIIU_ADAPTER, _trans("GameCube Adapter for Wii U")},
|
||||||
{SerialInterface::SIDEVICE_GC_GBA, 6}, {SerialInterface::SIDEVICE_GC_KEYBOARD, 7}};
|
{SerialInterface::SIDEVICE_GC_STEERING, _trans("Steering Wheel")},
|
||||||
|
{SerialInterface::SIDEVICE_DANCEMAT, _trans("Dance Mat")},
|
||||||
|
{SerialInterface::SIDEVICE_GC_TARUKONGA, _trans("DK Bongos")},
|
||||||
|
#ifdef HAS_LIBMGBA
|
||||||
|
{SerialInterface::SIDEVICE_GC_GBA_EMULATED, _trans("GBA (Integrated)")},
|
||||||
|
#endif
|
||||||
|
{SerialInterface::SIDEVICE_GC_GBA, _trans("GBA (TCP)")},
|
||||||
|
{SerialInterface::SIDEVICE_GC_KEYBOARD, _trans("Keyboard")}};
|
||||||
|
|
||||||
static std::optional<int> ToGCMenuIndex(const SerialInterface::SIDevices sidevice)
|
static std::optional<int> ToGCMenuIndex(const SerialInterface::SIDevices sidevice)
|
||||||
{
|
{
|
||||||
auto it = s_gc_types.find(sidevice);
|
for (size_t i = 0; i < s_gc_types.size(); ++i)
|
||||||
return it != s_gc_types.end() ? it->second : std::optional<int>();
|
{
|
||||||
|
if (s_gc_types[i].first == sidevice)
|
||||||
|
return static_cast<int>(i);
|
||||||
|
}
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<SerialInterface::SIDevices> FromGCMenuIndex(const int menudevice)
|
static SerialInterface::SIDevices FromGCMenuIndex(const int menudevice)
|
||||||
{
|
{
|
||||||
auto it = std::find_if(s_gc_types.begin(), s_gc_types.end(),
|
return s_gc_types[menudevice].first;
|
||||||
[=](auto pair) { return pair.second == menudevice; });
|
}
|
||||||
return it != s_gc_types.end() ? it->first : std::optional<SerialInterface::SIDevices>();
|
|
||||||
|
static bool IsConfigurable(SerialInterface::SIDevices sidevice)
|
||||||
|
{
|
||||||
|
return sidevice != SerialInterface::SIDEVICE_NONE && sidevice != SerialInterface::SIDEVICE_GC_GBA;
|
||||||
}
|
}
|
||||||
|
|
||||||
GamecubeControllersWidget::GamecubeControllersWidget(QWidget* parent) : QWidget(parent)
|
GamecubeControllersWidget::GamecubeControllersWidget(QWidget* parent) : QWidget(parent)
|
||||||
|
@ -63,11 +78,9 @@ void GamecubeControllersWidget::CreateLayout()
|
||||||
auto* gc_box = m_gc_controller_boxes[i] = new QComboBox();
|
auto* gc_box = m_gc_controller_boxes[i] = new QComboBox();
|
||||||
auto* gc_button = m_gc_buttons[i] = new QPushButton(tr("Configure"));
|
auto* gc_button = m_gc_buttons[i] = new QPushButton(tr("Configure"));
|
||||||
|
|
||||||
for (const auto& item :
|
for (const auto& item : s_gc_types)
|
||||||
{tr("None"), tr("Standard Controller"), tr("GameCube Adapter for Wii U"),
|
|
||||||
tr("Steering Wheel"), tr("Dance Mat"), tr("DK Bongos"), tr("GBA"), tr("Keyboard")})
|
|
||||||
{
|
{
|
||||||
gc_box->addItem(item);
|
gc_box->addItem(tr(item.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
int controller_row = m_gc_layout->rowCount();
|
int controller_row = m_gc_layout->rowCount();
|
||||||
|
@ -105,8 +118,8 @@ void GamecubeControllersWidget::OnGCTypeChanged(int type)
|
||||||
{
|
{
|
||||||
if (m_gc_controller_boxes[i] == box)
|
if (m_gc_controller_boxes[i] == box)
|
||||||
{
|
{
|
||||||
const int index = box->currentIndex();
|
const SerialInterface::SIDevices si_device = FromGCMenuIndex(box->currentIndex());
|
||||||
m_gc_buttons[i]->setEnabled(index != 0 && index != 6);
|
m_gc_buttons[i]->setEnabled(IsConfigurable(si_device));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,27 +138,30 @@ void GamecubeControllersWidget::OnGCPadConfigure()
|
||||||
|
|
||||||
MappingWindow::Type type;
|
MappingWindow::Type type;
|
||||||
|
|
||||||
switch (m_gc_controller_boxes[index]->currentIndex())
|
switch (FromGCMenuIndex(m_gc_controller_boxes[index]->currentIndex()))
|
||||||
{
|
{
|
||||||
case 0: // None
|
case SerialInterface::SIDEVICE_NONE:
|
||||||
case 6: // GBA
|
case SerialInterface::SIDEVICE_GC_GBA:
|
||||||
return;
|
return;
|
||||||
case 1: // Standard Controller
|
case SerialInterface::SIDEVICE_GC_CONTROLLER:
|
||||||
type = MappingWindow::Type::MAPPING_GCPAD;
|
type = MappingWindow::Type::MAPPING_GCPAD;
|
||||||
break;
|
break;
|
||||||
case 2: // GameCube Adapter for Wii U
|
case SerialInterface::SIDEVICE_WIIU_ADAPTER:
|
||||||
GCPadWiiUConfigDialog(static_cast<int>(index), this).exec();
|
GCPadWiiUConfigDialog(static_cast<int>(index), this).exec();
|
||||||
return;
|
return;
|
||||||
case 3: // Steering Wheel
|
case SerialInterface::SIDEVICE_GC_STEERING:
|
||||||
type = MappingWindow::Type::MAPPING_GC_STEERINGWHEEL;
|
type = MappingWindow::Type::MAPPING_GC_STEERINGWHEEL;
|
||||||
break;
|
break;
|
||||||
case 4: // Dance Mat
|
case SerialInterface::SIDEVICE_DANCEMAT:
|
||||||
type = MappingWindow::Type::MAPPING_GC_DANCEMAT;
|
type = MappingWindow::Type::MAPPING_GC_DANCEMAT;
|
||||||
break;
|
break;
|
||||||
case 5: // DK Bongos
|
case SerialInterface::SIDEVICE_GC_TARUKONGA:
|
||||||
type = MappingWindow::Type::MAPPING_GC_BONGOS;
|
type = MappingWindow::Type::MAPPING_GC_BONGOS;
|
||||||
break;
|
break;
|
||||||
case 7: // Keyboard
|
case SerialInterface::SIDEVICE_GC_GBA_EMULATED:
|
||||||
|
type = MappingWindow::Type::MAPPING_GC_GBA;
|
||||||
|
break;
|
||||||
|
case SerialInterface::SIDEVICE_GC_KEYBOARD:
|
||||||
type = MappingWindow::Type::MAPPING_GC_KEYBOARD;
|
type = MappingWindow::Type::MAPPING_GC_KEYBOARD;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -162,11 +178,12 @@ void GamecubeControllersWidget::LoadSettings()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_gc_groups.size(); i++)
|
for (size_t i = 0; i < m_gc_groups.size(); i++)
|
||||||
{
|
{
|
||||||
const std::optional<int> gc_index = ToGCMenuIndex(SConfig::GetInstance().m_SIDevice[i]);
|
const SerialInterface::SIDevices si_device = SConfig::GetInstance().m_SIDevice[i];
|
||||||
|
const std::optional<int> gc_index = ToGCMenuIndex(si_device);
|
||||||
if (gc_index)
|
if (gc_index)
|
||||||
{
|
{
|
||||||
m_gc_controller_boxes[i]->setCurrentIndex(*gc_index);
|
m_gc_controller_boxes[i]->setCurrentIndex(*gc_index);
|
||||||
m_gc_buttons[i]->setEnabled(*gc_index != 0 && *gc_index != 6);
|
m_gc_buttons[i]->setEnabled(IsConfigurable(si_device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,16 +193,13 @@ void GamecubeControllersWidget::SaveSettings()
|
||||||
for (size_t i = 0; i < m_gc_groups.size(); i++)
|
for (size_t i = 0; i < m_gc_groups.size(); i++)
|
||||||
{
|
{
|
||||||
const int index = m_gc_controller_boxes[i]->currentIndex();
|
const int index = m_gc_controller_boxes[i]->currentIndex();
|
||||||
const std::optional<SerialInterface::SIDevices> si_device = FromGCMenuIndex(index);
|
const SerialInterface::SIDevices si_device = FromGCMenuIndex(index);
|
||||||
if (si_device)
|
SConfig::GetInstance().m_SIDevice[i] = si_device;
|
||||||
{
|
|
||||||
SConfig::GetInstance().m_SIDevice[i] = *si_device;
|
|
||||||
|
|
||||||
if (Core::IsRunning())
|
if (Core::IsRunning())
|
||||||
SerialInterface::ChangeDevice(*si_device, static_cast<s32>(i));
|
SerialInterface::ChangeDevice(si_device, static_cast<s32>(i));
|
||||||
}
|
|
||||||
|
|
||||||
m_gc_buttons[i]->setEnabled(index != 0 && index != 6);
|
m_gc_buttons[i]->setEnabled(IsConfigurable(si_device));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GCAdapter::UseAdapter())
|
if (GCAdapter::UseAdapter())
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "DolphinQt/Config/Mapping/GBAPadEmu.h"
|
||||||
|
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
|
|
||||||
|
#include "Core/HW/GBAPad.h"
|
||||||
|
#include "Core/HW/GBAPadEmu.h"
|
||||||
|
#include "InputCommon/InputConfig.h"
|
||||||
|
|
||||||
|
GBAPadEmu::GBAPadEmu(MappingWindow* window) : MappingWidget(window)
|
||||||
|
{
|
||||||
|
CreateMainLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GBAPadEmu::CreateMainLayout()
|
||||||
|
{
|
||||||
|
auto* layout = new QGridLayout;
|
||||||
|
|
||||||
|
layout->addWidget(
|
||||||
|
CreateControlsBox(tr("D-Pad"), Pad::GetGBAGroup(GetPort(), GBAPadGroup::DPad), 2), 0, 0, -1,
|
||||||
|
1);
|
||||||
|
layout->addWidget(
|
||||||
|
CreateControlsBox(tr("Buttons"), Pad::GetGBAGroup(GetPort(), GBAPadGroup::Buttons), 2), 0, 1,
|
||||||
|
-1, 1);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GBAPadEmu::LoadSettings()
|
||||||
|
{
|
||||||
|
Pad::LoadGBAConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GBAPadEmu::SaveSettings()
|
||||||
|
{
|
||||||
|
Pad::GetGBAConfig()->SaveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
InputConfig* GBAPadEmu::GetConfig()
|
||||||
|
{
|
||||||
|
return Pad::GetGBAConfig();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2021 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||||
|
|
||||||
|
class GBAPadEmu final : public MappingWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit GBAPadEmu(MappingWindow* window);
|
||||||
|
|
||||||
|
InputConfig* GetConfig() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void LoadSettings() override;
|
||||||
|
void SaveSettings() override;
|
||||||
|
void CreateMainLayout();
|
||||||
|
};
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/FreeLookGeneral.h"
|
#include "DolphinQt/Config/Mapping/FreeLookGeneral.h"
|
||||||
#include "DolphinQt/Config/Mapping/FreeLookRotation.h"
|
#include "DolphinQt/Config/Mapping/FreeLookRotation.h"
|
||||||
|
#include "DolphinQt/Config/Mapping/GBAPadEmu.h"
|
||||||
#include "DolphinQt/Config/Mapping/GCKeyboardEmu.h"
|
#include "DolphinQt/Config/Mapping/GCKeyboardEmu.h"
|
||||||
#include "DolphinQt/Config/Mapping/GCMicrophone.h"
|
#include "DolphinQt/Config/Mapping/GCMicrophone.h"
|
||||||
#include "DolphinQt/Config/Mapping/GCPadEmu.h"
|
#include "DolphinQt/Config/Mapping/GCPadEmu.h"
|
||||||
|
@ -374,10 +375,15 @@ void MappingWindow::SetMappingType(MappingWindow::Type type)
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
case Type::MAPPING_GC_GBA:
|
||||||
|
widget = new GBAPadEmu(this);
|
||||||
|
setWindowTitle(tr("GameBoy Advance at Port %1").arg(GetPort() + 1));
|
||||||
|
AddWidget(tr("GameBoy Advance"), widget);
|
||||||
|
break;
|
||||||
case Type::MAPPING_GC_KEYBOARD:
|
case Type::MAPPING_GC_KEYBOARD:
|
||||||
widget = new GCKeyboardEmu(this);
|
widget = new GCKeyboardEmu(this);
|
||||||
AddWidget(tr("GameCube Keyboard"), widget);
|
|
||||||
setWindowTitle(tr("GameCube Keyboard at Port %1").arg(GetPort() + 1));
|
setWindowTitle(tr("GameCube Keyboard at Port %1").arg(GetPort() + 1));
|
||||||
|
AddWidget(tr("GameCube Keyboard"), widget);
|
||||||
break;
|
break;
|
||||||
case Type::MAPPING_GC_BONGOS:
|
case Type::MAPPING_GC_BONGOS:
|
||||||
case Type::MAPPING_GC_STEERINGWHEEL:
|
case Type::MAPPING_GC_STEERINGWHEEL:
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
// GameCube
|
// GameCube
|
||||||
MAPPING_GC_BONGOS,
|
MAPPING_GC_BONGOS,
|
||||||
MAPPING_GC_DANCEMAT,
|
MAPPING_GC_DANCEMAT,
|
||||||
|
MAPPING_GC_GBA,
|
||||||
MAPPING_GC_KEYBOARD,
|
MAPPING_GC_KEYBOARD,
|
||||||
MAPPING_GCPAD,
|
MAPPING_GCPAD,
|
||||||
MAPPING_GC_STEERINGWHEEL,
|
MAPPING_GC_STEERINGWHEEL,
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
<ClCompile Include="Config\LogWidget.cpp" />
|
<ClCompile Include="Config\LogWidget.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\FreeLookGeneral.cpp" />
|
<ClCompile Include="Config\Mapping\FreeLookGeneral.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\FreeLookRotation.cpp" />
|
<ClCompile Include="Config\Mapping\FreeLookRotation.cpp" />
|
||||||
|
<ClCompile Include="Config\Mapping\GBAPadEmu.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\GCKeyboardEmu.cpp" />
|
<ClCompile Include="Config\Mapping\GCKeyboardEmu.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\GCMicrophone.cpp" />
|
<ClCompile Include="Config\Mapping\GCMicrophone.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\GCPadEmu.cpp" />
|
<ClCompile Include="Config\Mapping\GCPadEmu.cpp" />
|
||||||
|
@ -256,6 +257,7 @@
|
||||||
<QtMoc Include="Config\LogWidget.h" />
|
<QtMoc Include="Config\LogWidget.h" />
|
||||||
<QtMoc Include="Config\Mapping\FreeLookGeneral.h" />
|
<QtMoc Include="Config\Mapping\FreeLookGeneral.h" />
|
||||||
<QtMoc Include="Config\Mapping\FreeLookRotation.h" />
|
<QtMoc Include="Config\Mapping\FreeLookRotation.h" />
|
||||||
|
<QtMoc Include="Config\Mapping\GBAPadEmu.h" />
|
||||||
<QtMoc Include="Config\Mapping\GCKeyboardEmu.h" />
|
<QtMoc Include="Config\Mapping\GCKeyboardEmu.h" />
|
||||||
<QtMoc Include="Config\Mapping\GCMicrophone.h" />
|
<QtMoc Include="Config\Mapping\GCMicrophone.h" />
|
||||||
<QtMoc Include="Config\Mapping\GCPadEmu.h" />
|
<QtMoc Include="Config\Mapping\GCPadEmu.h" />
|
||||||
|
|
Loading…
Reference in New Issue