mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Add workaround helper for bit_cast and missing #include <bit>
Allows compilation on native macOS build system.
This commit is contained in:
parent
d0ae5f0546
commit
e9b3b7c2a2
4 changed files with 9 additions and 2 deletions
|
@ -152,6 +152,12 @@ namespace Helpers {
|
||||||
static constexpr inline u8 incBCDByte(u8 value) {
|
static constexpr inline u8 incBCDByte(u8 value) {
|
||||||
return ((value & 0xf) == 0x9) ? value + 7 : value + 1;
|
return ((value & 0xf) == 0x9) ? value + 7 : value + 1;
|
||||||
}
|
}
|
||||||
|
// Use this helper for platforms that lack a working std::bit_cast implementation
|
||||||
|
// TODO: Replace this with C++20 version if available
|
||||||
|
template< class To, class From >
|
||||||
|
constexpr To bit_cast( const From& from ) noexcept{
|
||||||
|
return *reinterpret_cast<const To*>(&from);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// UDLs for memory size values
|
// UDLs for memory size values
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <bit>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void CFGService::getConfigInfoBlk2(u32 messagePointer) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
mem.write32(output + i * 4, std::bit_cast<u32, float>(STEREO_CAMERA_SETTINGS[i]));
|
mem.write32(output + i * 4, Helpers::bit_cast<u32, float>(STEREO_CAMERA_SETTINGS[i]));
|
||||||
}
|
}
|
||||||
} else if (size == 0x1C && blockID == 0xA0000) { // Username
|
} else if (size == 0x1C && blockID == 0xA0000) { // Username
|
||||||
writeStringU16(output, u"Pander");
|
writeStringU16(output, u"Pander");
|
||||||
|
|
|
@ -83,7 +83,7 @@ void HIDService::getGyroscopeCoefficient(u32 messagePointer) {
|
||||||
constexpr float gyroscopeCoeff = 14.375f; // Same as retail 3DS
|
constexpr float gyroscopeCoeff = 14.375f; // Same as retail 3DS
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x15, 2, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x15, 2, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
mem.write32(messagePointer + 8, std::bit_cast<u32, float>(gyroscopeCoeff));
|
mem.write32(messagePointer + 8, Helpers::bit_cast<u32, float>(gyroscopeCoeff));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HIDService::getIPCHandles(u32 messagePointer) {
|
void HIDService::getIPCHandles(u32 messagePointer) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue