mirror of https://github.com/stella-emu/stella.git
working on more controllers and debugger widgets
This commit is contained in:
parent
4a3503637e
commit
978ad7c270
|
@ -20,37 +20,52 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
|
DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y, Controller& controller)
|
int x, int y, Controller& controller, bool embedded)
|
||||||
: ControllerWidget(boss, font, x, y, controller)
|
: ControllerWidget(boss, font, x, y, controller)
|
||||||
{
|
{
|
||||||
const string& label = getHeader();
|
const string& label = getHeader();
|
||||||
|
|
||||||
const int fontHeight = font.getFontHeight(),
|
const int fontHeight = font.getFontHeight(),
|
||||||
bwidth = font.getStringWidth("Gray code +") + 10,
|
fontWidth = font.getMaxCharWidth(),
|
||||||
bheight = font.getLineHeight() + 4;
|
bheight = font.getLineHeight() + 4;
|
||||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving)");
|
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving)");
|
||||||
StaticTextWidget* t;
|
StaticTextWidget* t;
|
||||||
|
|
||||||
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
if(embedded)
|
||||||
fontHeight, label, TextAlign::Left);
|
{
|
||||||
|
const int bwidth = font.getStringWidth("GC+ ");
|
||||||
|
|
||||||
ypos += t->getHeight() + 20;
|
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||||
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
"GC+", kGrayUpCmd);
|
||||||
"Gray code +", kGrayUpCmd);
|
|
||||||
|
ypos += myGrayUp->getHeight() + 5;
|
||||||
|
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||||
|
"GC-", kGrayDownCmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int bwidth = font.getStringWidth("Gray code +") + 10;
|
||||||
|
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
|
||||||
|
fontHeight, label, TextAlign::Left);
|
||||||
|
|
||||||
|
ypos += t->getHeight() + 20;
|
||||||
|
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||||
|
"Gray code +", kGrayUpCmd);
|
||||||
|
|
||||||
|
ypos += myGrayUp->getHeight() + 5;
|
||||||
|
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
||||||
|
"Gray code -", kGrayDownCmd);
|
||||||
|
}
|
||||||
myGrayUp->setTarget(this);
|
myGrayUp->setTarget(this);
|
||||||
|
|
||||||
ypos += myGrayUp->getHeight() + 5;
|
|
||||||
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
|
|
||||||
"Gray code -", kGrayDownCmd);
|
|
||||||
myGrayDown->setTarget(this);
|
myGrayDown->setTarget(this);
|
||||||
|
|
||||||
xpos += myGrayDown->getWidth() + 10; ypos -= 10;
|
xpos += myGrayDown->getWidth() + fontWidth; ypos -= 10;
|
||||||
myGrayValue = new DataGridWidget(boss, font, xpos, ypos,
|
myGrayValue = new DataGridWidget(boss, font, xpos, ypos,
|
||||||
1, 1, 2, 8, Common::Base::Fmt::_16);
|
1, 1, 2, 8, Common::Base::Fmt::_16);
|
||||||
myGrayValue->setTarget(this);
|
myGrayValue->setTarget(this);
|
||||||
myGrayValue->setEditable(false);
|
myGrayValue->setEditable(false);
|
||||||
|
|
||||||
xpos = x + 30; ypos += myGrayDown->getHeight() + 20;
|
xpos = x + fontWidth*3; ypos += myGrayDown->getHeight() + 20;
|
||||||
myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd);
|
myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd);
|
||||||
myFire->setTarget(this);
|
myFire->setTarget(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class DrivingWidget : public ControllerWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrivingWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
DrivingWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
||||||
Controller& controller);
|
Controller& controller, bool embedded = false);
|
||||||
~DrivingWidget() override = default;
|
~DrivingWidget() override = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -34,7 +34,7 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
|
|
||||||
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
|
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
|
||||||
fontHeight, label, TextAlign::Left);
|
fontHeight, label, TextAlign::Left);
|
||||||
xpos += t->getWidth() / 2 - 5; ypos += t->getHeight() + 20;
|
xpos += t->getWidth() / 2 - 5; ypos = t->getBottom() + fontHeight;
|
||||||
}
|
}
|
||||||
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
|
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
|
||||||
CheckboxWidget::kCheckActionCmd);
|
CheckboxWidget::kCheckActionCmd);
|
||||||
|
|
|
@ -26,22 +26,38 @@ class NullControlWidget : public ControllerWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullControlWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
NullControlWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
||||||
Controller& controller)
|
Controller& controller, bool embedded = false)
|
||||||
: ControllerWidget(boss, font, x, y, controller)
|
: ControllerWidget(boss, font, x, y, controller)
|
||||||
{
|
{
|
||||||
ostringstream buf;
|
|
||||||
buf << getHeader();
|
|
||||||
const int fontHeight = font.getFontHeight(),
|
const int fontHeight = font.getFontHeight(),
|
||||||
lineHeight = font.getLineHeight(),
|
lineHeight = font.getLineHeight();
|
||||||
lwidth = std::max(font.getStringWidth(buf.str()),
|
|
||||||
font.getStringWidth("Controller input"));
|
if(embedded)
|
||||||
new StaticTextWidget(boss, font, x, y+2, lwidth,
|
{
|
||||||
fontHeight, buf.str(), TextAlign::Left);
|
const int lwidth = font.getStringWidth("avail.");
|
||||||
new StaticTextWidget(boss, font, x, y+2+2*lineHeight, lwidth,
|
|
||||||
fontHeight, "Controller input", TextAlign::Center);
|
y += fontHeight;
|
||||||
new StaticTextWidget(boss, font, x, y+2+3*lineHeight, lwidth,
|
new StaticTextWidget(boss, font, x, y, lwidth, fontHeight,
|
||||||
fontHeight, "not available",
|
"not", TextAlign::Center);
|
||||||
TextAlign::Center);
|
y += lineHeight;
|
||||||
|
new StaticTextWidget(boss, font, x, y, lwidth, fontHeight,
|
||||||
|
"avail.", TextAlign::Center);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ostringstream buf;
|
||||||
|
buf << getHeader();
|
||||||
|
const int lwidth = std::max(font.getStringWidth(buf.str()),
|
||||||
|
font.getStringWidth("Controller input"));
|
||||||
|
|
||||||
|
new StaticTextWidget(boss, font, x, y + 2, lwidth, fontHeight, buf.str());
|
||||||
|
y += 2 + lineHeight * 2;
|
||||||
|
new StaticTextWidget(boss, font, x, y, lwidth,
|
||||||
|
fontHeight, "Controller input", TextAlign::Center);
|
||||||
|
new StaticTextWidget(boss, font, x, y+lineHeight, lwidth,
|
||||||
|
fontHeight, "not available",
|
||||||
|
TextAlign::Center);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~NullControlWidget() override = default;
|
~NullControlWidget() override = default;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "TIA.hxx"
|
#include "TIA.hxx"
|
||||||
#include "QuadTari.hxx"
|
#include "QuadTari.hxx"
|
||||||
|
#include "DrivingWidget.hxx"
|
||||||
#include "JoystickWidget.hxx"
|
#include "JoystickWidget.hxx"
|
||||||
#include "NullControlWidget.hxx"
|
#include "NullControlWidget.hxx"
|
||||||
#include "QuadTariWidget.hxx"
|
#include "QuadTariWidget.hxx"
|
||||||
|
@ -28,40 +29,54 @@ QuadTariWidget::QuadTariWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y, Controller& controller)
|
int x, int y, Controller& controller)
|
||||||
: ControllerWidget(boss, font, x, y, controller)
|
: ControllerWidget(boss, font, x, y, controller)
|
||||||
{
|
{
|
||||||
|
const int fontWidth = font.getMaxCharWidth(),
|
||||||
|
fontHeight = font.getFontHeight();
|
||||||
string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)");
|
string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)");
|
||||||
StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label);
|
StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label);
|
||||||
QuadTari& qt = static_cast<QuadTari&>(controller);
|
QuadTari& qt = static_cast<QuadTari&>(controller);
|
||||||
|
|
||||||
x += font.getMaxCharWidth() * 2;
|
|
||||||
y = t->getBottom() + font.getFontHeight() * 1.25;
|
|
||||||
|
|
||||||
// TODO: support multiple controller types
|
// TODO: support multiple controller types
|
||||||
switch(qt.myFirstController->type())
|
switch(qt.myFirstController->type())
|
||||||
{
|
{
|
||||||
case Controller::Type::Joystick:
|
case Controller::Type::Joystick:
|
||||||
|
x += fontWidth * 2;
|
||||||
|
y = t->getBottom() + fontHeight;
|
||||||
myFirstControl = new JoystickWidget(boss, font, x, y, *qt.myFirstController, true);
|
myFirstControl = new JoystickWidget(boss, font, x, y, *qt.myFirstController, true);
|
||||||
x = myFirstControl->getRight() - font.getMaxCharWidth() * 8;
|
break;
|
||||||
|
|
||||||
|
case Controller::Type::Driving:
|
||||||
|
y = t->getBottom() + font.getFontHeight() * 1;
|
||||||
|
myFirstControl = new DrivingWidget(boss, font, x, y, *qt.myFirstController, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
myFirstControl = new NullControlWidget(boss, font, x, y, *qt.myFirstController);
|
y = t->getBottom() + font.getFontHeight() * 1.25;
|
||||||
x += font.getMaxCharWidth() * 8;
|
myFirstControl = new NullControlWidget(boss, font, x, y, *qt.myFirstController, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = t->getLeft() + fontWidth * 10;
|
||||||
switch(qt.mySecondController->type())
|
switch(qt.mySecondController->type())
|
||||||
{
|
{
|
||||||
case Controller::Type::Joystick:
|
case Controller::Type::Joystick:
|
||||||
|
x += fontWidth * 2;
|
||||||
|
y = t->getBottom() + fontHeight;
|
||||||
mySecondControl = new JoystickWidget(boss, font, x, y, *qt.mySecondController, true);
|
mySecondControl = new JoystickWidget(boss, font, x, y, *qt.mySecondController, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Controller::Type::Driving:
|
||||||
|
y = t->getBottom() + font.getFontHeight();
|
||||||
|
myFirstControl = new DrivingWidget(boss, font, x, y, *qt.mySecondController, true);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mySecondControl = new NullControlWidget(boss, font, x, y, *qt.mySecondController);
|
y = t->getBottom() + font.getFontHeight() * 1.25;
|
||||||
|
mySecondControl = new NullControlWidget(boss, font, x, y, *qt.mySecondController, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
myPointer = new StaticTextWidget(boss, font,
|
myPointer = new StaticTextWidget(boss, font,
|
||||||
x - font.getMaxCharWidth() * 5, y, " ");
|
t->getLeft() + font.getMaxCharWidth() * 7, y, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -25,18 +25,20 @@
|
||||||
#include "AtariVox.hxx"
|
#include "AtariVox.hxx"
|
||||||
#include "Driving.hxx"
|
#include "Driving.hxx"
|
||||||
#include "Joystick.hxx"
|
#include "Joystick.hxx"
|
||||||
|
#include "Paddles.hxx"
|
||||||
#include "SaveKey.hxx"
|
#include "SaveKey.hxx"
|
||||||
#include "QuadTari.hxx"
|
#include "QuadTari.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
QuadTari::QuadTari(Jack jack, OSystem& osystem, const System& system, const Properties& properties)
|
QuadTari::QuadTari(Jack jack, const OSystem& osystem, const System& system, const Properties& properties)
|
||||||
: Controller(jack, osystem.eventHandler().event(), system,
|
: Controller(jack, osystem.eventHandler().event(), system,
|
||||||
Controller::Type::QuadTari),
|
Controller::Type::QuadTari),
|
||||||
myOSystem(osystem)
|
myOSystem(osystem),
|
||||||
|
myProperties(properties)
|
||||||
{
|
{
|
||||||
string first, second;
|
|
||||||
Controller::Type firstType = Controller::Type::Joystick,
|
Controller::Type firstType = Controller::Type::Joystick,
|
||||||
secondType = Controller::Type::Joystick;
|
secondType = Controller::Type::Joystick;
|
||||||
|
string first, second;
|
||||||
|
|
||||||
if(jack == Controller::Jack::Left)
|
if(jack == Controller::Jack::Left)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +76,16 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
case Controller::Type::Paddles:
|
||||||
|
{
|
||||||
|
// Check if we should swap the paddles plugged into a jack
|
||||||
|
bool swapPaddles = myProperties.get(PropType::Controller_SwapPaddles) == "YES";
|
||||||
|
|
||||||
|
return make_unique<Paddles>(myJack, myEvent, mySystem, swapPaddles, false, false);
|
||||||
|
}
|
||||||
|
case Controller::Type::Driving:
|
||||||
|
return make_unique<Driving>(myJack, myEvent, mySystem, second);
|
||||||
|
|
||||||
case Controller::Type::AtariVox:
|
case Controller::Type::AtariVox:
|
||||||
{
|
{
|
||||||
nvramfile /= "atarivox_eeprom.dat";
|
nvramfile /= "atarivox_eeprom.dat";
|
||||||
|
@ -81,9 +93,6 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
|
||||||
myOSystem.settings().getString("avoxport"),
|
myOSystem.settings().getString("avoxport"),
|
||||||
nvramfile, callback); // no alternative mapping here
|
nvramfile, callback); // no alternative mapping here
|
||||||
}
|
}
|
||||||
case Controller::Type::Driving:
|
|
||||||
return make_unique<Driving>(myJack, myEvent, mySystem, second);
|
|
||||||
|
|
||||||
case Controller::Type::SaveKey:
|
case Controller::Type::SaveKey:
|
||||||
{
|
{
|
||||||
nvramfile /= "savekey_eeprom.dat";
|
nvramfile /= "savekey_eeprom.dat";
|
||||||
|
|
|
@ -38,7 +38,7 @@ class QuadTari : public Controller
|
||||||
@param system The system using this controller
|
@param system The system using this controller
|
||||||
@param properties The properties to use for the current ROM
|
@param properties The properties to use for the current ROM
|
||||||
*/
|
*/
|
||||||
QuadTari(Jack jack, OSystem& osystem, const System& system, const Properties& properties);
|
QuadTari(Jack jack, const OSystem& osystem, const System& system, const Properties& properties);
|
||||||
~QuadTari() override = default;
|
~QuadTari() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -91,7 +91,8 @@ class QuadTari : public Controller
|
||||||
private:
|
private:
|
||||||
unique_ptr<Controller> addController(const Controller::Type type, bool second);
|
unique_ptr<Controller> addController(const Controller::Type type, bool second);
|
||||||
|
|
||||||
OSystem& myOSystem;
|
const OSystem& myOSystem;
|
||||||
|
const Properties& myProperties;
|
||||||
unique_ptr<Controller> myFirstController;
|
unique_ptr<Controller> myFirstController;
|
||||||
unique_ptr<Controller> mySecondController;
|
unique_ptr<Controller> mySecondController;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
|
||||||
ctrls.clear();
|
ctrls.clear();
|
||||||
//VarList::push_back(ctrls, "Auto-detect", "AUTO");
|
//VarList::push_back(ctrls, "Auto-detect", "AUTO");
|
||||||
VarList::push_back(ctrls, "Joystick", "JOYSTICK");
|
VarList::push_back(ctrls, "Joystick", "JOYSTICK");
|
||||||
//VarList::push_back(ctrls, "Paddles", "PADDLES");
|
VarList::push_back(ctrls, "Paddles", "PADDLES");
|
||||||
//VarList::push_back(ctrls, "Paddles_IAxis", "PADDLES_IAXIS");
|
//VarList::push_back(ctrls, "Paddles_IAxis", "PADDLES_IAXIS");
|
||||||
//VarList::push_back(ctrls, "Paddles_IAxDr", "PADDLES_IAXDR");
|
//VarList::push_back(ctrls, "Paddles_IAxDr", "PADDLES_IAXDR");
|
||||||
//VarList::push_back(ctrls, "BoosterGrip", "BOOSTERGRIP");
|
//VarList::push_back(ctrls, "BoosterGrip", "BOOSTERGRIP");
|
||||||
|
@ -64,7 +64,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
|
||||||
//VarList::push_back(ctrls, "MindLink", "MINDLINK");
|
//VarList::push_back(ctrls, "MindLink", "MINDLINK");
|
||||||
//VarList::push_back(ctrls, "QuadTari", "QUADTARI");
|
//VarList::push_back(ctrls, "QuadTari", "QUADTARI");
|
||||||
|
|
||||||
int pwidth = font.getStringWidth("Joystick12"); // looks better overall
|
int pwidth = font.getStringWidth("Joystick12"); // a bit wider looks better overall
|
||||||
|
|
||||||
myLeftPortLabel = new StaticTextWidget(this, font, xpos, ypos + 1, "Left port");
|
myLeftPortLabel = new StaticTextWidget(this, font, xpos, ypos + 1, "Left port");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue