| 585 | } |
| 586 | |
| 587 | void SettingsScreen::update(const InputState& input) |
| 588 | { |
| 589 | u32 kDown = hidKeysDown(); |
| 590 | const size_t sel = navHid.index(); |
| 591 | |
| 592 | // Touch toggles a General row directly, from either focus state. |
| 593 | if (sel == SEC_GENERAL && (kDown & KEY_TOUCH)) { |
| 594 | for (int i = 0; i < VISIBLE_ROWS && contentOffset + i < (int)GENERAL_ROW_TOTAL; i++) { |
| 595 | const int idx = contentOffset + i; |
| 596 | const int rowY = 30 + i * 34; |
| 597 | if (input.py >= rowY && input.py < rowY + 32 && input.px >= 6 && input.px < 314) { |
| 598 | contentFocus = true; |
| 599 | contentCursor = idx; |
| 600 | toggleGeneral(idx); |
| 601 | break; |
| 602 | } |
| 603 | } |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | if (!contentFocus) { |
| 608 | navHid.update(SECTION_COUNT); |
| 609 | if (kDown & KEY_A) { |
| 610 | if (sectionInteractive(navHid.index())) { |
| 611 | contentFocus = true; |
| 612 | contentCursor = 0; |
| 613 | contentOffset = 0; |
| 614 | rebuildRows(); // refresh the row cache on entering an interactive section |
| 615 | } |
| 616 | } |
| 617 | else if (kDown & KEY_B) { |
| 618 | Configuration::getInstance().commit(); // flush any deferred General toggles |
| 619 | g_pendingScreen = mParent; // leave Settings, restore the parent screen |
| 620 | return; |
| 621 | } |
| 622 | } |
| 623 | else { |
| 624 | const int rows = (int)contentRowCount(sel); |
| 625 | |
| 626 | if ((kDown & KEY_DOWN) && contentCursor + 1 < rows) { |
| 627 | contentCursor++; |
| 628 | } |
| 629 | else if ((kDown & KEY_UP) && contentCursor > 0) { |
| 630 | contentCursor--; |
| 631 | } |
| 632 | |
| 633 | if (sel == SEC_GENERAL) { |
| 634 | if (kDown & KEY_A) { |
| 635 | toggleGeneral(contentCursor); |
| 636 | } |
| 637 | else if (kDown & KEY_B) { |
| 638 | contentFocus = false; |
| 639 | } |
| 640 | } |
| 641 | else if (sel == SEC_LIBRARY) { |
| 642 | if (kDown & KEY_A) { |
| 643 | currentOverlay = std::make_shared<TitlePickerOverlay>(*this, "Add favorite", [this](u64 id) { |
| 644 | Configuration::getInstance().addFavorite(id); |
nothing calls this directly
no test coverage detected