Skip to content

Commit

Permalink
fix timer sleep on Wii U
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtleP committed Apr 1, 2024
1 parent 4bacccc commit 78c6c19
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion debug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
let mut file = File::create(&filename).expect("Failed to create log file");

loop {
let bytes_read = stream.read(&mut buffer) else { break; };
let bytes_read = stream.read(&mut buffer).expect("Failed to read data from stream");

if bytes_read == 0 {
break;
Expand Down
2 changes: 1 addition & 1 deletion include/common/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace love
#define E_PHYSFS_NOT_INITIALIZED "PHYSFS is not initialized."
#define E_DATA_NOT_WRITTEN "Data could not be written."
#define E_COULD_NOT_OPEN_FILE "Could not open file at path {}."
#define E_PHYSFS_COULD_NOT_OPEN_FILE "Could not open file {} {:s}"
#define E_PHYSFS_COULD_NOT_OPEN_FILE "Could not open file {} ({:s})"
#define E_FILE_NOT_OPEN_FOR_WRITING "File not open for writing."
#define E_INVALID_READ_SIZE "Invalid read size."
#define E_INVALID_WRITE_SIZE "Invalid write size."
Expand Down
8 changes: 5 additions & 3 deletions platform/cafe/source/modules/timer/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ namespace love
double Timer::getTime()
{
const auto ns = OSTicksToNanoseconds(OSGetSystemTick() - Timer::reference);
return ns / 1'000'000'000.0;
return ns / Timer::SECONDS_TO_NS;
}

void Timer::sleep(double seconds) const
{
const auto time = std::chrono::duration<double>(seconds);
OSSleepTicks(std::chrono::duration<double, std::nano>(time).count());
const auto time = std::chrono::duration<double>(seconds);
const auto nanoseconds = std::chrono::duration<double, std::nano>(time).count();

OSSleepTicks(OSNanosecondsToTicks(nanoseconds));
}

double Timer::step()
Expand Down

0 comments on commit 78c6c19

Please sign in to comment.