mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-28 09:59:32 -06:00
WiimoteEmu: Add a static_assert in DesiredExtensionState to keep variant alternative order consistent.
This commit is contained in:
@ -17,21 +17,42 @@
|
|||||||
#include "Core/HW/WiimoteEmu/Extension/TaTaCon.h"
|
#include "Core/HW/WiimoteEmu/Extension/TaTaCon.h"
|
||||||
#include "Core/HW/WiimoteEmu/Extension/Turntable.h"
|
#include "Core/HW/WiimoteEmu/Extension/Turntable.h"
|
||||||
#include "Core/HW/WiimoteEmu/Extension/UDrawTablet.h"
|
#include "Core/HW/WiimoteEmu/Extension/UDrawTablet.h"
|
||||||
|
#include "Core/HW/WiimoteEmu/ExtensionPort.h"
|
||||||
|
|
||||||
namespace WiimoteEmu
|
namespace WiimoteEmu
|
||||||
{
|
{
|
||||||
struct DesiredExtensionState
|
struct DesiredExtensionState
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
template <ExtensionNumber N, typename T>
|
||||||
|
struct ExtNumTypePair
|
||||||
|
{
|
||||||
|
static constexpr ExtensionNumber ext_num = N;
|
||||||
|
using ext_type = T;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct ExtDataImpl
|
struct ExtDataImpl
|
||||||
{
|
{
|
||||||
using type = std::variant<std::monostate, typename Ts::DesiredState...>;
|
using type = std::variant<std::monostate, typename Ts::ext_type::DesiredState...>;
|
||||||
|
|
||||||
|
static_assert((std::is_same_v<std::variant_alternative_t<Ts::ext_num, type>,
|
||||||
|
typename Ts::ext_type::DesiredState> &&
|
||||||
|
...),
|
||||||
|
"Please use ExtensionNumber enum order for DTM file index consistency.");
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using ExtensionData = ExtDataImpl<Nunchuk, Classic, Guitar, Drums, Turntable, UDrawTablet,
|
using ExtensionData =
|
||||||
DrawsomeTablet, TaTaCon, Shinkansen>::type;
|
ExtDataImpl<ExtNumTypePair<ExtensionNumber::NUNCHUK, Nunchuk>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::CLASSIC, Classic>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::GUITAR, Guitar>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::DRUMS, Drums>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::TURNTABLE, Turntable>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::UDRAW_TABLET, UDrawTablet>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::DRAWSOME_TABLET, DrawsomeTablet>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::TATACON, TaTaCon>,
|
||||||
|
ExtNumTypePair<ExtensionNumber::SHINKANSEN, Shinkansen>>::type;
|
||||||
|
|
||||||
ExtensionData data = std::monostate{};
|
ExtensionData data = std::monostate{};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user