InputMapping: merge letters and numbers

This commit is contained in:
penfold42 2018-08-05 18:26:33 +10:00
parent 4ee11949fe
commit 807cee02d2
3 changed files with 29 additions and 42 deletions

View File

@ -375,11 +375,7 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation()
} }
// check for keys a-z and 0-9 // check for keys a-z and 0-9
char searchChar = 0; char searchChar = inputMappings->getKeyboardNumLetter();
if (inputMappings->BrowseLetter())
searchChar = inputMappings->getKeyboardLetter();
if (inputMappings->BrowseNumber())
searchChar = inputMappings->getKeyboardNumber();
if (searchChar) if (searchChar)
{ {
char temp[8]; char temp[8];
@ -833,12 +829,7 @@ void FileBrowser::Update()
dirty = inputMappings->CheckButtonsBrowseMode(); dirty = inputMappings->CheckButtonsBrowseMode();
if (dirty) if (dirty)
{
//if (state == State_Folders)
UpdateInputFolders(); UpdateInputFolders();
//else
// UpdateInputDiskCaddy();
}
UpdateCurrentHighlight(); UpdateCurrentHighlight();
} }
@ -1049,15 +1040,15 @@ void FileBrowser::UpdateInputFolders()
} }
else else
{ {
// check for number keys for ROM and Drive Number changes // check Fkeys for ROM and Drive Number changes
if (inputMappings->BrowseFunction() unsigned ROMOrDevice = inputMappings->getROMOrDevice();
&& inputMappings->getKeyboardFunction() >= 1 if ( inputMappings->BrowseFunction()
&& inputMappings->getKeyboardFunction() <= 11 ) && ROMOrDevice >= 1
&& ROMOrDevice <= 11 )
{ {
SelectROMOrDevice(inputMappings->getKeyboardFunction()); SelectROMOrDevice(ROMOrDevice);
} }
dirty = folder.CheckBrowseNavigation(); dirty = folder.CheckBrowseNavigation();
} }

View File

@ -44,18 +44,14 @@ InputMappings::InputMappings()
bool InputMappings::CheckButtonsBrowseMode() bool InputMappings::CheckButtonsBrowseMode()
{ {
buttonFlags = 0; buttonFlags = 0;
//if (IEC_Bus::GetInputButtonPressed(0))
// SetButtonFlag(ENTER_FLAG);
//else
if (IEC_Bus::GetInputButtonRepeating(1)) if (IEC_Bus::GetInputButtonRepeating(1))
SetButtonFlag(UP_FLAG); SetButtonFlag(UP_FLAG);
else if (IEC_Bus::GetInputButtonRepeating(2)) else if (IEC_Bus::GetInputButtonRepeating(2))
SetButtonFlag(DOWN_FLAG); SetButtonFlag(DOWN_FLAG);
else if (IEC_Bus::GetInputButtonPressed(3)) else if (IEC_Bus::GetInputButtonPressed(3))
SetButtonFlag(BACK_FLAG); SetButtonFlag(BACK_FLAG);
//else if (IEC_Bus::GetInputButtonPressed(4))
// SetButtonFlag(INSERT_FLAG);
// edge detection
insertButtonPressed = !IEC_Bus::GetInputButtonReleased(4); insertButtonPressed = !IEC_Bus::GetInputButtonReleased(4);
if (insertButtonPressedPrev && !insertButtonPressed) if (insertButtonPressedPrev && !insertButtonPressed)
SetButtonFlag(INSERT_FLAG); SetButtonFlag(INSERT_FLAG);
@ -152,6 +148,8 @@ bool InputMappings::CheckKeyboardBrowseMode()
Keyboard* keyboard = Keyboard::Instance(); Keyboard* keyboard = Keyboard::Instance();
keyboardFlags = 0; keyboardFlags = 0;
inputROMOrDevice = 0;
keyboardNumLetter = 0;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now(); reboot_now();
@ -206,26 +204,26 @@ bool InputMappings::CheckKeyboardBrowseMode()
{ {
if (keyboard->KeyHeld(index)) if (keyboard->KeyHeld(index))
{ {
SetKeyboardFlag(NUMBER_FLAG); SetKeyboardFlag(NUMLET_FLAG);
keyboardNumber = index-KEY_1+'1'; // key 1 is ascii '1' keyboardNumLetter = index-KEY_1+'1'; // key 1 is ascii '1'
if (keyboardNumber > '9') keyboardNumber = '0'; if (keyboardNumLetter > '9') keyboardNumLetter = '0';
} }
} }
for (index = KEY_KP1; index <= KEY_KP0; ++index) for (index = KEY_KP1; index <= KEY_KP0; ++index)
{ {
if (keyboard->KeyHeld(index)) if (keyboard->KeyHeld(index))
{ {
SetKeyboardFlag(NUMBER_FLAG); SetKeyboardFlag(NUMLET_FLAG);
keyboardNumber = index-KEY_KP1+'1'; // key 1 is ascii '1' keyboardNumLetter = index-KEY_KP1+'1'; // key 1 is ascii '1'
if (keyboardNumber > '9') keyboardNumber = '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))
{ {
SetKeyboardFlag(LETTER_FLAG); SetKeyboardFlag(NUMLET_FLAG);
keyboardLetter = index-KEY_A+'A'; // key A is ascii 'A' keyboardNumLetter = index-KEY_A+'A'; // key A is ascii 'A'
} }
} }
for (index = KEY_F1; index <= KEY_F12; ++index) // F13 isnt contiguous for (index = KEY_F1; index <= KEY_F12; ++index) // F13 isnt contiguous
@ -233,7 +231,7 @@ bool InputMappings::CheckKeyboardBrowseMode()
if (keyboard->KeyHeld(index)) if (keyboard->KeyHeld(index))
{ {
SetKeyboardFlag(FUNCTION_FLAG); SetKeyboardFlag(FUNCTION_FLAG);
keyboardFunction = index-KEY_F1+1; // key F1 is 1 inputROMOrDevice = index-KEY_F1+1; // key F1 is 1
} }
} }
} }

View File

@ -32,7 +32,8 @@
#define SPACE_FLAG (1 << 8) #define SPACE_FLAG (1 << 8)
#define BACK_FLAG (1 << 9) #define BACK_FLAG (1 << 9)
#define INSERT_FLAG (1 << 10) #define INSERT_FLAG (1 << 10)
#define NUMBER_FLAG (1 << 11)
#define NUMLET_FLAG (1 << 11)
#define PAGEDOWN_LCD_FLAG (1 << 12) #define PAGEDOWN_LCD_FLAG (1 << 12)
#define PAGEUP_LCD_FLAG (1 << 13) #define PAGEUP_LCD_FLAG (1 << 13)
@ -41,9 +42,10 @@
#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 LETTER_FLAG (1 << 18) //#define SPARE_FLAG (1 << 18)
#define HOME_FLAG (1 << 19) #define HOME_FLAG (1 << 19)
#define END_FLAG (1 << 20) #define END_FLAG (1 << 20)
#define FUNCTION_FLAG (1 << 21) #define FUNCTION_FLAG (1 << 21)
// dont exceed 32!! // dont exceed 32!!
@ -78,9 +80,8 @@ protected:
bool enterButtonPressedPrev; bool enterButtonPressedPrev;
bool enterButtonPressed; bool enterButtonPressed;
unsigned keyboardNumber; unsigned keyboardNumLetter;
unsigned keyboardLetter; unsigned inputROMOrDevice;
unsigned keyboardFunction;
//inline void SetUartFlag(unsigned flag) { uartFlags |= flag; } //inline void SetUartFlag(unsigned flag) { uartFlags |= flag; }
//inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; } //inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; }
@ -178,17 +179,14 @@ public:
inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); } inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); }
inline bool BrowseNumber() { return KeyboardFlag(NUMBER_FLAG); }
inline bool BrowseLetter() { return KeyboardFlag(LETTER_FLAG); }
inline bool BrowseFunction() { return KeyboardFlag(FUNCTION_FLAG); } inline bool BrowseFunction() { return KeyboardFlag(FUNCTION_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 char getKeyboardNumber() { return keyboardNumber; } inline char getKeyboardNumLetter() { return keyboardNumLetter; }
inline char getKeyboardLetter() { return (char) keyboardLetter; } inline unsigned getROMOrDevice() { return inputROMOrDevice; }
inline unsigned getKeyboardFunction() { return (char) keyboardFunction; }
// Used by the 2 cores so need to be volatile // Used by the 2 cores so need to be volatile
//volatile static unsigned directDiskSwapRequest; //volatile static unsigned directDiskSwapRequest;