diff --git a/Core/AutomaticRomTest.cpp b/Core/AutomaticRomTest.cpp index 1a1d2fd0..5b20975f 100644 --- a/Core/AutomaticRomTest.cpp +++ b/Core/AutomaticRomTest.cpp @@ -14,12 +14,14 @@ AutomaticRomTest::AutomaticRomTest() _running = true; _errorCode = 0; MessageManager::RegisterNotificationListener(this); + ControlManager::RegisterInputProvider(this); } AutomaticRomTest::~AutomaticRomTest() { _running = false; MessageManager::UnregisterNotificationListener(this); + ControlManager::UnregisterInputProvider(this); } void AutomaticRomTest::ProcessNotification(ConsoleNotificationType type, void* parameter) @@ -139,29 +141,32 @@ bool AutomaticRomTest::Running() return _running; } -uint8_t AutomaticRomTest::GetControllerState(uint8_t port) +bool AutomaticRomTest::SetInput(BaseControlDevice* device) { - if(port == 0) { + if(device->GetPort() == 0) { uint32_t frameNumber = PPU::GetFrameCount(); + ControlDeviceState state; if(frameNumber <= 1800) { if(frameNumber % 30 < 10) { //Press 1 button for 10 frames every second if((frameNumber / 30) % 8 != 1) { - return 1 << ((frameNumber / 60) % 8); + state.State.push_back(1 << ((frameNumber / 60) % 8)); } } } else { if(frameNumber % 30 < 10) { if((frameNumber / 30) % 2) { - return 0x01; + state.State.push_back(0x01); } else { - return 0x08; + state.State.push_back(0x08); } } } - return 0; - } else { - return 0; + if(state.State.empty()) { + state.State.push_back(0); + } + device->SetRawState(state); } + return true; } diff --git a/Core/AutomaticRomTest.h b/Core/AutomaticRomTest.h index 48d9f4cf..80fe33d5 100644 --- a/Core/AutomaticRomTest.h +++ b/Core/AutomaticRomTest.h @@ -1,9 +1,10 @@ #pragma once #include "stdafx.h" #include "INotificationListener.h" +#include "IInputProvider.h" #include "../Utilities/AutoResetEvent.h" -class AutomaticRomTest : public INotificationListener +class AutomaticRomTest : public INotificationListener, public IInputProvider { private: AutoResetEvent _signal; @@ -19,5 +20,7 @@ public: int32_t Run(string filename); static bool Running(); - static uint8_t GetControllerState(uint8_t port); + + // Inherited via IInputProvider + virtual bool SetInput(BaseControlDevice * device) override; }; \ No newline at end of file