Qt/Core: Implement GBA Hotkeys

This commit is contained in:
Bonta
2021-07-04 13:26:47 +02:00
parent d6f86e1754
commit b73d16a71a
9 changed files with 193 additions and 8 deletions

View File

@ -7,6 +7,7 @@
#include <cmath>
#include <thread>
#include <QApplication>
#include <QCoreApplication>
#include "AudioCommon/AudioCommon.h"
@ -28,6 +29,10 @@
#include "Core/State.h"
#include "Core/WiiUtils.h"
#ifdef HAS_LIBMGBA
#include "DolphinQt/GBAWidget.h"
#endif
#include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/Settings.h"
#include "InputCommon/ControlReference/ControlReference.h"
@ -157,11 +162,13 @@ void HotkeyScheduler::Run()
// Obey window focus (config permitting) before checking hotkeys.
Core::UpdateInputGate(Config::Get(Config::MAIN_FOCUSED_HOTKEYS));
HotkeyManagerEmu::GetStatus();
HotkeyManagerEmu::GetStatus(false);
// Everything else on the host thread (controller config dialog) should always get input.
ControlReference::SetInputGate(true);
HotkeyManagerEmu::GetStatus(true);
if (!Core::IsRunningAndStarted())
continue;
@ -520,6 +527,8 @@ void HotkeyScheduler::Run()
Config::SetCurrent(Config::GFX_ENHANCE_POST_SHADER, "");
}
}
CheckGBAHotkeys();
}
const auto stereo_depth = Config::Get(Config::GFX_STEREO_DEPTH);
@ -607,3 +616,42 @@ void HotkeyScheduler::CheckDebuggingHotkeys()
if (IsHotkey(HK_BP_ADD))
emit AddBreakpoint();
}
void HotkeyScheduler::CheckGBAHotkeys()
{
#ifdef HAS_LIBMGBA
GBAWidget* gba_widget = qobject_cast<GBAWidget*>(QApplication::activeWindow());
if (!gba_widget)
return;
if (IsHotkey(HK_GBA_LOAD))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->LoadROM(); });
if (IsHotkey(HK_GBA_UNLOAD))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->UnloadROM(); });
if (IsHotkey(HK_GBA_RESET))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->ResetCore(); });
if (IsHotkey(HK_GBA_VOLUME_DOWN))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->VolumeDown(); });
if (IsHotkey(HK_GBA_VOLUME_UP))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->VolumeUp(); });
if (IsHotkey(HK_GBA_TOGGLE_MUTE))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->ToggleMute(); });
if (IsHotkey(HK_GBA_1X))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(1); });
if (IsHotkey(HK_GBA_2X))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(2); });
if (IsHotkey(HK_GBA_3X))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(3); });
if (IsHotkey(HK_GBA_4X))
QueueOnObject(gba_widget, [gba_widget] { gba_widget->Resize(4); });
#endif
}