Fixed issue #133

This commit is contained in:
Stephen White 2019-05-20 20:00:38 +10:00
parent 1921f5755d
commit 50a590ee84
3 changed files with 38 additions and 10 deletions

View file

@ -23,6 +23,7 @@
extern "C" extern "C"
{ {
#include "rpi-aux.h" #include "rpi-aux.h"
extern void usDelay(unsigned nMicroSeconds);
} }
extern void Reboot_Pi(void); extern void Reboot_Pi(void);
@ -67,6 +68,7 @@ bool InputMappings::CheckButtonsBrowseMode()
SetButtonFlag(FUNCTION_FLAG); SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 11; inputROMOrDevice = 11;
} }
insertButtonPressedPrev = false;
} }
else if (IEC_Bus::GetInputButtonHeld(INPUT_BUTTON_ENTER)) // Change ROMs else if (IEC_Bus::GetInputButtonHeld(INPUT_BUTTON_ENTER)) // Change ROMs
{ {
@ -90,6 +92,7 @@ bool InputMappings::CheckButtonsBrowseMode()
SetButtonFlag(FUNCTION_FLAG); SetButtonFlag(FUNCTION_FLAG);
inputROMOrDevice = 4; inputROMOrDevice = 4;
} }
enterButtonPressedPrev = false;
} }
else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_UP)) else if (IEC_Bus::GetInputButtonRepeating(INPUT_BUTTON_UP))
SetButtonFlag(UP_FLAG); SetButtonFlag(UP_FLAG);
@ -97,8 +100,9 @@ bool InputMappings::CheckButtonsBrowseMode()
SetButtonFlag(DOWN_FLAG); SetButtonFlag(DOWN_FLAG);
else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_BACK)) else if (IEC_Bus::GetInputButtonPressed(INPUT_BUTTON_BACK))
SetButtonFlag(BACK_FLAG); SetButtonFlag(BACK_FLAG);
else
// edge detection {
// edge detection
insertButtonPressed = !IEC_Bus::GetInputButtonReleased(INPUT_BUTTON_INSERT); insertButtonPressed = !IEC_Bus::GetInputButtonReleased(INPUT_BUTTON_INSERT);
if (insertButtonPressedPrev && !insertButtonPressed) if (insertButtonPressedPrev && !insertButtonPressed)
SetButtonFlag(INSERT_FLAG); SetButtonFlag(INSERT_FLAG);
@ -108,10 +112,29 @@ bool InputMappings::CheckButtonsBrowseMode()
if (enterButtonPressedPrev && !enterButtonPressed) if (enterButtonPressedPrev && !enterButtonPressed)
SetButtonFlag(ENTER_FLAG); SetButtonFlag(ENTER_FLAG);
enterButtonPressedPrev = enterButtonPressed; enterButtonPressedPrev = enterButtonPressed;
}
return buttonFlags != 0; return buttonFlags != 0;
} }
void InputMappings::WaitForClearButtons()
{
buttonFlags = 0;
do
{
IEC_Bus::ReadBrowseMode();
insertButtonPressed = !IEC_Bus::GetInputButtonReleased(INPUT_BUTTON_INSERT);
insertButtonPressedPrev = insertButtonPressed;
enterButtonPressed = !IEC_Bus::GetInputButtonReleased(INPUT_BUTTON_ENTER);
enterButtonPressedPrev = enterButtonPressed;
usDelay(1);
} while (insertButtonPressedPrev || enterButtonPressedPrev);
}
void InputMappings::CheckButtonsEmulationMode() void InputMappings::CheckButtonsEmulationMode()
{ {
buttonFlags = 0; buttonFlags = 0;

View file

@ -84,6 +84,8 @@ public:
bool CheckButtonsBrowseMode(); bool CheckButtonsBrowseMode();
void CheckButtonsEmulationMode(); void CheckButtonsEmulationMode();
void WaitForClearButtons();
u8 INPUT_BUTTON_ENTER = 0; u8 INPUT_BUTTON_ENTER = 0;
u8 INPUT_BUTTON_UP = 1; u8 INPUT_BUTTON_UP = 1;
u8 INPUT_BUTTON_DOWN = 2; u8 INPUT_BUTTON_DOWN = 2;

View file

@ -618,6 +618,7 @@ EmulatingMode BeginEmulating(FileBrowser* fileBrowser, const char* filenameForIc
return EMULATING_1541; return EMULATING_1541;
} }
} }
inputMappings->WaitForClearButtons();
return IEC_COMMANDS; return IEC_COMMANDS;
} }
@ -1251,6 +1252,8 @@ void emulator()
if ((exitReason == EXIT_RESET) && (options.GetOnResetChangeToStartingFolder() || selectedViaIECCommands)) if ((exitReason == EXIT_RESET) && (options.GetOnResetChangeToStartingFolder() || selectedViaIECCommands))
fileBrowser->DisplayRoot(); // TO CHECK fileBrowser->DisplayRoot(); // TO CHECK
inputMappings->WaitForClearButtons();
} }
} }
delete fileBrowser; delete fileBrowser;