Lua: Fixed inputPolled event being called multiple times per frame
This commit is contained in:
parent
2c7a169d9c
commit
9c5cfa2e79
8 changed files with 30 additions and 35 deletions
|
@ -240,7 +240,7 @@ void ControlManager::UpdateInputState()
|
|||
|
||||
auto lock = _deviceLock.AcquireSafe();
|
||||
|
||||
string log = "";
|
||||
//string log = "";
|
||||
for(shared_ptr<BaseControlDevice> &device : _controlDevices) {
|
||||
device->ClearState();
|
||||
|
||||
|
@ -258,24 +258,18 @@ void ControlManager::UpdateInputState()
|
|||
}
|
||||
|
||||
device->OnAfterSetState();
|
||||
//log += "|" + device->GetTextState();
|
||||
}
|
||||
|
||||
shared_ptr<Debugger> debugger = Console::GetInstance()->GetDebugger(false);
|
||||
if(debugger) {
|
||||
debugger->ProcessEvent(EventType::InputPolled);
|
||||
}
|
||||
|
||||
log += "|" + device->GetTextState();
|
||||
|
||||
for(IInputRecorder* recorder : _inputRecorders) {
|
||||
recorder->RecordInput(device.get());
|
||||
recorder->RecordInput(_controlDevices);
|
||||
}
|
||||
}
|
||||
|
||||
for(IInputRecorder* recorder : _inputRecorders) {
|
||||
recorder->EndFrame();
|
||||
}
|
||||
|
||||
MessageManager::Log(log);
|
||||
//MessageManager::Log(log);
|
||||
}
|
||||
|
||||
uint32_t ControlManager::GetLagCounter()
|
||||
|
|
|
@ -85,14 +85,16 @@ bool GameServer::SetInput(BaseControlDevice *device)
|
|||
return false;
|
||||
}
|
||||
|
||||
void GameServer::RecordInput(BaseControlDevice *device)
|
||||
void GameServer::RecordInput(vector<shared_ptr<BaseControlDevice>> devices)
|
||||
{
|
||||
for(shared_ptr<BaseControlDevice> &device : devices) {
|
||||
for(shared_ptr<GameServerConnection> connection : _openConnections) {
|
||||
if(!connection->ConnectionError()) {
|
||||
//Send movie stream
|
||||
connection->SendMovieData(device->GetPort(), device->GetRawState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameServer::Exec()
|
||||
|
|
|
@ -47,5 +47,5 @@ public:
|
|||
static list<shared_ptr<GameServerConnection>> GetConnectionList();
|
||||
|
||||
bool SetInput(BaseControlDevice *device) override;
|
||||
void RecordInput(BaseControlDevice *device) override;
|
||||
void RecordInput(vector<shared_ptr<BaseControlDevice>> devices) override;
|
||||
};
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
|
||||
class BaseControlDevice;
|
||||
|
||||
class IInputRecorder
|
||||
{
|
||||
public:
|
||||
virtual void RecordInput(BaseControlDevice *device) = 0;
|
||||
virtual void EndFrame() { }
|
||||
virtual void RecordInput(vector<shared_ptr<BaseControlDevice>> devices) = 0;
|
||||
};
|
|
@ -179,13 +179,11 @@ bool MovieRecorder::Stop()
|
|||
return false;
|
||||
}
|
||||
|
||||
void MovieRecorder::RecordInput(BaseControlDevice *device)
|
||||
void MovieRecorder::RecordInput(vector<shared_ptr<BaseControlDevice>> devices)
|
||||
{
|
||||
for(shared_ptr<BaseControlDevice> &device : devices) {
|
||||
_inputData << ("|" + device->GetTextState());
|
||||
}
|
||||
|
||||
void MovieRecorder::EndFrame()
|
||||
{
|
||||
}
|
||||
_inputData << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ public:
|
|||
bool Record(string filename, bool reset);
|
||||
bool Stop();
|
||||
|
||||
void RecordInput(BaseControlDevice *device) override;
|
||||
void EndFrame() override;
|
||||
void RecordInput(vector<shared_ptr<BaseControlDevice>> devices) override;
|
||||
|
||||
// Inherited via IBatteryRecorder
|
||||
virtual void OnLoadBattery(string extension, vector<uint8_t> batteryData) override;
|
||||
|
|
|
@ -267,11 +267,13 @@ bool RewindManager::ProcessAudio(int16_t * soundBuffer, uint32_t sampleCount, ui
|
|||
}
|
||||
}
|
||||
|
||||
void RewindManager::RecordInput(BaseControlDevice *device)
|
||||
void RewindManager::RecordInput(vector<shared_ptr<BaseControlDevice>> devices)
|
||||
{
|
||||
if(EmulationSettings::GetRewindBufferSize() > 0 && _instance && _instance->_rewindState == RewindState::Stopped) {
|
||||
for(shared_ptr<BaseControlDevice> &device : devices) {
|
||||
_instance->_currentHistory.InputLogs[device->GetPort()].push_back(device->GetRawState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RewindManager::SetInput(BaseControlDevice *device)
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
|
||||
void ProcessEndOfFrame();
|
||||
|
||||
void RecordInput(BaseControlDevice *device) override;
|
||||
void RecordInput(vector<shared_ptr<BaseControlDevice>> devices) override;
|
||||
bool SetInput(BaseControlDevice *device) override;
|
||||
|
||||
static void StartRewinding(bool forDebugger = false);
|
||||
|
|
Loading…
Add table
Reference in a new issue