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

View file

@ -44,18 +44,14 @@ InputMappings::InputMappings()
bool InputMappings::CheckButtonsBrowseMode()
{
buttonFlags = 0;
//if (IEC_Bus::GetInputButtonPressed(0))
// SetButtonFlag(ENTER_FLAG);
//else
if (IEC_Bus::GetInputButtonRepeating(1))
SetButtonFlag(UP_FLAG);
else if (IEC_Bus::GetInputButtonRepeating(2))
SetButtonFlag(DOWN_FLAG);
else if (IEC_Bus::GetInputButtonPressed(3))
SetButtonFlag(BACK_FLAG);
//else if (IEC_Bus::GetInputButtonPressed(4))
// SetButtonFlag(INSERT_FLAG);
// edge detection
insertButtonPressed = !IEC_Bus::GetInputButtonReleased(4);
if (insertButtonPressedPrev && !insertButtonPressed)
SetButtonFlag(INSERT_FLAG);
@ -152,6 +148,8 @@ bool InputMappings::CheckKeyboardBrowseMode()
Keyboard* keyboard = Keyboard::Instance();
keyboardFlags = 0;
inputROMOrDevice = 0;
keyboardNumLetter = 0;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now();
@ -206,26 +204,26 @@ bool InputMappings::CheckKeyboardBrowseMode()
{
if (keyboard->KeyHeld(index))
{
SetKeyboardFlag(NUMBER_FLAG);
keyboardNumber = index-KEY_1+'1'; // key 1 is ascii '1'
if (keyboardNumber > '9') keyboardNumber = '0';
SetKeyboardFlag(NUMLET_FLAG);
keyboardNumLetter = index-KEY_1+'1'; // key 1 is ascii '1'
if (keyboardNumLetter > '9') keyboardNumLetter = '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';
SetKeyboardFlag(NUMLET_FLAG);
keyboardNumLetter = index-KEY_KP1+'1'; // key 1 is ascii '1'
if (keyboardNumLetter > '9') keyboardNumLetter = '0';
}
}
for (index = KEY_A; index <= KEY_Z; ++index)
{
if (keyboard->KeyHeld(index))
{
SetKeyboardFlag(LETTER_FLAG);
keyboardLetter = index-KEY_A+'A'; // key A is ascii 'A'
SetKeyboardFlag(NUMLET_FLAG);
keyboardNumLetter = index-KEY_A+'A'; // key A is ascii 'A'
}
}
for (index = KEY_F1; index <= KEY_F12; ++index) // F13 isnt contiguous
@ -233,7 +231,7 @@ bool InputMappings::CheckKeyboardBrowseMode()
if (keyboard->KeyHeld(index))
{
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 BACK_FLAG (1 << 9)
#define INSERT_FLAG (1 << 10)
#define NUMBER_FLAG (1 << 11)
#define NUMLET_FLAG (1 << 11)
#define PAGEDOWN_LCD_FLAG (1 << 12)
#define PAGEUP_LCD_FLAG (1 << 13)
@ -41,9 +42,10 @@
#define AUTOLOAD_FLAG (1 << 15)
#define FAKERESET_FLAG (1 << 16)
#define WRITEPROTECT_FLAG (1 << 17)
#define LETTER_FLAG (1 << 18)
//#define SPARE_FLAG (1 << 18)
#define HOME_FLAG (1 << 19)
#define END_FLAG (1 << 20)
#define FUNCTION_FLAG (1 << 21)
// dont exceed 32!!
@ -78,9 +80,8 @@ protected:
bool enterButtonPressedPrev;
bool enterButtonPressed;
unsigned keyboardNumber;
unsigned keyboardLetter;
unsigned keyboardFunction;
unsigned keyboardNumLetter;
unsigned inputROMOrDevice;
//inline void SetUartFlag(unsigned flag) { uartFlags |= flag; }
//inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; }
@ -178,17 +179,14 @@ public:
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 BrowseHome() { return KeyboardFlag(HOME_FLAG); }
inline bool BrowseEnd() { return KeyboardFlag(END_FLAG); }
inline char getKeyboardNumber() { return keyboardNumber; }
inline char getKeyboardLetter() { return (char) keyboardLetter; }
inline unsigned getKeyboardFunction() { return (char) keyboardFunction; }
inline char getKeyboardNumLetter() { return keyboardNumLetter; }
inline unsigned getROMOrDevice() { return inputROMOrDevice; }
// Used by the 2 cores so need to be volatile
//volatile static unsigned directDiskSwapRequest;