Cemu/src/gui/MainWindow.h

242 lines
6.3 KiB
C
Raw Normal View History

2022-08-22 22:21:23 +02:00
#pragma once
#include <wx/wx.h>
#include <wx/dataview.h>
#include <wx/infobar.h>
#include "wxcomponents/checkedlistctrl.h"
#include "gui/PadViewFrame.h"
#include "gui/MemorySearcherTool.h"
#include "config/XMLConfig.h"
#include "gui/LoggingWindow.h"
#include "gui/components/wxGameList.h"
#include <future>
Add GDB stub for debugging (#657) * Implement GDB stub debugger Can be enabled by using the "--enable-gdbstub" option (and the debugger GUI, although that's untested) which'll pause any game you launch at start-up. Will start at port 1337 although it'll eventually be user-editable. The code is a bit weirdly sorted and also just needs a general cleanup, so expect that eventually too. And uses egyptian braces but formatting was easier to do at the end, so that's also something to do. It has been tested to work with IDA Pro, Clion and the standalone interface for now, but I plan on writing some instructions in the PR to follow for people who want to use this. Memory breakpoints aren't possible yet, only execution breakpoints. This code was aimed to be decoupled from the existing debugger to be able to be ported to the Wii U for an equal debugging experience. That's also why it uses the Cafe OS's thread sleep and resuming functions whenever possible instead of using recompiler/interpreter controls. * Add memory writing and floating point registers support * Reformat code a bit * Format code to adhere to Cemu's coding style * Rework GDB Stub settings in GUI * Small styling fixes * Rework execution breakpoints Should work better in some edge cases now. But this should also allow for adding access breakpoints since it's now more separated. * Implement access breakpoints * Fix some issues with breakpoints * Fix includes for Linux * Fix unnecessary include * Tweaks for Linux compatibility * Use std::thread instead of std::jthread to fix MacOS support * Enable GDB read/write breakpoints on x86 only * Fix compilation for GCC compilers at least The thread type varies on some platforms, so supporting this is hell... but let's get it to compile on MacOS first. * Disable them for MacOS due to lack of ptrace --------- Co-authored-by: Exzap <13877693+Exzap@users.noreply.github.com>
2023-02-19 15:41:49 +01:00
#include "Cafe/HW/Espresso/Debugger/GDBStub.h"
#include "Cafe/CafeSystem.h"
2022-08-22 22:21:23 +02:00
class DebuggerWindow2;
struct GameEntry;
class DiscordPresence;
class TitleManager;
class wxLaunchGameEvent;
wxDECLARE_EVENT(wxEVT_LAUNCH_GAME, wxLaunchGameEvent);
wxDECLARE_EVENT(wxEVT_SET_WINDOW_TITLE, wxCommandEvent);
class wxLaunchGameEvent : public wxCommandEvent
{
public:
enum class INITIATED_BY
{
MENU, // via file menu
DRAG_AND_DROP,
GAME_LIST,
TITLE_MANAGER,
COMMAND_LINE, // -g parameter
};
wxLaunchGameEvent(fs::path path, INITIATED_BY initiatedBy)
: wxCommandEvent(wxEVT_LAUNCH_GAME), m_launchPath(path), m_initiatedBy(initiatedBy) {}
[[nodiscard]] fs::path GetPath() const { return m_launchPath; }
[[nodiscard]] INITIATED_BY GetInitiatedBy() const { return m_initiatedBy; }
wxEvent* Clone() const { return new wxLaunchGameEvent(*this); }
private:
fs::path m_launchPath;
INITIATED_BY m_initiatedBy;
};
class MainWindow : public wxFrame, public CafeSystem::SystemImplementation
2022-08-22 22:21:23 +02:00
{
friend class CemuApp;
public:
MainWindow();
~MainWindow();
void CreateGameListAndStatusBar();
void DestroyGameListAndStatusBar();
2022-08-22 22:21:23 +02:00
void UpdateSettingsAfterGameLaunch();
void RestoreSettingsAfterGameExited();
bool FileLoad(const fs::path launchPath, wxLaunchGameEvent::INITIATED_BY initiatedBy);
2022-08-22 22:21:23 +02:00
[[nodiscard]] bool IsGameLaunched() const { return m_game_launched; }
void SetFullScreen(bool state);
void SetMenuVisible(bool state);
void UpdateNFCMenu();
bool IsMenuHidden() const;
void TogglePadView();
#if BOOST_OS_WINDOWS
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
#endif
void OpenSettings();
PadViewFrame* GetPadView() const { return m_padView; }
void OnSizeEvent(wxSizeEvent& event);
void OnDPIChangedEvent(wxDPIChangedEvent& event);
2022-08-22 22:21:23 +02:00
void OnMove(wxMoveEvent& event);
void OnDebuggerClose(wxCloseEvent& event);
void OnPadClose(wxCloseEvent& event);
void OnMemorySearcherClose(wxCloseEvent& event);
void OnMouseWheel(wxMouseEvent& event);
void OnClose(wxCloseEvent& event);
void OnFileMenu(wxCommandEvent& event);
void OnOpenFolder(wxCommandEvent& event);
2022-08-22 22:21:23 +02:00
void OnLaunchFromFile(wxLaunchGameEvent& event);
void OnInstallUpdate(wxCommandEvent& event);
void OnFileExit(wxCommandEvent& event);
void OnNFCMenu(wxCommandEvent& event);
void OnOptionsInput(wxCommandEvent& event);
void OnAccountSelect(wxCommandEvent& event);
void OnConsoleLanguage(wxCommandEvent& event);
void OnHelpAbout(wxCommandEvent& event);
void OnHelpGettingStarted(wxCommandEvent& event);
void OnHelpUpdate(wxCommandEvent& event);
void OnDebugSetting(wxCommandEvent& event);
void OnDebugLoggingToggleFlagGeneric(wxCommandEvent& event);
void OnPPCInfoToggle(wxCommandEvent& event);
void OnDebugDumpUsedTextures(wxCommandEvent& event);
void OnDebugDumpUsedShaders(wxCommandEvent& event);
void OnLoggingWindow(wxCommandEvent& event);
Add GDB stub for debugging (#657) * Implement GDB stub debugger Can be enabled by using the "--enable-gdbstub" option (and the debugger GUI, although that's untested) which'll pause any game you launch at start-up. Will start at port 1337 although it'll eventually be user-editable. The code is a bit weirdly sorted and also just needs a general cleanup, so expect that eventually too. And uses egyptian braces but formatting was easier to do at the end, so that's also something to do. It has been tested to work with IDA Pro, Clion and the standalone interface for now, but I plan on writing some instructions in the PR to follow for people who want to use this. Memory breakpoints aren't possible yet, only execution breakpoints. This code was aimed to be decoupled from the existing debugger to be able to be ported to the Wii U for an equal debugging experience. That's also why it uses the Cafe OS's thread sleep and resuming functions whenever possible instead of using recompiler/interpreter controls. * Add memory writing and floating point registers support * Reformat code a bit * Format code to adhere to Cemu's coding style * Rework GDB Stub settings in GUI * Small styling fixes * Rework execution breakpoints Should work better in some edge cases now. But this should also allow for adding access breakpoints since it's now more separated. * Implement access breakpoints * Fix some issues with breakpoints * Fix includes for Linux * Fix unnecessary include * Tweaks for Linux compatibility * Use std::thread instead of std::jthread to fix MacOS support * Enable GDB read/write breakpoints on x86 only * Fix compilation for GCC compilers at least The thread type varies on some platforms, so supporting this is hell... but let's get it to compile on MacOS first. * Disable them for MacOS due to lack of ptrace --------- Co-authored-by: Exzap <13877693+Exzap@users.noreply.github.com>
2023-02-19 15:41:49 +01:00
void OnGDBStubToggle(wxCommandEvent& event);
2022-08-22 22:21:23 +02:00
void OnDebugViewPPCThreads(wxCommandEvent& event);
void OnDebugViewPPCDebugger(wxCommandEvent& event);
void OnDebugViewAudioDebugger(wxCommandEvent& event);
void OnDebugViewTextureRelations(wxCommandEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnMouseLeft(wxMouseEvent& event);
void OnMouseRight(wxMouseEvent& event);
void OnGameListBeginUpdate(wxCommandEvent& event);
void OnGameListEndUpdate(wxCommandEvent& event);
void OnAccountListRefresh(wxCommandEvent& event);
void OnRequestGameListRefresh(wxCommandEvent& event);
void OnSetWindowTitle(wxCommandEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
2022-08-22 22:21:23 +02:00
void OnChar(wxKeyEvent& event);
void OnToolsInput(wxCommandEvent& event);
void OnGesturePan(wxPanGestureEvent& event);
void OnGameLoaded();
void AsyncSetTitle(std::string_view windowTitle);
void CreateCanvas();
void DestroyCanvas();
static void ShowCursor(bool state);
uintptr_t GetRenderCanvasHWND();
static void RequestGameListRefresh();
static void RequestLaunchGame(fs::path filePath, wxLaunchGameEvent::INITIATED_BY initiatedBy);
private:
void RecreateMenu();
static wxString GetInitialWindowTitle();
void ShowGettingStartedDialog();
bool InstallUpdate(const fs::path& metaFilePath);
void OnTimer(wxTimerEvent& event);
// CafeSystem implementation
void CafeRecreateCanvas() override;
void OnRequestRecreateCanvas(wxCommandEvent& event);
2022-08-22 22:21:23 +02:00
wxRect GetDesktopRect();
MemorySearcherTool* m_toolWindow = nullptr;
TitleManager* m_title_manager = nullptr;
PadViewFrame* m_padView = nullptr;
wxWindow* m_graphic_pack_window = nullptr;
wxTimer* m_timer;
wxPoint m_mouse_position{};
std::chrono::steady_clock::time_point m_last_mouse_move_time;
wxSize m_restored_size;
wxPoint m_restored_position;
bool m_menu_visible = false;
bool m_game_launched = false;
#ifdef ENABLE_DISCORD_RPC
std::unique_ptr<DiscordPresence> m_discord;
#endif
std::string m_launched_game_name;
Add GDB stub for debugging (#657) * Implement GDB stub debugger Can be enabled by using the "--enable-gdbstub" option (and the debugger GUI, although that's untested) which'll pause any game you launch at start-up. Will start at port 1337 although it'll eventually be user-editable. The code is a bit weirdly sorted and also just needs a general cleanup, so expect that eventually too. And uses egyptian braces but formatting was easier to do at the end, so that's also something to do. It has been tested to work with IDA Pro, Clion and the standalone interface for now, but I plan on writing some instructions in the PR to follow for people who want to use this. Memory breakpoints aren't possible yet, only execution breakpoints. This code was aimed to be decoupled from the existing debugger to be able to be ported to the Wii U for an equal debugging experience. That's also why it uses the Cafe OS's thread sleep and resuming functions whenever possible instead of using recompiler/interpreter controls. * Add memory writing and floating point registers support * Reformat code a bit * Format code to adhere to Cemu's coding style * Rework GDB Stub settings in GUI * Small styling fixes * Rework execution breakpoints Should work better in some edge cases now. But this should also allow for adding access breakpoints since it's now more separated. * Implement access breakpoints * Fix some issues with breakpoints * Fix includes for Linux * Fix unnecessary include * Tweaks for Linux compatibility * Use std::thread instead of std::jthread to fix MacOS support * Enable GDB read/write breakpoints on x86 only * Fix compilation for GCC compilers at least The thread type varies on some platforms, so supporting this is hell... but let's get it to compile on MacOS first. * Disable them for MacOS due to lack of ptrace --------- Co-authored-by: Exzap <13877693+Exzap@users.noreply.github.com>
2023-02-19 15:41:49 +01:00
wxMenuItem* m_gdbstub_toggle{};
2022-08-22 22:21:23 +02:00
DebuggerWindow2* m_debugger_window = nullptr;
LoggingWindow* m_logging_window = nullptr;
std::future<bool> m_update_available;
wxMenuItem* m_check_update_menu{};
void LoadSettings();
void SaveSettings();
void OnGraphicWindowClose(wxCloseEvent& event);
void OnGraphicWindowOpen(wxTitleIdEvent& event);
// panels
wxPanel* m_main_panel{}, * m_game_panel{};
// rendering
wxWindow* m_render_canvas{};
// gamelist
wxGameList* m_game_list{};
wxInfoBar* m_info_bar{};
2022-08-22 22:21:23 +02:00
// menu
wxMenuBar* m_menuBar{};
2022-08-22 22:21:23 +02:00
// file
wxMenu* m_fileMenu{};
wxMenuItem* m_fileMenuSeparator0{};
wxMenuItem* m_fileMenuSeparator1{};
wxMenuItem* m_loadMenuItem{};
wxMenuItem* m_installUpdateMenuItem{};
wxMenuItem* m_exitMenuItem{};
2022-08-22 22:21:23 +02:00
// options
wxMenu* m_optionsAccountMenu{};
2022-08-22 22:21:23 +02:00
wxMenuItem* m_fullscreenMenuItem{};
wxMenuItem* m_padViewMenuItem{};
2022-08-22 22:21:23 +02:00
// tools
wxMenuItem* m_memorySearcherMenuItem{};
2022-08-22 22:21:23 +02:00
// cpu
wxMenu* m_cpuTimerSubmenu{};
2022-08-22 22:21:23 +02:00
// nfc
wxMenu* m_nfcMenu{};
wxMenuItem* m_nfcMenuSeparator0{};
2022-08-22 22:21:23 +02:00
// debug
wxMenu* m_debugMenu{};
wxMenu* m_loggingSubmenu{};
wxMenuItem* m_asyncCompile{};
2022-08-22 22:21:23 +02:00
wxDECLARE_EVENT_TABLE();
};
extern MainWindow* g_mainFrame;