Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Go round to the last row with Up in side menus

Leonardo Lobato155967cd1cbe
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index f1fe58d..441fa5e 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -8149,6 +8149,23 @@ void Simulation::move(int delta_x, int delta_y) {
state_.log_offset = std::clamp(state_.log_offset + delta, 0, std::max(0, static_cast<int>(state_.log_lines.size()) - 8));
return;
}
+ // Up from a side menu's top row goes round to its last row (a jump stops at the top); a dialog's buttons stay
+ // where they are.
+ if (delta_y == -1 && !modal.destructive && modal.id != "confirmation" && !modal.action_keys.empty()) {
+ const auto passed_over = [&modal](int index) {
+ const auto& key = modal.action_keys[static_cast<std::size_t>(index)];
+ return SheetDecoration(key) || (modal.id == "import-games" && key.rfind("import-group-", 0) == 0);
+ };
+ bool above = false;
+ for (int index = 0; index < modal.focused_action; ++index) above = above || !passed_over(index);
+ if (!above) {
+ int bottom = static_cast<int>(modal.action_keys.size()) - 1;
+ while (bottom > modal.focused_action && passed_over(bottom)) --bottom;
+ modal.focused_action = bottom;
+ state_.navigation.focus_key = modal.action_keys[static_cast<std::size_t>(bottom)];
+ return;
+ }
+ }
if (modal.id == "import-games") { move_import_sheet(delta_y != 0 ? delta_y : delta_x); return; }
const int delta = delta_y != 0 ? delta_y : delta_x;
const int last = static_cast<int>(modal.action_keys.size()) - 1;
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index 19e45cd..40761a8 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -1491,8 +1491,10 @@ void live_filters_sheet_sections() {
const auto* playable=find_row(model,"filter-compat-playable");
check(playable && playable->kind==RowKind::Toggle && !playable->selected && playable->value=="Off","Playable is a toggle, off");
- // Up from the first sort stays there; down goes past the Filter heading and the divider.
- check(model.action("up") && model.state().navigation.focus_key=="sort-name","no row above the first sort");
+ // Up from the first sort goes round to the last row; down goes past the Filter heading and the divider.
+ const auto filter_keys=model.state().navigation.modals.back().action_keys;
+ check(model.action("up") && model.state().navigation.focus_key==filter_keys.back(),"Up from the first sort goes to the last row");
+ check(model.action("focus:sort-name"),"back on the first sort");
for(const auto* expected:{"sort-recent-played","sort-playtime","filter-compat-playable","filter-hide-demos","filters-reset"})
check(model.action("down") && model.state().navigation.focus_key==expected,"down skips headings and the divider");
check(model.action("up") && model.state().navigation.focus_key=="filter-hide-demos","up goes back past the divider");
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index 9418705..07d8dd3 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -736,6 +736,14 @@ void live_runs_setup_program_once(const std::filesystem::path& base) {
check(model.state().navigation.modals.back().title == "Run BmLauncher.exe once?" &&
model.state().navigation.modals.back().body.find("Mouse preset") != std::string::npos,
"setup program: the confirmation names the program and the Mouse preset");
+ {
+ // A dialog isn't a side menu: Up stops at its first button.
+ const auto buttons = model.state().navigation.modals.back().action_keys;
+ model.action("up");
+ model.action("up");
+ check(model.state().navigation.focus_key == buttons.front() && buttons.front() != buttons.back(),
+ "setup program: Up stops at a dialog's first button");
+ }
check(model.TakeRuntimePlayRequests().empty(), "setup program: nothing starts before the confirmation");
activate(model, "run-once-start");
check(model.state().navigation.modals.empty() &&
@@ -796,6 +804,21 @@ void live_runs_setup_program_once(const std::filesystem::path& base) {
model.NotifyLauncherHint(SteamId(35140), "Binaries/BatmanAC.exe");
check(model.state().navigation.modals.empty(), "launcher hint: not offered with the setting on");
+ // Up from a side menu's top row goes round to its last row, and carries on from there.
+ {
+ activate(model, "details-more");
+ const auto keys = model.state().navigation.modals.back().action_keys;
+ check(model.state().navigation.focus_key == keys.front(), "side menu: focus starts on the top row");
+ model.action("up");
+ check(model.state().navigation.focus_key == keys.back(), "side menu: Up from the top goes to the last row");
+ model.action("up");
+ check(model.state().navigation.focus_key == keys[keys.size() - 2], "side menu: Up carries on from the bottom");
+ model.action("down");
+ model.action("down");
+ check(model.state().navigation.focus_key == keys.back(), "side menu: Down stops on the last row");
+ while (!model.state().navigation.modals.empty()) model.action("circle");
+ }
+
// Play with detailed logs: Verbose for this start, Normal again as the game starts, even if it crashes right
// away or Playden quits before seeing the session end.
{