removed keyboard.h from filebrowser

remove len>0 check from FileBrowser::UpdateInputFolders()
removed NumberKeys table
This commit is contained in:
penfold42 2018-08-05 21:22:21 +10:00
parent c42f4d3643
commit a7cf8107d2
3 changed files with 119 additions and 160 deletions

View file

@ -22,7 +22,6 @@
#include <strings.h>
#include <algorithm>
#include "debug.h"
#include "Keyboard.h"
#include "options.h"
#include "InputMappings.h"
#include "stb_image.h"
@ -817,15 +816,8 @@ void FileBrowser::UpdateCurrentHighlight()
void FileBrowser::Update()
{
InputMappings* inputMappings = InputMappings::Instance();
Keyboard* keyboard = Keyboard::Instance();
bool dirty = false;
if (keyboard->CheckChanged())
dirty = inputMappings->CheckKeyboardBrowseMode();
else
dirty = inputMappings->CheckButtonsBrowseMode();
if (dirty)
if ( inputMappings->CheckKeyboardBrowseMode() || inputMappings->CheckButtonsBrowseMode() )
UpdateInputFolders();
UpdateCurrentHighlight();
@ -877,8 +869,8 @@ bool FileBrowser::AddToCaddy(FileBrowser::BrowsableList::Entry* current)
void FileBrowser::UpdateInputFolders()
{
Keyboard* keyboard = Keyboard::Instance();
InputMappings* inputMappings = InputMappings::Instance();
bool dirty = false;
if (inputMappings->BrowseFunction())
{
@ -887,14 +879,7 @@ void FileBrowser::UpdateInputFolders()
if ( ROMOrDevice >= 1 && ROMOrDevice <= 11 )
SelectROMOrDevice(ROMOrDevice);
}
else
{
if (folder.entries.size() > 0)
{
//u32 numberOfEntriesMinus1 = folder.entries.size() - 1;
bool dirty = false;
if (inputMappings->BrowseSelect())
else if (inputMappings->BrowseSelect())
{
FileBrowser::BrowsableList::Entry* current = folder.current;
if (current)
@ -912,13 +897,9 @@ void FileBrowser::UpdateInputFolders()
}
dirty = true;
}
else
else // not a directory
{
if (strcmp(current->filImage.fname, "..") == 0)
{
PopFolder();
}
else if (DiskImage::IsDiskImageExtention(current->filImage.fname))
if (DiskImage::IsDiskImageExtention(current->filImage.fname))
{
DiskImage::DiskType diskType = DiskImage::GetDiskImageTypeViaExtention(current->filImage.fname);
@ -946,11 +927,6 @@ void FileBrowser::UpdateInputFolders()
{
selectionsMade = FillCaddyWithSelections();
}
//else if (keyboard->KeyPressed(KEY_TAB))
//{
// state = State_DiskCaddy;
// dirty = true;
//}
else if (inputMappings->BrowseBack())
{
PopFolder();
@ -995,6 +971,10 @@ void FileBrowser::UpdateInputFolders()
dirty = true;
}
}
else if (inputMappings->BrowseAutoLoad())
{
CheckAutoMountImage(EXIT_RESET, this);
}
else
{
dirty = folder.CheckBrowseNavigation();
@ -1002,17 +982,6 @@ void FileBrowser::UpdateInputFolders()
if (dirty) RefeshDisplay();
}
else // no folder entries, could this ever happen?? ".." is everpresent?
{
if (inputMappings->BrowseBack())
PopFolder();
}
if (inputMappings->BrowseAutoLoad())
{
CheckAutoMountImage(EXIT_RESET, this);
}
}
}
bool FileBrowser::SelectROMOrDevice(u32 index)
// 1-7 select ROM image
@ -1084,11 +1053,11 @@ bool FileBrowser::SelectLST(const char* filenameLST)
return validImage;
}
/*
// Not used
void FileBrowser::UpdateInputDiskCaddy()
{
bool dirty = false;
Keyboard* keyboard = Keyboard::Instance();
if (keyboard->KeyPressed(KEY_DELETE))
{
@ -1110,6 +1079,7 @@ void FileBrowser::UpdateInputDiskCaddy()
if (dirty) RefeshDisplay();
}
*/
void FileBrowser::DisplayStatusBar()
{

View file

@ -198,6 +198,10 @@ bool InputMappings::CheckKeyboardBrowseMode()
keyboardFlags = 0;
keyboardNumLetter = 0;
if (!keyboard->CheckChanged())
{
return false;
}
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now();
@ -293,8 +297,8 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned
Keyboard* keyboard = Keyboard::Instance();
keyboardFlags = 0;
if (keyboard->CheckChanged())
{
if (!keyboard->CheckChanged())
return;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now();
@ -312,13 +316,12 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned
else if (numberOfImages > 1)
{
unsigned index;
for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3)
for (index = 0; index < 10; index++)
{
if (keyboard->KeyHeld(NumberKeys[index])
|| keyboard->KeyHeld(NumberKeys[index + 1])
|| keyboard->KeyHeld(NumberKeys[index + 2]) )
directDiskSwapRequest |= (1 << index/3);
}
if ( keyboard->KeyHeld(KEY_F1+index)
|| keyboard->KeyHeld(KEY_1+index)
|| keyboard->KeyHeld(KEY_KP1+index) )
directDiskSwapRequest |= (1 << index);
}
}
}

View file

@ -49,20 +49,6 @@
#define FUNCTION_FLAG (1 << 21)
// 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<InputMappings>
{