mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Qt/Core: Implement GBA Hotkeys
This commit is contained in:
@ -140,6 +140,8 @@ add_executable(dolphin-emu
|
||||
Config/Mapping/HotkeyControllerProfile.h
|
||||
Config/Mapping/HotkeyDebugging.cpp
|
||||
Config/Mapping/HotkeyDebugging.h
|
||||
Config/Mapping/HotkeyGBA.cpp
|
||||
Config/Mapping/HotkeyGBA.h
|
||||
Config/Mapping/HotkeyGeneral.cpp
|
||||
Config/Mapping/HotkeyGeneral.h
|
||||
Config/Mapping/HotkeyGraphics.cpp
|
||||
|
43
Source/Core/DolphinQt/Config/Mapping/HotkeyGBA.cpp
Normal file
43
Source/Core/DolphinQt/Config/Mapping/HotkeyGBA.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright 2021 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "DolphinQt/Config/Mapping/HotkeyGBA.h"
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "Core/HotkeyManager.h"
|
||||
|
||||
HotkeyGBA::HotkeyGBA(MappingWindow* window) : MappingWidget(window)
|
||||
{
|
||||
CreateMainLayout();
|
||||
}
|
||||
|
||||
void HotkeyGBA::CreateMainLayout()
|
||||
{
|
||||
m_main_layout = new QHBoxLayout();
|
||||
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(tr("Core"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GBA_CORE)));
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(tr("Volume"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GBA_VOLUME)));
|
||||
m_main_layout->addWidget(
|
||||
CreateGroupBox(tr("Window Size"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GBA_SIZE)));
|
||||
|
||||
setLayout(m_main_layout);
|
||||
}
|
||||
|
||||
InputConfig* HotkeyGBA::GetConfig()
|
||||
{
|
||||
return HotkeyManagerEmu::GetConfig();
|
||||
}
|
||||
|
||||
void HotkeyGBA::LoadSettings()
|
||||
{
|
||||
HotkeyManagerEmu::LoadConfig();
|
||||
}
|
||||
|
||||
void HotkeyGBA::SaveSettings()
|
||||
{
|
||||
HotkeyManagerEmu::GetConfig()->SaveConfig();
|
||||
}
|
25
Source/Core/DolphinQt/Config/Mapping/HotkeyGBA.h
Normal file
25
Source/Core/DolphinQt/Config/Mapping/HotkeyGBA.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2021 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||
|
||||
class QHBoxLayout;
|
||||
|
||||
class HotkeyGBA final : public MappingWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HotkeyGBA(MappingWindow* window);
|
||||
|
||||
InputConfig* GetConfig() override;
|
||||
|
||||
private:
|
||||
void LoadSettings() override;
|
||||
void SaveSettings() override;
|
||||
void CreateMainLayout();
|
||||
|
||||
// Main
|
||||
QHBoxLayout* m_main_layout;
|
||||
};
|
@ -30,6 +30,7 @@
|
||||
#include "DolphinQt/Config/Mapping/Hotkey3D.h"
|
||||
#include "DolphinQt/Config/Mapping/HotkeyControllerProfile.h"
|
||||
#include "DolphinQt/Config/Mapping/HotkeyDebugging.h"
|
||||
#include "DolphinQt/Config/Mapping/HotkeyGBA.h"
|
||||
#include "DolphinQt/Config/Mapping/HotkeyGeneral.h"
|
||||
#include "DolphinQt/Config/Mapping/HotkeyGraphics.h"
|
||||
#include "DolphinQt/Config/Mapping/HotkeyStates.h"
|
||||
@ -435,6 +436,7 @@ void MappingWindow::SetMappingType(MappingWindow::Type type)
|
||||
AddWidget(tr("3D"), new Hotkey3D(this));
|
||||
AddWidget(tr("Save and Load State"), new HotkeyStates(this));
|
||||
AddWidget(tr("Other State Management"), new HotkeyStatesOther(this));
|
||||
AddWidget(tr("GameBoy Advance"), new HotkeyGBA(this));
|
||||
setWindowTitle(tr("Hotkey Settings"));
|
||||
break;
|
||||
}
|
||||
|
@ -90,6 +90,7 @@
|
||||
<ClCompile Include="Config\Mapping\HotkeyControllerProfile.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyDebugging.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyGeneral.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyGBA.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyGraphics.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyStates.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyStatesOther.cpp" />
|
||||
@ -268,6 +269,7 @@
|
||||
<QtMoc Include="Config\Mapping\Hotkey3D.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyControllerProfile.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyDebugging.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyGBA.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyGeneral.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyGraphics.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyStates.h" />
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ signals:
|
||||
private:
|
||||
void Run();
|
||||
void CheckDebuggingHotkeys();
|
||||
void CheckGBAHotkeys();
|
||||
|
||||
Common::Flag m_stop_requested;
|
||||
std::thread m_thread;
|
||||
|
Reference in New Issue
Block a user