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 #8057 from jordan-woyak/emu-tatacon
WiimoteEmu: Implement TaTaCon extension.
- Loading branch information
Showing
12 changed files
with
192 additions
and
0 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "Core/HW/WiimoteEmu/Extension/TaTaCon.h" | ||
|
|
||
| #include <array> | ||
| #include <cassert> | ||
| #include <cstring> | ||
|
|
||
| #include "Common/BitUtils.h" | ||
| #include "Common/Common.h" | ||
| #include "Common/CommonTypes.h" | ||
| #include "Core/HW/WiimoteEmu/WiimoteEmu.h" | ||
|
|
||
| #include "InputCommon/ControllerEmu/Control/Input.h" | ||
| #include "InputCommon/ControllerEmu/ControlGroup/Buttons.h" | ||
|
|
||
| namespace WiimoteEmu | ||
| { | ||
| constexpr std::array<u8, 6> tatacon_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x11}}; | ||
|
|
||
| constexpr std::array<u8, 2> center_bitmasks{{ | ||
| TaTaCon::CENTER_LEFT, | ||
| TaTaCon::CENTER_RIGHT, | ||
| }}; | ||
|
|
||
| constexpr std::array<u8, 2> rim_bitmasks{{ | ||
| TaTaCon::RIM_LEFT, | ||
| TaTaCon::RIM_RIGHT, | ||
| }}; | ||
|
|
||
| constexpr std::array<const char*, 2> position_names{{ | ||
| _trans("Left"), | ||
| _trans("Right"), | ||
| }}; | ||
|
|
||
| // i18n: The drum controller used in "Taiko no Tatsujin" games. Also known as a "TaTaCon". | ||
| TaTaCon::TaTaCon() : Extension3rdParty("TaTaCon", _trans("Taiko Drum")) | ||
| { | ||
| // i18n: Refers to the "center" of a TaTaCon drum. | ||
| groups.emplace_back(m_center = new ControllerEmu::Buttons(_trans("Center"))); | ||
| for (auto& name : position_names) | ||
| m_center->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, name)); | ||
|
|
||
| // i18n: Refers to the "rim" of a TaTaCon drum. | ||
| groups.emplace_back(m_rim = new ControllerEmu::Buttons(_trans("Rim"))); | ||
| for (auto& name : position_names) | ||
| m_rim->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, name)); | ||
| } | ||
|
|
||
| void TaTaCon::Update() | ||
| { | ||
| DataFormat tatacon_data = {}; | ||
|
|
||
| m_center->GetState(&tatacon_data.state, center_bitmasks.data()); | ||
| m_rim->GetState(&tatacon_data.state, rim_bitmasks.data()); | ||
|
|
||
| // Flip button bits. | ||
| tatacon_data.state ^= 0xff; | ||
|
|
||
| Common::BitCastPtr<DataFormat>(&m_reg.controller_data) = tatacon_data; | ||
| } | ||
|
|
||
| bool TaTaCon::IsButtonPressed() const | ||
| { | ||
| u8 state = 0; | ||
| m_center->GetState(&state, center_bitmasks.data()); | ||
| m_rim->GetState(&state, rim_bitmasks.data()); | ||
| return state != 0; | ||
| } | ||
|
|
||
| void TaTaCon::Reset() | ||
| { | ||
| m_reg = {}; | ||
| m_reg.identifier = tatacon_id; | ||
|
|
||
| // Assuming calibration is 0xff filled like every other 3rd-party extension. | ||
| m_reg.calibration.fill(0xff); | ||
| } | ||
|
|
||
| ControllerEmu::ControlGroup* TaTaCon::GetGroup(TaTaConGroup group) | ||
| { | ||
| switch (group) | ||
| { | ||
| case TaTaConGroup::Center: | ||
| return m_center; | ||
| case TaTaConGroup::Rim: | ||
| return m_rim; | ||
| default: | ||
| assert(false); | ||
| return nullptr; | ||
| } | ||
| } | ||
| } // namespace WiimoteEmu |
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,50 @@ | ||
| // Copyright 2019 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Core/HW/WiimoteEmu/Extension/Extension.h" | ||
|
|
||
| namespace ControllerEmu | ||
| { | ||
| class Buttons; | ||
| } // namespace ControllerEmu | ||
|
|
||
| namespace WiimoteEmu | ||
| { | ||
| enum class TaTaConGroup | ||
| { | ||
| Center, | ||
| Rim, | ||
| }; | ||
|
|
||
| class TaTaCon : public Extension3rdParty | ||
| { | ||
| public: | ||
| struct DataFormat | ||
| { | ||
| std::array<u8, 5> nothing; | ||
|
|
||
| u8 state; | ||
| }; | ||
| static_assert(sizeof(DataFormat) == 6, "Wrong size"); | ||
|
|
||
| TaTaCon(); | ||
|
|
||
| void Update() override; | ||
| bool IsButtonPressed() const override; | ||
| void Reset() override; | ||
|
|
||
| ControllerEmu::ControlGroup* GetGroup(TaTaConGroup group); | ||
|
|
||
| static constexpr u8 CENTER_LEFT = 0x40; | ||
| static constexpr u8 CENTER_RIGHT = 0x10; | ||
| static constexpr u8 RIM_LEFT = 0x20; | ||
| static constexpr u8 RIM_RIGHT = 0x08; | ||
|
|
||
| private: | ||
| ControllerEmu::Buttons* m_center; | ||
| ControllerEmu::Buttons* m_rim; | ||
| }; | ||
| } // namespace WiimoteEmu |
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 |
|---|---|---|
| @@ -20,6 +20,7 @@ enum ExtensionNumber : u8 | ||
| DRUMS, | ||
| TURNTABLE, | ||
| UDRAW_TABLET, | ||
| TATACON, | ||
| }; | ||
|
|
||
| // FYI: An extension must be attached. | ||
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