mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-13 04:36:59 +00:00
UI: Fix static initialization in regards to hotkey map (#1643)
This commit is contained in:
parent
1ec8c713b4
commit
955ce9b973
2 changed files with 25 additions and 12 deletions
|
|
@ -112,13 +112,7 @@ std::optional<std::string> SaveScreenshot(std::vector<uint8> data, int width, in
|
|||
}
|
||||
|
||||
extern WindowSystem::WindowInfo g_window_info;
|
||||
const std::unordered_map<sHotkeyCfg*, std::function<void(void)>> HotkeySettings::s_cfgHotkeyToFuncMap{
|
||||
{&s_cfgHotkeys.toggleFullscreen, [](void) { s_mainWindow->ShowFullScreen(!s_mainWindow->IsFullScreen()); }},
|
||||
{&s_cfgHotkeys.toggleFullscreenAlt, [](void) { s_mainWindow->ShowFullScreen(!s_mainWindow->IsFullScreen()); }},
|
||||
{&s_cfgHotkeys.exitFullscreen, [](void) { s_mainWindow->ShowFullScreen(false); }},
|
||||
{&s_cfgHotkeys.takeScreenshot, [](void) { if(g_renderer) g_renderer->RequestScreenshot(SaveScreenshot); }},
|
||||
{&s_cfgHotkeys.toggleFastForward, [](void) { ActiveSettings::SetTimerShiftFactor((ActiveSettings::GetTimerShiftFactor() < 3) ? 3 : 1); }},
|
||||
};
|
||||
std::unordered_map<sHotkeyCfg*, std::function<void(void)>> HotkeySettings::s_cfgHotkeyToFuncMap;
|
||||
|
||||
struct HotkeyEntry
|
||||
{
|
||||
|
|
@ -180,6 +174,25 @@ HotkeySettings::~HotkeySettings()
|
|||
|
||||
void HotkeySettings::Init(wxFrame* mainWindowFrame)
|
||||
{
|
||||
s_cfgHotkeyToFuncMap.insert({
|
||||
{&s_cfgHotkeys.toggleFullscreen, [](void) {
|
||||
s_mainWindow->ShowFullScreen(!s_mainWindow->IsFullScreen());
|
||||
}},
|
||||
{&s_cfgHotkeys.toggleFullscreenAlt, [](void) {
|
||||
s_mainWindow->ShowFullScreen(!s_mainWindow->IsFullScreen());
|
||||
}},
|
||||
{&s_cfgHotkeys.exitFullscreen, [](void) {
|
||||
s_mainWindow->ShowFullScreen(false);
|
||||
}},
|
||||
{&s_cfgHotkeys.takeScreenshot, [](void) {
|
||||
if (g_renderer)
|
||||
g_renderer->RequestScreenshot(SaveScreenshot);
|
||||
}},
|
||||
{&s_cfgHotkeys.toggleFastForward, [](void) {
|
||||
ActiveSettings::SetTimerShiftFactor((ActiveSettings::GetTimerShiftFactor() < 3) ? 3 : 1);
|
||||
}},
|
||||
});
|
||||
|
||||
s_keyboardHotkeyToFuncMap.reserve(s_cfgHotkeyToFuncMap.size());
|
||||
for (const auto& [cfgHotkey, func] : s_cfgHotkeyToFuncMap)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
private:
|
||||
inline static wxFrame* s_mainWindow = nullptr;
|
||||
static const std::unordered_map<sHotkeyCfg*, std::function<void(void)>> s_cfgHotkeyToFuncMap;
|
||||
static std::unordered_map<sHotkeyCfg*, std::function<void(void)>> s_cfgHotkeyToFuncMap;
|
||||
inline static std::unordered_map<uint16, std::function<void(void)>> s_keyboardHotkeyToFuncMap{};
|
||||
inline static std::unordered_map<uint16, std::function<void(void)>> s_controllerHotkeyToFuncMap{};
|
||||
inline static auto& s_cfgHotkeys = GetWxGUIConfig().hotkeys;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue