From b2904f391f6eb9d6b3475665c8ab7ce323097d16 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Thu, 3 Jul 2025 01:40:11 +0300 Subject: [PATCH] IR: Deglobalize receiveBuffer --- include/services/ir/ir_user.hpp | 2 ++ src/core/services/ir/ir_user.cpp | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/services/ir/ir_user.hpp b/include/services/ir/ir_user.hpp index 556ff1d9..00944e93 100644 --- a/include/services/ir/ir_user.hpp +++ b/include/services/ir/ir_user.hpp @@ -1,4 +1,5 @@ #pragma once +#include #include #include @@ -51,6 +52,7 @@ class IRUserService { IR::CirclePadPro cpp; std::optional sharedMemory = std::nullopt; + std::unique_ptr receiveBuffer; bool connectedDevice = false; // Header of the IR shared memory containing various bits of info diff --git a/src/core/services/ir/ir_user.cpp b/src/core/services/ir/ir_user.cpp index 6af21182..8c565ec0 100644 --- a/src/core/services/ir/ir_user.cpp +++ b/src/core/services/ir/ir_user.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -29,8 +28,6 @@ namespace IRUserCommands { }; } -std::unique_ptr receiveBuffer; - void IRUserService::reset() { connectionStatusEvent = std::nullopt; receiveEvent = std::nullopt; @@ -293,16 +290,16 @@ void IRUserService::sendPayload(std::span payload) { return; } + // Based on: https://github.com/azahar-emu/azahar/blob/df3c0c18e4b71ecb5c4e009bfc07b9fd14fd39d9/src/core/hle/service/ir/ir_user.cpp#L231 std::vector packet; // Builds packet header. For the format info: // https://www.3dbrew.org/wiki/IRUSER_Shared_Memory#Packet_structure - packet.push_back(0xA5); const u8 networkID = *(receiveBuffer->getPointer(offsetof(SharedMemoryStatus, networkID))); packet.push_back(networkID); - // puts the size info. + // Append size info. // The highest bit of the first byte is unknown, which is set to zero here. The second highest // bit is a flag that determines whether the size info is in extended form. If the packet size // can be represent within 6 bits, the short form (1 byte) of size info is chosen, the size is