diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index b8a0937..15a992d 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1030,6 +1030,23 @@ void FileBrowser::UpdateInputFolders() { CheckAutoMountImage(EXIT_RESET, this); } + else if (inputMappings->MakeLSTFile()) + { + MakeLST("autoswap.lst"); + FolderChanged(); + FileBrowser::BrowsableList::Entry* current = 0; + for (unsigned index = 0; index < folder.entries.size(); ++index) + { + current = &folder.entries[index]; + if (strcasecmp(current->filImage.fname, "autoswap.lst") == 0) + { + folder.currentIndex = index; + folder.SetCurrent(); + dirty=true; + break; + } + } + } else { dirty = folder.CheckBrowseNavigation(); @@ -1061,6 +1078,42 @@ bool FileBrowser::SelectROMOrDevice(u32 index) } +bool FileBrowser::MakeLST(const char* filenameLST) +{ + bool retcode=true; + FIL fp; + FRESULT res; + res = f_open(&fp, filenameLST, FA_CREATE_ALWAYS | FA_WRITE); + if (res == FR_OK) + { + FileBrowser::BrowsableList::Entry* entry = 0; + u32 bytes; + + for (unsigned index = 0; index < folder.entries.size(); ++index) + { + entry = &folder.entries[index]; + if (entry->filImage.fattrib & AM_DIR) + continue; // skip dirs + + if ( DiskImage::IsDiskImageExtention(entry->filImage.fname) + && !DiskImage::IsLSTExtention(entry->filImage.fname) ) + { + f_write(&fp, + entry->filImage.fname, + strlen(entry->filImage.fname), + &bytes); + f_write(&fp, "\r\n", 2, &bytes); + } + } + + f_close(&fp); + } + else + retcode=false; + + return retcode; +} + bool FileBrowser::SelectLST(const char* filenameLST) { bool validImage = false; diff --git a/src/FileBrowser.h b/src/FileBrowser.h index f7e9c90..c1be6d2 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -193,6 +193,7 @@ public: static u32 Colour(int index); + bool MakeLST(const char* filenameLST); bool SelectLST(const char* filenameLST); void SetScrollHighlightRate(float value) { scrollHighlightRate = value; } diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index fb1abdd..89b9e5e 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -246,30 +246,24 @@ bool InputMappings::CheckKeyboardBrowseMode() SetKeyboardFlag(FAKERESET_FLAG); else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt() ) SetKeyboardFlag(WRITEPROTECT_FLAG); + else if (keyboard->KeyHeld(KEY_L) && keyboard->KeyEitherAlt() ) + SetKeyboardFlag(MAKELST_FLAG); else { if (keyboard->KeyNoModifiers()) { unsigned index; - for (index = KEY_1; index <= KEY_0; ++index) + for (index = 0; index <= 9; ++index) { - if (keyboard->KeyHeld(index)) + if (keyboard->KeyHeld(KEY_1+index) || keyboard->KeyHeld(KEY_KP1+index)) { SetKeyboardFlag(NUMLET_FLAG); - keyboardNumLetter = index-KEY_1+'1'; // key 1 is ascii '1' - if (keyboardNumLetter > '9') keyboardNumLetter = '0'; - } - } - for (index = KEY_KP1; index <= KEY_KP0; ++index) - { - if (keyboard->KeyHeld(index)) - { - SetKeyboardFlag(NUMLET_FLAG); - keyboardNumLetter = index-KEY_KP1+'1'; // key 1 is ascii '1' + keyboardNumLetter = index+'1'; // key 1 is ascii '1' if (keyboardNumLetter > '9') keyboardNumLetter = '0'; } } + for (index = KEY_A; index <= KEY_Z; ++index) { if (keyboard->KeyHeld(index)) diff --git a/src/InputMappings.h b/src/InputMappings.h index 9d6c3f8..0cfc119 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -42,7 +42,7 @@ #define AUTOLOAD_FLAG (1 << 15) #define FAKERESET_FLAG (1 << 16) #define WRITEPROTECT_FLAG (1 << 17) -//#define SPARE_FLAG (1 << 18) +#define MAKELST_FLAG (1 << 18) #define HOME_FLAG (1 << 19) #define END_FLAG (1 << 20) @@ -170,6 +170,8 @@ public: inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); } + inline bool MakeLSTFile() { return KeyboardFlag(MAKELST_FLAG); } + inline bool BrowseHome() { return KeyboardFlag(HOME_FLAG); } inline bool BrowseEnd() { return KeyboardFlag(END_FLAG); }