From b809e3e70b2d6832b8bdafe9e61a8b3ae16f4400 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 31 Jul 2018 09:41:50 +1000 Subject: [PATCH 1/8] ROM and deviceID cleanups start implementing a-z --- src/FileBrowser.cpp | 158 +++++++++++++++++++++----------------------- src/FileBrowser.h | 5 +- 2 files changed, 77 insertions(+), 86 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index d5918bb..c3b570b 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -386,8 +386,7 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool di , roms(roms) , deviceID(deviceID) , displayPNGIcons(displayPNGIcons) - , buttonChangedDevice(false) - , buttonSelectROM(false) + , buttonChangedROMDevice(false) , screenMain(screenMain) , screenLCD(screenLCD) , scrollHighlightRate(scrollHighlightRate) @@ -823,54 +822,51 @@ void FileBrowser::UpdateInputFolders() Keyboard* keyboard = Keyboard::Instance(); InputMappings* inputMappings = InputMappings::Instance(); + buttonChangedROMDevice = false; if (IEC_Bus::GetInputButtonHeld(4)) { if (inputMappings->BrowseSelect()) { - GlobalSetDeviceID(8); - ShowDeviceAndROM(); - buttonChangedDevice = true; + SelectROMOrDevice(7); // == device 8 + buttonChangedROMDevice = true; } else if (inputMappings->BrowseUp()) { - GlobalSetDeviceID(9); - ShowDeviceAndROM(); - buttonChangedDevice = true; + SelectROMOrDevice(8); // == device 9 + buttonChangedROMDevice = true; } else if (inputMappings->BrowseDown()) { - GlobalSetDeviceID(10); - ShowDeviceAndROM(); - buttonChangedDevice = true; + SelectROMOrDevice(9); // == device 10 + buttonChangedROMDevice = true; } else if (inputMappings->BrowseBack()) { - GlobalSetDeviceID(11); - ShowDeviceAndROM(); - buttonChangedDevice = true; + SelectROMOrDevice(10); // == device 11 + buttonChangedROMDevice = true; } } else if (IEC_Bus::GetInputButtonHeld(0)) { if (inputMappings->BrowseUp()) { - SelectROM(0); - buttonSelectROM = true; + SelectROMOrDevice(0); + buttonChangedROMDevice = true; } else if (inputMappings->BrowseDown()) { - SelectROM(1); - buttonSelectROM = true; + SelectROMOrDevice(1); + buttonChangedROMDevice = true; } else if (inputMappings->BrowseBack()) { - SelectROM(2); - buttonSelectROM = true; + SelectROMOrDevice(2); + buttonChangedROMDevice = true; } else if (inputMappings->BrowseInsert()) { - SelectROM(3); - buttonSelectROM = true; + SelectROMOrDevice(3); + buttonChangedROMDevice = true; } } else @@ -880,57 +876,50 @@ void FileBrowser::UpdateInputFolders() //u32 numberOfEntriesMinus1 = folder.entries.size() - 1; bool dirty = false; - if (inputMappings->BrowseSelect()) + if (inputMappings->BrowseSelect() && !buttonChangedROMDevice ) { - if (buttonSelectROM) + FileBrowser::BrowsableList::Entry* current = folder.current; + if (current) { - buttonSelectROM = false; - } - else - { - FileBrowser::BrowsableList::Entry* current = folder.current; - if (current) + if (current->filImage.fattrib & AM_DIR) { - if (current->filImage.fattrib & AM_DIR) + if (strcmp(current->filImage.fname, "..") == 0) { - if (strcmp(current->filImage.fname, "..") == 0) - { - PopFolder(); - } - else if (strcmp(current->filImage.fname, ".") != 0) - { - f_chdir(current->filImage.fname); - RefreshFolderEntries(); - } - dirty = true; + PopFolder(); } - else + else if (strcmp(current->filImage.fname, ".") != 0) { - if (strcmp(current->filImage.fname, "..") == 0) + f_chdir(current->filImage.fname); + RefreshFolderEntries(); + } + dirty = true; + } + else + { + if (strcmp(current->filImage.fname, "..") == 0) + { + PopFolder(); + } + else if (DiskImage::IsDiskImageExtention(current->filImage.fname)) + { + DiskImage::DiskType diskType = DiskImage::GetDiskImageTypeViaExtention(current->filImage.fname); + + // Should also be able to create a LST file from all the images currently selected in the caddy + if (diskType == DiskImage::LST) { - PopFolder(); + selectionsMade = SelectLST(current->filImage.fname); } - else if (DiskImage::IsDiskImageExtention(current->filImage.fname)) + else { - DiskImage::DiskType diskType = DiskImage::GetDiskImageTypeViaExtention(current->filImage.fname); - - // Should also be able to create a LST file from all the images currently selected in the caddy - if (diskType == DiskImage::LST) - { - selectionsMade = SelectLST(current->filImage.fname); - } - else - { - // Add the current selected - AddToCaddy(current); - selectionsMade = FillCaddyWithSelections(); - } - - if (selectionsMade) - lastSelectionName = current->filImage.fname; - - dirty = true; + // Add the current selected + AddToCaddy(current); + selectionsMade = FillCaddyWithSelections(); } + + if (selectionsMade) + lastSelectionName = current->filImage.fname; + + dirty = true; } } } @@ -954,19 +943,12 @@ void FileBrowser::UpdateInputFolders() ClearSelections(); dirty = true; } - else if (inputMappings->BrowseInsert()) + else if (inputMappings->BrowseInsert() && !buttonChangedROMDevice ) { - if (buttonChangedDevice) + FileBrowser::BrowsableList::Entry* current = folder.current; + if (current) { - buttonChangedDevice = false; - } - else - { - FileBrowser::BrowsableList::Entry* current = folder.current; - if (current) - { - dirty = AddToCaddy(current); - } + dirty = AddToCaddy(current); } } else if (inputMappings->BrowseNewD64()) @@ -997,6 +979,7 @@ void FileBrowser::UpdateInputFolders() } else { + // check for number keys for ROM and Drive Number changes unsigned keySetIndex; for (keySetIndex = 0; keySetIndex < 11; ++keySetIndex) { @@ -1004,15 +987,16 @@ void FileBrowser::UpdateInputFolders() if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2])) + SelectROMOrDevice(keySetIndex); + } + + // check for keys a-z + if ( keyboard->KeyAnyHeld() && !keyboard->KeyEitherAlt() ) + for (unsigned i=KEY_A; i<=KEY_Z; i++) + { + if (keyboard->KeyPressed( i )) { - if (SelectROM(keySetIndex)) - { - } - else if ( (keySetIndex >= 7) && (keySetIndex <= 10 ) ) - { - GlobalSetDeviceID( keySetIndex+1 ); - ShowDeviceAndROM(); - } + char ascKey = i-KEY_A+'A'; } } @@ -1033,7 +1017,9 @@ void FileBrowser::UpdateInputFolders() } } -bool FileBrowser::SelectROM(u32 index) +bool FileBrowser::SelectROMOrDevice(u32 index) +// 0-6 select ROM image +// 7-10 change deviceID to 8-11 { if ((index < ROMs::MAX_ROMS) && (roms->ROMValid[index])) { @@ -1043,6 +1029,12 @@ bool FileBrowser::SelectROM(u32 index) ShowDeviceAndROM(); return true; } + else if ( (index >= 7) && (index <= 10 ) ) + { + GlobalSetDeviceID( index+1 ); + ShowDeviceAndROM(); + return true; + } return false; } diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 84f5a97..4e35ab2 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -217,7 +217,7 @@ private: bool CheckForPNG(const char* filename, FILINFO& filIcon); void DisplayPNG(); - bool SelectROM(u32 index); + bool SelectROMOrDevice(u32 index); enum State { @@ -232,8 +232,7 @@ private: ROMs* roms; u8* deviceID; bool displayPNGIcons; - bool buttonChangedDevice; - bool buttonSelectROM; + bool buttonChangedROMDevice; BrowsableList caddySelections; From 8fe97363e79bd889b9527cae2e2a9af216915960 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 31 Jul 2018 18:38:24 +1000 Subject: [PATCH 2/8] Moved Number key checking code to inputmapping --- src/FileBrowser.cpp | 48 +++++++++++++++++++++++-------------------- src/FileBrowser.h | 3 +-- src/InputMappings.cpp | 32 +++++++++++++++++++++-------- src/InputMappings.h | 28 +++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 33 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index c3b570b..74337f8 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -45,21 +45,6 @@ extern void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowse unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size]; -const unsigned FileBrowser::SwapKeys[33] = -{ - KEY_F1, KEY_KP1, KEY_1, - KEY_F2, KEY_KP2, KEY_2, - KEY_F3, KEY_KP3, KEY_3, - KEY_F4, KEY_KP4, KEY_4, - KEY_F5, KEY_KP5, KEY_5, - KEY_F6, KEY_KP6, KEY_6, - KEY_F7, KEY_KP7, KEY_7, - KEY_F8, KEY_KP8, KEY_8, - KEY_F9, KEY_KP9, KEY_9, - KEY_F10, KEY_KP0, KEY_0, - KEY_F11, KEY_KPMINUS, KEY_MINUS -}; - static const u32 palette[] = { RGBA(0x00, 0x00, 0x00, 0xFF), @@ -379,6 +364,28 @@ FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindEntry(const c return 0; } +FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindNextPartialEntry(const char* name, int match_len) +{ + int index; + int len = (int)entries.size(); + + for (index = 0; index < len; ++index) + { + Entry* entry = &entries[index]; + if (match_len) // partial match + { + if (strncasecmp(name, entry->filImage.fname, match_len) == 0) + return entry; + } + else // full match + { + if (strcasecmp(name, entry->filImage.fname) == 0) + return entry; + } + } + return 0; +} + FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate) : state(State_Folders) , diskCaddy(diskCaddy) @@ -980,14 +987,11 @@ void FileBrowser::UpdateInputFolders() else { // check for number keys for ROM and Drive Number changes - unsigned keySetIndex; - for (keySetIndex = 0; keySetIndex < 11; ++keySetIndex) + if (inputMappings->BrowseNumber() + && inputMappings->getKeyboardNumber() >= 0 + && inputMappings->getKeyboardNumber() < 11 ) { - unsigned keySetIndexBase = keySetIndex * 3; - if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase]) - || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1]) - || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2])) - SelectROMOrDevice(keySetIndex); + SelectROMOrDevice(inputMappings->getKeyboardNumber()); } // check for keys a-z diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 4e35ab2..4db2861 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -151,6 +151,7 @@ public: }; Entry* FindEntry(const char* name); + Entry* FindNextPartialEntry(const char* name, int match_len); int FindNextAutoName(char* basename); void RefreshViews(); @@ -191,8 +192,6 @@ public: static const long int LSTBuffer_size = 1024 * 8; static unsigned char LSTBuffer[]; - static const unsigned SwapKeys[]; - static u32 Colour(int index); bool SelectLST(const char* filenameLST); diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 9cb5140..62443d1 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -191,16 +191,28 @@ bool InputMappings::CheckKeyboardBrowseMode() SetKeyboardFlag(AUTOLOAD_FLAG); else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() ) SetKeyboardFlag(FAKERESET_FLAG); - else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt()) + else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt() ) SetKeyboardFlag(WRITEPROTECT_FLAG); else { unsigned index; - for (index = 0; index < 11; ++index) + for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3) { - unsigned keySetIndexBase = index * 3; - if (keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 2])) - keyboardFlags |= NUMBER_FLAG; + if (keyboard->KeyHeld(NumberKeys[index]) + || keyboard->KeyHeld(NumberKeys[index + 1]) + || keyboard->KeyHeld(NumberKeys[index + 2]) ) + { + SetKeyboardFlag(NUMBER_FLAG); + keyboardNumber = index/3; + } + } + for (index = KEY_A; index <= KEY_Z; ++index) + { + if (keyboard->KeyHeld(index)) + { + SetKeyboardFlag(AtoZ_FLAG); + keyboardNumber = index-KEY_A+1; + } } } @@ -227,12 +239,14 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned else if (numberOfImages > 1) { unsigned index; - for (index = 0; index < numberOfImagesMax; ++index) + for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3) { - unsigned keySetIndexBase = index * 3; - if (keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 2])) - directDiskSwapRequest |= (1 << index); + if (keyboard->KeyHeld(NumberKeys[index]) + || keyboard->KeyHeld(NumberKeys[index + 1]) + || keyboard->KeyHeld(NumberKeys[index + 2]) ) + directDiskSwapRequest |= (1 << index/3); } } } } + diff --git a/src/InputMappings.h b/src/InputMappings.h index ffce76e..f4cd801 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -41,8 +41,24 @@ #define AUTOLOAD_FLAG (1 << 15) #define FAKERESET_FLAG (1 << 16) #define WRITEPROTECT_FLAG (1 << 17) +#define AtoZ_FLAG (1 << 18) // dont exceed 32!! +const unsigned NumberKeys[33] = +{ + KEY_F1, KEY_KP1, KEY_1, + KEY_F2, KEY_KP2, KEY_2, + KEY_F3, KEY_KP3, KEY_3, + KEY_F4, KEY_KP4, KEY_4, + KEY_F5, KEY_KP5, KEY_5, + KEY_F6, KEY_KP6, KEY_6, + KEY_F7, KEY_KP7, KEY_7, + KEY_F8, KEY_KP8, KEY_8, + KEY_F9, KEY_KP9, KEY_9, + KEY_F10, KEY_KP0, KEY_0, + KEY_F11, KEY_KPMINUS, KEY_MINUS +}; + class InputMappings : public Singleton { protected: @@ -59,6 +75,9 @@ protected: bool enterButtonPressedPrev; bool enterButtonPressed; + unsigned keyboardNumber; + unsigned keyboardLetter; + //inline void SetUartFlag(unsigned flag) { uartFlags |= flag; } //inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; } inline void SetKeyboardFlag(unsigned flag) { keyboardFlags |= flag; } @@ -179,6 +198,14 @@ public: return KeyboardFlag(WRITEPROTECT_FLAG); } + inline bool BrowseNumber() + { + return KeyboardFlag(NUMBER_FLAG); + } + + inline unsigned getKeyboardNumber() { return keyboardNumber; } + inline unsigned getKeyboardLetter() { return keyboardLetter; } + // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; static unsigned directDiskSwapRequest; @@ -187,3 +214,4 @@ public: // static unsigned escapeSequenceIndex; }; #endif + From df58673e65b879452fce1ba230d8455bf7290e8f Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 00:43:52 +1000 Subject: [PATCH 3/8] pressing a-z will jump to the next list entry starting with that letter --- src/FileBrowser.cpp | 71 ++++++++++++++++++++++++------------------- src/FileBrowser.h | 1 - src/InputMappings.cpp | 29 ++++++++++-------- src/InputMappings.h | 9 ++++-- src/Keyboard.h | 4 +++ 5 files changed, 67 insertions(+), 47 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 74337f8..518fd6c 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -308,6 +308,46 @@ bool FileBrowser::BrowsableListView::CheckBrowseNavigation(bool pageOnly) dirty = true; } + // check for keys a-z + if (inputMappings->BrowseLetter()) + { + char temp[8]; + unsigned found=0; + u32 i=0; + snprintf (temp, sizeof(temp), "%c", inputMappings->getKeyboardLetter()); + + // first look from next to last + for (i=1+list->currentIndex; i <= numberOfEntriesMinus1 ; i++) + { + FileBrowser::BrowsableList::Entry* entry = &list->entries[i]; + if (strncasecmp(temp, entry->filImage.fname, 1) == 0) + { + found=i; + break; + } + } + if (!found) + { + // look from first to previous + for (i=0; i< 1+list->currentIndex ; i++) + { + FileBrowser::BrowsableList::Entry* entry = &list->entries[i]; + if (strncasecmp(temp, entry->filImage.fname, 1) == 0) + { + found=i; + break; + } + } + } + + if (found) + { + list->currentIndex=found; + list->SetCurrent(); + dirty = true; + } + } + return dirty; } @@ -364,28 +404,6 @@ FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindEntry(const c return 0; } -FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindNextPartialEntry(const char* name, int match_len) -{ - int index; - int len = (int)entries.size(); - - for (index = 0; index < len; ++index) - { - Entry* entry = &entries[index]; - if (match_len) // partial match - { - if (strncasecmp(name, entry->filImage.fname, match_len) == 0) - return entry; - } - else // full match - { - if (strcasecmp(name, entry->filImage.fname) == 0) - return entry; - } - } - return 0; -} - FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate) : state(State_Folders) , diskCaddy(diskCaddy) @@ -994,15 +1012,6 @@ void FileBrowser::UpdateInputFolders() SelectROMOrDevice(inputMappings->getKeyboardNumber()); } - // check for keys a-z - if ( keyboard->KeyAnyHeld() && !keyboard->KeyEitherAlt() ) - for (unsigned i=KEY_A; i<=KEY_Z; i++) - { - if (keyboard->KeyPressed( i )) - { - char ascKey = i-KEY_A+'A'; - } - } dirty = folder.CheckBrowseNavigation(); } diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 4db2861..d6de6cc 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -151,7 +151,6 @@ public: }; Entry* FindEntry(const char* name); - Entry* FindNextPartialEntry(const char* name, int match_len); int FindNextAutoName(char* basename); void RefreshViews(); diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 62443d1..1e23883 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -195,23 +195,26 @@ bool InputMappings::CheckKeyboardBrowseMode() SetKeyboardFlag(WRITEPROTECT_FLAG); else { - unsigned index; - for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3) + if (keyboard->KeyNoModifiers()) { - if (keyboard->KeyHeld(NumberKeys[index]) - || keyboard->KeyHeld(NumberKeys[index + 1]) - || keyboard->KeyHeld(NumberKeys[index + 2]) ) + unsigned index; + for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3) { - SetKeyboardFlag(NUMBER_FLAG); - keyboardNumber = index/3; + if (keyboard->KeyHeld(NumberKeys[index]) + || keyboard->KeyHeld(NumberKeys[index + 1]) + || keyboard->KeyHeld(NumberKeys[index + 2]) ) + { + SetKeyboardFlag(NUMBER_FLAG); + keyboardNumber = index/3; // key 1 is 0 + } } - } - for (index = KEY_A; index <= KEY_Z; ++index) - { - if (keyboard->KeyHeld(index)) + for (index = KEY_A; index <= KEY_Z; ++index) { - SetKeyboardFlag(AtoZ_FLAG); - keyboardNumber = index-KEY_A+1; + if (keyboard->KeyHeld(index)) + { + SetKeyboardFlag(LETTER_FLAG); + keyboardLetter = index-KEY_A+'A'; // key A is ascii 'A' + } } } } diff --git a/src/InputMappings.h b/src/InputMappings.h index f4cd801..9bf610b 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -41,7 +41,7 @@ #define AUTOLOAD_FLAG (1 << 15) #define FAKERESET_FLAG (1 << 16) #define WRITEPROTECT_FLAG (1 << 17) -#define AtoZ_FLAG (1 << 18) +#define LETTER_FLAG (1 << 18) // dont exceed 32!! const unsigned NumberKeys[33] = @@ -203,8 +203,13 @@ public: return KeyboardFlag(NUMBER_FLAG); } + inline bool BrowseLetter() + { + return KeyboardFlag(LETTER_FLAG); + } + inline unsigned getKeyboardNumber() { return keyboardNumber; } - inline unsigned getKeyboardLetter() { return keyboardLetter; } + inline char getKeyboardLetter() { return (char) keyboardLetter; } // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; diff --git a/src/Keyboard.h b/src/Keyboard.h index ad0e631..774ef6c 100644 --- a/src/Keyboard.h +++ b/src/Keyboard.h @@ -348,5 +348,9 @@ public: { return (modifier & (KEY_MOD_LALT | KEY_MOD_RALT) ); } + inline bool KeyNoModifiers() + { + return (!modifier ); + } }; #endif From b3cdf92238b057e8cf12c6d9e292539abf4ea48f Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 00:53:31 +1000 Subject: [PATCH 4/8] Oops... a-z code was in BrowsableListView::CheckNavigation. With 2 screens it was running ttwwiiccee Moved to BrowsableList::CheckNavigation --- src/FileBrowser.cpp | 83 +++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 518fd6c..219d1b3 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -308,46 +308,6 @@ bool FileBrowser::BrowsableListView::CheckBrowseNavigation(bool pageOnly) dirty = true; } - // check for keys a-z - if (inputMappings->BrowseLetter()) - { - char temp[8]; - unsigned found=0; - u32 i=0; - snprintf (temp, sizeof(temp), "%c", inputMappings->getKeyboardLetter()); - - // first look from next to last - for (i=1+list->currentIndex; i <= numberOfEntriesMinus1 ; i++) - { - FileBrowser::BrowsableList::Entry* entry = &list->entries[i]; - if (strncasecmp(temp, entry->filImage.fname, 1) == 0) - { - found=i; - break; - } - } - if (!found) - { - // look from first to previous - for (i=0; i< 1+list->currentIndex ; i++) - { - FileBrowser::BrowsableList::Entry* entry = &list->entries[i]; - if (strncasecmp(temp, entry->filImage.fname, 1) == 0) - { - found=i; - break; - } - } - } - - if (found) - { - list->currentIndex=found; - list->SetCurrent(); - dirty = true; - } - } - return dirty; } @@ -381,12 +341,55 @@ void FileBrowser::BrowsableList::RefreshViewsHighlightScroll() bool FileBrowser::BrowsableList::CheckBrowseNavigation() { + InputMappings* inputMappings = InputMappings::Instance(); + u32 numberOfEntriesMinus1 = entries.size() - 1; + bool dirty = false; u32 index; for (index = 0; index < views.size(); ++index) { dirty |= views[index].CheckBrowseNavigation(index != 0); } + // check for keys a-z + if (inputMappings->BrowseLetter()) + { + char temp[8]; + unsigned found=0; + u32 i=0; + snprintf (temp, sizeof(temp), "%c", inputMappings->getKeyboardLetter()); + + // first look from next to last + for (i=1+currentIndex; i <= numberOfEntriesMinus1 ; i++) + { + FileBrowser::BrowsableList::Entry* entry = &entries[i]; + if (strncasecmp(temp, entry->filImage.fname, 1) == 0) + { + found=i; + break; + } + } + if (!found) + { + // look from first to previous + for (i=0; i< 1+currentIndex ; i++) + { + FileBrowser::BrowsableList::Entry* entry = &entries[i]; + if (strncasecmp(temp, entry->filImage.fname, 1) == 0) + { + found=i; + break; + } + } + } + + if (found) + { + currentIndex=found; + SetCurrent(); + dirty |= 1; + } + } + return dirty; } From 792c259714efed4d716eafff5c55cf366db83900 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 17:57:01 +1000 Subject: [PATCH 5/8] Browse: Home and End move to 1st and last entry --- src/FileBrowser.cpp | 14 +++++++++++++- src/InputMappings.cpp | 9 ++++----- src/InputMappings.h | 12 ++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 219d1b3..14e59e2 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -350,6 +350,7 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation() { dirty |= views[index].CheckBrowseNavigation(index != 0); } + // check for keys a-z if (inputMappings->BrowseLetter()) { @@ -389,7 +390,18 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation() dirty |= 1; } } - + else if (inputMappings->BrowseHome()) + { + currentIndex = 0; + SetCurrent(); + dirty |= 1; + } + else if (inputMappings->BrowseEnd()) + { + currentIndex = numberOfEntriesMinus1; + SetCurrent(); + dirty |= 1; + } return dirty; } diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 1e23883..36750f7 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -152,7 +152,6 @@ bool InputMappings::CheckKeyboardBrowseMode() keyboardFlags = 0; - // TODO: add KEY_HOME and KEY_END if (keyboard->KeyHeld(KEY_ESC)) SetKeyboardFlag(ESC_FLAG); else if (keyboard->KeyHeld(KEY_ENTER)) @@ -181,10 +180,10 @@ bool InputMappings::CheckKeyboardBrowseMode() else SetKeyboardFlag(PAGEDOWN_FLAG); } - //else if (keyboard->KeyHeld(KEY_HOME)) - // SetKeyboardFlag(PAGEUP_LCD_FLAG); - //else if (keyboard->KeyHeld(KEY_END)) - // SetKeyboardFlag(PAGEDOWN_LCD_FLAG); + else if (keyboard->KeyHeld(KEY_HOME)) + SetKeyboardFlag(HOME_FLAG); + else if (keyboard->KeyHeld(KEY_END)) + SetKeyboardFlag(END_FLAG); else if (keyboard->KeyHeld(KEY_N) && keyboard->KeyEitherAlt() ) SetKeyboardFlag(NEWD64_FLAG); else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() ) diff --git a/src/InputMappings.h b/src/InputMappings.h index 9bf610b..186d400 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -42,6 +42,8 @@ #define FAKERESET_FLAG (1 << 16) #define WRITEPROTECT_FLAG (1 << 17) #define LETTER_FLAG (1 << 18) +#define HOME_FLAG (1 << 19) +#define END_FLAG (1 << 20) // dont exceed 32!! const unsigned NumberKeys[33] = @@ -208,6 +210,16 @@ public: return KeyboardFlag(LETTER_FLAG); } + inline bool BrowseHome() + { + return KeyboardFlag(HOME_FLAG); + } + + inline bool BrowseEnd() + { + return KeyboardFlag(END_FLAG); + } + inline unsigned getKeyboardNumber() { return keyboardNumber; } inline char getKeyboardLetter() { return (char) keyboardLetter; } From 313ad5a9781acc4cfefe12d5254abcfa0fb0f68f Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 18:38:40 +1000 Subject: [PATCH 6/8] Fix caddy column width... 6?? --- src/FileBrowser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 14e59e2..1707525 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -443,7 +443,8 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool di folder.AddView(screenMain, columns, rows, positionX, positionY, false); positionX = screenMain->ScaleX(1024 - 320); - caddySelections.AddView(screenMain, 6, rows, positionX, positionY, false); + columns = screenMain->ScaleX(40); + caddySelections.AddView(screenMain, columns, rows, positionX, positionY, false); From c080a8cb0cae804310b8bd2088b58caeafd441db Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 21:24:33 +1000 Subject: [PATCH 7/8] Browse mode - MUST use F1..F11 for rom and device ID changes numbers have been removed --- src/FileBrowser.cpp | 25 +++++++++-------- src/InputMappings.cpp | 27 ++++++++++++++---- src/InputMappings.h | 65 +++++++++++-------------------------------- 3 files changed, 51 insertions(+), 66 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 1707525..9f78803 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1021,11 +1021,11 @@ void FileBrowser::UpdateInputFolders() else { // check for number keys for ROM and Drive Number changes - if (inputMappings->BrowseNumber() - && inputMappings->getKeyboardNumber() >= 0 - && inputMappings->getKeyboardNumber() < 11 ) + if (inputMappings->BrowseFunction() + && inputMappings->getKeyboardFunction() >= 1 + && inputMappings->getKeyboardFunction() <= 11 ) { - SelectROMOrDevice(inputMappings->getKeyboardNumber()); + SelectROMOrDevice(inputMappings->getKeyboardFunction()); } @@ -1047,9 +1047,16 @@ void FileBrowser::UpdateInputFolders() } bool FileBrowser::SelectROMOrDevice(u32 index) -// 0-6 select ROM image -// 7-10 change deviceID to 8-11 +// 1-7 select ROM image +// 8-11 change deviceID to 8-11 { + if ( (index >= 8) && (index <= 11 ) ) + { + GlobalSetDeviceID( index ); + ShowDeviceAndROM(); + return true; + } + index--; if ((index < ROMs::MAX_ROMS) && (roms->ROMValid[index])) { roms->currentROMIndex = index; @@ -1058,12 +1065,6 @@ bool FileBrowser::SelectROMOrDevice(u32 index) ShowDeviceAndROM(); return true; } - else if ( (index >= 7) && (index <= 10 ) ) - { - GlobalSetDeviceID( index+1 ); - ShowDeviceAndROM(); - return true; - } return false; } diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 36750f7..a300ede 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -197,14 +197,23 @@ bool InputMappings::CheckKeyboardBrowseMode() if (keyboard->KeyNoModifiers()) { unsigned index; - for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3) + + for (index = KEY_1; index <= KEY_0; ++index) { - if (keyboard->KeyHeld(NumberKeys[index]) - || keyboard->KeyHeld(NumberKeys[index + 1]) - || keyboard->KeyHeld(NumberKeys[index + 2]) ) + if (keyboard->KeyHeld(index)) { SetKeyboardFlag(NUMBER_FLAG); - keyboardNumber = index/3; // key 1 is 0 + keyboardNumber = index-KEY_1+'1'; // key 1 is ascii '1' + if (keyboardNumber > '9') keyboardNumber = '0'; + } + } + for (index = KEY_KP1; index <= KEY_KP0; ++index) + { + if (keyboard->KeyHeld(index)) + { + SetKeyboardFlag(NUMBER_FLAG); + keyboardNumber = index-KEY_KP1+'1'; // key 1 is ascii '1' + if (keyboardNumber > '9') keyboardNumber = '0'; } } for (index = KEY_A; index <= KEY_Z; ++index) @@ -215,6 +224,14 @@ bool InputMappings::CheckKeyboardBrowseMode() keyboardLetter = index-KEY_A+'A'; // key A is ascii 'A' } } + for (index = KEY_F1; index <= KEY_F12; ++index) // F13 isnt contiguous + { + if (keyboard->KeyHeld(index)) + { + SetKeyboardFlag(FUNCTION_FLAG); + keyboardFunction = index-KEY_F1+1; // key F1 is 1 + } + } } } diff --git a/src/InputMappings.h b/src/InputMappings.h index 186d400..6ed0453 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -44,6 +44,7 @@ #define LETTER_FLAG (1 << 18) #define HOME_FLAG (1 << 19) #define END_FLAG (1 << 20) +#define FUNCTION_FLAG (1 << 21) // dont exceed 32!! const unsigned NumberKeys[33] = @@ -79,6 +80,7 @@ protected: unsigned keyboardNumber; unsigned keyboardLetter; + unsigned keyboardFunction; //inline void SetUartFlag(unsigned flag) { uartFlags |= flag; } //inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; } @@ -122,15 +124,9 @@ public: return KeyboardFlag(PREV_FLAG)/* | UartFlag(PREV_FLAG)*/ | ButtonFlag(PREV_FLAG); } - inline bool AutoLoad() - { - return KeyboardFlag(AUTOLOAD_FLAG); - } + inline bool AutoLoad() { return KeyboardFlag(AUTOLOAD_FLAG); } - inline bool FakeReset() - { - return KeyboardFlag(FAKERESET_FLAG); - } + inline bool FakeReset() { return KeyboardFlag(FAKERESET_FLAG); } inline bool BrowseSelect() { @@ -156,10 +152,7 @@ public: { return KeyboardFlag(PAGEUP_FLAG)/* | UartFlag(PAGEUP_FLAG)*/; } - inline bool BrowsePageUpLCD() - { - return KeyboardFlag(PAGEUP_LCD_FLAG); - } + inline bool BrowsePageUpLCD() { return KeyboardFlag(PAGEUP_LCD_FLAG); } inline bool BrowseDown() { @@ -170,58 +163,32 @@ public: { return KeyboardFlag(PAGEDOWN_FLAG)/* | UartFlag(PAGEDOWN_FLAG)*/; } - inline bool BrowsePageDownLCD() - { - return KeyboardFlag(PAGEDOWN_LCD_FLAG); - } + inline bool BrowsePageDownLCD() { return KeyboardFlag(PAGEDOWN_LCD_FLAG); } inline bool BrowseInsert() { return KeyboardFlag(INSERT_FLAG)/* | UartFlag(INSERT_FLAG)*/ | ButtonFlag(INSERT_FLAG); } - inline bool BrowseNewD64() - { - return KeyboardFlag(NEWD64_FLAG); - } + inline bool BrowseNewD64() { return KeyboardFlag(NEWD64_FLAG); } - inline bool BrowseAutoLoad() - { - return KeyboardFlag(AUTOLOAD_FLAG); - } + inline bool BrowseAutoLoad() { return KeyboardFlag(AUTOLOAD_FLAG); } - inline bool BrowseFakeReset() - { - return KeyboardFlag(FAKERESET_FLAG); - } + inline bool BrowseFakeReset() { return KeyboardFlag(FAKERESET_FLAG); } - inline bool BrowseWriteProtect() - { - return KeyboardFlag(WRITEPROTECT_FLAG); - } + inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); } - inline bool BrowseNumber() - { - return KeyboardFlag(NUMBER_FLAG); - } + inline bool BrowseNumber() { return KeyboardFlag(NUMBER_FLAG); } + inline bool BrowseLetter() { return KeyboardFlag(LETTER_FLAG); } + inline bool BrowseFunction() { return KeyboardFlag(FUNCTION_FLAG); } - inline bool BrowseLetter() - { - return KeyboardFlag(LETTER_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); } inline unsigned getKeyboardNumber() { return keyboardNumber; } inline char getKeyboardLetter() { return (char) keyboardLetter; } + inline char getKeyboardFunction() { return (char) keyboardFunction; } // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; From 016b9ce2851dd78cf40fdd418073a44f1b709d78 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 21:42:17 +1000 Subject: [PATCH 8/8] Browse: can use 0-9 like a-z --- src/FileBrowser.cpp | 9 +++++++-- src/InputMappings.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 9f78803..4284dd3 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -351,13 +351,18 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation() dirty |= views[index].CheckBrowseNavigation(index != 0); } - // check for keys a-z + // check for keys a-z and 0-9 + char searchChar = 0; if (inputMappings->BrowseLetter()) + searchChar = inputMappings->getKeyboardLetter(); + if (inputMappings->BrowseNumber()) + searchChar = inputMappings->getKeyboardNumber(); + if (searchChar) { char temp[8]; unsigned found=0; u32 i=0; - snprintf (temp, sizeof(temp), "%c", inputMappings->getKeyboardLetter()); + snprintf (temp, sizeof(temp), "%c", searchChar); // first look from next to last for (i=1+currentIndex; i <= numberOfEntriesMinus1 ; i++) diff --git a/src/InputMappings.h b/src/InputMappings.h index 6ed0453..4f873fe 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -186,9 +186,9 @@ public: inline bool BrowseEnd() { return KeyboardFlag(END_FLAG); } - inline unsigned getKeyboardNumber() { return keyboardNumber; } + inline char getKeyboardNumber() { return keyboardNumber; } inline char getKeyboardLetter() { return (char) keyboardLetter; } - inline char getKeyboardFunction() { return (char) keyboardFunction; } + inline unsigned getKeyboardFunction() { return (char) keyboardFunction; } // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest;