IR: Deglobalize receiveBuffer
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ class IRUserService {
|
|||||||
IR::CirclePadPro cpp;
|
IR::CirclePadPro cpp;
|
||||||
|
|
||||||
std::optional<MemoryBlock> sharedMemory = std::nullopt;
|
std::optional<MemoryBlock> sharedMemory = std::nullopt;
|
||||||
|
std::unique_ptr<IR::Buffer> receiveBuffer;
|
||||||
bool connectedDevice = false;
|
bool connectedDevice = false;
|
||||||
|
|
||||||
// Header of the IR shared memory containing various bits of info
|
// Header of the IR shared memory containing various bits of info
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -29,8 +28,6 @@ namespace IRUserCommands {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IR::Buffer> receiveBuffer;
|
|
||||||
|
|
||||||
void IRUserService::reset() {
|
void IRUserService::reset() {
|
||||||
connectionStatusEvent = std::nullopt;
|
connectionStatusEvent = std::nullopt;
|
||||||
receiveEvent = std::nullopt;
|
receiveEvent = std::nullopt;
|
||||||
@@ -293,16 +290,16 @@ void IRUserService::sendPayload(std::span<const u8> payload) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Based on: https://github.com/azahar-emu/azahar/blob/df3c0c18e4b71ecb5c4e009bfc07b9fd14fd39d9/src/core/hle/service/ir/ir_user.cpp#L231
|
||||||
std::vector<u8> packet;
|
std::vector<u8> packet;
|
||||||
|
|
||||||
// Builds packet header. For the format info:
|
// Builds packet header. For the format info:
|
||||||
// https://www.3dbrew.org/wiki/IRUSER_Shared_Memory#Packet_structure
|
// https://www.3dbrew.org/wiki/IRUSER_Shared_Memory#Packet_structure
|
||||||
|
|
||||||
packet.push_back(0xA5);
|
packet.push_back(0xA5);
|
||||||
const u8 networkID = *(receiveBuffer->getPointer(offsetof(SharedMemoryStatus, networkID)));
|
const u8 networkID = *(receiveBuffer->getPointer(offsetof(SharedMemoryStatus, networkID)));
|
||||||
packet.push_back(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
|
// 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
|
// 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
|
// can be represent within 6 bits, the short form (1 byte) of size info is chosen, the size is
|
||||||
|
|||||||
Reference in New Issue
Block a user