Merge pull request #8057 from jordan-woyak/emu-tatacon
WiimoteEmu: Implement TaTaCon extension.
This commit is contained in:
commit
159fa3ec36
|
@ -148,6 +148,7 @@ add_library(core
|
|||
HW/WiimoteEmu/Extension/Nunchuk.cpp
|
||||
HW/WiimoteEmu/Extension/Drums.cpp
|
||||
HW/WiimoteEmu/Extension/Guitar.cpp
|
||||
HW/WiimoteEmu/Extension/TaTaCon.cpp
|
||||
HW/WiimoteEmu/Extension/Turntable.cpp
|
||||
HW/WiimoteEmu/Extension/UDrawTablet.cpp
|
||||
HW/WiimoteReal/WiimoteReal.cpp
|
||||
|
|
|
@ -182,6 +182,7 @@
|
|||
<ClCompile Include="HW\WiimoteEmu\Extension\Extension.cpp" />
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\Guitar.cpp" />
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\Nunchuk.cpp" />
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\TaTaCon.cpp" />
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\Turntable.cpp" />
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\UDrawTablet.cpp" />
|
||||
<ClCompile Include="HW\WiimoteEmu\I2CBus.cpp" />
|
||||
|
@ -451,6 +452,7 @@
|
|||
<ClInclude Include="HW\WiimoteEmu\Extension\Extension.h" />
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\Guitar.h" />
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\Nunchuk.h" />
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\TaTaCon.h" />
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\Turntable.h" />
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\UDrawTablet.h" />
|
||||
<ClInclude Include="HW\WiimoteEmu\I2CBus.h" />
|
||||
|
|
|
@ -904,6 +904,9 @@
|
|||
<ClCompile Include="HW\WiimoteEmu\Extension\Nunchuk.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu\Extension</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\TaTaCon.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu\Extension</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HW\WiimoteEmu\Extension\Turntable.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu\Extension</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1622,6 +1625,9 @@
|
|||
<ClInclude Include="HW\WiimoteEmu\Extension\Nunchuk.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu\Extension</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\TaTaCon.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu\Extension</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HW\WiimoteEmu\Extension\Turntable.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu\Extension</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -72,6 +72,11 @@ ControllerEmu::ControlGroup* GetUDrawTabletGroup(int number, WiimoteEmu::UDrawTa
|
|||
->GetUDrawTabletGroup(group);
|
||||
}
|
||||
|
||||
ControllerEmu::ControlGroup* GetTaTaConGroup(int number, WiimoteEmu::TaTaConGroup group)
|
||||
{
|
||||
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->GetTaTaConGroup(group);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
s_config.UnregisterHotplugCallback();
|
||||
|
|
|
@ -27,6 +27,7 @@ enum class GuitarGroup;
|
|||
enum class DrumsGroup;
|
||||
enum class TurntableGroup;
|
||||
enum class UDrawTabletGroup;
|
||||
enum class TaTaConGroup;
|
||||
} // namespace WiimoteEmu
|
||||
|
||||
enum
|
||||
|
@ -80,6 +81,7 @@ ControllerEmu::ControlGroup* GetGuitarGroup(int number, WiimoteEmu::GuitarGroup
|
|||
ControllerEmu::ControlGroup* GetDrumsGroup(int number, WiimoteEmu::DrumsGroup group);
|
||||
ControllerEmu::ControlGroup* GetTurntableGroup(int number, WiimoteEmu::TurntableGroup group);
|
||||
ControllerEmu::ControlGroup* GetUDrawTabletGroup(int number, WiimoteEmu::UDrawTabletGroup group);
|
||||
ControllerEmu::ControlGroup* GetTaTaConGroup(int number, WiimoteEmu::TaTaConGroup group);
|
||||
|
||||
void ControlChannel(int number, u16 channel_id, const void* data, u32 size);
|
||||
void InterruptChannel(int number, u16 channel_id, const void* data, u32 size);
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -20,6 +20,7 @@ enum ExtensionNumber : u8
|
|||
DRUMS,
|
||||
TURNTABLE,
|
||||
UDRAW_TABLET,
|
||||
TATACON,
|
||||
};
|
||||
|
||||
// FYI: An extension must be attached.
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Core/HW/WiimoteEmu/Extension/Drums.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Guitar.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/TaTaCon.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Turntable.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/UDrawTablet.h"
|
||||
|
||||
|
@ -167,6 +168,7 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
|
|||
m_attachments->AddAttachment(std::make_unique<WiimoteEmu::Drums>());
|
||||
m_attachments->AddAttachment(std::make_unique<WiimoteEmu::Turntable>());
|
||||
m_attachments->AddAttachment(std::make_unique<WiimoteEmu::UDrawTablet>());
|
||||
m_attachments->AddAttachment(std::make_unique<WiimoteEmu::TaTaCon>());
|
||||
|
||||
m_attachments->AddSetting(&m_motion_plus_setting, {_trans("Attach MotionPlus")}, true);
|
||||
|
||||
|
@ -291,6 +293,13 @@ ControllerEmu::ControlGroup* Wiimote::GetUDrawTabletGroup(UDrawTabletGroup group
|
|||
return static_cast<UDrawTablet*>(
|
||||
m_attachments->GetAttachmentList()[ExtensionNumber::UDRAW_TABLET].get())
|
||||
->GetGroup(group);
|
||||
;
|
||||
}
|
||||
|
||||
ControllerEmu::ControlGroup* Wiimote::GetTaTaConGroup(TaTaConGroup group)
|
||||
{
|
||||
return static_cast<TaTaCon*>(m_attachments->GetAttachmentList()[ExtensionNumber::TATACON].get())
|
||||
->GetGroup(group);
|
||||
}
|
||||
|
||||
bool Wiimote::ProcessExtensionPortEvent()
|
||||
|
|
|
@ -56,6 +56,7 @@ enum class GuitarGroup;
|
|||
enum class DrumsGroup;
|
||||
enum class TurntableGroup;
|
||||
enum class UDrawTabletGroup;
|
||||
enum class TaTaConGroup;
|
||||
|
||||
template <typename T>
|
||||
void UpdateCalibrationDataChecksum(T& data, int cksum_bytes)
|
||||
|
@ -115,6 +116,7 @@ public:
|
|||
ControllerEmu::ControlGroup* GetDrumsGroup(DrumsGroup group);
|
||||
ControllerEmu::ControlGroup* GetTurntableGroup(TurntableGroup group);
|
||||
ControllerEmu::ControlGroup* GetUDrawTabletGroup(UDrawTabletGroup group);
|
||||
ControllerEmu::ControlGroup* GetTaTaConGroup(TaTaConGroup group);
|
||||
|
||||
void Update();
|
||||
void StepDynamics();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Core/HW/WiimoteEmu/Extension/Drums.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Guitar.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/TaTaCon.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Turntable.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/UDrawTablet.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
|
@ -29,6 +30,7 @@ WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(
|
|||
CreateNunchukLayout();
|
||||
CreateTurntableLayout();
|
||||
CreateUDrawTabletLayout();
|
||||
CreateTaTaConLayout();
|
||||
CreateMainLayout();
|
||||
|
||||
ChangeExtensionType(WiimoteEmu::ExtensionNumber::NONE);
|
||||
|
@ -201,6 +203,19 @@ void WiimoteEmuExtension::CreateUDrawTabletLayout()
|
|||
m_udraw_tablet_box->setLayout(hbox);
|
||||
}
|
||||
|
||||
void WiimoteEmuExtension::CreateTaTaConLayout()
|
||||
{
|
||||
auto* hbox = new QHBoxLayout();
|
||||
m_tatacon_box = new QGroupBox(tr("Taiko Drum"), this);
|
||||
|
||||
hbox->addWidget(CreateGroupBox(
|
||||
tr("Center"), Wiimote::GetTaTaConGroup(GetPort(), WiimoteEmu::TaTaConGroup::Center)));
|
||||
hbox->addWidget(CreateGroupBox(
|
||||
tr("Rim"), Wiimote::GetTaTaConGroup(GetPort(), WiimoteEmu::TaTaConGroup::Rim)));
|
||||
|
||||
m_tatacon_box->setLayout(hbox);
|
||||
}
|
||||
|
||||
void WiimoteEmuExtension::CreateMainLayout()
|
||||
{
|
||||
m_main_layout = new QHBoxLayout();
|
||||
|
@ -212,6 +227,7 @@ void WiimoteEmuExtension::CreateMainLayout()
|
|||
m_main_layout->addWidget(m_nunchuk_box);
|
||||
m_main_layout->addWidget(m_turntable_box);
|
||||
m_main_layout->addWidget(m_udraw_tablet_box);
|
||||
m_main_layout->addWidget(m_tatacon_box);
|
||||
|
||||
setLayout(m_main_layout);
|
||||
}
|
||||
|
@ -242,4 +258,5 @@ void WiimoteEmuExtension::ChangeExtensionType(u32 type)
|
|||
m_drums_box->setHidden(type != ExtensionNumber::DRUMS);
|
||||
m_turntable_box->setHidden(type != ExtensionNumber::TURNTABLE);
|
||||
m_udraw_tablet_box->setHidden(type != ExtensionNumber::UDRAW_TABLET);
|
||||
m_tatacon_box->setHidden(type != ExtensionNumber::TATACON);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
void CreateNunchukLayout();
|
||||
void CreateTurntableLayout();
|
||||
void CreateUDrawTabletLayout();
|
||||
void CreateTaTaConLayout();
|
||||
void CreateMainLayout();
|
||||
|
||||
// Main
|
||||
|
@ -43,4 +44,5 @@ private:
|
|||
QGroupBox* m_nunchuk_box;
|
||||
QGroupBox* m_turntable_box;
|
||||
QGroupBox* m_udraw_tablet_box;
|
||||
QGroupBox* m_tatacon_box;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue