Backport more common classes

This commit is contained in:
Connor McLaughlin
2022-07-11 19:45:31 +10:00
parent f6b3652ae6
commit af91fcf195
24 changed files with 1381 additions and 134 deletions

View File

@ -1652,7 +1652,7 @@ void CommonHostInterface::AddControllerRumble(u32 controller_index, u32 num_moto
rumble.num_motors = std::min<u32>(num_motors, ControllerRumbleState::MAX_MOTORS);
rumble.last_strength.fill(0.0f);
rumble.update_callback = std::move(callback);
rumble.last_update_time = Common::Timer::GetValue();
rumble.last_update_time = Common::Timer::GetCurrentValue();
m_controller_vibration_motors.push_back(std::move(rumble));
}
@ -1666,7 +1666,7 @@ void CommonHostInterface::UpdateControllerRumble()
// This is because the rumble update is synchronous, and with bluetooth latency can severely impact fast forward
// performance.
static constexpr float UPDATE_FREQUENCY = 1000.0f;
const u64 time = Common::Timer::GetValue();
const u64 time = Common::Timer::GetCurrentValue();
for (ControllerRumbleState& rumble : m_controller_vibration_motors)
{

View File

@ -481,19 +481,27 @@ void DestroyResources()
static std::unique_ptr<HostDisplayTexture> LoadTexture(const char* path, bool from_package)
{
std::unique_ptr<ByteStream> stream;
std::vector<u8> data;
if (from_package)
stream = g_host_interface->OpenPackageFile(path, BYTESTREAM_OPEN_READ);
{
std::unique_ptr<ByteStream> stream = g_host_interface->OpenPackageFile(path, BYTESTREAM_OPEN_READ);
if (stream)
data = ByteStream::ReadBinaryStream(stream.get(), false);
}
else
stream = ByteStream::OpenFile(path, BYTESTREAM_OPEN_READ);
if (!stream)
{
std::optional<std::vector<u8>> odata(FileSystem::ReadBinaryFile(path));
if (!odata.has_value())
data = std::move(odata.value());
}
if (data.empty())
{
Log_ErrorPrintf("Failed to open texture resource '%s'", path);
return {};
}
Common::RGBA8Image image;
if (!Common::LoadImageFromStream(&image, stream.get()) && image.IsValid())
if (!image.LoadFromBuffer(path, data.data(), data.size()) && image.IsValid())
{
Log_ErrorPrintf("Failed to read texture resource '%s'", path);
return {};