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 <strings.h>
#include <algorithm> #include <algorithm>
#include "debug.h" #include "debug.h"
#include "Keyboard.h"
#include "options.h" #include "options.h"
#include "InputMappings.h" #include "InputMappings.h"
#include "stb_image.h" #include "stb_image.h"
@ -817,15 +816,8 @@ void FileBrowser::UpdateCurrentHighlight()
void FileBrowser::Update() void FileBrowser::Update()
{ {
InputMappings* inputMappings = InputMappings::Instance(); InputMappings* inputMappings = InputMappings::Instance();
Keyboard* keyboard = Keyboard::Instance();
bool dirty = false;
if (keyboard->CheckChanged()) if ( inputMappings->CheckKeyboardBrowseMode() || inputMappings->CheckButtonsBrowseMode() )
dirty = inputMappings->CheckKeyboardBrowseMode();
else
dirty = inputMappings->CheckButtonsBrowseMode();
if (dirty)
UpdateInputFolders(); UpdateInputFolders();
UpdateCurrentHighlight(); UpdateCurrentHighlight();
@ -877,8 +869,8 @@ bool FileBrowser::AddToCaddy(FileBrowser::BrowsableList::Entry* current)
void FileBrowser::UpdateInputFolders() void FileBrowser::UpdateInputFolders()
{ {
Keyboard* keyboard = Keyboard::Instance();
InputMappings* inputMappings = InputMappings::Instance(); InputMappings* inputMappings = InputMappings::Instance();
bool dirty = false;
if (inputMappings->BrowseFunction()) if (inputMappings->BrowseFunction())
{ {
@ -887,131 +879,108 @@ void FileBrowser::UpdateInputFolders()
if ( ROMOrDevice >= 1 && ROMOrDevice <= 11 ) if ( ROMOrDevice >= 1 && ROMOrDevice <= 11 )
SelectROMOrDevice(ROMOrDevice); SelectROMOrDevice(ROMOrDevice);
} }
else else if (inputMappings->BrowseSelect())
{ {
if (folder.entries.size() > 0) FileBrowser::BrowsableList::Entry* current = folder.current;
if (current)
{ {
//u32 numberOfEntriesMinus1 = folder.entries.size() - 1; if (current->filImage.fattrib & AM_DIR)
bool dirty = false;
if (inputMappings->BrowseSelect())
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; if (strcmp(current->filImage.fname, "..") == 0)
if (current)
{ {
if (current->filImage.fattrib & AM_DIR) PopFolder();
}
else if (strcmp(current->filImage.fname, ".") != 0)
{
f_chdir(current->filImage.fname);
RefreshFolderEntries();
}
dirty = true;
}
else // not a directory
{
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)
{ {
if (strcmp(current->filImage.fname, "..") == 0) selectionsMade = SelectLST(current->filImage.fname);
{
PopFolder();
}
else if (strcmp(current->filImage.fname, ".") != 0)
{
f_chdir(current->filImage.fname);
RefreshFolderEntries();
}
dirty = true;
} }
else else
{ {
if (strcmp(current->filImage.fname, "..") == 0) // Add the current selected
{ AddToCaddy(current);
PopFolder(); selectionsMade = FillCaddyWithSelections();
}
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)
{
selectionsMade = SelectLST(current->filImage.fname);
}
else
{
// Add the current selected
AddToCaddy(current);
selectionsMade = FillCaddyWithSelections();
}
if (selectionsMade)
lastSelectionName = current->filImage.fname;
dirty = true;
}
}
}
}
else if (inputMappings->BrowseDone())
{
selectionsMade = FillCaddyWithSelections();
}
//else if (keyboard->KeyPressed(KEY_TAB))
//{
// state = State_DiskCaddy;
// dirty = true;
//}
else if (inputMappings->BrowseBack())
{
PopFolder();
dirty = true;
}
else if (inputMappings->Exit())
{
ClearSelections();
dirty = true;
}
else if (inputMappings->BrowseInsert())
{
FileBrowser::BrowsableList::Entry* current = folder.current;
if (current)
{
dirty = AddToCaddy(current);
}
}
else if (inputMappings->BrowseNewD64())
{
char newFileName[64];
strncpy (newFileName, options.GetAutoBaseName(), 63);
int num = folder.FindNextAutoName( newFileName );
m_IEC_Commands.CreateD64(newFileName, "42", true);
FolderChanged();
}
else if (inputMappings->BrowseWriteProtect())
{
FileBrowser::BrowsableList::Entry* current = folder.current;
if (current)
{
if (current->filImage.fattrib & AM_RDO)
{
current->filImage.fattrib &= ~AM_RDO;
f_chmod(current->filImage.fname, 0, AM_RDO);
}
else
{
current->filImage.fattrib |= AM_RDO;
f_chmod(current->filImage.fname, AM_RDO, AM_RDO);
} }
if (selectionsMade)
lastSelectionName = current->filImage.fname;
dirty = true; dirty = true;
} }
} }
else
{
dirty = folder.CheckBrowseNavigation();
}
if (dirty) RefeshDisplay();
}
else // no folder entries, could this ever happen?? ".." is everpresent?
{
if (inputMappings->BrowseBack())
PopFolder();
}
if (inputMappings->BrowseAutoLoad())
{
CheckAutoMountImage(EXIT_RESET, this);
} }
} }
else if (inputMappings->BrowseDone())
{
selectionsMade = FillCaddyWithSelections();
}
else if (inputMappings->BrowseBack())
{
PopFolder();
dirty = true;
}
else if (inputMappings->Exit())
{
ClearSelections();
dirty = true;
}
else if (inputMappings->BrowseInsert())
{
FileBrowser::BrowsableList::Entry* current = folder.current;
if (current)
{
dirty = AddToCaddy(current);
}
}
else if (inputMappings->BrowseNewD64())
{
char newFileName[64];
strncpy (newFileName, options.GetAutoBaseName(), 63);
int num = folder.FindNextAutoName( newFileName );
m_IEC_Commands.CreateD64(newFileName, "42", true);
FolderChanged();
}
else if (inputMappings->BrowseWriteProtect())
{
FileBrowser::BrowsableList::Entry* current = folder.current;
if (current)
{
if (current->filImage.fattrib & AM_RDO)
{
current->filImage.fattrib &= ~AM_RDO;
f_chmod(current->filImage.fname, 0, AM_RDO);
}
else
{
current->filImage.fattrib |= AM_RDO;
f_chmod(current->filImage.fname, AM_RDO, AM_RDO);
}
dirty = true;
}
}
else if (inputMappings->BrowseAutoLoad())
{
CheckAutoMountImage(EXIT_RESET, this);
}
else
{
dirty = folder.CheckBrowseNavigation();
}
if (dirty) RefeshDisplay();
} }
bool FileBrowser::SelectROMOrDevice(u32 index) bool FileBrowser::SelectROMOrDevice(u32 index)
@ -1084,11 +1053,11 @@ bool FileBrowser::SelectLST(const char* filenameLST)
return validImage; return validImage;
} }
/*
// Not used // Not used
void FileBrowser::UpdateInputDiskCaddy() void FileBrowser::UpdateInputDiskCaddy()
{ {
bool dirty = false; bool dirty = false;
Keyboard* keyboard = Keyboard::Instance();
if (keyboard->KeyPressed(KEY_DELETE)) if (keyboard->KeyPressed(KEY_DELETE))
{ {
@ -1110,6 +1079,7 @@ void FileBrowser::UpdateInputDiskCaddy()
if (dirty) RefeshDisplay(); if (dirty) RefeshDisplay();
} }
*/
void FileBrowser::DisplayStatusBar() void FileBrowser::DisplayStatusBar()
{ {

View File

@ -198,6 +198,10 @@ bool InputMappings::CheckKeyboardBrowseMode()
keyboardFlags = 0; keyboardFlags = 0;
keyboardNumLetter = 0; keyboardNumLetter = 0;
if (!keyboard->CheckChanged())
{
return false;
}
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now(); reboot_now();
@ -293,32 +297,31 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned
Keyboard* keyboard = Keyboard::Instance(); Keyboard* keyboard = Keyboard::Instance();
keyboardFlags = 0; keyboardFlags = 0;
if (keyboard->CheckChanged()) if (!keyboard->CheckChanged())
return;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now();
if (keyboard->KeyHeld(KEY_ESC))
SetKeyboardFlag(ESC_FLAG);
else if (keyboard->KeyHeld(KEY_PAGEUP))
SetKeyboardFlag(PREV_FLAG);
else if (keyboard->KeyHeld(KEY_PAGEDOWN))
SetKeyboardFlag(NEXT_FLAG);
else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(AUTOLOAD_FLAG);
else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(FAKERESET_FLAG);
else if (numberOfImages > 1)
{ {
unsigned index;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) for (index = 0; index < 10; index++)
reboot_now();
if (keyboard->KeyHeld(KEY_ESC))
SetKeyboardFlag(ESC_FLAG);
else if (keyboard->KeyHeld(KEY_PAGEUP))
SetKeyboardFlag(PREV_FLAG);
else if (keyboard->KeyHeld(KEY_PAGEDOWN))
SetKeyboardFlag(NEXT_FLAG);
else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(AUTOLOAD_FLAG);
else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(FAKERESET_FLAG);
else if (numberOfImages > 1)
{ {
unsigned index; if ( keyboard->KeyHeld(KEY_F1+index)
for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3) || keyboard->KeyHeld(KEY_1+index)
{ || keyboard->KeyHeld(KEY_KP1+index) )
if (keyboard->KeyHeld(NumberKeys[index]) directDiskSwapRequest |= (1 << index);
|| keyboard->KeyHeld(NumberKeys[index + 1])
|| keyboard->KeyHeld(NumberKeys[index + 2]) )
directDiskSwapRequest |= (1 << index/3);
}
} }
} }
} }

View File

@ -49,20 +49,6 @@
#define FUNCTION_FLAG (1 << 21) #define FUNCTION_FLAG (1 << 21)
// dont exceed 32!! // 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> class InputMappings : public Singleton<InputMappings>
{ {