Putting controller into its own namespace

This commit is contained in:
SergioMartin86 2024-03-19 19:47:30 +01:00
parent d61ff4580c
commit 45840b6527
4 changed files with 19 additions and 13 deletions

View File

@ -7,6 +7,9 @@
#include <string>
#include <sstream>
namespace quickNES
{
class Controller
{
public:
@ -204,4 +207,7 @@ public:
input_t _input;
controller_t _controller1Type;
controller_t _controller2Type;
};
}; // class Controller
} // namespace quickNES

View File

@ -38,10 +38,10 @@ class NESInstanceBase
{
bool isTypeRecognized = false;
if (type == "None") { _controller.setController1Type(Controller::controller_t::none); isTypeRecognized = true; }
if (type == "Joypad") { _controller.setController1Type(Controller::controller_t::joypad); isTypeRecognized = true; }
if (type == "FourScore1") { _controller.setController1Type(Controller::controller_t::fourscore1); isTypeRecognized = true; }
if (type == "FourScore2") { _controller.setController1Type(Controller::controller_t::fourscore2); isTypeRecognized = true; }
if (type == "None") { _controller.setController1Type(quickNES::Controller::controller_t::none); isTypeRecognized = true; }
if (type == "Joypad") { _controller.setController1Type(quickNES::Controller::controller_t::joypad); isTypeRecognized = true; }
if (type == "FourScore1") { _controller.setController1Type(quickNES::Controller::controller_t::fourscore1); isTypeRecognized = true; }
if (type == "FourScore2") { _controller.setController1Type(quickNES::Controller::controller_t::fourscore2); isTypeRecognized = true; }
if (isTypeRecognized == false) JAFFAR_THROW_LOGIC("Input type not recognized: '%s'\n", type.c_str());
}
@ -50,10 +50,10 @@ class NESInstanceBase
{
bool isTypeRecognized = false;
if (type == "None") { _controller.setController2Type(Controller::controller_t::none); isTypeRecognized = true; }
if (type == "Joypad") { _controller.setController2Type(Controller::controller_t::joypad); isTypeRecognized = true; }
if (type == "FourScore1") { _controller.setController2Type(Controller::controller_t::fourscore1); isTypeRecognized = true; }
if (type == "FourScore2") { _controller.setController2Type(Controller::controller_t::fourscore2); isTypeRecognized = true; }
if (type == "None") { _controller.setController2Type(quickNES::Controller::controller_t::none); isTypeRecognized = true; }
if (type == "Joypad") { _controller.setController2Type(quickNES::Controller::controller_t::joypad); isTypeRecognized = true; }
if (type == "FourScore1") { _controller.setController2Type(quickNES::Controller::controller_t::fourscore1); isTypeRecognized = true; }
if (type == "FourScore2") { _controller.setController2Type(quickNES::Controller::controller_t::fourscore2); isTypeRecognized = true; }
if (isTypeRecognized == false) JAFFAR_THROW_LOGIC("Input type not recognized: '%s'\n", type.c_str());
}
@ -112,7 +112,7 @@ class NESInstanceBase
virtual void enableStateBlockImpl(const std::string& block) = 0;
virtual void disableStateBlockImpl(const std::string& block) = 0;
virtual bool loadROMImpl(const uint8_t* romData, const size_t romSize) = 0;
virtual void advanceStateImpl(const Controller::port_t controller1, const Controller::port_t controller2) = 0;
virtual void advanceStateImpl(const quickNES::Controller::port_t controller1, const quickNES::Controller::port_t controller2) = 0;
// Storage for the light state size
size_t _stateSize;
@ -123,5 +123,5 @@ class NESInstanceBase
private:
// Controller class for input parsing
Controller _controller;
quickNES::Controller _controller;
};

View File

@ -74,7 +74,7 @@ class NESInstance final : public NESInstanceBase
void enableStateBlockImpl(const std::string& block) override {};
void disableStateBlockImpl(const std::string& block) override {};
void advanceStateImpl(const Controller::port_t controller1, const Controller::port_t controller2) override
void advanceStateImpl(const quickNES::Controller::port_t controller1, const quickNES::Controller::port_t controller2) override
{
if (_doRendering == true) _nes.emulate_frame(controller1, controller2);
if (_doRendering == false) _nes.emulate_skip_frame(controller1, controller2);

View File

@ -59,7 +59,7 @@ class NESInstance final : public NESInstanceBase
void enableStateBlockImpl(const std::string& block) override { _nes.enableStateBlock(block); };
void disableStateBlockImpl(const std::string& block) override { _nes.disableStateBlock(block); };
void advanceStateImpl(const Controller::port_t controller1, const Controller::port_t controller2) override
void advanceStateImpl(const quickNES::Controller::port_t controller1, const quickNES::Controller::port_t controller2) override
{
if (_doRendering == true) _nes.emulate_frame(controller1, controller2);
if (_doRendering == false) _nes.emulate_skip_frame(controller1, controller2);