Frame: Make TAS dialogs private

Amends the TAS callbacks to internally store functions using
std::function instead of raw function pointers. This allows binding
extra contextual state via lambda functions, as well as keeping the
dialogs internal to the main frame (on top of being a more flexible
interface).
This commit is contained in:
Lioncash
2017-04-02 01:45:11 -04:00
parent a65a176777
commit 7f0203a5b0
5 changed files with 35 additions and 37 deletions

View File

@ -47,6 +47,7 @@
#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HotkeyManager.h"
#include "Core/IOS/IPC.h"
#include "Core/IOS/USB/Bluetooth/BTBase.h"
@ -389,11 +390,7 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo
m_LogWindow->Hide();
m_LogWindow->Disable();
for (int i = 0; i < 8; ++i)
g_TASInputDlg[i] = new TASInputDlg(this);
Movie::SetGCInputManip(GCTASManipFunction);
Movie::SetWiiInputManip(WiiTASManipFunction);
InitializeTASDialogs();
State::SetOnAfterLoadCallback(OnAfterLoadCallback);
Core::SetOnStoppedCallback(OnStoppedCallback);
@ -502,6 +499,21 @@ void CFrame::BindEvents()
Bind(DOLPHIN_EVT_STOP_SOFTWARE, &CFrame::OnStop, this);
}
void CFrame::InitializeTASDialogs()
{
for (int i = 0; i < 8; ++i)
g_TASInputDlg[i] = new TASInputDlg(this);
Movie::SetGCInputManip([this](GCPadStatus* pad_status, int controller_id) {
g_TASInputDlg[controller_id]->GetValues(pad_status);
});
Movie::SetWiiInputManip([this](u8* data, WiimoteEmu::ReportFeatures rptf, int controller_id,
int ext, wiimote_key key) {
g_TASInputDlg[controller_id + 4]->GetValues(data, rptf, ext, key);
});
}
bool CFrame::RendererIsFullscreen()
{
bool fullscreen = false;
@ -1034,21 +1046,6 @@ void OnStoppedCallback()
}
}
void GCTASManipFunction(GCPadStatus* PadStatus, int controllerID)
{
if (main_frame)
main_frame->g_TASInputDlg[controllerID]->GetValues(PadStatus);
}
void WiiTASManipFunction(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID, int ext,
const wiimote_key key)
{
if (main_frame)
{
main_frame->g_TASInputDlg[controllerID + 4]->GetValues(data, rptf, ext, key);
}
}
void CFrame::OnKeyDown(wxKeyEvent& event)
{
// On OS X, we claim all keyboard events while