MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / updateGridCursor

Method updateGridCursor

switch/source/MainScreen.cpp:284–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284void MainScreen::updateGridCursor(const InputState& input, size_t count)
285{
286 if (count == 0) {
287 mCursor = 0;
288 mScrollRow = 0;
289 return;
290 }
291 if (mCursor >= count) {
292 mCursor = count - 1;
293 }
294
295 const u64 now = armGetSystemTick();
296 // A fresh press moves immediately; a held direction repeats every
297 // GRID_REPEAT_TICKS (which also serves as the initial delay).
298 auto pressed = [&](u64 mask) { return (input.kDown & mask) || ((input.kHeld & mask) && now > mLastMoveTick + GRID_REPEAT_TICKS); };
299
300 const size_t lastRow = (count - 1) / GRID_COLS;
301 const size_t row = mCursor / GRID_COLS;
302 bool moved = false;
303
304 if (pressed(HidNpadButton_AnyUp)) {
305 if (row > 0) {
306 mCursor -= GRID_COLS;
307 moved = true;
308 }
309 }
310 else if (pressed(HidNpadButton_AnyDown)) {
311 if (row < lastRow) {
312 mCursor = std::min(mCursor + GRID_COLS, count - 1);
313 moved = true;
314 }
315 }
316 else if (pressed(HidNpadButton_AnyLeft)) {
317 // Left at column 0 is the sidebar-entry gesture, handled by the
318 // caller before this runs.
319 if (mCursor % GRID_COLS != 0) {
320 mCursor--;
321 moved = true;
322 }
323 }
324 else if (pressed(HidNpadButton_AnyRight)) {
325 // Row-major continuation: right on the last column flows to the next
326 // row's first tile.
327 if (mCursor + 1 < count) {
328 mCursor++;
329 moved = true;
330 }
331 }
332
333 if (moved) {
334 mLastMoveTick = now;
335 }
336 scrollToCursor(count);
337}
338
339void MainScreen::setSaveTypeFilter(saveTypeFilter_t filter)
340{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected