mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
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+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "Core/Movie.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@ -10,6 +12,7 @@
|
|||||||
#include <mbedtls/md.h>
|
#include <mbedtls/md.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
@ -34,7 +37,6 @@
|
|||||||
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
#include "Core/HW/WiimoteEmu/WiimoteHid.h"
|
||||||
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
||||||
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
||||||
#include "Core/Movie.h"
|
|
||||||
#include "Core/NetPlayProto.h"
|
#include "Core/NetPlayProto.h"
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
@ -91,8 +93,8 @@ static bool s_bPolled = false;
|
|||||||
static std::mutex s_input_display_lock;
|
static std::mutex s_input_display_lock;
|
||||||
static std::string s_InputDisplay[8];
|
static std::string s_InputDisplay[8];
|
||||||
|
|
||||||
static GCManipFunction gcmfunc = nullptr;
|
static GCManipFunction gcmfunc;
|
||||||
static WiiManipFunction wiimfunc = nullptr;
|
static WiiManipFunction wiimfunc;
|
||||||
|
|
||||||
// NOTE: Host / CPU Thread
|
// NOTE: Host / CPU Thread
|
||||||
static void EnsureTmpInputSize(size_t bound)
|
static void EnsureTmpInputSize(size_t bound)
|
||||||
@ -1440,25 +1442,25 @@ void SaveRecording(const std::string& filename)
|
|||||||
|
|
||||||
void SetGCInputManip(GCManipFunction func)
|
void SetGCInputManip(GCManipFunction func)
|
||||||
{
|
{
|
||||||
gcmfunc = func;
|
gcmfunc = std::move(func);
|
||||||
}
|
}
|
||||||
void SetWiiInputManip(WiiManipFunction func)
|
void SetWiiInputManip(WiiManipFunction func)
|
||||||
{
|
{
|
||||||
wiimfunc = func;
|
wiimfunc = std::move(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: CPU Thread
|
// NOTE: CPU Thread
|
||||||
void CallGCInputManip(GCPadStatus* PadStatus, int controllerID)
|
void CallGCInputManip(GCPadStatus* PadStatus, int controllerID)
|
||||||
{
|
{
|
||||||
if (gcmfunc)
|
if (gcmfunc)
|
||||||
(*gcmfunc)(PadStatus, controllerID);
|
gcmfunc(PadStatus, controllerID);
|
||||||
}
|
}
|
||||||
// NOTE: CPU Thread
|
// NOTE: CPU Thread
|
||||||
void CallWiiInputManip(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID, int ext,
|
void CallWiiInputManip(u8* data, WiimoteEmu::ReportFeatures rptf, int controllerID, int ext,
|
||||||
const wiimote_key key)
|
const wiimote_key key)
|
||||||
{
|
{
|
||||||
if (wiimfunc)
|
if (wiimfunc)
|
||||||
(*wiimfunc)(data, rptf, controllerID, ext, key);
|
wiimfunc(data, rptf, controllerID, ext, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: GPU Thread
|
// NOTE: GPU Thread
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
@ -181,8 +182,9 @@ std::string GetInputDisplay();
|
|||||||
std::string GetRTCDisplay();
|
std::string GetRTCDisplay();
|
||||||
|
|
||||||
// Done this way to avoid mixing of core and gui code
|
// Done this way to avoid mixing of core and gui code
|
||||||
typedef void (*GCManipFunction)(GCPadStatus*, int);
|
using GCManipFunction = std::function<void(GCPadStatus*, int)>;
|
||||||
typedef void (*WiiManipFunction)(u8*, WiimoteEmu::ReportFeatures, int, int, wiimote_key);
|
using WiiManipFunction =
|
||||||
|
std::function<void(u8*, WiimoteEmu::ReportFeatures, int, int, wiimote_key)>;
|
||||||
|
|
||||||
void SetGCInputManip(GCManipFunction);
|
void SetGCInputManip(GCManipFunction);
|
||||||
void SetWiiInputManip(WiiManipFunction);
|
void SetWiiInputManip(WiiManipFunction);
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <fstream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "Core/HW/GCKeyboard.h"
|
#include "Core/HW/GCKeyboard.h"
|
||||||
#include "Core/HW/GCPad.h"
|
#include "Core/HW/GCPad.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||||
#include "Core/HotkeyManager.h"
|
#include "Core/HotkeyManager.h"
|
||||||
#include "Core/IOS/IPC.h"
|
#include "Core/IOS/IPC.h"
|
||||||
#include "Core/IOS/USB/Bluetooth/BTBase.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->Hide();
|
||||||
m_LogWindow->Disable();
|
m_LogWindow->Disable();
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
InitializeTASDialogs();
|
||||||
g_TASInputDlg[i] = new TASInputDlg(this);
|
|
||||||
|
|
||||||
Movie::SetGCInputManip(GCTASManipFunction);
|
|
||||||
Movie::SetWiiInputManip(WiiTASManipFunction);
|
|
||||||
|
|
||||||
State::SetOnAfterLoadCallback(OnAfterLoadCallback);
|
State::SetOnAfterLoadCallback(OnAfterLoadCallback);
|
||||||
Core::SetOnStoppedCallback(OnStoppedCallback);
|
Core::SetOnStoppedCallback(OnStoppedCallback);
|
||||||
@ -502,6 +499,21 @@ void CFrame::BindEvents()
|
|||||||
Bind(DOLPHIN_EVT_STOP_SOFTWARE, &CFrame::OnStop, this);
|
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 CFrame::RendererIsFullscreen()
|
||||||
{
|
{
|
||||||
bool fullscreen = false;
|
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)
|
void CFrame::OnKeyDown(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
// On OS X, we claim all keyboard events while
|
// On OS X, we claim all keyboard events while
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Event.h"
|
#include "Common/Event.h"
|
||||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
|
||||||
#include "DolphinWX/Globals.h"
|
#include "DolphinWX/Globals.h"
|
||||||
#include "InputCommon/GCPadStatus.h"
|
|
||||||
|
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
#if defined(HAVE_X11) && HAVE_X11
|
||||||
#include "UICommon/X11Utils.h"
|
#include "UICommon/X11Utils.h"
|
||||||
@ -88,7 +86,6 @@ public:
|
|||||||
CCodeWindow* g_pCodeWindow = nullptr;
|
CCodeWindow* g_pCodeWindow = nullptr;
|
||||||
NetPlaySetupFrame* g_NetPlaySetupDiag = nullptr;
|
NetPlaySetupFrame* g_NetPlaySetupDiag = nullptr;
|
||||||
wxCheatsWindow* g_CheatsWindow = nullptr;
|
wxCheatsWindow* g_CheatsWindow = nullptr;
|
||||||
TASInputDlg* g_TASInputDlg[8];
|
|
||||||
|
|
||||||
void DoStop();
|
void DoStop();
|
||||||
void UpdateGUI();
|
void UpdateGUI();
|
||||||
@ -140,6 +137,7 @@ private:
|
|||||||
CLogWindow* m_LogWindow = nullptr;
|
CLogWindow* m_LogWindow = nullptr;
|
||||||
LogConfigWindow* m_LogConfigWindow = nullptr;
|
LogConfigWindow* m_LogConfigWindow = nullptr;
|
||||||
FifoPlayerDlg* m_FifoPlayerDlg = nullptr;
|
FifoPlayerDlg* m_FifoPlayerDlg = nullptr;
|
||||||
|
TASInputDlg* g_TASInputDlg[8];
|
||||||
bool UseDebugger = false;
|
bool UseDebugger = false;
|
||||||
bool m_bBatchMode = false;
|
bool m_bBatchMode = false;
|
||||||
bool m_bEdit = false;
|
bool m_bEdit = false;
|
||||||
@ -174,6 +172,8 @@ private:
|
|||||||
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString& name) override;
|
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString& name) override;
|
||||||
wxMenuBar* CreateMenuBar() const;
|
wxMenuBar* CreateMenuBar() const;
|
||||||
|
|
||||||
|
void InitializeTASDialogs();
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
wxWindow* GetNotebookPageFromId(wxWindowID Id);
|
wxWindow* GetNotebookPageFromId(wxWindowID Id);
|
||||||
wxAuiNotebook* GetNotebookFromId(u32 NBId);
|
wxAuiNotebook* GetNotebookFromId(u32 NBId);
|
||||||
@ -339,8 +339,3 @@ private:
|
|||||||
|
|
||||||
void OnAfterLoadCallback();
|
void OnAfterLoadCallback();
|
||||||
void OnStoppedCallback();
|
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…
x
Reference in New Issue
Block a user