diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index a1455d373..024980a91 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -382,7 +382,7 @@ int main(int argc, char** argv) { break; // Expected case } - system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "SDL"); + system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "SDL"); if (use_multiplayer) { if (auto member = Network::GetRoomMember().lock()) { diff --git a/src/citra_qt/compatdb.cpp b/src/citra_qt/compatdb.cpp index 50d31a77b..9f3e0de96 100644 --- a/src/citra_qt/compatdb.cpp +++ b/src/citra_qt/compatdb.cpp @@ -52,7 +52,8 @@ void CompatDB::Submit() { back(); LOG_DEBUG(Frontend, "Compatibility Rating: {}", compatibility->checkedId()); Core::System::GetInstance().TelemetrySession().AddField( - Telemetry::FieldType::UserFeedback, "Compatibility", compatibility->checkedId()); + Common::Telemetry::FieldType::UserFeedback, "Compatibility", + compatibility->checkedId()); button(NextButton)->setEnabled(false); button(NextButton)->setText(tr("Submitting")); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5c57dbeda..6ada2628f 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1002,7 +1002,7 @@ bool GMainWindow::LoadROM(const QString& filename) { game_path = filename; - system.TelemetrySession().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); + system.TelemetrySession().AddField(Common::Telemetry::FieldType::App, "Frontend", "Qt"); return true; } diff --git a/src/common/telemetry.cpp b/src/common/telemetry.cpp index 16d42facd..6241d08b3 100644 --- a/src/common/telemetry.cpp +++ b/src/common/telemetry.cpp @@ -12,7 +12,7 @@ #include "common/x64/cpu_detect.h" #endif -namespace Telemetry { +namespace Common::Telemetry { void FieldCollection::Accept(VisitorInterface& visitor) const { for (const auto& field : fields) { @@ -88,4 +88,4 @@ void AppendOSInfo(FieldCollection& fc) { #endif } -} // namespace Telemetry +} // namespace Common::Telemetry diff --git a/src/common/telemetry.h b/src/common/telemetry.h index a3ebed4a7..ba5f0c87d 100644 --- a/src/common/telemetry.h +++ b/src/common/telemetry.h @@ -10,7 +10,7 @@ #include #include "common/common_types.h" -namespace Telemetry { +namespace Common::Telemetry { /// Field type, used for grouping fields together in the final submitted telemetry log enum class FieldType : u8 { @@ -196,4 +196,4 @@ void AppendCPUInfo(FieldCollection& fc); /// such as platform name, etc. void AppendOSInfo(FieldCollection& fc); -} // namespace Telemetry +} // namespace Common::Telemetry diff --git a/src/core/core.cpp b/src/core/core.cpp index ee90da82f..20a9b34b5 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -519,14 +519,13 @@ void System::RegisterImageInterface(std::shared_ptr im void System::Shutdown(bool is_deserializing) { // Log last frame performance stats const auto perf_results = GetAndResetPerfStats(); - telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_EmulationSpeed", + constexpr auto performance = Common::Telemetry::FieldType::Performance; + + telemetry_session->AddField(performance, "Shutdown_EmulationSpeed", perf_results.emulation_speed * 100.0); - telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Framerate", - perf_results.game_fps); - telemetry_session->AddField(Telemetry::FieldType::Performance, "Shutdown_Frametime", - perf_results.frametime * 1000.0); - telemetry_session->AddField(Telemetry::FieldType::Performance, "Mean_Frametime_MS", - perf_stats->GetMeanFrametime()); + telemetry_session->AddField(performance, "Shutdown_Framerate", perf_results.game_fps); + telemetry_session->AddField(performance, "Shutdown_Frametime", perf_results.frametime * 1000.0); + telemetry_session->AddField(performance, "Mean_Frametime_MS", perf_stats->GetMeanFrametime()); // Shutdown emulation session VideoCore::Shutdown(); diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index a22926a9c..323bebaab 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -230,8 +230,8 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); // Log in telemetry if the game uses the shared font - apt->system.TelemetrySession().AddField(Telemetry::FieldType::Session, "RequiresSharedFont", - true); + apt->system.TelemetrySession().AddField(Common::Telemetry::FieldType::Session, + "RequiresSharedFont", true); if (!apt->shared_font_loaded) { // On real 3DS, font loading happens on booting. However, we load it on demand to coordinate diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 6f32cc2eb..3fade83a9 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -199,7 +199,8 @@ ResultStatus AppLoader_NCCH::Load(std::shared_ptr& process) { } auto& system = Core::System::GetInstance(); - system.TelemetrySession().AddField(Telemetry::FieldType::Session, "ProgramId", program_id); + system.TelemetrySession().AddField(Common::Telemetry::FieldType::Session, "ProgramId", + program_id); if (auto room_member = Network::GetRoomMember().lock()) { Network::GameInfo game_info; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 685cbe5e9..13c58e2f7 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -20,6 +20,8 @@ namespace Core { +namespace Telemetry = Common::Telemetry; + static u64 GenerateTelemetryId() { u64 telemetry_id{}; CryptoPP::AutoSeededRandomPool rng; diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index a5dd57ab1..f64dd2a64 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h @@ -53,7 +53,7 @@ public: * @param value Value for the field to add. */ template - void AddField(Telemetry::FieldType type, const char* name, T value) { + void AddField(Common::Telemetry::FieldType type, const char* name, T value) { field_collection.AddField(type, name, std::move(value)); } @@ -64,7 +64,8 @@ public: bool SubmitTestcase(); private: - Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session + /// Tracks all added fields for the session + Common::Telemetry::FieldCollection field_collection; }; /** diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 9ac385ed9..0b195f764 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -1532,8 +1532,8 @@ vec4 secondary_fragment_color = vec4(0.0); // Blend the fog out += "last_tex_env_out.rgb = mix(fog_color.rgb, last_tex_env_out.rgb, fog_factor);\n"; } else if (state.fog_mode == TexturingRegs::FogMode::Gas) { - Core::System::GetInstance().TelemetrySession().AddField(Telemetry::FieldType::Session, - "VideoCore_Pica_UseGasMode", true); + Core::System::GetInstance().TelemetrySession().AddField( + Common::Telemetry::FieldType::Session, "VideoCore_Pica_UseGasMode", true); LOG_CRITICAL(Render_OpenGL, "Unimplemented gas mode"); out += "discard; }"; return {std::move(out)}; diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index ce25f7907..3b44efd49 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -91,7 +91,7 @@ inline GLenum WrapMode(Pica::TexturingRegs::TextureConfig::WrapMode mode) { if (index > 3) { Core::System::GetInstance().TelemetrySession().AddField( - Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode", + Common::Telemetry::FieldType::Session, "VideoCore_Pica_UnsupportedTextureWrapMode", static_cast(index)); LOG_WARNING(Render_OpenGL, "Using texture wrap mode {}", index); } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index bf123c4e0..5578c4a03 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -1210,12 +1210,10 @@ VideoCore::ResultStatus RendererOpenGL::Init() { LOG_INFO(Render_OpenGL, "GL_RENDERER: {}", gpu_model); auto& telemetry_session = Core::System::GetInstance().TelemetrySession(); - telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Vendor", - std::string(gpu_vendor)); - telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_Model", - std::string(gpu_model)); - telemetry_session.AddField(Telemetry::FieldType::UserSystem, "GPU_OpenGL_Version", - std::string(gl_version)); + constexpr auto user_system = Common::Telemetry::FieldType::UserSystem; + telemetry_session.AddField(user_system, "GPU_Vendor", std::string(gpu_vendor)); + telemetry_session.AddField(user_system, "GPU_Model", std::string(gpu_model)); + telemetry_session.AddField(user_system, "GPU_OpenGL_Version", std::string(gl_version)); if (!strcmp(gpu_vendor, "GDI Generic")) { return VideoCore::ResultStatus::ErrorGenericDrivers; diff --git a/src/web_service/telemetry_json.cpp b/src/web_service/telemetry_json.cpp index 9156ce802..97d19f696 100644 --- a/src/web_service/telemetry_json.cpp +++ b/src/web_service/telemetry_json.cpp @@ -10,6 +10,8 @@ namespace WebService { +namespace Telemetry = Common::Telemetry; + struct TelemetryJson::Impl { Impl(std::string host, std::string username, std::string token) : host{std::move(host)}, username{std::move(username)}, token{std::move(token)} {} diff --git a/src/web_service/telemetry_json.h b/src/web_service/telemetry_json.h index 5b6d3cfb5..f2cb19840 100644 --- a/src/web_service/telemetry_json.h +++ b/src/web_service/telemetry_json.h @@ -15,25 +15,25 @@ namespace WebService { * Implementation of VisitorInterface that serialized telemetry into JSON, and submits it to the * Citra web service */ -class TelemetryJson : public Telemetry::VisitorInterface { +class TelemetryJson : public Common::Telemetry::VisitorInterface { public: TelemetryJson(std::string host, std::string username, std::string token); ~TelemetryJson() override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; - void Visit(const Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; + void Visit(const Common::Telemetry::Field& field) override; void Complete() override; bool SubmitTestcase() override;