Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #8451 from rlnilsen/motion-input-nunchuk
Add motion input support to nunchuk
- Loading branch information
Showing
12 changed files
with
268 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionInput.h" | ||
|
|
||
| #include <QGridLayout> | ||
| #include <QGroupBox> | ||
| #include <QHBoxLayout> | ||
| #include <QLabel> | ||
| #include <QPushButton> | ||
|
|
||
| #include "Core/HW/Wiimote.h" | ||
| #include "Core/HW/WiimoteEmu/Extension/Nunchuk.h" | ||
| #include "Core/HW/WiimoteEmu/WiimoteEmu.h" | ||
|
|
||
| #include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h" | ||
|
|
||
| #include "InputCommon/InputConfig.h" | ||
|
|
||
| WiimoteEmuExtensionMotionInput::WiimoteEmuExtensionMotionInput(MappingWindow* window) | ||
| : MappingWidget(window) | ||
| { | ||
| CreateNunchukLayout(); | ||
| CreateMainLayout(); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionInput::CreateNunchukLayout() | ||
| { | ||
| auto* layout = new QGridLayout(); | ||
| m_nunchuk_box = new QGroupBox(tr("Nunchuk"), this); | ||
|
|
||
| auto* warning_layout = new QHBoxLayout(); | ||
| auto* warning_label = new QLabel( | ||
| tr("WARNING: These controls are designed to interface directly with motion " | ||
| "sensor hardware. They are not intended for mapping traditional buttons, triggers or " | ||
| "axes. You might need to configure alternate input sources before using these controls.")); | ||
| warning_label->setWordWrap(true); | ||
| auto* warning_input_sources_button = new QPushButton(tr("Alternate Input Sources")); | ||
| warning_layout->addWidget(warning_label, 1); | ||
| warning_layout->addWidget(warning_input_sources_button, 0, Qt::AlignRight); | ||
| connect(warning_input_sources_button, &QPushButton::clicked, this, [this] { | ||
| ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this); | ||
| window->setAttribute(Qt::WA_DeleteOnClose, true); | ||
| window->setWindowModality(Qt::WindowModality::WindowModal); | ||
| window->show(); | ||
| }); | ||
| layout->addLayout(warning_layout, 0, 0, 1, -1); | ||
|
|
||
| layout->addWidget(CreateGroupBox(tr("Accelerometer"), | ||
| Wiimote::GetNunchukGroup( | ||
| GetPort(), WiimoteEmu::NunchukGroup::IMUAccelerometer)), | ||
| 1, 0); | ||
|
|
||
| m_nunchuk_box->setLayout(layout); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionInput::CreateMainLayout() | ||
| { | ||
| m_main_layout = new QHBoxLayout(); | ||
|
|
||
| m_main_layout->addWidget(m_nunchuk_box); | ||
|
|
||
| setLayout(m_main_layout); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionInput::LoadSettings() | ||
| { | ||
| Wiimote::LoadConfig(); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionInput::SaveSettings() | ||
| { | ||
| Wiimote::GetConfig()->SaveConfig(); | ||
| } | ||
|
|
||
| InputConfig* WiimoteEmuExtensionMotionInput::GetConfig() | ||
| { | ||
| return Wiimote::GetConfig(); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "DolphinQt/Config/Mapping/MappingWidget.h" | ||
|
|
||
| #include "Core/HW/WiimoteEmu/ExtensionPort.h" | ||
|
|
||
| class QGroupBox; | ||
| class QHBoxLayout; | ||
|
|
||
| class WiimoteEmuExtensionMotionInput final : public MappingWidget | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| explicit WiimoteEmuExtensionMotionInput(MappingWindow* window); | ||
|
|
||
| InputConfig* GetConfig() override; | ||
|
|
||
| private: | ||
| void LoadSettings() override; | ||
| void SaveSettings() override; | ||
|
|
||
| void CreateNunchukLayout(); | ||
| void CreateMainLayout(); | ||
|
|
||
| // Main | ||
| QHBoxLayout* m_main_layout; | ||
| QGroupBox* m_nunchuk_box; | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "DolphinQt/Config/Mapping/WiimoteEmuExtensionMotionSimulation.h" | ||
|
|
||
| #include <QGridLayout> | ||
| #include <QGroupBox> | ||
| #include <QHBoxLayout> | ||
| #include <QLabel> | ||
|
|
||
| #include "Core/HW/Wiimote.h" | ||
| #include "Core/HW/WiimoteEmu/Extension/Nunchuk.h" | ||
| #include "Core/HW/WiimoteEmu/WiimoteEmu.h" | ||
|
|
||
| #include "InputCommon/InputConfig.h" | ||
|
|
||
| WiimoteEmuExtensionMotionSimulation::WiimoteEmuExtensionMotionSimulation(MappingWindow* window) | ||
| : MappingWidget(window) | ||
| { | ||
| CreateNunchukLayout(); | ||
| CreateMainLayout(); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionSimulation::CreateNunchukLayout() | ||
| { | ||
| auto* layout = new QGridLayout(); | ||
| m_nunchuk_box = new QGroupBox(tr("Nunchuk"), this); | ||
|
|
||
| layout->addWidget(CreateGroupBox(tr("Shake"), Wiimote::GetNunchukGroup( | ||
| GetPort(), WiimoteEmu::NunchukGroup::Shake)), | ||
| 0, 0); | ||
| layout->addWidget(CreateGroupBox(tr("Tilt"), Wiimote::GetNunchukGroup( | ||
| GetPort(), WiimoteEmu::NunchukGroup::Tilt)), | ||
| 0, 1); | ||
| layout->addWidget(CreateGroupBox(tr("Swing"), Wiimote::GetNunchukGroup( | ||
| GetPort(), WiimoteEmu::NunchukGroup::Swing)), | ||
| 0, 2); | ||
|
|
||
| m_nunchuk_box->setLayout(layout); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionSimulation::CreateMainLayout() | ||
| { | ||
| m_main_layout = new QHBoxLayout(); | ||
|
|
||
| m_main_layout->addWidget(m_nunchuk_box); | ||
|
|
||
| setLayout(m_main_layout); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionSimulation::LoadSettings() | ||
| { | ||
| Wiimote::LoadConfig(); | ||
| } | ||
|
|
||
| void WiimoteEmuExtensionMotionSimulation::SaveSettings() | ||
| { | ||
| Wiimote::GetConfig()->SaveConfig(); | ||
| } | ||
|
|
||
| InputConfig* WiimoteEmuExtensionMotionSimulation::GetConfig() | ||
| { | ||
| return Wiimote::GetConfig(); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "DolphinQt/Config/Mapping/MappingWidget.h" | ||
|
|
||
| #include "Core/HW/WiimoteEmu/ExtensionPort.h" | ||
|
|
||
| class QGroupBox; | ||
| class QHBoxLayout; | ||
|
|
||
| class WiimoteEmuExtensionMotionSimulation final : public MappingWidget | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| explicit WiimoteEmuExtensionMotionSimulation(MappingWindow* window); | ||
|
|
||
| InputConfig* GetConfig() override; | ||
|
|
||
| private: | ||
| void LoadSettings() override; | ||
| void SaveSettings() override; | ||
|
|
||
| void CreateNunchukLayout(); | ||
| void CreateMainLayout(); | ||
|
|
||
| // Main | ||
| QHBoxLayout* m_main_layout; | ||
| QGroupBox* m_nunchuk_box; | ||
| }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.