Merge pull request #77 from penfold42/configbuttons

Configurable PCB button mapping
This commit is contained in:
Stephen White 2018-09-09 18:57:18 +10:00 committed by GitHub
commit 6912ae1e80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 3 deletions

View file

@ -90,3 +90,10 @@ GraphIEC = 1
//ShowOptions = 0 // display some options on startup screen //ShowOptions = 0 // display some options on startup screen
//IgnoreReset = 0 //IgnoreReset = 0
// You can remap the physical button functions
// numbers correspond to the standard board layout
//buttonEnter = 1
//buttonUp = 2
//buttonDown = 3
//buttonBack = 4
//buttonInsert = 5

View file

@ -99,12 +99,12 @@ bool InputMappings::CheckButtonsBrowseMode()
SetButtonFlag(BACK_FLAG); SetButtonFlag(BACK_FLAG);
// edge detection // edge detection
insertButtonPressed = !IEC_Bus::GetInputButtonReleased(4); insertButtonPressed = !IEC_Bus::GetInputButtonReleased(INPUT_BUTTON_INSERT);
if (insertButtonPressedPrev && !insertButtonPressed) if (insertButtonPressedPrev && !insertButtonPressed)
SetButtonFlag(INSERT_FLAG); SetButtonFlag(INSERT_FLAG);
insertButtonPressedPrev = insertButtonPressed; insertButtonPressedPrev = insertButtonPressed;
enterButtonPressed = !IEC_Bus::GetInputButtonReleased(0); enterButtonPressed = !IEC_Bus::GetInputButtonReleased(INPUT_BUTTON_ENTER);
if (enterButtonPressedPrev && !enterButtonPressed) if (enterButtonPressedPrev && !enterButtonPressed)
SetButtonFlag(ENTER_FLAG); SetButtonFlag(ENTER_FLAG);
enterButtonPressedPrev = enterButtonPressed; enterButtonPressedPrev = enterButtonPressed;

View file

@ -85,6 +85,12 @@ public:
bool CheckButtonsBrowseMode(); bool CheckButtonsBrowseMode();
void CheckButtonsEmulationMode(); void CheckButtonsEmulationMode();
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;
void Reset() void Reset()
{ {
keyboardFlags = 0; keyboardFlags = 0;

View file

@ -28,11 +28,13 @@
#define INPUT_BUTTON_DEBOUNCE_THRESHOLD 20000 #define INPUT_BUTTON_DEBOUNCE_THRESHOLD 20000
#define INPUT_BUTTON_REPEAT_THRESHOLD 460000 #define INPUT_BUTTON_REPEAT_THRESHOLD 460000
/* moved to variables in InputMapping
#define INPUT_BUTTON_ENTER 0 #define INPUT_BUTTON_ENTER 0
#define INPUT_BUTTON_UP 1 #define INPUT_BUTTON_UP 1
#define INPUT_BUTTON_DOWN 2 #define INPUT_BUTTON_DOWN 2
#define INPUT_BUTTON_BACK 3 #define INPUT_BUTTON_BACK 3
#define INPUT_BUTTON_INSERT 4 #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

View file

@ -1289,6 +1289,20 @@ static void CheckOptions()
} }
while (1); while (1);
} }
InputMappings* inputMappings = InputMappings::Instance();
if (options.GetButtonEnter() )
inputMappings->INPUT_BUTTON_ENTER = options.GetButtonEnter()-1;
if (options.GetButtonUp() )
inputMappings->INPUT_BUTTON_UP = options.GetButtonUp()-1;
if (options.GetButtonDown() )
inputMappings->INPUT_BUTTON_DOWN = options.GetButtonDown()-1;
if (options.GetButtonBack() )
inputMappings->INPUT_BUTTON_BACK = options.GetButtonBack()-1;
if (options.GetButtonInsert() )
inputMappings->INPUT_BUTTON_INSERT = options.GetButtonInsert()-1;
} }
void Reboot_Pi() void Reboot_Pi()
@ -1358,7 +1372,6 @@ extern "C"
InputMappings::Instance(); InputMappings::Instance();
//USPiMouseRegisterStatusHandler(MouseHandler); //USPiMouseRegisterStatusHandler(MouseHandler);
CheckOptions(); CheckOptions();
IEC_Bus::SetSplitIECLines(options.SplitIECLines()); IEC_Bus::SetSplitIECLines(options.SplitIECLines());

View file

@ -149,6 +149,12 @@ Options::Options(void)
, i2cLcdModel(LCD_UNKNOWN) , i2cLcdModel(LCD_UNKNOWN)
, scrollHighlightRate(0.125f) , scrollHighlightRate(0.125f)
, keyboardBrowseLCDScreen(0) , keyboardBrowseLCDScreen(0)
, buttonEnter(0)
, buttonUp(1)
, buttonDown(2)
, buttonBack(3)
, buttonInsert(4)
{ {
autoMountImageName[0] = 0; autoMountImageName[0] = 0;
strcpy(ROMFontName, "chargen"); strcpy(ROMFontName, "chargen");
@ -228,6 +234,11 @@ void Options::Process(char* buffer)
ELSE_CHECK_DECIMAL_OPTION(i2cLcdDimTime) ELSE_CHECK_DECIMAL_OPTION(i2cLcdDimTime)
ELSE_CHECK_FLOAT_OPTION(scrollHighlightRate) ELSE_CHECK_FLOAT_OPTION(scrollHighlightRate)
ELSE_CHECK_DECIMAL_OPTION(keyboardBrowseLCDScreen) ELSE_CHECK_DECIMAL_OPTION(keyboardBrowseLCDScreen)
ELSE_CHECK_DECIMAL_OPTION(buttonEnter)
ELSE_CHECK_DECIMAL_OPTION(buttonUp)
ELSE_CHECK_DECIMAL_OPTION(buttonDown)
ELSE_CHECK_DECIMAL_OPTION(buttonBack)
ELSE_CHECK_DECIMAL_OPTION(buttonInsert)
else if ((strcasecmp(pOption, "AutoBaseName") == 0)) else if ((strcasecmp(pOption, "AutoBaseName") == 0))
{ {
strncpy(autoBaseName, pValue, 255); strncpy(autoBaseName, pValue, 255);

View file

@ -88,6 +88,12 @@ public:
inline float ScrollHighlightRate() const { return scrollHighlightRate; } inline float ScrollHighlightRate() const { return scrollHighlightRate; }
inline unsigned int GetButtonEnter() const { return buttonEnter; }
inline unsigned int GetButtonUp() const { return buttonUp; }
inline unsigned int GetButtonDown() const { return buttonDown; }
inline unsigned int GetButtonBack() const { return buttonBack; }
inline unsigned int GetButtonInsert() const { return buttonInsert; }
// Page up and down will jump a different amount based on the maximum number rows displayed. // Page up and down will jump a different amount based on the maximum number rows displayed.
// Perhaps we should use some keyboard modifier to the the other screen? // Perhaps we should use some keyboard modifier to the the other screen?
inline unsigned int KeyboardBrowseLCDScreen() const { return keyboardBrowseLCDScreen; } inline unsigned int KeyboardBrowseLCDScreen() const { return keyboardBrowseLCDScreen; }
@ -135,6 +141,12 @@ private:
unsigned int keyboardBrowseLCDScreen; unsigned int keyboardBrowseLCDScreen;
u8 buttonEnter;
u8 buttonUp;
u8 buttonDown;
u8 buttonBack;
u8 buttonInsert;
char starFileName[256]; char starFileName[256];
char C128BootSectorName[256]; char C128BootSectorName[256];
char autoBaseName[256]; char autoBaseName[256];