From 9c68b156d1572f5e8fd1094d16568896b85e4dee Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Tue, 9 Jan 2024 18:27:30 +0100 Subject: [PATCH] Core/HW/WiimoteCommon: Add a method to DataReport to query the format of the stored IR data. --- .../Core/Core/HW/WiimoteCommon/DataReport.cpp | 28 +++++++++++++++---- .../Core/Core/HW/WiimoteCommon/DataReport.h | 2 ++ .../Core/HW/WiimoteCommon/WiimoteConstants.h | 9 ++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteCommon/DataReport.cpp b/Source/Core/Core/HW/WiimoteCommon/DataReport.cpp index 68a2a7a726..9bac2e9348 100644 --- a/Source/Core/Core/HW/WiimoteCommon/DataReport.cpp +++ b/Source/Core/Core/HW/WiimoteCommon/DataReport.cpp @@ -125,13 +125,14 @@ struct NoExt : virtual DataReportManipulator u8* GetExtDataPtr() override { return nullptr; } }; -template +template 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, + 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, + IncludeExt<12, 9> { }; -struct ReportCoreAccelIR10Ext6 : IncludeCore, IncludeAccel, IncludeIR<5, 10>, IncludeExt<15, 6> +struct ReportCoreAccelIR10Ext6 : IncludeCore, + IncludeAccel, + IncludeIR, + 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, 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, 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); diff --git a/Source/Core/Core/HW/WiimoteCommon/DataReport.h b/Source/Core/Core/HW/WiimoteCommon/DataReport.h index 8297424e6a..df11b3f6dd 100644 --- a/Source/Core/Core/HW/WiimoteCommon/DataReport.h +++ b/Source/Core/Core/HW/WiimoteCommon/DataReport.h @@ -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; diff --git a/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h b/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h index 651ee5f20d..7475f80439 100644 --- a/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h +++ b/Source/Core/Core/HW/WiimoteCommon/WiimoteConstants.h @@ -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,