From c080a8cb0cae804310b8bd2088b58caeafd441db Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 21:24:33 +1000 Subject: [PATCH] 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;