Merge pull request #79 from narayanx/feature/switch-song-lr
Allow switching with L/R, fix with pause/play, remove stop song
This commit is contained in:
@@ -13,7 +13,7 @@ The latest 3DSX/CIA/3DS download can be found on the <a href="https://github.com
|
|||||||
## Controls
|
## Controls
|
||||||
L+R or L+Up: Pause
|
L+R or L+Up: Pause
|
||||||
|
|
||||||
L+B: Stop
|
ZL/ZR or L/R: Previous/Next Song
|
||||||
|
|
||||||
L+Left: Show Controls
|
L+Left: Show Controls
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ static void showControls(void)
|
|||||||
{
|
{
|
||||||
printf("Button mappings:\n"
|
printf("Button mappings:\n"
|
||||||
"Pause: L+R or L+Up\n"
|
"Pause: L+R or L+Up\n"
|
||||||
"Stop: L+B\n"
|
"Previous/Next Song: ZL/ZR or L/R\n"
|
||||||
"A: Open File\n"
|
"A: Open File\n"
|
||||||
"B: Go up folder\n"
|
"B: Go up folder\n"
|
||||||
"Start: Exit\n"
|
"Start: Exit\n"
|
||||||
@@ -302,6 +302,10 @@ int main(int argc, char **argv)
|
|||||||
volatile int error = 0;
|
volatile int error = 0;
|
||||||
struct dirList_t dirList = { 0 };
|
struct dirList_t dirList = { 0 };
|
||||||
|
|
||||||
|
/* ignore key release of L/R if L+R or L+down was pressed */
|
||||||
|
bool keyLComboPressed = false;
|
||||||
|
bool keyRComboPressed = false;
|
||||||
|
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
consoleInit(GFX_TOP, &topScreenLog);
|
consoleInit(GFX_TOP, &topScreenLog);
|
||||||
consoleInit(GFX_TOP, &topScreenInfo);
|
consoleInit(GFX_TOP, &topScreenInfo);
|
||||||
@@ -358,6 +362,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
u32 kDown;
|
u32 kDown;
|
||||||
u32 kHeld;
|
u32 kHeld;
|
||||||
|
u32 kUp;
|
||||||
static u64 mill = 0;
|
static u64 mill = 0;
|
||||||
|
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
@@ -367,6 +372,7 @@ int main(int argc, char **argv)
|
|||||||
hidScanInput();
|
hidScanInput();
|
||||||
kDown = hidKeysDown();
|
kDown = hidKeysDown();
|
||||||
kHeld = hidKeysHeld();
|
kHeld = hidKeysHeld();
|
||||||
|
kUp = hidKeysUp();
|
||||||
|
|
||||||
consoleSelect(&bottomScreen);
|
consoleSelect(&bottomScreen);
|
||||||
|
|
||||||
@@ -396,6 +402,11 @@ int main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
puts("Playing");
|
puts("Playing");
|
||||||
|
|
||||||
|
keyLComboPressed = true;
|
||||||
|
// distinguish between L+R and L+Up
|
||||||
|
if (KEY_R & kDown) {
|
||||||
|
keyRComboPressed = true;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,27 +415,25 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
consoleSelect(&topScreenLog);
|
consoleSelect(&topScreenLog);
|
||||||
showControls();
|
showControls();
|
||||||
|
keyLComboPressed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Stop */
|
// if R is pressed first
|
||||||
if(kDown & KEY_B)
|
if ((kHeld & KEY_R) && (kDown & KEY_L))
|
||||||
{
|
{
|
||||||
stopPlayback();
|
if(isPlaying() == false)
|
||||||
|
continue;
|
||||||
/* Clear playback information. */
|
|
||||||
consoleSelect(&topScreenInfo);
|
consoleSelect(&topScreenLog);
|
||||||
consoleClear();
|
if(togglePlayback() == true)
|
||||||
consoleSelect(&topScreenLog);
|
puts("Paused");
|
||||||
//consoleClear();
|
else
|
||||||
|
puts("Playing");
|
||||||
changeFile(NULL, &playbackInfo);
|
|
||||||
|
keyLComboPressed = true;
|
||||||
/* If the playback thread is currently playing, it will now
|
keyRComboPressed = true;
|
||||||
* stop and tell the Watchdog thread to display "Stopped".
|
|
||||||
*/
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((kDown & KEY_UP ||
|
if((kDown & KEY_UP ||
|
||||||
@@ -571,7 +580,16 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kDown & KEY_ZR && fileNum < fileMax) {
|
// ignore R release if key combo with R used
|
||||||
|
bool keyRActivation = false;
|
||||||
|
if (kUp & KEY_R) {
|
||||||
|
if (!keyRComboPressed) {
|
||||||
|
keyRActivation = true;
|
||||||
|
}
|
||||||
|
keyRComboPressed = false;
|
||||||
|
}
|
||||||
|
bool goToNextFile = (kDown & KEY_ZR) || keyRActivation;
|
||||||
|
if (goToNextFile && fileNum < fileMax) {
|
||||||
fileNum += 1;
|
fileNum += 1;
|
||||||
if(fileNum >= MAX_LIST && fileMax - fileNum >= 0 &&
|
if(fileNum >= MAX_LIST && fileMax - fileNum >= 0 &&
|
||||||
from < fileMax - MAX_LIST)
|
from < fileMax - MAX_LIST)
|
||||||
@@ -586,9 +604,17 @@ int main(int argc, char **argv)
|
|||||||
if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory.");
|
if(listDir(from, MAX_LIST, fileNum, dirList) < 0) err_print("Unable to list directory.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// ignore L release if key combo with L used
|
||||||
|
bool keyLActivation = false;
|
||||||
|
if (kUp & KEY_L) {
|
||||||
|
if (!keyLComboPressed) {
|
||||||
|
keyLActivation = true;
|
||||||
|
}
|
||||||
|
keyLComboPressed = false;
|
||||||
|
}
|
||||||
|
bool goToPrevFile = (kDown & KEY_ZL) || keyLActivation;
|
||||||
// don't go to ../
|
// don't go to ../
|
||||||
if (kDown & KEY_ZL && fileNum > 1) {
|
if (goToPrevFile && fileNum > 1) {
|
||||||
fileNum -= 1;
|
fileNum -= 1;
|
||||||
if(fileMax - fileNum > MAX_LIST-2 && from != 0)
|
if(fileMax - fileNum > MAX_LIST-2 && from != 0)
|
||||||
from--;
|
from--;
|
||||||
|
|||||||
Reference in New Issue
Block a user