| 1 | // Copyright 2019 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionSimulation.h" |
| 5 | |
| 6 | #include <QGridLayout> |
| 7 | #include <QGroupBox> |
| 8 | #include <QHBoxLayout> |
| 9 | #include <QLabel> |
| 10 | |
| 11 | #include "Core/HW/Wiimote.h" |
| 12 | #include "Core/HW/WiimoteEmu/Extension/Nunchuk.h" |
| 13 | #include "Core/HW/WiimoteEmu/WiimoteEmu.h" |
| 14 | |
| 15 | #include "InputCommon/InputConfig.h" |
| 16 | |
| 17 | WiimoteEmuExtensionMotionSimulation::WiimoteEmuExtensionMotionSimulation(MappingWindow* window) |
| 18 | : MappingWidget(window) |
| 19 | { |
| 20 | CreateNunchukLayout(); |
| 21 | CreateMainLayout(); |
| 22 | } |
| 23 | |
| 24 | void WiimoteEmuExtensionMotionSimulation::CreateNunchukLayout() |
| 25 | { |
| 26 | auto* layout = new QGridLayout(); |
| 27 | m_nunchuk_box = new QGroupBox(tr("Nunchuk"), this); |
| 28 | |
| 29 | layout->addWidget(CreateGroupBox(tr("Shake"), Wiimote::GetNunchukGroup( |
| 30 | GetPort(), WiimoteEmu::NunchukGroup::Shake)), |
| 31 | 0, 0); |
| 32 | layout->addWidget(CreateGroupBox(tr("Tilt"), Wiimote::GetNunchukGroup( |
| 33 | GetPort(), WiimoteEmu::NunchukGroup::Tilt)), |
| 34 | 0, 1); |
| 35 | layout->addWidget(CreateGroupBox(tr("Swing"), Wiimote::GetNunchukGroup( |
| 36 | GetPort(), WiimoteEmu::NunchukGroup::Swing)), |
| 37 | 0, 2); |
| 38 | |
| 39 | m_nunchuk_box->setLayout(layout); |
| 40 | } |
| 41 | |
| 42 | void WiimoteEmuExtensionMotionSimulation::CreateMainLayout() |
| 43 | { |
| 44 | m_main_layout = new QHBoxLayout(); |
| 45 | |
| 46 | m_main_layout->addWidget(m_nunchuk_box); |
| 47 | |
| 48 | setLayout(m_main_layout); |
| 49 | } |
| 50 | |
| 51 | void WiimoteEmuExtensionMotionSimulation::LoadSettings() |
| 52 | { |
| 53 | Wiimote::LoadConfig(); |
| 54 | } |
| 55 | |
| 56 | void WiimoteEmuExtensionMotionSimulation::SaveSettings() |
| 57 | { |
| 58 | Wiimote::GetConfig()->SaveConfig(); |
| 59 | } |
| 60 | |
| 61 | InputConfig* WiimoteEmuExtensionMotionSimulation::GetConfig() |
| 62 | { |
| 63 | return Wiimote::GetConfig(); |
| 64 | } |