mirror of https://github.com/stella-emu/stella.git
Fixes for previous commit; remove indirection and inherit directly from ControllerLowLevel.
This commit is contained in:
parent
cfe79ec0b1
commit
e6e337cd02
|
@ -29,7 +29,7 @@ AtariVoxWidget::AtariVoxWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariVoxWidget::eraseCurrent()
|
||||
{
|
||||
AtariVox& avox = static_cast<AtariVox&>(myController->base());
|
||||
AtariVox& avox = static_cast<AtariVox&>(controller());
|
||||
|
||||
avox.eraseCurrent();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ void AtariVoxWidget::eraseCurrent()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool AtariVoxWidget::isPageUsed(uInt32 page)
|
||||
{
|
||||
AtariVox& avox = static_cast<AtariVox&>(myController->base());
|
||||
AtariVox& avox = static_cast<AtariVox&>(controller());
|
||||
|
||||
return avox.isPageUsed(page);
|
||||
}
|
||||
|
|
|
@ -78,16 +78,16 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void BoosterWidget::loadConfig()
|
||||
{
|
||||
myPins[kJUp]->setState(!myController->getPin(ourPinNo[kJUp]));
|
||||
myPins[kJDown]->setState(!myController->getPin(ourPinNo[kJDown]));
|
||||
myPins[kJLeft]->setState(!myController->getPin(ourPinNo[kJLeft]));
|
||||
myPins[kJRight]->setState(!myController->getPin(ourPinNo[kJRight]));
|
||||
myPins[kJFire]->setState(!myController->getPin(ourPinNo[kJFire]));
|
||||
myPins[kJUp]->setState(!getPin(ourPinNo[kJUp]));
|
||||
myPins[kJDown]->setState(!getPin(ourPinNo[kJDown]));
|
||||
myPins[kJLeft]->setState(!getPin(ourPinNo[kJLeft]));
|
||||
myPins[kJRight]->setState(!getPin(ourPinNo[kJRight]));
|
||||
myPins[kJFire]->setState(!getPin(ourPinNo[kJFire]));
|
||||
|
||||
myPins[kJBooster]->setState(
|
||||
myController->getPin(Controller::AnalogPin::Five) == Controller::MIN_RESISTANCE);
|
||||
getPin(Controller::AnalogPin::Five) == Controller::MIN_RESISTANCE);
|
||||
myPins[kJTrigger]->setState(
|
||||
myController->getPin(Controller::AnalogPin::Nine) == Controller::MIN_RESISTANCE);
|
||||
getPin(Controller::AnalogPin::Nine) == Controller::MIN_RESISTANCE);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -103,15 +103,15 @@ void BoosterWidget::handleCommand(
|
|||
case kJLeft:
|
||||
case kJRight:
|
||||
case kJFire:
|
||||
myController->setPin(ourPinNo[id], !myPins[id]->getState());
|
||||
setPin(ourPinNo[id], !myPins[id]->getState());
|
||||
break;
|
||||
case kJBooster:
|
||||
myController->setPin(Controller::AnalogPin::Five,
|
||||
setPin(Controller::AnalogPin::Five,
|
||||
myPins[id]->getState() ? Controller::MIN_RESISTANCE :
|
||||
Controller::MAX_RESISTANCE);
|
||||
break;
|
||||
case kJTrigger:
|
||||
myController->setPin(Controller::AnalogPin::Nine,
|
||||
setPin(Controller::AnalogPin::Nine,
|
||||
myPins[id]->getState() ? Controller::MIN_RESISTANCE :
|
||||
Controller::MAX_RESISTANCE);
|
||||
break;
|
||||
|
|
|
@ -27,38 +27,32 @@ class ButtonWidget;
|
|||
#include "Command.hxx"
|
||||
#include "ControlLowLevel.hxx"
|
||||
|
||||
|
||||
class ControllerWidget : public Widget, public CommandSender
|
||||
class ControllerWidget : public Widget, public CommandSender, public ControllerLowLevel
|
||||
{
|
||||
public:
|
||||
ControllerWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
||||
Controller& controller)
|
||||
: Widget(boss, font, x, y, 16, 16),
|
||||
CommandSender(boss),
|
||||
myController(make_unique<ControllerLowLevel>(controller))
|
||||
ControllerLowLevel(controller)
|
||||
{
|
||||
_w = 18 * font.getMaxCharWidth();
|
||||
_h = 8 * font.getLineHeight();
|
||||
}
|
||||
|
||||
virtual ~ControllerWidget() = default;
|
||||
|
||||
virtual void loadConfig() override { }
|
||||
|
||||
protected:
|
||||
unique_ptr<ControllerLowLevel> myController;
|
||||
|
||||
protected:
|
||||
bool isLeftPort()
|
||||
{
|
||||
bool swappedPorts = instance().console().properties().get(Console_SwapPorts) == "YES";
|
||||
|
||||
return (myController->base().jack() == Controller::Jack::Left) ^ swappedPorts;
|
||||
return (controller().jack() == Controller::Jack::Left) ^ swappedPorts;
|
||||
}
|
||||
|
||||
string getHeader()
|
||||
{
|
||||
return (isLeftPort() ? "Left (" : "Right (") + myController->base().name() + ")";
|
||||
return (isLeftPort() ? "Left (" : "Right (") + controller().name() + ")";
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -60,8 +60,8 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
void DrivingWidget::loadConfig()
|
||||
{
|
||||
uInt8 gray = 0;
|
||||
if(myController->getPin(Controller::DigitalPin::One)) gray += 1;
|
||||
if(myController->getPin(Controller::DigitalPin::Two)) gray += 2;
|
||||
if(getPin(Controller::DigitalPin::One)) gray += 1;
|
||||
if(getPin(Controller::DigitalPin::Two)) gray += 2;
|
||||
|
||||
for(myGrayIndex = 0; myGrayIndex < 4; ++myGrayIndex)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ void DrivingWidget::loadConfig()
|
|||
}
|
||||
}
|
||||
|
||||
myFire->setState(!myController->getPin(Controller::DigitalPin::Six));
|
||||
myFire->setState(!getPin(Controller::DigitalPin::Six));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -83,18 +83,18 @@ void DrivingWidget::handleCommand(
|
|||
{
|
||||
case kGrayUpCmd:
|
||||
myGrayIndex = (myGrayIndex + 1) % 4;
|
||||
myController->setPin(Controller::DigitalPin::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
|
||||
myController->setPin(Controller::DigitalPin::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
|
||||
setPin(Controller::DigitalPin::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
|
||||
setPin(Controller::DigitalPin::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
|
||||
setValue(myGrayIndex);
|
||||
break;
|
||||
case kGrayDownCmd:
|
||||
myGrayIndex = myGrayIndex == 0 ? 3 : myGrayIndex - 1;
|
||||
myController->setPin(Controller::DigitalPin::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
|
||||
myController->setPin(Controller::DigitalPin::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
|
||||
setPin(Controller::DigitalPin::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
|
||||
setPin(Controller::DigitalPin::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
|
||||
setValue(myGrayIndex);
|
||||
break;
|
||||
case kFireCmd:
|
||||
myController->setPin(Controller::DigitalPin::Six, !myFire->getState());
|
||||
setPin(Controller::DigitalPin::Six, !myFire->getState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,14 +72,14 @@ GenesisWidget::GenesisWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void GenesisWidget::loadConfig()
|
||||
{
|
||||
myPins[kJUp]->setState(!myController->getPin(ourPinNo[kJUp]));
|
||||
myPins[kJDown]->setState(!myController->getPin(ourPinNo[kJDown]));
|
||||
myPins[kJLeft]->setState(!myController->getPin(ourPinNo[kJLeft]));
|
||||
myPins[kJRight]->setState(!myController->getPin(ourPinNo[kJRight]));
|
||||
myPins[kJBbtn]->setState(!myController->getPin(ourPinNo[kJBbtn]));
|
||||
myPins[kJUp]->setState(!getPin(ourPinNo[kJUp]));
|
||||
myPins[kJDown]->setState(!getPin(ourPinNo[kJDown]));
|
||||
myPins[kJLeft]->setState(!getPin(ourPinNo[kJLeft]));
|
||||
myPins[kJRight]->setState(!getPin(ourPinNo[kJRight]));
|
||||
myPins[kJBbtn]->setState(!getPin(ourPinNo[kJBbtn]));
|
||||
|
||||
myPins[kJCbtn]->setState(
|
||||
myController->getPin(Controller::AnalogPin::Five) == Controller::MAX_RESISTANCE);
|
||||
getPin(Controller::AnalogPin::Five) == Controller::MAX_RESISTANCE);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -95,10 +95,10 @@ void GenesisWidget::handleCommand(
|
|||
case kJLeft:
|
||||
case kJRight:
|
||||
case kJBbtn:
|
||||
myController->setPin(ourPinNo[id], !myPins[id]->getState());
|
||||
setPin(ourPinNo[id], !myPins[id]->getState());
|
||||
break;
|
||||
case kJCbtn:
|
||||
myController->setPin(Controller::AnalogPin::Five,
|
||||
setPin(Controller::AnalogPin::Five,
|
||||
myPins[id]->getState() ? Controller::MAX_RESISTANCE :
|
||||
Controller::MIN_RESISTANCE);
|
||||
break;
|
||||
|
|
|
@ -65,11 +65,11 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void JoystickWidget::loadConfig()
|
||||
{
|
||||
myPins[kJUp]->setState(!myController->getPin(ourPinNo[kJUp]));
|
||||
myPins[kJDown]->setState(!myController->getPin(ourPinNo[kJDown]));
|
||||
myPins[kJLeft]->setState(!myController->getPin(ourPinNo[kJLeft]));
|
||||
myPins[kJRight]->setState(!myController->getPin(ourPinNo[kJRight]));
|
||||
myPins[kJFire]->setState(!myController->getPin(ourPinNo[kJFire]));
|
||||
myPins[kJUp]->setState(!getPin(ourPinNo[kJUp]));
|
||||
myPins[kJDown]->setState(!getPin(ourPinNo[kJDown]));
|
||||
myPins[kJLeft]->setState(!getPin(ourPinNo[kJLeft]));
|
||||
myPins[kJRight]->setState(!getPin(ourPinNo[kJRight]));
|
||||
myPins[kJFire]->setState(!getPin(ourPinNo[kJFire]));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -77,7 +77,7 @@ void JoystickWidget::handleCommand(
|
|||
CommandSender* sender, int cmd, int data, int id)
|
||||
{
|
||||
if(cmd == CheckboxWidget::kCheckActionCmd)
|
||||
myController->setPin(ourPinNo[id], !myPins[id]->getState());
|
||||
setPin(ourPinNo[id], !myPins[id]->getState());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -68,11 +68,11 @@ PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font,
|
|||
void PaddleWidget::loadConfig()
|
||||
{
|
||||
myP0Resistance->setValue(Int32(Paddles::MAX_RESISTANCE -
|
||||
myController->getPin(Controller::AnalogPin::Nine)));
|
||||
getPin(Controller::AnalogPin::Nine)));
|
||||
myP1Resistance->setValue(Int32(Paddles::MAX_RESISTANCE -
|
||||
myController->getPin(Controller::AnalogPin::Five)));
|
||||
myP0Fire->setState(!myController->getPin(Controller::DigitalPin::Four));
|
||||
myP1Fire->setState(!myController->getPin(Controller::DigitalPin::Three));
|
||||
getPin(Controller::AnalogPin::Five)));
|
||||
myP0Fire->setState(!getPin(Controller::DigitalPin::Four));
|
||||
myP1Fire->setState(!getPin(Controller::DigitalPin::Three));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -82,18 +82,18 @@ void PaddleWidget::handleCommand(
|
|||
switch(cmd)
|
||||
{
|
||||
case kP0Changed:
|
||||
myController->setPin(Controller::AnalogPin::Nine,
|
||||
setPin(Controller::AnalogPin::Nine,
|
||||
Int32(Paddles::MAX_RESISTANCE - myP0Resistance->getValue()));
|
||||
break;
|
||||
case kP1Changed:
|
||||
myController->setPin(Controller::AnalogPin::Five,
|
||||
setPin(Controller::AnalogPin::Five,
|
||||
Int32(Paddles::MAX_RESISTANCE - myP1Resistance->getValue()));
|
||||
break;
|
||||
case kP0Fire:
|
||||
myController->setPin(Controller::DigitalPin::Four, !myP0Fire->getState());
|
||||
setPin(Controller::DigitalPin::Four, !myP0Fire->getState());
|
||||
break;
|
||||
case kP1Fire:
|
||||
myController->setPin(Controller::DigitalPin::Three, !myP1Fire->getState());
|
||||
setPin(Controller::DigitalPin::Three, !myP1Fire->getState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ void PointingDeviceWidget::loadConfig()
|
|||
{
|
||||
setGrayCodeH();
|
||||
setGrayCodeV();
|
||||
myFire->setState(!myController->getPin(Controller::DigitalPin::Six));
|
||||
myFire->setState(!getPin(Controller::DigitalPin::Six));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -83,7 +83,7 @@ void PointingDeviceWidget::handleCommand(CommandSender* sender, int cmd, int dat
|
|||
{
|
||||
// since the PointingDevice uses its own, internal state (not reading the controller),
|
||||
// we have to communicate directly with it
|
||||
PointingDevice& pDev = static_cast<PointingDevice&>(myController->base());
|
||||
PointingDevice& pDev = static_cast<PointingDevice&>(controller());
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ void PointingDeviceWidget::handleCommand(CommandSender* sender, int cmd, int dat
|
|||
setGrayCodeV();
|
||||
break;
|
||||
case kTBFire:
|
||||
myController->setPin(Controller::DigitalPin::Six, !myFire->getState());
|
||||
setPin(Controller::DigitalPin::Six, !myFire->getState());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void PointingDeviceWidget::handleCommand(CommandSender* sender, int cmd, int dat
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PointingDeviceWidget::setGrayCodeH()
|
||||
{
|
||||
PointingDevice& pDev = static_cast<PointingDevice&>(myController->base());
|
||||
PointingDevice& pDev = static_cast<PointingDevice&>(controller());
|
||||
|
||||
pDev.myCountH &= 0b11;
|
||||
setValue(myGrayValueH, pDev.myCountH, pDev.myTrackBallLeft);
|
||||
|
@ -125,7 +125,7 @@ void PointingDeviceWidget::setGrayCodeH()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PointingDeviceWidget::setGrayCodeV()
|
||||
{
|
||||
PointingDevice& pDev = static_cast<PointingDevice&>(myController->base());
|
||||
PointingDevice& pDev = static_cast<PointingDevice&>(controller());
|
||||
|
||||
pDev.myCountV &= 0b11;
|
||||
setValue(myGrayValueV, pDev.myCountV, !pDev.myTrackBallDown);
|
||||
|
|
|
@ -29,7 +29,7 @@ SaveKeyWidget::SaveKeyWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SaveKeyWidget::eraseCurrent()
|
||||
{
|
||||
SaveKey& skey = static_cast<SaveKey&>(myController->base());
|
||||
SaveKey& skey = static_cast<SaveKey&>(controller());
|
||||
|
||||
skey.eraseCurrent();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ void SaveKeyWidget::eraseCurrent()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool SaveKeyWidget::isPageUsed(uInt32 page)
|
||||
{
|
||||
SaveKey& skey = static_cast<SaveKey&>(myController->base());
|
||||
SaveKey& skey = static_cast<SaveKey&>(controller());
|
||||
|
||||
return skey.isPageUsed(page);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ class Controller : public Serializable
|
|||
Various classes that need special access to the underlying controller state
|
||||
*/
|
||||
friend class M6532; // FIXME - only needs two methods from this class
|
||||
friend class CompuMate;
|
||||
friend class CompuMate; // FIXME - should go through CMControl instead
|
||||
friend class ControllerLowLevel;
|
||||
|
||||
public:
|
||||
|
|
|
@ -56,7 +56,7 @@ class ControllerLowLevel
|
|||
inline void resetAnalogPins() {
|
||||
myController.resetAnalogPins();
|
||||
}
|
||||
inline Controller& base() const { return myController; }
|
||||
inline Controller& controller() const { return myController; }
|
||||
|
||||
protected:
|
||||
Controller& myController;
|
||||
|
|
Loading…
Reference in New Issue