diff --git a/src/debugger/gui/BoosterWidget.cxx b/src/debugger/gui/BoosterWidget.cxx index 6f5d83352..fd2aec940 100644 --- a/src/debugger/gui/BoosterWidget.cxx +++ b/src/debugger/gui/BoosterWidget.cxx @@ -24,8 +24,7 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = myController.jack() == Controller::Left; - const string& label = leftport ? "Left (Booster)" : "Right (Booster)"; + const string& label = isLeftPort() ? "Left (Booster)" : "Right (Booster)"; const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster)"); diff --git a/src/debugger/gui/ControllerWidget.hxx b/src/debugger/gui/ControllerWidget.hxx index 880f3fd8c..d72ef351a 100644 --- a/src/debugger/gui/ControllerWidget.hxx +++ b/src/debugger/gui/ControllerWidget.hxx @@ -24,6 +24,7 @@ class ButtonWidget; #include "Widget.hxx" #include "Command.hxx" + class ControllerWidget : public Widget, public CommandSender { public: @@ -44,6 +45,19 @@ class ControllerWidget : public Widget, public CommandSender protected: Controller& myController; + protected: + bool isLeftPort() + { + bool swappedPorts = instance().console().properties().get(Console_SwapPorts) == "YES"; + + return (myController.jack() == Controller::Left) ^ swappedPorts; + } + + string getHeader() + { + return (isLeftPort() ? "Left (" : "Right (") + myController.name() + ")"; + } + private: virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { } diff --git a/src/debugger/gui/DrivingWidget.cxx b/src/debugger/gui/DrivingWidget.cxx index c7cd45a2a..f171f4819 100644 --- a/src/debugger/gui/DrivingWidget.cxx +++ b/src/debugger/gui/DrivingWidget.cxx @@ -24,8 +24,7 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font, : ControllerWidget(boss, font, x, y, controller), myGrayIndex(0) { - bool leftport = myController.jack() == Controller::Left; - const string& label = leftport ? "Left (Driving)" : "Right (Driving)"; + const string& label = getHeader(); const int fontHeight = font.getFontHeight(), bwidth = font.getStringWidth("Gray code +") + 10, diff --git a/src/debugger/gui/FlashWidget.cxx b/src/debugger/gui/FlashWidget.cxx index 1d9e3535b..084c024a6 100644 --- a/src/debugger/gui/FlashWidget.cxx +++ b/src/debugger/gui/FlashWidget.cxx @@ -33,10 +33,8 @@ void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y) const int lineHeight = font.getLineHeight(); int xpos = x, ypos = y; - bool leftport = myController.jack() == Controller::Left; - new StaticTextWidget(boss, font, xpos, ypos + 2, - (leftport ? "Left (" : "Right (") + myController.name() + ")"); - + new StaticTextWidget(boss, font, xpos, ypos + 2, getHeader()); + ypos += lineHeight + 6; new StaticTextWidget(boss, ifont, xpos, ypos, "Pages/Ranges used:"); diff --git a/src/debugger/gui/GenesisWidget.cxx b/src/debugger/gui/GenesisWidget.cxx index 04626a954..5cfb6e435 100644 --- a/src/debugger/gui/GenesisWidget.cxx +++ b/src/debugger/gui/GenesisWidget.cxx @@ -24,8 +24,7 @@ GenesisWidget::GenesisWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = myController.jack() == Controller::Left; - const string& label = leftport ? "Left (Genesis)" : "Right (Genesis)"; + const string& label = getHeader(); const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Genesis)"); diff --git a/src/debugger/gui/JoystickWidget.cxx b/src/debugger/gui/JoystickWidget.cxx index 21698f2aa..97a1929ab 100644 --- a/src/debugger/gui/JoystickWidget.cxx +++ b/src/debugger/gui/JoystickWidget.cxx @@ -24,9 +24,7 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = myController.jack() == Controller::Left; - const string& label = leftport ? "Left (Joystick)" : "Right (Joystick)"; - + const string& label = getHeader(); const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Joystick)"); StaticTextWidget* t; diff --git a/src/debugger/gui/KeyboardWidget.cxx b/src/debugger/gui/KeyboardWidget.cxx index 567aed9bf..e38af14bd 100644 --- a/src/debugger/gui/KeyboardWidget.cxx +++ b/src/debugger/gui/KeyboardWidget.cxx @@ -24,7 +24,7 @@ KeyboardWidget::KeyboardWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = myController.jack() == Controller::Left; + bool leftport = isLeftPort(); const string& label = leftport ? "Left (Keyboard)" : "Right (Keyboard)"; const int fontHeight = font.getFontHeight(); diff --git a/src/debugger/gui/NullControlWidget.hxx b/src/debugger/gui/NullControlWidget.hxx index 905713980..c21242101 100644 --- a/src/debugger/gui/NullControlWidget.hxx +++ b/src/debugger/gui/NullControlWidget.hxx @@ -29,10 +29,8 @@ class NullControlWidget : public ControllerWidget Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = controller.jack() == Controller::Left; ostringstream buf; - buf << (leftport ? "Left (" : "Right (") - << controller.name() << "):"; + buf << getHeader(); const int fontHeight = font.getFontHeight(), lineHeight = font.getLineHeight(), lwidth = std::max(font.getStringWidth(buf.str()), diff --git a/src/debugger/gui/PaddleWidget.cxx b/src/debugger/gui/PaddleWidget.cxx index e83abaccd..9d6979b3a 100644 --- a/src/debugger/gui/PaddleWidget.cxx +++ b/src/debugger/gui/PaddleWidget.cxx @@ -25,8 +25,8 @@ PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = myController.jack() == Controller::Left; - const string& label = leftport ? "Left (Paddles)" : "Right (Paddles)"; + bool leftport = isLeftPort(); + const string& label = getHeader(); const int fontWidth = font.getMaxCharWidth(), fontHeight = font.getFontHeight(), diff --git a/src/debugger/gui/PointingDeviceWidget.cxx b/src/debugger/gui/PointingDeviceWidget.cxx index e278425a9..04a839c8f 100644 --- a/src/debugger/gui/PointingDeviceWidget.cxx +++ b/src/debugger/gui/PointingDeviceWidget.cxx @@ -23,7 +23,6 @@ PointingDeviceWidget::PointingDeviceWidget(GuiObject* boss, const GUI::Font& fon int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - bool leftport = controller.jack() == Controller::Left; int ypos = y; int xLeft = x + 10; int xMid = xLeft + 30; @@ -31,7 +30,7 @@ PointingDeviceWidget::PointingDeviceWidget(GuiObject* boss, const GUI::Font& fon int xValue = xLeft + 87; StaticTextWidget* t; - t = new StaticTextWidget(boss, font, x, y + 2, (leftport ? "Left (" : "Right (") + myController.name() + ")"); + t = new StaticTextWidget(boss, font, x, y + 2, getHeader()); ypos += t->getHeight() + 8; // add gray code and up widgets diff --git a/src/emucore/AtariVox.hxx b/src/emucore/AtariVox.hxx index 655432912..96faeb15a 100644 --- a/src/emucore/AtariVox.hxx +++ b/src/emucore/AtariVox.hxx @@ -88,8 +88,7 @@ class AtariVox : public SaveKey string about() const override { return Controller::about() + myAboutString; } private: - void clockDataIn(bool value); - void shiftIn(bool value); + void clockDataIn(bool value); private: // Instance of an real serial port on the system