2016-08-21 22:11:24 +00:00
|
|
|
#include <md/md.hpp>
|
|
|
|
|
|
|
|
namespace MegaDrive {
|
|
|
|
|
|
|
|
#include "gamepad/gamepad.cpp"
|
|
|
|
|
|
|
|
Controller::Controller(uint port) : port(port) {
|
|
|
|
if(!handle()) create(Controller::Enter, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller::~Controller() {
|
2017-01-22 00:33:36 +00:00
|
|
|
scheduler.remove(*this);
|
2016-08-21 22:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::Enter() -> void {
|
|
|
|
while(true) {
|
|
|
|
scheduler.synchronize();
|
|
|
|
if(peripherals.controllerPort1->active()) peripherals.controllerPort1->main();
|
|
|
|
if(peripherals.controllerPort2->active()) peripherals.controllerPort2->main();
|
|
|
|
if(peripherals.extensionPort->active()) peripherals.extensionPort->main();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::main() -> void {
|
|
|
|
step(1);
|
|
|
|
synchronize(cpu);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|