Fixed bugs with remapping the buttons via options.txt

Reported by Frank here https://www.lemon64.com/forum/viewtopic.php?p=934239#934239
This commit is contained in:
Stephen White 2021-01-11 17:10:17 +11:00
parent 0ae620842f
commit 42a3375ff6
5 changed files with 27 additions and 17 deletions

View file

@ -34,6 +34,12 @@ unsigned InputMappings::directDiskSwapRequest = 0;
//volatile unsigned InputMappings::uartFlags = 0; //volatile unsigned InputMappings::uartFlags = 0;
//unsigned InputMappings::escapeSequenceIndex = 0; //unsigned InputMappings::escapeSequenceIndex = 0;
u8 InputMappings::INPUT_BUTTON_ENTER = 0;
u8 InputMappings::INPUT_BUTTON_UP = 1;
u8 InputMappings::INPUT_BUTTON_DOWN = 2;
u8 InputMappings::INPUT_BUTTON_BACK = 3;
u8 InputMappings::INPUT_BUTTON_INSERT = 4;
InputMappings::InputMappings() InputMappings::InputMappings()
: keyboardBrowseLCDScreen(false) : keyboardBrowseLCDScreen(false)
, insertButtonPressedPrev(false) , insertButtonPressedPrev(false)

View file

@ -86,11 +86,11 @@ public:
void WaitForClearButtons(); void WaitForClearButtons();
u8 INPUT_BUTTON_ENTER = 0; static u8 INPUT_BUTTON_ENTER;
u8 INPUT_BUTTON_UP = 1; static u8 INPUT_BUTTON_UP;
u8 INPUT_BUTTON_DOWN = 2; static u8 INPUT_BUTTON_DOWN;
u8 INPUT_BUTTON_BACK = 3; static u8 INPUT_BUTTON_BACK;
u8 INPUT_BUTTON_INSERT = 4; static u8 INPUT_BUTTON_INSERT;
void Reset() void Reset()
{ {

View file

@ -17,9 +17,12 @@
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>. // along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
#include "iec_bus.h" #include "iec_bus.h"
#include "InputMappings.h"
//#define REAL_XOR 1 //#define REAL_XOR 1
int IEC_Bus::buttonCount = sizeof(ButtonPinFlags) / sizeof(unsigned);
u32 IEC_Bus::oldClears = 0; u32 IEC_Bus::oldClears = 0;
u32 IEC_Bus::oldSets = 0; u32 IEC_Bus::oldSets = 0;
u32 IEC_Bus::PIGPIO_MASK_IN_ATN = 1 << PIGPIO_ATN; u32 IEC_Bus::PIGPIO_MASK_IN_ATN = 1 << PIGPIO_ATN;
@ -77,16 +80,16 @@ bool IEC_Bus::rotaryEncoderEnable;
//ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo... //ROTARY: Added for rotary encoder inversion (Issue#185) - 08/13/2020 by Geo...
bool IEC_Bus::rotaryEncoderInvert; bool IEC_Bus::rotaryEncoderInvert;
void IEC_Bus::ReadGPIOUserInput( int buttonCount) void IEC_Bus::ReadGPIOUserInput()
{ {
//ROTARY: Added for rotary encoder support - 09/05/2019 by Geo... //ROTARY: Added for rotary encoder support - 09/05/2019 by Geo...
if (IEC_Bus::rotaryEncoderEnable == true) if (IEC_Bus::rotaryEncoderEnable == true)
{ {
int indexEnter = 0; int indexEnter = InputMappings::INPUT_BUTTON_ENTER;
int indexUp = 1; int indexUp = InputMappings::INPUT_BUTTON_UP;
int indexDown = 2; int indexDown = InputMappings::INPUT_BUTTON_DOWN;
int indexBack = 3; int indexBack = InputMappings::INPUT_BUTTON_BACK;
int indexInsert = 4; int indexInsert = InputMappings::INPUT_BUTTON_INSERT;
//Poll the rotary encoder //Poll the rotary encoder
// //
@ -139,7 +142,7 @@ void IEC_Bus::ReadGPIOUserInput( int buttonCount)
void IEC_Bus::ReadBrowseMode(void) void IEC_Bus::ReadBrowseMode(void)
{ {
gplev0 = read32(ARM_GPIO_GPLEV0); gplev0 = read32(ARM_GPIO_GPLEV0);
ReadGPIOUserInput(buttonCount); ReadGPIOUserInput();
bool ATNIn = (gplev0 & PIGPIO_MASK_IN_ATN) == (invertIECInputs ? PIGPIO_MASK_IN_ATN : 0); bool ATNIn = (gplev0 & PIGPIO_MASK_IN_ATN) == (invertIECInputs ? PIGPIO_MASK_IN_ATN : 0);
if (PI_Atn != ATNIn) if (PI_Atn != ATNIn)

View file

@ -199,7 +199,6 @@ enum PIGPIOMasks
}; };
static const unsigned ButtonPinFlags[5] = { PIGPIO_MASK_IN_BUTTON1, PIGPIO_MASK_IN_BUTTON2, PIGPIO_MASK_IN_BUTTON3, PIGPIO_MASK_IN_BUTTON4, PIGPIO_MASK_IN_BUTTON5 }; static const unsigned ButtonPinFlags[5] = { PIGPIO_MASK_IN_BUTTON1, PIGPIO_MASK_IN_BUTTON2, PIGPIO_MASK_IN_BUTTON3, PIGPIO_MASK_IN_BUTTON4, PIGPIO_MASK_IN_BUTTON5 };
static int buttonCount = sizeof(ButtonPinFlags) / sizeof(unsigned);
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
// Original Non-split lines // Original Non-split lines
@ -401,7 +400,7 @@ public:
} }
#endif #endif
static inline void UpdateButton(int index, unsigned gplev0) static void UpdateButton(int index, unsigned gplev0)
{ {
bool inputcurrent = (gplev0 & ButtonPinFlags[index]) == 0; bool inputcurrent = (gplev0 & ButtonPinFlags[index]) == 0;
@ -476,7 +475,7 @@ public:
static void ReadBrowseMode(void); static void ReadBrowseMode(void);
static void ReadGPIOUserInput(int buttonCount); static void ReadGPIOUserInput(void);
static void ReadEmulationMode1541(void); static void ReadEmulationMode1541(void);
static void ReadEmulationMode1581(void); static void ReadEmulationMode1581(void);
@ -739,6 +738,8 @@ private:
static bool SRQSetToOut; static bool SRQSetToOut;
static bool Resetting; static bool Resetting;
static int buttonCount;
static u32 myOutsGPFSEL0; static u32 myOutsGPFSEL0;
static u32 myOutsGPFSEL1; static u32 myOutsGPFSEL1;
static bool InputButton[5]; static bool InputButton[5];

View file

@ -904,7 +904,7 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
#endif #endif
IEC_Bus::ReadGPIOUserInput(3); IEC_Bus::ReadGPIOUserInput();
// Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?) // Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?)
#if not defined(EXPERIMENTALZERO) #if not defined(EXPERIMENTALZERO)
@ -1120,7 +1120,7 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
} }
#endif #endif
IEC_Bus::ReadGPIOUserInput(3); IEC_Bus::ReadGPIOUserInput();
// Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?) // Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?)
#if not defined(EXPERIMENTALZERO) #if not defined(EXPERIMENTALZERO)