Added options to remap the input push buttons

This commit is contained in:
penfold42 2018-08-19 22:11:36 +10:00
parent e09301c3db
commit a54f1804ba
7 changed files with 46 additions and 3 deletions

View File

@ -90,3 +90,9 @@ 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
//buttonEnter = 0
//buttonUp = 1
//buttonDown = 2
//buttonBack = 3
//buttonInsert = 4

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

@ -1348,9 +1348,15 @@ extern "C"
// DEBUG_LOG("Mouse found\r\n"); // DEBUG_LOG("Mouse found\r\n");
Keyboard::Instance(); Keyboard::Instance();
InputMappings::Instance(); // InputMappings::Instance();
InputMappings* inputMappings = InputMappings::Instance();
//USPiMouseRegisterStatusHandler(MouseHandler); //USPiMouseRegisterStatusHandler(MouseHandler);
inputMappings->INPUT_BUTTON_ENTER = options.GetButtonEnter();
inputMappings->INPUT_BUTTON_UP = options.GetButtonUp();
inputMappings->INPUT_BUTTON_DOWN = options.GetButtonDown();
inputMappings->INPUT_BUTTON_BACK = options.GetButtonBack();
inputMappings->INPUT_BUTTON_INSERT = options.GetButtonInsert();
CheckOptions(); CheckOptions();

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];