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;
//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()
: keyboardBrowseLCDScreen(false)
, insertButtonPressedPrev(false)

View file

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

View file

@ -17,9 +17,12 @@
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
#include "iec_bus.h"
#include "InputMappings.h"
//#define REAL_XOR 1
int IEC_Bus::buttonCount = sizeof(ButtonPinFlags) / sizeof(unsigned);
u32 IEC_Bus::oldClears = 0;
u32 IEC_Bus::oldSets = 0;
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...
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...
if (IEC_Bus::rotaryEncoderEnable == true)
{
int indexEnter = 0;
int indexUp = 1;
int indexDown = 2;
int indexBack = 3;
int indexInsert = 4;
int indexEnter = InputMappings::INPUT_BUTTON_ENTER;
int indexUp = InputMappings::INPUT_BUTTON_UP;
int indexDown = InputMappings::INPUT_BUTTON_DOWN;
int indexBack = InputMappings::INPUT_BUTTON_BACK;
int indexInsert = InputMappings::INPUT_BUTTON_INSERT;
//Poll the rotary encoder
//
@ -139,7 +142,7 @@ void IEC_Bus::ReadGPIOUserInput( int buttonCount)
void IEC_Bus::ReadBrowseMode(void)
{
gplev0 = read32(ARM_GPIO_GPLEV0);
ReadGPIOUserInput(buttonCount);
ReadGPIOUserInput();
bool ATNIn = (gplev0 & PIGPIO_MASK_IN_ATN) == (invertIECInputs ? PIGPIO_MASK_IN_ATN : 0);
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 int buttonCount = sizeof(ButtonPinFlags) / sizeof(unsigned);
///////////////////////////////////////////////////////////////////////////////////////////////
// Original Non-split lines
@ -401,7 +400,7 @@ public:
}
#endif
static inline void UpdateButton(int index, unsigned gplev0)
static void UpdateButton(int index, unsigned gplev0)
{
bool inputcurrent = (gplev0 & ButtonPinFlags[index]) == 0;
@ -476,7 +475,7 @@ public:
static void ReadBrowseMode(void);
static void ReadGPIOUserInput(int buttonCount);
static void ReadGPIOUserInput(void);
static void ReadEmulationMode1541(void);
static void ReadEmulationMode1581(void);
@ -739,6 +738,8 @@ private:
static bool SRQSetToOut;
static bool Resetting;
static int buttonCount;
static u32 myOutsGPFSEL0;
static u32 myOutsGPFSEL1;
static bool InputButton[5];

View file

@ -904,7 +904,7 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
#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?)
#if not defined(EXPERIMENTALZERO)
@ -1120,7 +1120,7 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
}
#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?)
#if not defined(EXPERIMENTALZERO)