Browser: Alt-L to create LST file in current dir with all images included

Also small optimise number scanner in inputmapping
This commit is contained in:
penfold42 2018-08-08 00:38:08 +10:00
parent d08e5e781a
commit 05d89d2505
4 changed files with 63 additions and 13 deletions

View file

@ -1030,6 +1030,23 @@ void FileBrowser::UpdateInputFolders()
{ {
CheckAutoMountImage(EXIT_RESET, this); 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 else
{ {
dirty = folder.CheckBrowseNavigation(); 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 FileBrowser::SelectLST(const char* filenameLST)
{ {
bool validImage = false; bool validImage = false;

View file

@ -193,6 +193,7 @@ public:
static u32 Colour(int index); static u32 Colour(int index);
bool MakeLST(const char* filenameLST);
bool SelectLST(const char* filenameLST); bool SelectLST(const char* filenameLST);
void SetScrollHighlightRate(float value) { scrollHighlightRate = value; } void SetScrollHighlightRate(float value) { scrollHighlightRate = value; }

View file

@ -246,30 +246,24 @@ bool InputMappings::CheckKeyboardBrowseMode()
SetKeyboardFlag(FAKERESET_FLAG); SetKeyboardFlag(FAKERESET_FLAG);
else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt() ) else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(WRITEPROTECT_FLAG); SetKeyboardFlag(WRITEPROTECT_FLAG);
else if (keyboard->KeyHeld(KEY_L) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(MAKELST_FLAG);
else else
{ {
if (keyboard->KeyNoModifiers()) if (keyboard->KeyNoModifiers())
{ {
unsigned index; 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); SetKeyboardFlag(NUMLET_FLAG);
keyboardNumLetter = index-KEY_1+'1'; // key 1 is ascii '1' keyboardNumLetter = index+'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'
if (keyboardNumLetter > '9') keyboardNumLetter = '0'; if (keyboardNumLetter > '9') keyboardNumLetter = '0';
} }
} }
for (index = KEY_A; index <= KEY_Z; ++index) for (index = KEY_A; index <= KEY_Z; ++index)
{ {
if (keyboard->KeyHeld(index)) if (keyboard->KeyHeld(index))

View file

@ -42,7 +42,7 @@
#define AUTOLOAD_FLAG (1 << 15) #define AUTOLOAD_FLAG (1 << 15)
#define FAKERESET_FLAG (1 << 16) #define FAKERESET_FLAG (1 << 16)
#define WRITEPROTECT_FLAG (1 << 17) #define WRITEPROTECT_FLAG (1 << 17)
//#define SPARE_FLAG (1 << 18) #define MAKELST_FLAG (1 << 18)
#define HOME_FLAG (1 << 19) #define HOME_FLAG (1 << 19)
#define END_FLAG (1 << 20) #define END_FLAG (1 << 20)
@ -170,6 +170,8 @@ public:
inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); } inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); }
inline bool MakeLSTFile() { return KeyboardFlag(MAKELST_FLAG); }
inline bool BrowseHome() { return KeyboardFlag(HOME_FLAG); } inline bool BrowseHome() { return KeyboardFlag(HOME_FLAG); }
inline bool BrowseEnd() { return KeyboardFlag(END_FLAG); } inline bool BrowseEnd() { return KeyboardFlag(END_FLAG); }