Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Add "Steps per hour" system setting #211

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/android/app/src/main/jni/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ void Config::ReadValues() {
ReadSetting("System", Settings::values.init_ticks_override);
ReadSetting("System", Settings::values.plugin_loader_enabled);
ReadSetting("System", Settings::values.allow_plugin_loader);
ReadSetting("System", Settings::values.steps_per_hour);

// Camera
using namespace Service::CAM;
Expand Down
4 changes: 4 additions & 0 deletions src/android/app/src/main/jni/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ init_ticks_type =
# Defaults to 0.
init_ticks_override =

# Number of steps per hour reported by the pedometer.
# Defaults to 0.
steps_per_hour =

# Plugin loader state, if enabled plugins will be loaded from the SD card.
# You can also set if homebrew apps are allowed to enable the plugin loader
plugin_loader =
Expand Down
1 change: 1 addition & 0 deletions src/citra/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ void Config::ReadValues() {
ReadSetting("System", Settings::values.init_ticks_override);
ReadSetting("System", Settings::values.plugin_loader_enabled);
ReadSetting("System", Settings::values.allow_plugin_loader);
ReadSetting("System", Settings::values.steps_per_hour);

{
constexpr const char* default_init_time_offset = "0 00:00:00";
Expand Down
4 changes: 4 additions & 0 deletions src/citra/default_ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ init_ticks_type =
# Defaults to 0.
init_ticks_override =

# Number of steps per hour reported by the pedometer.
# Defaults to 0.
steps_per_hour =

[Camera]
# Which camera engine to use for the right outer camera
# blank (default): a dummy camera that always returns black image
Expand Down
2 changes: 2 additions & 0 deletions src/citra_qt/configuration/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ void Config::ReadSystemValues() {
ReadBasicSetting(Settings::values.init_time_offset);
ReadBasicSetting(Settings::values.init_ticks_type);
ReadBasicSetting(Settings::values.init_ticks_override);
ReadBasicSetting(Settings::values.steps_per_hour);
ReadBasicSetting(Settings::values.plugin_loader_enabled);
ReadBasicSetting(Settings::values.allow_plugin_loader);
}
Expand Down Expand Up @@ -1219,6 +1220,7 @@ void Config::SaveSystemValues() {
WriteBasicSetting(Settings::values.init_time_offset);
WriteBasicSetting(Settings::values.init_ticks_type);
WriteBasicSetting(Settings::values.init_ticks_override);
WriteBasicSetting(Settings::values.steps_per_hour);
WriteBasicSetting(Settings::values.plugin_loader_enabled);
WriteBasicSetting(Settings::values.allow_plugin_loader);
}
Expand Down
6 changes: 6 additions & 0 deletions src/citra_qt/configuration/configure_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ void ConfigureSystem::SetConfiguration() {
ui->edit_init_ticks_value->setText(
QString::number(Settings::values.init_ticks_override.GetValue()));

ui->spinBox_steps_per_hour->setValue(Settings::values.steps_per_hour.GetValue());

cfg = Service::CFG::GetModule(system);
ReadSystemSettings();

Expand Down Expand Up @@ -460,6 +462,8 @@ void ConfigureSystem::ApplyConfiguration() {
Settings::values.init_ticks_override =
static_cast<s64>(ui->edit_init_ticks_value->text().toLongLong());

Settings::values.steps_per_hour = static_cast<u16>(ui->spinBox_steps_per_hour->value());

s64 time_offset_time = ui->edit_init_time_offset_time->time().msecsSinceStartOfDay() / 1000;
s64 time_offset_days = ui->edit_init_time_offset_days->value() * 86400;

Expand Down Expand Up @@ -631,8 +635,10 @@ void ConfigureSystem::SetupPerGameUI() {
ui->label_language->setVisible(false);
ui->label_country->setVisible(false);
ui->label_play_coins->setVisible(false);
ui->label_steps_per_hour->setVisible(false);
ui->edit_username->setVisible(false);
ui->spinBox_play_coins->setVisible(false);
ui->spinBox_steps_per_hour->setVisible(false);
ui->combo_birthday->setVisible(false);
ui->combo_birthmonth->setVisible(false);
ui->combo_init_clock->setVisible(false);
Expand Down
29 changes: 22 additions & 7 deletions src/citra_qt/configuration/configure_system.ui
Original file line number Diff line number Diff line change
Expand Up @@ -392,21 +392,35 @@
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_steps_per_hour">
<property name="text">
<string>Pedometer steps per hour:</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="spinBox_steps_per_hour">
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="toggle_system_setup">
<property name="text">
<string>Run System Setup when Home Menu is launched</string>
</property>
</widget>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QLabel" name="label_console_id">
<property name="text">
<string>Console ID:</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QPushButton" name="button_regenerate_console_id">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
Expand All @@ -422,35 +436,35 @@
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<widget class="QLabel" name="label_plugin_loader">
<property name="text">
<string>3GX Plugin Loader:</string>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QCheckBox" name="plugin_loader">
<property name="text">
<string>Enable 3GX plugin loader</string>
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QCheckBox" name="allow_plugin_loader">
<property name="text">
<string>Allow games to change plugin loader state</string>
</property>
</widget>
</item>
<item row="17" column="0">
<item row="18" column="0">
<widget class="QLabel" name="label_nus_download">
<property name="text">
<string>Download System Files from Nitendo servers</string>
</property>
</widget>
</item>
<item row="17" column="1">
<item row="18" column="1">
<widget class="QWidget" name="body_nus_download">
<layout class="QHBoxLayout" name="horizontalLayout_nus_download">
<item>
Expand Down Expand Up @@ -692,6 +706,7 @@
<tabstop>combo_init_clock</tabstop>
<tabstop>edit_init_time</tabstop>
<tabstop>spinBox_play_coins</tabstop>
<tabstop>spinBox_steps_per_hour</tabstop>
<tabstop>button_regenerate_console_id</tabstop>
</tabstops>
<resources/>
Expand Down
1 change: 1 addition & 0 deletions src/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ struct Values {
Setting<s64> init_ticks_override{0, "init_ticks_override"};
Setting<bool> plugin_loader_enabled{false, "plugin_loader"};
Setting<bool> allow_plugin_loader{true, "allow_plugin_loader"};
Setting<u16> steps_per_hour{0, "steps_per_hour"};

// Renderer
SwitchableSetting<GraphicsAPI, true> graphics_api {
Expand Down
3 changes: 1 addition & 2 deletions src/core/hle/service/ptm/ptm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ void Module::Interface::GetStepHistory(Kernel::HLERequestContext& ctx) {
ASSERT_MSG(sizeof(u16) * hours == buffer.GetSize(),
"Buffer for steps count has incorrect size");

// Stub: set zero steps count for every hour
const u16_le steps_per_hour = Settings::values.steps_per_hour.GetValue();
for (u32 i = 0; i < hours; ++i) {
const u16_le steps_per_hour = 0;
buffer.Write(&steps_per_hour, i * sizeof(u16), sizeof(u16));
}

Expand Down