diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 59647ea..2bfc5f6 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -32,6 +32,9 @@ extern "C" #include "rpi-gpio.h" } +#include "iec_commands.h" +extern IEC_Commands m_IEC_Commands; + #define PNG_WIDTH 320 #define PNG_HEIGHT 200 @@ -892,6 +895,14 @@ void FileBrowser::UpdateInputFolders() dirty = AddToCaddy(current); } } + else if (inputMappings->BrowseNewD64()) + { + char newFileName[64]; + int num = folder.FindNextAutoName("testfile"); + snprintf(newFileName, 64, "testfile%03d.d64", num); + m_IEC_Commands.CreateD64(newFileName, "42"); + FolderChanged(); + } else { unsigned keySetIndex; @@ -1241,3 +1252,21 @@ void FileBrowser::AutoSelectImage(const char* image) selectionsMade = FillCaddyWithSelections(); } } + +int FileBrowser::BrowsableList::FindNextAutoName(const char* basename) +{ + int index; + int len = (int)entries.size(); + int baselen = strlen(basename); + int lastNumber = 0; + + for (index = 0; index < len; ++index) + { + Entry* entry = &entries[index]; + if (!(entry->filImage.fattrib & AM_DIR) && strncasecmp(basename, entry->filImage.fname, baselen) == 0) + { + lastNumber = 55; + } + } + return lastNumber+1; +} diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 45611de..a864d0f 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -151,6 +151,7 @@ public: }; Entry* FindEntry(const char* name); + int FindNextAutoName(const char* basename); void RefreshViews(); void RefreshViewsHighlightScroll(); diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 6ca7164..705a40f 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -170,6 +170,8 @@ bool InputMappings::CheckKeyboardBrowseMode() // SetKeyboardFlag(PAGEUP_LCD_FLAG); //else if (keyboard->KeyHeld(KEY_END)) // SetKeyboardFlag(PAGEDOWN_LCD_FLAG); + else if (keyboard->KeyHeld(KEY_N)) + SetKeyboardFlag(NEWD64_FLAG); else { unsigned index; diff --git a/src/InputMappings.h b/src/InputMappings.h index 6e5f99f..19a5d64 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -28,14 +28,17 @@ #define UP_FLAG (1 << 4) #define PAGEUP_FLAG (1 << 5) #define DOWN_FLAG (1 << 6) -#define PAGEDOWN_FLAG (1 << 7) +#define PAGEDOWN_FLAG (1 << 7) #define SPACE_FLAG (1 << 8) #define BACK_FLAG (1 << 9) #define INSERT_FLAG (1 << 10) #define NUMBER_FLAG (1 << 11) -#define PAGEDOWN_LCD_FLAG (1 << 12) -#define PAGEUP_LCD_FLAG (1 << 13) +#define PAGEDOWN_LCD_FLAG (1 << 12) +#define PAGEUP_LCD_FLAG (1 << 13) + +#define NEWD64_FLAG (1 << 14) +// dont exceed 32!! class InputMappings : public Singleton { @@ -137,6 +140,11 @@ public: return KeyboardFlag(INSERT_FLAG)/* | UartFlag(INSERT_FLAG)*/ | ButtonFlag(INSERT_FLAG); } + inline bool BrowseNewD64() + { + return KeyboardFlag(NEWD64_FLAG); + } + // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; static unsigned directDiskSwapRequest; diff --git a/src/Keyboard.h b/src/Keyboard.h index 4d2ba74..5420534 100644 --- a/src/Keyboard.h +++ b/src/Keyboard.h @@ -344,5 +344,9 @@ public: { return (keyStatus[0] | keyStatus[1]); } + inline bool KeyLeftAlt() + { + return (modifier & 1<<2); + } }; #endif diff --git a/src/iec_commands.h b/src/iec_commands.h index dbdf4f0..173d379 100644 --- a/src/iec_commands.h +++ b/src/iec_commands.h @@ -78,6 +78,9 @@ public: const char* GetNameOfImageSelected() const { return selectedImageName; } const FILINFO* GetImageSelected() const { return &filInfoSelectedImage; } void SetStarFileName(const char* fileName) { starFileName = fileName; } + + int CreateD64(char* filenameNew, char* ID); + protected: enum ATNSequence { @@ -128,7 +131,6 @@ protected: void CloseAllChannels(); void SendError(); - int CreateD64(char* filenameNew, char* ID); bool Enter(DIR& dir, FILINFO& filInfo); bool FindFirst(DIR& dir, const char* matchstr, FILINFO& filInfo); diff --git a/src/main.cpp b/src/main.cpp index 3978f98..4257c67 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -793,7 +793,7 @@ void emulator() deviceID = m_IEC_Commands.GetDeviceId(); fileBrowser->SetDeviceID(deviceID); fileBrowser->ShowDeviceAndROM(); - SetVIAsDeviceID(deviceID); // Let the emilated VIA know + SetVIAsDeviceID(deviceID); // Let the emulated VIA know break; default: break; @@ -1361,3 +1361,4 @@ extern "C" #endif } } +