Cemu/src/gui/wxgui.h

107 lines
2.7 KiB
C
Raw Normal View History

2022-08-22 22:21:23 +02:00
#pragma once
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/listctrl.h>
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/timer.h>
#include <wx/slider.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
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 <wx/spinctrl.h>
2022-08-22 22:21:23 +02:00
#include <wx/listbase.h>
#include <wx/display.h>
#include <wx/aboutdlg.h>
#include <wx/dialog.h>
#include <wx/timer.h>
#include <wx/gauge.h>
#include <wx/dataview.h>
#include <wx/statline.h>
#include <wx/wrapsizer.h>
#include <wx/gbsizer.h>
#include <wx/radiobox.h>
#include <wx/combobox.h>
#include <wx/sizer.h>
#include <wx/scrolbar.h>
#include <wx/richtext/richtextctrl.h>
#include <wx/dcbuffer.h>
#include <wx/combo.h>
#include <wx/wupdlock.h>
#include <wx/infobar.h>
#include <wx/splitter.h>
extern bool g_inputConfigWindowHasFocus;
// wx helper functions
#include <wx/string.h>
struct wxStringFormatParameters
{
sint32 parameter_index;
sint32 parameter_count;
wchar_t* token_buffer;
wchar_t* substitude_parameter;
};
template <typename ...Args>
wxString wxStringFormat(std::wstring& format, wxStringFormatParameters& parameters)
{
return format;
}
template <typename T, typename ...Args>
wxString wxStringFormat(std::wstring& format, wxStringFormatParameters& parameters, T arg, Args... args)
{
wchar_t tmp[64];
swprintf(tmp, 64, LR"(\{[%d]+\})", parameters.parameter_index);
const std::wregex placeholder_regex(tmp);
auto result = format;
while (std::regex_search(result, placeholder_regex))
{
result = std::regex_replace(result, placeholder_regex, parameters.substitude_parameter, std::regex_constants::format_first_only);
result = wxString::Format(wxString(result), arg);
}
parameters.parameter_index++;
if (parameters.parameter_index == parameters.parameter_count)
return result;
parameters.substitude_parameter = std::wcstok(nullptr, LR"( )", &parameters.token_buffer);
return wxStringFormat(result, parameters, args...);
}
template <typename ...T>
wxString wxStringFormat(const wxString& format, const wchar_t* parameters, T... args)
{
const auto parameter_count = std::count(parameters, parameters + wcslen(parameters), '%');
if (parameter_count == 0)
return format;
const auto copy = wcsdup(parameters);
wxStringFormatParameters para;
para.substitude_parameter = std::wcstok(copy, LR"( )", &para.token_buffer);
para.parameter_count = parameter_count;
para.parameter_index = 0;
auto tmp_string = format.ToStdWstring();
auto result = wxStringFormat(tmp_string, para, args...);
free(copy);
return result;
}
inline bool SendSliderEvent(wxSlider* slider, int new_value)
{
wxCommandEvent cevent(wxEVT_SLIDER, slider->GetId());
cevent.SetInt(new_value);
cevent.SetEventObject(slider);
return slider->HandleWindowEvent(cevent);
}