diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 8acf7a2..b781ac7 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -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) diff --git a/src/InputMappings.h b/src/InputMappings.h index 7cdf5c6..4500da4 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -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() { diff --git a/src/iec_bus.cpp b/src/iec_bus.cpp index 1640d91..4f3782a 100644 --- a/src/iec_bus.cpp +++ b/src/iec_bus.cpp @@ -17,9 +17,12 @@ // along with Pi1541. If not, see . #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) diff --git a/src/iec_bus.h b/src/iec_bus.h index 5449d72..9f6bd36 100644 --- a/src/iec_bus.h +++ b/src/iec_bus.h @@ -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]; diff --git a/src/main.cpp b/src/main.cpp index c8e32f4..d39f070 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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)