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:
parent
a65a176777
commit
7f0203a5b0
|
@ -2,6 +2,8 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/Movie.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
|
@ -10,6 +12,7 @@
|
|||
#include <mbedtls/md.h>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
|
@ -34,7 +37,6 @@
|
|||
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
||||
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/State.h"
|
||||
|
@ -91,8 +93,8 @@ static bool s_bPolled = false;
|
|||
static std::mutex s_input_display_lock;
|
||||
static std::string s_InputDisplay[8];
|
||||
|
||||
static GCManipFunction gcmfunc = nullptr;
|
||||
static WiiManipFunction wiimfunc = nullptr;
|
||||
static GCManipFunction gcmfunc;
|
||||
static WiiManipFunction wiimfunc;
|
||||
|
||||
// NOTE: Host / CPU Thread
|
||||
static void EnsureTmpInputSize(size_t bound)
|
||||
|
@ -1440,25 +1442,25 @@ void SaveRecording(const std::string& filename)
|
|||
|
||||
void SetGCInputManip(GCManipFunction func)
|
||||
{
|
||||
gcmfunc = func;
|
||||
gcmfunc = std::move(func);
|
||||
}
|
||||
void SetWiiInputManip(WiiManipFunction func)
|
||||
{
|
||||
wiimfunc = func;
|
||||
wiimfunc = std::move(func);
|
||||
}
|
||||
|
||||
// NOTE: CPU Thread
|
||||
void CallGCInputManip(GCPadStatus* PadStatus, int controllerID)
|
||||
{
|
||||
if (gcmfunc)
|
||||
(*gcmfunc)(PadStatus, controllerID);
|
||||
gcmfunc(PadStatus, controllerID);
|
||||
}
|
||||
// NOTE: CPU Thread
|
||||
void CallWiiInputManip(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID, int ext,
|
||||
const wiimote_key key)
|
||||
{
|
||||
if (wiimfunc)
|
||||
(*wiimfunc)(data, rptf, controllerID, ext, key);
|
||||
wiimfunc(data, rptf, controllerID, ext, key);
|
||||
}
|
||||
|
||||
// NOTE: GPU Thread
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -181,8 +182,9 @@ std::string GetInputDisplay();
|
|||
std::string GetRTCDisplay();
|
||||
|
||||
// Done this way to avoid mixing of core and gui code
|
||||
typedef void (*GCManipFunction)(GCPadStatus*, int);
|
||||
typedef void (*WiiManipFunction)(u8*, WiimoteEmu::ReportFeatures, int, int, wiimote_key);
|
||||
using GCManipFunction = std::function<void(GCPadStatus*, int)>;
|
||||
using WiiManipFunction =
|
||||
std::function<void(u8*, WiimoteEmu::ReportFeatures, int, int, wiimote_key)>;
|
||||
|
||||
void SetGCInputManip(GCManipFunction);
|
||||
void SetWiiInputManip(WiiManipFunction);
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Event.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "DolphinWX/Globals.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
#include "UICommon/X11Utils.h"
|
||||
|
@ -88,7 +86,6 @@ public:
|
|||
CCodeWindow* g_pCodeWindow = nullptr;
|
||||
NetPlaySetupFrame* g_NetPlaySetupDiag = nullptr;
|
||||
wxCheatsWindow* g_CheatsWindow = nullptr;
|
||||
TASInputDlg* g_TASInputDlg[8];
|
||||
|
||||
void DoStop();
|
||||
void UpdateGUI();
|
||||
|
@ -140,6 +137,7 @@ private:
|
|||
CLogWindow* m_LogWindow = nullptr;
|
||||
LogConfigWindow* m_LogConfigWindow = nullptr;
|
||||
FifoPlayerDlg* m_FifoPlayerDlg = nullptr;
|
||||
TASInputDlg* g_TASInputDlg[8];
|
||||
bool UseDebugger = false;
|
||||
bool m_bBatchMode = false;
|
||||
bool m_bEdit = false;
|
||||
|
@ -174,6 +172,8 @@ private:
|
|||
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString& name) override;
|
||||
wxMenuBar* CreateMenuBar() const;
|
||||
|
||||
void InitializeTASDialogs();
|
||||
|
||||
// Utility
|
||||
wxWindow* GetNotebookPageFromId(wxWindowID Id);
|
||||
wxAuiNotebook* GetNotebookFromId(u32 NBId);
|
||||
|
@ -339,8 +339,3 @@ private:
|
|||
|
||||
void OnAfterLoadCallback();
|
||||
void OnStoppedCallback();
|
||||
|
||||
// For TASInputDlg
|
||||
void GCTASManipFunction(GCPadStatus* PadStatus, int controllerID);
|
||||
void WiiTASManipFunction(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID, int ext,
|
||||
const wiimote_key key);
|
||||
|
|
Loading…
Reference in New Issue