| 264 | } |
| 265 | |
| 266 | void MainScreen::updateGridCursor(const InputState& input, size_t count) |
| 267 | { |
| 268 | if (count == 0) { |
| 269 | mCursor = 0; |
| 270 | mScrollRow = 0; |
| 271 | return; |
| 272 | } |
| 273 | if (mCursor >= count) { |
| 274 | mCursor = count - 1; |
| 275 | } |
| 276 | |
| 277 | const u64 now = armGetSystemTick(); |
| 278 | // A fresh press moves immediately; a held direction repeats every |
| 279 | // GRID_REPEAT_TICKS (which also serves as the initial delay). |
| 280 | auto pressed = [&](u64 mask) { return (input.kDown & mask) || ((input.kHeld & mask) && now > mLastMoveTick + GRID_REPEAT_TICKS); }; |
| 281 | |
| 282 | const size_t lastRow = (count - 1) / GRID_COLS; |
| 283 | const size_t row = mCursor / GRID_COLS; |
| 284 | bool moved = false; |
| 285 | |
| 286 | if (pressed(HidNpadButton_AnyUp)) { |
| 287 | if (row > 0) { |
| 288 | mCursor -= GRID_COLS; |
| 289 | moved = true; |
| 290 | } |
| 291 | } |
| 292 | else if (pressed(HidNpadButton_AnyDown)) { |
| 293 | if (row < lastRow) { |
| 294 | mCursor = std::min(mCursor + GRID_COLS, count - 1); |
| 295 | moved = true; |
| 296 | } |
| 297 | } |
| 298 | else if (pressed(HidNpadButton_AnyLeft)) { |
| 299 | // Left at column 0 is the sidebar-entry gesture, handled by the |
| 300 | // caller before this runs. |
| 301 | if (mCursor % GRID_COLS != 0) { |
| 302 | mCursor--; |
| 303 | moved = true; |
| 304 | } |
| 305 | } |
| 306 | else if (pressed(HidNpadButton_AnyRight)) { |
| 307 | // Row-major continuation: right on the last column flows to the next |
| 308 | // row's first tile. |
| 309 | if (mCursor + 1 < count) { |
| 310 | mCursor++; |
| 311 | moved = true; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | if (moved) { |
| 316 | mLastMoveTick = now; |
| 317 | } |
| 318 | scrollToCursor(count); |
| 319 | } |
| 320 | |
| 321 | void MainScreen::setSaveTypeFilter(saveTypeFilter_t filter) |
| 322 | { |
nothing calls this directly
no outgoing calls
no test coverage detected