Skip to content

Commit 0f86355

Browse files
committed
Pagination and Wrap Around Nav
1 parent e732cb5 commit 0f86355

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

Launchers/retro-esp32/main/includes/structures.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ typedef struct{
2020
int limit;
2121
int offset;
2222
int total;
23+
int pages;
24+
int page;
2325
} LIST;
24-
LIST ROMS = {8, 0, 0};
26+
LIST ROMS = {8, 0, 0, 0, 0};
2527
bool LAUNCHER = false;
2628

2729
// FILE

Launchers/retro-esp32/main/main.c

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@
571571
ROMS.total++;
572572
}
573573
}
574+
ROMS.pages = ROMS.total/ROMS.limit;
575+
printf("\nDIRECTORY:%s ROMS.page:%d ROMS.pages:%d\n", DIRECTORIES[STEP], ROMS.page, ROMS.pages);
574576
closedir(directory);
575577
}
576578

@@ -590,6 +592,7 @@
590592
int x = ORIGIN.x;
591593
int y = POS.y + 48;
592594
int game = ROMS.offset ;
595+
ROMS.page = ROMS.offset/ROMS.limit;
593596

594597
for (int i = 0; i < 4; i++) draw_mask(0, y+(i*40)-6, 320, 40);
595598
for(int n = 0; n < ROMS.total; n++) {
@@ -893,7 +896,8 @@
893896
ROMS.total = 0;
894897
animate(-1);
895898
}
896-
debounce(ODROID_INPUT_LEFT);
899+
usleep(100000);
900+
//debounce(ODROID_INPUT_LEFT);
897901
}
898902
/*
899903
RIGHT
@@ -908,7 +912,8 @@
908912
ROMS.total = 0;
909913
animate(1);
910914
}
911-
debounce(ODROID_INPUT_RIGHT);
915+
usleep(100000);
916+
//debounce(ODROID_INPUT_RIGHT);
912917
}
913918
/*
914919
UP
@@ -932,7 +937,8 @@
932937
draw_options();
933938
}
934939
}
935-
debounce(ODROID_INPUT_UP);
940+
usleep(100000);
941+
//debounce(ODROID_INPUT_UP);
936942
}
937943
/*
938944
DOWN
@@ -956,8 +962,48 @@
956962
draw_options();
957963
}
958964
}
959-
debounce(ODROID_INPUT_DOWN);
960-
}
965+
966+
usleep(100000);
967+
//debounce(ODROID_INPUT_DOWN);
968+
}
969+
970+
/*
971+
START + SELECT
972+
*/
973+
if (gamepad.values[ODROID_INPUT_START] || gamepad.values[ODROID_INPUT_SELECT]) {
974+
/*
975+
SELECT
976+
*/
977+
if (gamepad.values[ODROID_INPUT_START] && !gamepad.values[ODROID_INPUT_SELECT]) {
978+
if(!LAUNCHER) {
979+
if(STEP != 0) {
980+
ROMS.page++;
981+
if( ROMS.page > ROMS.pages ) { ROMS.page = 0; }
982+
ROMS.offset = ROMS.page * ROMS.limit;
983+
get_files();
984+
}
985+
}
986+
//debounce(ODROID_INPUT_START);
987+
}
988+
989+
/*
990+
SELECT
991+
*/
992+
if (!gamepad.values[ODROID_INPUT_START] && gamepad.values[ODROID_INPUT_SELECT]) {
993+
if(!LAUNCHER) {
994+
if(STEP != 0) {
995+
ROMS.page--;
996+
if( ROMS.page < 0 ) { ROMS.page = ROMS.pages; };
997+
ROMS.offset = ROMS.page * ROMS.limit;
998+
get_files();
999+
}
1000+
}
1001+
//debounce(ODROID_INPUT_SELECT);
1002+
}
1003+
1004+
usleep(200000);
1005+
}
1006+
9611007
/*
9621008
BUTTON A
9631009
*/

0 commit comments

Comments
 (0)