Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
added Joy 2B+ support (resolves #909)
- Loading branch information
Showing
21 changed files
with
475 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //============================================================================ | ||
| // | ||
| // 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-2022 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. | ||
| //============================================================================ | ||
|
|
||
| #ifndef JOY2BPLUS_WIDGET_HXX | ||
| #define JOY2BPLUS_WIDGET_HXX | ||
|
|
||
| #include "Control.hxx" | ||
| #include "ControllerWidget.hxx" | ||
|
|
||
| class Joy2BPlusWidget : public ControllerWidget | ||
| { | ||
| public: | ||
| Joy2BPlusWidget(GuiObject* boss, const GUI::Font& font, int x, int y, | ||
| Controller& controller); | ||
| ~Joy2BPlusWidget() override = default; | ||
|
|
||
| private: | ||
| enum { kJUp = 0, kJDown, kJLeft, kJRight, kJButtonB, kJButtonC, kJButton3 }; | ||
|
|
||
| std::array<CheckboxWidget*, 7> myPins{nullptr}; | ||
| static constexpr std::array<Controller::DigitalPin, 5> ourPinNo = {{ | ||
| Controller::DigitalPin::One, Controller::DigitalPin::Two, | ||
| Controller::DigitalPin::Three, Controller::DigitalPin::Four, | ||
| Controller::DigitalPin::Six | ||
| }}; | ||
|
|
||
| private: | ||
| void loadConfig() override; | ||
| void handleCommand(CommandSender* sender, int cmd, int data, int id) override; | ||
|
|
||
| // Following constructors and assignment operators not supported | ||
| Joy2BPlusWidget() = delete; | ||
| Joy2BPlusWidget(const Joy2BPlusWidget&) = delete; | ||
| Joy2BPlusWidget(Joy2BPlusWidget&&) = delete; | ||
| Joy2BPlusWidget& operator=(const Joy2BPlusWidget&) = delete; | ||
| Joy2BPlusWidget& operator=(Joy2BPlusWidget&&) = delete; | ||
| }; | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| //============================================================================ | ||
| // | ||
| // 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-2022 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. | ||
| //============================================================================ | ||
|
|
||
| #include "Joy2BPlusWidget.hxx" | ||
|
|
||
| // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| Joy2BPlusWidget::Joy2BPlusWidget(GuiObject* boss, const GUI::Font& font, | ||
| int x, int y, Controller& controller) | ||
| : ControllerWidget(boss, font, x, y, controller) | ||
| { | ||
| const string& label = isLeftPort() ? "Left (Joy 2B+)" : "Right (Joy 2B+)"; | ||
|
|
||
| const int fontHeight = font.getFontHeight(); | ||
| int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Joy 2B+)"); | ||
| StaticTextWidget* t; | ||
|
|
||
| t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, | ||
| fontHeight, label, TextAlign::Left); | ||
| xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10; | ||
| myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", | ||
| CheckboxWidget::kCheckActionCmd); | ||
| myPins[kJUp]->setID(kJUp); | ||
| myPins[kJUp]->setTarget(this); | ||
|
|
||
| ypos += myPins[kJUp]->getHeight() * 2 + 10; | ||
| myPins[kJDown] = new CheckboxWidget(boss, font, xpos, ypos, "", | ||
| CheckboxWidget::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, "", | ||
| CheckboxWidget::kCheckActionCmd); | ||
| myPins[kJLeft]->setID(kJLeft); | ||
| myPins[kJLeft]->setTarget(this); | ||
|
|
||
| xpos += (myPins[kJUp]->getWidth() + 5) * 2; | ||
| myPins[kJRight] = new CheckboxWidget(boss, font, xpos, ypos, "", | ||
| CheckboxWidget::kCheckActionCmd); | ||
| myPins[kJRight]->setID(kJRight); | ||
| myPins[kJRight]->setTarget(this); | ||
|
|
||
| xpos -= (myPins[kJUp]->getWidth() + 5) * 2; | ||
| ypos = 20 + (myPins[kJUp]->getHeight() + 10) * 3; | ||
| myPins[kJButtonB] = new CheckboxWidget(boss, font, xpos, ypos, "Button B", | ||
| CheckboxWidget::kCheckActionCmd); | ||
| myPins[kJButtonB]->setID(kJButtonB); | ||
| myPins[kJButtonB]->setTarget(this); | ||
|
|
||
| ypos += myPins[kJButtonB]->getHeight() + 5; | ||
| myPins[kJButtonC] = new CheckboxWidget(boss, font, xpos, ypos, "Button C", | ||
| CheckboxWidget::kCheckActionCmd); | ||
| myPins[kJButtonC]->setID(kJButtonC); | ||
| myPins[kJButtonC]->setTarget(this); | ||
|
|
||
| ypos += myPins[kJButtonC]->getHeight() + 5; | ||
| myPins[kJButton3] = new CheckboxWidget(boss, font, xpos, ypos, "Button 3", | ||
| CheckboxWidget::kCheckActionCmd); | ||
| myPins[kJButton3]->setID(kJButton3); | ||
| myPins[kJButton3]->setTarget(this); | ||
|
|
||
| addFocusWidget(myPins[kJUp]); | ||
| addFocusWidget(myPins[kJLeft]); | ||
| addFocusWidget(myPins[kJRight]); | ||
| addFocusWidget(myPins[kJDown]); | ||
| addFocusWidget(myPins[kJButtonB]); | ||
| addFocusWidget(myPins[kJButtonC]); | ||
| addFocusWidget(myPins[kJButton3]); | ||
| } | ||
|
|
||
| // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| void Joy2BPlusWidget::loadConfig() | ||
| { | ||
| 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[kJButtonB]->setState(!getPin(ourPinNo[kJButtonB])); | ||
|
|
||
| myPins[kJButton3]->setState( | ||
| getPin(Controller::AnalogPin::Five) == AnalogReadout::connectToGround()); | ||
| myPins[kJButtonC]->setState( | ||
| getPin(Controller::AnalogPin::Nine) == AnalogReadout::connectToGround()); | ||
| } | ||
|
|
||
| // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| void Joy2BPlusWidget::handleCommand( | ||
| CommandSender* sender, int cmd, int data, int id) | ||
| { | ||
| if(cmd == CheckboxWidget::kCheckActionCmd) | ||
| { | ||
| switch(id) | ||
| { | ||
| case kJUp: | ||
| case kJDown: | ||
| case kJLeft: | ||
| case kJRight: | ||
| case kJButtonB: | ||
| setPin(ourPinNo[id], !myPins[id]->getState()); | ||
| break; | ||
| case kJButtonC: | ||
| setPin(Controller::AnalogPin::Nine, | ||
| myPins[id]->getState() ? AnalogReadout::connectToGround() | ||
| : AnalogReadout::connectToVcc()); | ||
| break; | ||
| case kJButton3: | ||
| setPin(Controller::AnalogPin::Five, | ||
| myPins[id]->getState() ? AnalogReadout::connectToGround() | ||
| : AnalogReadout::connectToVcc()); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| constexpr std::array<Controller::DigitalPin, 5> Joy2BPlusWidget::ourPinNo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
73ffb94There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thrust26, there is a naming issue here. File
Joy2PlusWidget.cxxshould be namedJoy2BPlusWidget.cxx. I guess do agit mv, and then update the Windows project. Ironically, it's spelled correctly in the module.mk; that's how I found the issue 😄73ffb94There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's a type. Who will fix this?
73ffb94There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can fix it, but not until I get home and get access to my Windows machine.
73ffb94There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I will do it.