Skip to content

Commit

Permalink
Backported changes to prepare for merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel K. O. (dkosmari) committed Jun 2, 2024
1 parent 30f9d3b commit b943564
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 35 deletions.
33 changes: 23 additions & 10 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,46 @@ A plugin that synchronizes a Wii U's clock to the Internet.
Wii U Time Sync is a Wii U homebrew plugin for the Aroma environment. It allows the console to automatically synchronize its date and time through the Internet, similar to the feature found on the Nintendo Switch and other modern devices.

## Installation
A Wii U plugin file will be bundled with each release. It should be placed on your SD card, particularly in `wiiu/environments/aroma/plugins`.
For convenience, it is recommended that you download Wii U Time Sync from the [Homebrew App Store](https://hb-app.store/wiiu/Wii-U-Time-Sync). Both are maintained by me, and I ensure that the mirror is updated instantaneously after a new release.

<p align="center">
<a href="https://hb-app.store/wiiu/Wii-U-Time-Sync">
<img src="appstore.png" alt="Get it on the Homebrew App Store!">
</a>
</p>

Otherwise, a Wii U plugin file will be bundled with each release. It should be placed on your SD card, particularly in `wiiu/environments/aroma/plugins`.
* It's important to have the Aroma environment installed for Wii U Time Sync to work. Please visit our [hacking guide](https://wiiu.hacks.guide/) and the [Aroma webpage](https://aroma.foryour.cafe/) if you would like to softmod your Wii U console.

## Usage
If the program is placed correctly on an SD card, Wii U Time Sync will be listed in the Aroma environment's Wii U Plugin System Config Menu.

* If Wii U Time Sync doesn't show up in the Wii U Plugin System Config Menu, confirm you placed the WPS file on your SD card correctly and restart your console.
* `Configuration -> Syncing Enabled`: Enables syncing to the Internet, `false` by default.
* `Configuration -> Show Notifications`: Shows a notification whenever Wii U Time Sync adjusts the clock, `false` by default.
* `Configuration -> Hour Offset`: The amount of hours to add/subtract from the coordinated universal time, `0` by default.
* `Configuration -> Minutes Offset`: The amount of minutes to add/subtract from the coordinated universal time, `0` by default.
* `Configuration -> Syncing Enabled`: Enables syncing to the Internet, `off` by default.
* `Configuration -> Show Notifications`: Shows a notification whenever Wii U Time Sync adjusts the clock, `normal` by default.
* `quiet` means that no notifications will appear on success.
* `normal` means that only success or failure notifications will appear, but no others.
* `verbose` means that all notifications (statistics and such) will appear, useful for debugging.
* `Configuration -> Time Offset (UTC)`: The amount of time to add/subtract from the coordinated universal time, `+00:00` by default.
* `Configuration -> Detect Time Zone (press A)`: Uses the IP Geolocation API to guess the time zone, setting the offset accordingly.
* `Configuration -> Auto Update Time Zone`: Automatically utilizes the IP Geolocation API to set your offset accordingly, `off` by default.
* `Configuration -> Notification Duration (seconds)`: The amount of seconds which notifications will appear on screen for, `5` by default.
* `Configuration -> Tolerance (milliseconds)`: The amount of milliseconds in which Wii U Time Sync will tolerate differences, `250` by default.
* `Configuration -> Detect Timezone`: Uses the IP Geolocation API to guess the timezone, setting the offset accordingly.
* `Configuration -> NTP Servers`: The list of NTP servers in which the plugin connects to, only `ntp.pool.org` by default.
* `Configuration -> Tolerance (milliseconds)`: The amount of milliseconds in which Wii U Time Sync will tolerate differences, `500` by default.
* `Configuration -> Background Threads`: Controls how many servers are queried at once, `4` by default.
* If you stick to the default server, you do not need to set this to more than `4`.
* `Configuration -> NTP Servers`: The list of NTP servers in which the plugin connects to, only `pool.ntp.org` by default.
* This cannot be edited on the console. However, you can edit the Wii U Time Sync configuration file on a computer to adjust the default server, or add more.
* The configuration file: `wiiu/environments/aroma/plugins/config/Wii U Time Sync.json`
* An example edit: `"server": "pool.ntp.org time.windows.com",`
* `Preview`: Lets you preview what the system's clock is currently set to, as well as correction and latency statistics.
* `Preview Time`: Lets you preview what the system's clock is currently set to, as well as correction and latency statistics.

As long as syncing is enabled by the user, the clock will sync whenever Wii U Time Sync starts, or when the plugin settings are exited.

**The changes will not be reflected in the HOME Menu and most other applications right away, so the console will need to be rebooted for changes to be completed.**

## Credits
I hope that I am able to express my thanks as much as possible to those who made this repository possible.
* [dkosmari](https://github.com/dkosmari), for his excellent refactoring of Wii U Time Sync, being used as our codebase ever since the release of v2.0.0.
* [dkosmari](https://github.com/dkosmari), who is now co-developing Wii U Time Sync with me and has greatly contributed to the plugin for a much longer period, including his refactoring in the v2.0.0 release.
* [GaryOderNichts](https://github.com/GaryOderNichts), for writing the network connection code and figuring out how to set the console's date and time through homebrew (so basically all the functionality).
* [Maschell](https://github.com/Maschell), for his work not only with figuring out setting the date and time, but also his work on the Aroma environment.
* [LumaTeam](https://github.com/LumaTeam), for the time syncing code in [Luma3DS](https://github.com/LumaTeam/Luma3DS), which we based our code off of.
Expand Down
6 changes: 3 additions & 3 deletions source/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ namespace cfg {


namespace label {
const char* auto_tz = "Auto-update Timezone Offset";
const char* msg_duration = "Notification Duration (seconds)";
const char* auto_tz = "Auto Update Time Zone";
const char* msg_duration = "Notification Duration";
const char* notify = "Show Notifications";
const char* server = "NTP Servers";
const char* sync = "Syncing Enabled";
const char* threads = "Background Threads";
const char* tolerance = "Tolerance (milliseconds)";
const char* utc_offset = "UTC Offset";
const char* utc_offset = "Time Offset (UTC)";
}


Expand Down
2 changes: 1 addition & 1 deletion source/clock_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace {


clock_item::clock_item() :
text_item{{}, "Clock (Press " NIN_GLYPH_BTN_A ")", "", 48}
text_item{{}, "Clock (press " NIN_GLYPH_BTN_A ")", "", 48}
{}


Expand Down
20 changes: 10 additions & 10 deletions source/config_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ make_config_screen()
cfg::label::sync,
cfg::sync,
cfg::defaults::sync,
"yes", "no"));
"on", "off"));

cat.add(verbosity_item::create(cfg::key::notify,
cfg::label::notify,
cfg::notify,
cfg::defaults::notify));

cat.add(seconds_item::create(cfg::key::msg_duration,
cfg::label::msg_duration,
cfg::msg_duration,
cfg::defaults::msg_duration,
1s, 30s, 5s));
cat.add(timezone_offset_item::create(cfg::key::utc_offset,
cfg::label::utc_offset,
cfg::utc_offset));

cat.add(timezone_query_item::create());

cat.add(bool_item::create(cfg::key::auto_tz,
cfg::label::auto_tz,
cfg::auto_tz,
cfg::defaults::auto_tz,
"yes", "no"));
"on", "off"));

cat.add(timezone_offset_item::create(cfg::key::utc_offset,
cfg::label::utc_offset,
cfg::utc_offset));
cat.add(seconds_item::create(cfg::key::msg_duration,
cfg::label::msg_duration,
cfg::msg_duration,
cfg::defaults::msg_duration,
1s, 30s, 5s));

cat.add(milliseconds_item::create(cfg::key::tolerance,
cfg::label::tolerance,
Expand Down
14 changes: 7 additions & 7 deletions source/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ namespace core {

// Detect the wraparound that will happen at the end of Era 0.
constexpr dbl_seconds half_era{0x1.0p32}; // 2^32 seconds
constexpr dbl_seconds quarter_era{0x1.0p31}; // 2^31 seconds
constexpr dbl_seconds quarter_era{0x1.0p31}; // 2^31 seconds
if (d4 < d1)
d4 += half_era; // d4 += 2^32
if (d3 < d2)
Expand Down Expand Up @@ -276,13 +276,13 @@ namespace core {
if (offset != cfg::utc_offset) {
cfg::set_and_store_utc_offset(offset);
notify::info(notify::level::verbose,
"Auto-updated timezone to " + name +
"Updated timezone to " + name +
"(" + time_utils::tz_offset_to_string(offset) + ")");
}
}
catch (std::exception& e) {
notify::error(notify::level::verbose,
"Failed to auto-update timezone: "s + e.what());
"Failed to update timezone: "s + e.what());
}
}

Expand Down Expand Up @@ -350,10 +350,10 @@ namespace core {
return;
}

dbl_seconds total_cor = std::accumulate(corrections.begin(),
corrections.end(),
dbl_seconds{0});
dbl_seconds avg = total_cor / static_cast<double>(corrections.size());
dbl_seconds total = std::accumulate(corrections.begin(),
corrections.end(),
dbl_seconds{0});
dbl_seconds avg = total / static_cast<double>(corrections.size());

if (abs(avg) <= cfg::tolerance) {
notify::success(notify::level::verbose,
Expand Down
3 changes: 2 additions & 1 deletion source/notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ namespace notify {
guard::guard(bool init) :
must_finalize{init}
{
initialize();
if (init)
initialize();
}


Expand Down
2 changes: 1 addition & 1 deletion source/timezone_offset_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ timezone_offset_item::on_changed()
variable.reset();
}
catch (std::exception& e) {
logging::printf("Error storing timezone offset: %s", e.what());
logging::printf("Error storing time zone offset: %s", e.what());
}
}
4 changes: 2 additions & 2 deletions source/timezone_query_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ using namespace std::literals;

timezone_query_item::timezone_query_item() :
wups::config::text_item{{},
"Detect Timezone (press " NIN_GLYPH_BTN_A ")",
"Using http://ip-api.com",
"Detect Time Zone (press " NIN_GLYPH_BTN_A ")",
"using http://ip-api.com",
30}
{}

Expand Down

0 comments on commit b943564

Please sign in to comment.