Fixed wrong display of swapped controllers in debugger

This commit is contained in:
thrust26 2017-10-03 18:42:46 +02:00
parent 9f97184d9b
commit cd189050ec
11 changed files with 26 additions and 23 deletions

View File

@ -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)");

View File

@ -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 { }

View File

@ -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,

View File

@ -33,9 +33,7 @@ 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;

View File

@ -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)");

View File

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

View File

@ -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();

View File

@ -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()),

View File

@ -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(),

View File

@ -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

View File

@ -89,7 +89,6 @@ class AtariVox : public SaveKey
private:
void clockDataIn(bool value);
void shiftIn(bool value);
private:
// Instance of an real serial port on the system