move button rom and device code to inputmappings

remove a temp buffer
add defines for button numbers
This commit is contained in:
penfold42 2018-08-05 20:20:48 +10:00
parent 807cee02d2
commit c42f4d3643
4 changed files with 77 additions and 72 deletions

View file

@ -378,16 +378,14 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation()
char searchChar = inputMappings->getKeyboardNumLetter(); char searchChar = inputMappings->getKeyboardNumLetter();
if (searchChar) if (searchChar)
{ {
char temp[8];
unsigned found=0; unsigned found=0;
u32 i=0; u32 i=0;
snprintf (temp, sizeof(temp), "%c", searchChar);
// first look from next to last // first look from next to last
for (i=1+currentIndex; i <= numberOfEntriesMinus1 ; i++) for (i=1+currentIndex; i <= numberOfEntriesMinus1 ; i++)
{ {
FileBrowser::BrowsableList::Entry* entry = &entries[i]; FileBrowser::BrowsableList::Entry* entry = &entries[i];
if (strncasecmp(temp, entry->filImage.fname, 1) == 0) if (strncasecmp(&searchChar, entry->filImage.fname, 1) == 0)
{ {
found=i; found=i;
break; break;
@ -399,7 +397,7 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation()
for (i=0; i< 1+currentIndex ; i++) for (i=0; i< 1+currentIndex ; i++)
{ {
FileBrowser::BrowsableList::Entry* entry = &entries[i]; FileBrowser::BrowsableList::Entry* entry = &entries[i];
if (strncasecmp(temp, entry->filImage.fname, 1) == 0) if (strncasecmp(&searchChar, entry->filImage.fname, 1) == 0)
{ {
found=i; found=i;
break; break;
@ -450,7 +448,6 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool di
, roms(roms) , roms(roms)
, deviceID(deviceID) , deviceID(deviceID)
, displayPNGIcons(displayPNGIcons) , displayPNGIcons(displayPNGIcons)
, buttonChangedROMDevice(false)
, screenMain(screenMain) , screenMain(screenMain)
, screenLCD(screenLCD) , screenLCD(screenLCD)
, scrollHighlightRate(scrollHighlightRate) , scrollHighlightRate(scrollHighlightRate)
@ -883,52 +880,12 @@ void FileBrowser::UpdateInputFolders()
Keyboard* keyboard = Keyboard::Instance(); Keyboard* keyboard = Keyboard::Instance();
InputMappings* inputMappings = InputMappings::Instance(); InputMappings* inputMappings = InputMappings::Instance();
buttonChangedROMDevice = false; if (inputMappings->BrowseFunction())
if (IEC_Bus::GetInputButtonHeld(4))
{ {
if (inputMappings->BrowseSelect()) // check for ROM and Drive Number changes
{ unsigned ROMOrDevice = inputMappings->getROMOrDevice();
SelectROMOrDevice(8); // == device 8 if ( ROMOrDevice >= 1 && ROMOrDevice <= 11 )
buttonChangedROMDevice = true; SelectROMOrDevice(ROMOrDevice);
}
else if (inputMappings->BrowseUp())
{
SelectROMOrDevice(9); // == device 9
buttonChangedROMDevice = true;
}
else if (inputMappings->BrowseDown())
{
SelectROMOrDevice(10); // == device 10
buttonChangedROMDevice = true;
}
else if (inputMappings->BrowseBack())
{
SelectROMOrDevice(11); // == device 11
buttonChangedROMDevice = true;
}
}
else if (IEC_Bus::GetInputButtonHeld(0))
{
if (inputMappings->BrowseUp())
{
SelectROMOrDevice(1);
buttonChangedROMDevice = true;
}
else if (inputMappings->BrowseDown())
{
SelectROMOrDevice(2);
buttonChangedROMDevice = true;
}
else if (inputMappings->BrowseBack())
{
SelectROMOrDevice(3);
buttonChangedROMDevice = true;
}
else if (inputMappings->BrowseInsert())
{
SelectROMOrDevice(4);
buttonChangedROMDevice = true;
}
} }
else else
{ {
@ -937,7 +894,7 @@ void FileBrowser::UpdateInputFolders()
//u32 numberOfEntriesMinus1 = folder.entries.size() - 1; //u32 numberOfEntriesMinus1 = folder.entries.size() - 1;
bool dirty = false; bool dirty = false;
if (inputMappings->BrowseSelect() && !buttonChangedROMDevice ) if (inputMappings->BrowseSelect())
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; FileBrowser::BrowsableList::Entry* current = folder.current;
if (current) if (current)
@ -1004,7 +961,7 @@ void FileBrowser::UpdateInputFolders()
ClearSelections(); ClearSelections();
dirty = true; dirty = true;
} }
else if (inputMappings->BrowseInsert() && !buttonChangedROMDevice ) else if (inputMappings->BrowseInsert())
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; FileBrowser::BrowsableList::Entry* current = folder.current;
if (current) if (current)
@ -1040,21 +997,12 @@ void FileBrowser::UpdateInputFolders()
} }
else else
{ {
// check Fkeys for ROM and Drive Number changes
unsigned ROMOrDevice = inputMappings->getROMOrDevice();
if ( inputMappings->BrowseFunction()
&& ROMOrDevice >= 1
&& ROMOrDevice <= 11 )
{
SelectROMOrDevice(ROMOrDevice);
}
dirty = folder.CheckBrowseNavigation(); dirty = folder.CheckBrowseNavigation();
} }
if (dirty) RefeshDisplay(); if (dirty) RefeshDisplay();
} }
else else // no folder entries, could this ever happen?? ".." is everpresent?
{ {
if (inputMappings->BrowseBack()) if (inputMappings->BrowseBack())
PopFolder(); PopFolder();

View file

@ -44,11 +44,58 @@ InputMappings::InputMappings()
bool InputMappings::CheckButtonsBrowseMode() bool InputMappings::CheckButtonsBrowseMode()
{ {
buttonFlags = 0; buttonFlags = 0;
if (IEC_Bus::GetInputButtonRepeating(1))
if (IEC_Bus::GetInputButtonHeld(INPUT_BUTTON_INSERT)) // Change DeviceID
{
if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_ENTER))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 8;
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_UP))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 9;
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_DOWN))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 10;
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_BACK))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 11;
}
}
else if (IEC_Bus::GetInputButtonHeld(INPUT_BUTTON_ENTER)) // Change ROMs
{
if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_UP))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 1;
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_DOWN))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 2;
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_BACK))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 3;
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_INSERT))
{
SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 4;
}
}
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_UP))
SetButtonFlag(UP_FLAG); SetButtonFlag(UP_FLAG);
else if (IEC_Bus::GetInputButtonRepeating(2)) else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_DOWN))
SetButtonFlag(DOWN_FLAG); SetButtonFlag(DOWN_FLAG);
else if (IEC_Bus::GetInputButtonPressed(3)) else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_BACK))
SetButtonFlag(BACK_FLAG); SetButtonFlag(BACK_FLAG);
// edge detection // edge detection
@ -69,14 +116,16 @@ void InputMappings::CheckButtonsEmulationMode()
{ {
buttonFlags = 0; buttonFlags = 0;
if (IEC_Bus::GetInputButtonPressed(0)) if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_ENTER))
SetButtonFlag(ESC_FLAG); SetButtonFlag(ESC_FLAG);
else if (IEC_Bus::GetInputButtonPressed(1)) else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_UP))
SetButtonFlag(NEXT_FLAG); SetButtonFlag(NEXT_FLAG);
else if (IEC_Bus::GetInputButtonPressed(2)) else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_DOWN))
SetButtonFlag(PREV_FLAG); SetButtonFlag(PREV_FLAG);
//else if (IEC_Bus::GetInputButtonPressed(3)) //else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_BACK))
// SetButtonFlag(BACK_FLAG); // SetButtonFlag(BACK_FLAG);
//else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_INSERT))
// SetButtonFlag(INSERT_FLAG);
} }
@ -148,7 +197,6 @@ bool InputMappings::CheckKeyboardBrowseMode()
Keyboard* keyboard = Keyboard::Instance(); Keyboard* keyboard = Keyboard::Instance();
keyboardFlags = 0; keyboardFlags = 0;
inputROMOrDevice = 0;
keyboardNumLetter = 0; keyboardNumLetter = 0;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )

View file

@ -171,6 +171,11 @@ public:
return KeyboardFlag(INSERT_FLAG)/* | UartFlag(INSERT_FLAG)*/ | ButtonFlag(INSERT_FLAG); return KeyboardFlag(INSERT_FLAG)/* | UartFlag(INSERT_FLAG)*/ | ButtonFlag(INSERT_FLAG);
} }
inline bool BrowseFunction()
{
return KeyboardFlag(FUNCTION_FLAG) | ButtonFlag(FUNCTION_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); }
@ -179,8 +184,6 @@ public:
inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_FLAG); } inline bool BrowseWriteProtect() { return KeyboardFlag(WRITEPROTECT_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); }

View file

@ -28,6 +28,12 @@
#define INPUT_BUTTON_DEBOUNCE_THRESHOLD 20000 #define INPUT_BUTTON_DEBOUNCE_THRESHOLD 20000
#define INPUT_BUTTON_REPEAT_THRESHOLD 460000 #define INPUT_BUTTON_REPEAT_THRESHOLD 460000
#define INPUT_BUTTON_ENTER 0
#define INPUT_BUTTON_UP 1
#define INPUT_BUTTON_DOWN 2
#define INPUT_BUTTON_BACK 3
#define INPUT_BUTTON_INSERT 4
// DIN ATN is inverted and then connected to pb7 and ca1 // DIN ATN is inverted and then connected to pb7 and ca1
// - also input to xor with ATNAout pb4 // - also input to xor with ATNAout pb4
// - output of xor is inverted and connected to DIN pin 5 DATAout (OC so can only pull low) // - output of xor is inverted and connected to DIN pin 5 DATAout (OC so can only pull low)