From bec1784d1855beb4dd0ed10a4807a70b1cfe23d8 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Mon, 2 Oct 2017 19:57:21 -0230 Subject: [PATCH] Added infrastructure to call methods on AVox/SaveKey controllers from InputDialog. Thomas, you will need to edit InputDialog::eraseEEPROM and finish the logic there. --- src/emucore/SaveKey.cxx | 4 ++-- src/gui/InputDialog.cxx | 47 ++++++++++++++++++++++++++++++++--------- src/gui/InputDialog.hxx | 6 ++++-- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/emucore/SaveKey.cxx b/src/emucore/SaveKey.cxx index ac67e6760..725737ca8 100644 --- a/src/emucore/SaveKey.cxx +++ b/src/emucore/SaveKey.cxx @@ -26,7 +26,7 @@ SaveKey::SaveKey(Jack jack, const Event& event, const System& system, { myEEPROM = make_unique(eepromfile, system); - myDigitalPinState[One] = myDigitalPinState[Two] = true; + myDigitalPinState[One] = myDigitalPinState[Two] = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -44,7 +44,7 @@ bool SaveKey::read(DigitalPin pin) default: return Controller::read(pin); - } + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 83f1e15b7..7171cf82a 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -211,10 +211,11 @@ void InputDialog::addDevicePortTab(const GUI::Font& font) int fwidth; - // Add EEPROM erase (part 1/2) - /*fwidth = font.getStringWidth("Erase EEPROM") + 20; + // Add EEPROM erase (part 1/2) + fwidth = font.getStringWidth("Erase EEPROM") + 20; lwidth = font.getStringWidth("AVox/SaveKey"); - new StaticTextWidget(myTab, font, _w - 10 - (fwidth + lwidth) / 2, ypos + 1+8, "AVox/SaveKey");*/ + new StaticTextWidget(myTab, font, _w - 10 - (fwidth + lwidth) / 2, ypos + 8, + "AVox/SaveKey"); // Show joystick database xpos += 20; ypos += lineHeight + 8; @@ -223,10 +224,10 @@ void InputDialog::addDevicePortTab(const GUI::Font& font) wid.push_back(myJoyDlgButton); // Add EEPROM erase (part 1/2) - /*myEraseEEPROMButton = new ButtonWidget(myTab, font, _w - 14 - fwidth, ypos, - "Erase EEPROM", kEEButtonPressed);*/ - - // Add AtariVox serial port + myEraseEEPROMButton = new ButtonWidget(myTab, font, _w - 14 - fwidth, ypos, + "Erase EEPROM", kEEButtonPressed); + + // Add AtariVox serial port xpos -= 20; ypos += lineHeight + 12; lwidth = font.getStringWidth("AVox serial port "); fwidth = _w - 14 - xpos - lwidth; @@ -270,6 +271,12 @@ void InputDialog::loadConfig() // AtariVox serial port myAVoxPort->setText(instance().settings().getString("avoxport")); + // EEPROM erase (only enable in emulation mode) + if(instance().hasConsole()) + myEraseEEPROMButton->setFlags(WIDGET_ENABLED); + else + myEraseEEPROMButton->clearFlags(WIDGET_ENABLED); + // Allow all 4 joystick directions myAllowAll4->setState(instance().settings().getBool("joyallow4")); @@ -435,6 +442,26 @@ bool InputDialog::handleJoyHat(int stick, int hat, int value) return Dialog::handleJoyHat(stick, hat, value); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void InputDialog::eraseEEPROM() +{ + // This method will only be callable if a console exists, so we don't + // need to check again here + Controller& lport = instance().console().leftController(); + Controller& rport = instance().console().rightController(); + + // FIXME thrust26 - cast to correct type and call whatever method you like ... + if(lport.type() == Controller::AtariVox) + cerr << "left avox needs to be erased\n"; + else if(lport.type() == Controller::SaveKey) + cerr << "left savekey needs to be erased\n"; + + if(rport.type() == Controller::AtariVox) + cerr << "right avox needs to be erased\n"; + else if(rport.type() == Controller::SaveKey) + cerr << "right savekey needs to be erased\n"; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void InputDialog::handleCommand(CommandSender* sender, int cmd, int data, int id) @@ -478,9 +505,9 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd, myJoyDialog->show(); break; - /*case kEEButtonPressed: - // TODO - break;*/ + case kEEButtonPressed: + eraseEEPROM(); + break; default: Dialog::handleCommand(sender, cmd, data, 0); diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index 0955df1b4..1cea406f9 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -52,6 +52,8 @@ class InputDialog : public Dialog void addDevicePortTab(const GUI::Font& font); + void eraseEEPROM(); + private: enum { kDeadzoneChanged = 'DZch', @@ -59,7 +61,7 @@ class InputDialog : public Dialog kMPSpeedChanged = 'PMch', kTBSpeedChanged = 'TBch', kDBButtonPressed = 'DBbp', - //kEEButtonPressed = 'EEbp' + kEEButtonPressed = 'EEbp' }; TabWidget* myTab; @@ -86,7 +88,7 @@ class InputDialog : public Dialog CheckboxWidget* myCtrlCombo; ButtonWidget* myJoyDlgButton; - //ButtonWidget* myEraseEEPROMButton; + ButtonWidget* myEraseEEPROMButton; // Show the list of joysticks that the eventhandler knows about unique_ptr myJoyDialog;