Added NullControlWidget, for those controllers that won't have

any UI items within the debugger.

Added BoosterWidget UI class for changing BoosterGrip data in
the debugger I/O tab.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2339 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-01-07 00:39:46 +00:00
parent 3c94923720
commit d39404f5c9
8 changed files with 241 additions and 32 deletions

View File

@ -0,0 +1,129 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#include "OSystem.hxx"
#include "EventHandler.hxx"
#include "BoosterWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 int fontHeight = font.getFontHeight();
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster):");
StaticTextWidget* t;
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, kTextAlignLeft);
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10;
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJUp]->setID(kJUp);
myPins[kJUp]->setTarget(this);
ypos += myPins[kJUp]->getHeight() * 2 + 10;
myPins[kJDown] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJDown]->setID(kJDown);
myPins[kJDown]->setTarget(this);
xpos -= myPins[kJUp]->getWidth() + 5;
ypos -= myPins[kJUp]->getHeight() + 5;
myPins[kJLeft] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJLeft]->setID(kJLeft);
myPins[kJLeft]->setTarget(this);
xpos += (myPins[kJUp]->getWidth() + 5) * 2;
myPins[kJRight] = new CheckboxWidget(boss, font, xpos, ypos, "", kCheckActionCmd);
myPins[kJRight]->setID(kJRight);
myPins[kJRight]->setTarget(this);
xpos -= (myPins[kJUp]->getWidth() + 5) * 2;
ypos = 20 + (myPins[kJUp]->getHeight() + 10) * 3;
myPins[kJFire] = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kCheckActionCmd);
myPins[kJFire]->setID(kJFire);
myPins[kJFire]->setTarget(this);
ypos += myPins[kJFire]->getHeight() + 5;
myPins[kJBooster] = new CheckboxWidget(boss, font, xpos, ypos, "Booster", kCheckActionCmd);
myPins[kJBooster]->setID(kJBooster);
myPins[kJBooster]->setTarget(this);
ypos += myPins[kJBooster]->getHeight() + 5;
myPins[kJTrigger] = new CheckboxWidget(boss, font, xpos, ypos, "Trigger", kCheckActionCmd);
myPins[kJTrigger]->setID(kJTrigger);
myPins[kJTrigger]->setTarget(this);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BoosterWidget::~BoosterWidget()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BoosterWidget::loadConfig()
{
myPins[kJUp]->setState(!myController.read(ourPinNo[kJUp]));
myPins[kJDown]->setState(!myController.read(ourPinNo[kJDown]));
myPins[kJLeft]->setState(!myController.read(ourPinNo[kJLeft]));
myPins[kJRight]->setState(!myController.read(ourPinNo[kJRight]));
myPins[kJFire]->setState(!myController.read(ourPinNo[kJFire]));
myPins[kJBooster]->setState(
myController.read(Controller::Five) == Controller::minimumResistance);
myPins[kJTrigger]->setState(
myController.read(Controller::Nine) == Controller::minimumResistance);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BoosterWidget::handleCommand(
CommandSender* sender, int cmd, int data, int id)
{
if(cmd == kCheckActionCmd)
{
switch(id)
{
case kJUp:
case kJDown:
case kJLeft:
case kJRight:
case kJFire:
myController.set(ourPinNo[id], !myPins[id]->getState());
break;
case kJBooster:
myController.set(Controller::Five,
myPins[id]->getState() ? Controller::minimumResistance :
Controller::maximumResistance);
break;
case kJTrigger:
myController.set(Controller::Nine,
myPins[id]->getState() ? Controller::minimumResistance :
Controller::maximumResistance);
break;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Controller::DigitalPin BoosterWidget::ourPinNo[5] = {
Controller::One, Controller::Two, Controller::Three, Controller::Four,
Controller::Six
};

View File

@ -0,0 +1,44 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#ifndef BOOSTER_WIDGET_HXX
#define BOOSTER_WIDGET_HXX
#include "Control.hxx"
#include "Event.hxx"
#include "ControllerWidget.hxx"
class BoosterWidget : public ControllerWidget
{
public:
BoosterWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
Controller& controller);
virtual ~BoosterWidget();
void loadConfig();
void handleCommand(CommandSender* sender, int cmd, int data, int id);
private:
enum { kJUp = 0, kJDown, kJLeft, kJRight, kJFire, kJBooster, kJTrigger };
CheckboxWidget* myPins[7];
static Controller::DigitalPin ourPinNo[5];
};
#endif

View File

@ -36,21 +36,8 @@ class ControllerWidget : public Widget, public CommandSender
myController(controller)
{
_type = kControllerWidget;
/* FIXME - add this to controllers that won't have their own widget class
bool leftport = controller.jack() == Controller::Left;
const string& label = leftport ? "Left (Unknown):" : "Right (Unknown):";
const int fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight(),
lwidth = font.getStringWidth("Controller not implemented");
new StaticTextWidget(boss, font, x, y+2, lwidth,
fontHeight, label, kTextAlignLeft);
new StaticTextWidget(boss, font, x, y+2+2*lineHeight, lwidth,
fontHeight, "Controller not implemented",
kTextAlignLeft);
_w = lwidth + 10;
_h = 6 * lineHeight;
*/
_w = 18 * font.getMaxCharWidth();
_h = 8 * font.getLineHeight();
}
virtual ~ControllerWidget() { };

View File

@ -29,15 +29,10 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
bool leftport = myController.jack() == Controller::Left;
const string& label = leftport ? "Left (Joystick):" : "Right (Joystick):";
const int /*fontWidth = font.getMaxCharWidth(),*/
fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight();
const int fontHeight = font.getFontHeight();
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Joystick):");
StaticTextWidget* t;
_w = lwidth + 10;
_h = 6 * lineHeight;
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, kTextAlignLeft);
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10;

View File

@ -0,0 +1,55 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2012 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#ifndef NULLCONTROL_WIDGET_HXX
#define NULLCONTROL_WIDGET_HXX
class GuiObject;
#include "ControllerWidget.hxx"
class NullControlWidget : public ControllerWidget
{
public:
NullControlWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
Controller& controller)
: ControllerWidget(boss, font, x, y, controller)
{
_type = kControllerWidget;
bool leftport = controller.jack() == Controller::Left;
ostringstream buf;
buf << (leftport ? "Left (" : "Right (")
<< controller.name() << "):";
const int fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight(),
lwidth = font.getStringWidth(buf.str());
new StaticTextWidget(boss, font, x, y+2, lwidth,
fontHeight, buf.str(), kTextAlignLeft);
new StaticTextWidget(boss, font, x, y+2+2*lineHeight, lwidth,
fontHeight, "Controller", kTextAlignCenter);
new StaticTextWidget(boss, font, x, y+2+3*lineHeight, lwidth,
fontHeight, "not implemented",
kTextAlignCenter);
}
virtual ~NullControlWidget() { };
};
#endif

View File

@ -33,16 +33,11 @@ PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font,
fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight();
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Paddles):");
StaticTextWidget* t;
_w = lwidth + 10;
_h = 6 * lineHeight;
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, kTextAlignLeft);
xpos = x; ypos += t->getHeight() + 10;
new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, kTextAlignLeft);
ypos += lineHeight + 10;
const string& p0string = leftport ? "P0 pot: " : "P2 pot: ";
const string& p1string = leftport ? "P1 pot: " : "P3 pot: ";
lwidth = font.getStringWidth("P3 pot: ");

View File

@ -30,9 +30,10 @@
#include "ToggleBitWidget.hxx"
#include "Widget.hxx"
#include "ControllerWidget.hxx"
#include "NullControlWidget.hxx"
#include "JoystickWidget.hxx"
#include "PaddleWidget.hxx"
#include "BoosterWidget.hxx"
#include "RiotWidget.hxx"
@ -342,7 +343,9 @@ ControllerWidget* RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font&
return new JoystickWidget(boss, font, x, y, controller);
case Controller::Paddles:
return new PaddleWidget(boss, font, x, y, controller);
case Controller::BoosterGrip:
return new BoosterWidget(boss, font, x, y, controller);
default:
return new ControllerWidget(boss, font, x, y, controller);
return new NullControlWidget(boss, font, x, y, controller);
}
}

View File

@ -20,7 +20,8 @@ MODULE_OBJS := \
src/debugger/gui/TogglePixelWidget.o \
src/debugger/gui/ToggleWidget.o \
src/debugger/gui/JoystickWidget.o \
src/debugger/gui/PaddleWidget.o
src/debugger/gui/PaddleWidget.o \
src/debugger/gui/BoosterWidget.o
MODULE_DIRS += \
src/debugger/gui