diff --git a/README.md b/README.md index b914fdd..45f7172 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,13 @@ The latest 3DSX/CIA/3DS download can be found on the = MAX_LIST && fileMax - fileNum >= 0 && - from < fileMax - MAX_LIST) - from++; - consoleSelect(&topScreenInfo); - consoleClear(); - consoleSelect(&topScreenLog); - changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); - error = 0; - consoleSelect(&bottomScreen); - if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); - continue; + + if ((kHeld & KEY_ZR) && zrPressTime != 0) + { + for (int i = 0; i < MAX_PRESSES; i++) + { + if (zrPressTime - zrPressCount[i] <= 500) // accept skip attempts that occur in under 500ms + { + count++; + if (count == MAX_PRESSES) + { + if (now - lastSkipTime > 1000) // cannot skip song for one second to avoid button spam + { + if (fileNum < fileMax && dirList.dirNum < fileNum+1) + { + fileNum += 1; + if(fileNum >= MAX_LIST && fileMax - fileNum >= 0 && from < fileMax - MAX_LIST) + from++; + lastSkipTime = now; + } + consoleSelect(&topScreenInfo); + consoleClear(); + consoleSelect(&topScreenLog); + changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); + error = 0; + consoleSelect(&bottomScreen); + if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); + + /* reset index after operation completes */ + zrPressIdx = 0; + memset(zrPressCount, 0, sizeof(zrPressCount)); + } + } + } + } } - - /* Instant previous (ZL) */ - if ((kDown & KEY_ZL) && fileNum > 1 && dirList.dirNum < fileNum-1) { - fileNum -= 1; - if(fileMax - fileNum > MAX_LIST-2 && from != 0) - from--; - consoleSelect(&topScreenInfo); - consoleClear(); - consoleSelect(&topScreenLog); - changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); - error = 0; - consoleSelect(&bottomScreen); - if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); - continue; + + if ((kHeld & KEY_ZL) && zlPressTime != 0) + { + for (int i = 0; i < MAX_PRESSES; i++) + { + if (zlPressTime - zlPressCount[i] <= 500) + { + count++; + if (count == MAX_PRESSES) + { + if (now - lastSkipTime > 1000) + { + if (fileNum > 1 && dirList.dirNum < fileNum-1) + { + fileNum -= 1; + if(fileMax - fileNum > MAX_LIST-2 && from != 0) + from--; + lastSkipTime = now; + } + consoleSelect(&topScreenInfo); + consoleClear(); + consoleSelect(&topScreenLog); + changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); + error = 0; + consoleSelect(&bottomScreen); + if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); + zlPressIdx = 0; + memset(zlPressCount, 0, sizeof(zlPressCount)); + //zlHoldTriggered = true; + } + } + } + } } - /* R held for >=1000ms: Next song (only if not part of combo) */ - if ((kHeld & KEY_R) && rPressTime != 0 && !rHoldTriggered && !keyRComboPressed) { - if (osGetTime() - rPressTime >= 1000) { - if (fileNum < fileMax && dirList.dirNum < fileNum+1) { - fileNum += 1; - if(fileNum >= MAX_LIST && fileMax - fileNum >= 0 && - from < fileMax - MAX_LIST) - from++; - consoleSelect(&topScreenInfo); - consoleClear(); - consoleSelect(&topScreenLog); - changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); - error = 0; - consoleSelect(&bottomScreen); - if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); + if ((kHeld & KEY_R) && rPressTime != 0) + { + for (int i = 0; i < MAX_PRESSES; i++) + { + if (rPressTime - rPressCount[i] <= 500) + { + count++; + if (count == MAX_PRESSES) + { + if (now - lastSkipTime > 1000) + { + if (fileNum < fileMax && dirList.dirNum < fileNum+1) { + fileNum += 1; + if(fileNum >= MAX_LIST && fileMax - fileNum >= 0 && from < fileMax - MAX_LIST) + from++; + lastSkipTime = now; + } + consoleSelect(&topScreenInfo); + consoleClear(); + consoleSelect(&topScreenLog); + changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); + error = 0; + consoleSelect(&bottomScreen); + if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); + rPressIdx = 0; + memset(rPressCount, 0, sizeof(rPressCount)); + } + } } - rHoldTriggered = true; - continue; } } - /* L held for >=1000ms: Previous song (only if not part of combo) */ - if ((kHeld & KEY_L) && lPressTime != 0 && !lHoldTriggered && !keyLComboPressed) { - if (osGetTime() - lPressTime >= 1000) { - if (fileNum > 1 && dirList.dirNum < fileNum-1) { - fileNum -= 1; - if(fileMax - fileNum > MAX_LIST-2 && from != 0) - from--; - consoleSelect(&topScreenInfo); - consoleClear(); - consoleSelect(&topScreenLog); - changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); - error = 0; - consoleSelect(&bottomScreen); - if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); + if ((kHeld & KEY_L) && lPressTime != 0) + { + for (int i = 0; i < MAX_PRESSES; i++) + { + if (lPressTime - lPressCount[i] <= 500) + { + count++; + if (count == MAX_PRESSES) + { + if (now - lastSkipTime > 1000){ + if (fileNum > 1 && dirList.dirNum < fileNum-1) { + fileNum -= 1; + if(fileMax - fileNum > MAX_LIST-2 && from != 0) + from--; + lastSkipTime = now; + } + consoleSelect(&topScreenInfo); + consoleClear(); + consoleSelect(&topScreenLog); + changeFile(dirList.files[fileNum - dirList.dirNum - 1], &playbackInfo); + error = 0; + consoleSelect(&bottomScreen); + if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory."); + lPressIdx = 0; + memset(lPressCount, 0, sizeof(lPressCount)); + } + } } - lHoldTriggered = true; - continue; } } // play next song automatically - if (error == -1) { + if (error == -1) + { // don't try to play folders - if (fileNum >= fileMax || dirList.dirNum >= fileNum) { + if (fileNum >= fileMax || dirList.dirNum >= fileNum) + { error = 0; continue; }