Core/HW/WiimoteCommon: Add a method to DataReport to query the format of the stored IR data.

This commit is contained in:
Admiral H. Curtiss 2024-01-09 18:27:30 +01:00
parent eced34f3f3
commit 9c68b156d1
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
3 changed files with 33 additions and 6 deletions

View File

@ -125,13 +125,14 @@ struct NoExt : virtual DataReportManipulator
u8* GetExtDataPtr() override { return nullptr; }
};
template <u32 Offset, u32 Length, u32 DataOffset = 0>
template <IRReportFormat Format, u32 Offset, u32 Length, u32 DataOffset = 0>
struct IncludeIR : virtual DataReportManipulator
{
u32 GetIRDataSize() const override { return Length; }
const u8* GetIRDataPtr() const override { return data_ptr + Offset; }
u8* GetIRDataPtr() override { return data_ptr + Offset; }
u32 GetIRDataFormatOffset() const override { return DataOffset; }
IRReportFormat GetIRReportFormat() const override { return Format; }
};
struct NoIR : virtual DataReportManipulator
@ -140,6 +141,7 @@ struct NoIR : virtual DataReportManipulator
const u8* GetIRDataPtr() const override { return nullptr; }
u8* GetIRDataPtr() override { return nullptr; }
u32 GetIRDataFormatOffset() const override { return 0; }
IRReportFormat GetIRReportFormat() const override { return IRReportFormat::None; }
};
#ifdef _MSC_VER
@ -162,7 +164,10 @@ struct ReportCoreExt8 : IncludeCore, NoAccel, NoIR, IncludeExt<2, 8>
{
};
struct ReportCoreAccelIR12 : IncludeCore, IncludeAccel, IncludeIR<5, 12>, NoExt
struct ReportCoreAccelIR12 : IncludeCore,
IncludeAccel,
IncludeIR<IRReportFormat::Extended, 5, 12>,
NoExt
{
u32 GetDataSize() const override { return 17; }
};
@ -175,11 +180,17 @@ struct ReportCoreAccelExt16 : IncludeCore, IncludeAccel, NoIR, IncludeExt<5, 16>
{
};
struct ReportCoreIR10Ext9 : IncludeCore, NoAccel, IncludeIR<2, 10>, IncludeExt<12, 9>
struct ReportCoreIR10Ext9 : IncludeCore,
NoAccel,
IncludeIR<IRReportFormat::Basic, 2, 10>,
IncludeExt<12, 9>
{
};
struct ReportCoreAccelIR10Ext6 : IncludeCore, IncludeAccel, IncludeIR<5, 10>, IncludeExt<15, 6>
struct ReportCoreAccelIR10Ext6 : IncludeCore,
IncludeAccel,
IncludeIR<IRReportFormat::Basic, 5, 10>,
IncludeExt<15, 6>
{
};
@ -187,7 +198,7 @@ struct ReportExt21 : NoCore, NoAccel, NoIR, IncludeExt<0, 21>
{
};
struct ReportInterleave1 : IncludeCore, IncludeIR<3, 18, 0>, NoExt
struct ReportInterleave1 : IncludeCore, IncludeIR<IRReportFormat::Full1, 3, 18, 0>, NoExt
{
// FYI: Only 8-bits of precision in this report, and no Y axis.
void GetAccelData(AccelData* accel) const override
@ -220,7 +231,7 @@ struct ReportInterleave1 : IncludeCore, IncludeIR<3, 18, 0>, NoExt
u32 GetDataSize() const override { return 21; }
};
struct ReportInterleave2 : IncludeCore, IncludeIR<3, 18, 18>, NoExt
struct ReportInterleave2 : IncludeCore, IncludeIR<IRReportFormat::Full2, 3, 18, 18>, NoExt
{
// FYI: Only 8-bits of precision in this report, and no X axis.
void GetAccelData(AccelData* accel) const override
@ -372,6 +383,11 @@ u32 DataReportBuilder::GetIRDataFormatOffset() const
return m_manip->GetIRDataFormatOffset();
}
IRReportFormat DataReportBuilder::GetIRReportFormat() const
{
return m_manip->GetIRReportFormat();
}
void DataReportBuilder::GetCoreData(CoreData* core) const
{
m_manip->GetCoreData(core);

View File

@ -39,6 +39,7 @@ public:
virtual const u8* GetIRDataPtr() const = 0;
virtual u32 GetIRDataSize() const = 0;
virtual u32 GetIRDataFormatOffset() const = 0;
virtual IRReportFormat GetIRReportFormat() const = 0;
virtual u8* GetExtDataPtr() = 0;
virtual const u8* GetExtDataPtr() const = 0;
@ -76,6 +77,7 @@ public:
u32 GetExtDataSize() const;
u32 GetIRDataFormatOffset() const;
IRReportFormat GetIRReportFormat() const;
void GetCoreData(CoreData*) const;
void GetAccelData(AccelData*) const;

View File

@ -50,6 +50,15 @@ enum class OutputReportID : u8
IRLogicEnable2 = 0x1a,
};
enum class IRReportFormat : u8
{
None,
Basic, // from ReportCoreIR10Ext9 or ReportCoreAccelIR10Ext6
Extended, // from ReportCoreAccelIR12
Full1, // from ReportInterleave1
Full2, // from ReportInterleave2
};
enum class LED : u8
{
None = 0x00,