mirror of https://github.com/PCSX2/pcsx2.git
Qt: Move hotkeys to VMManager, remove sorting
This commit is contained in:
parent
e87d507c0c
commit
9269792a8c
|
@ -37,7 +37,6 @@
|
|||
#include "pcsx2/HostSettings.h"
|
||||
#include "pcsx2/PAD/Host/PAD.h"
|
||||
#include "pcsx2/PerformanceMetrics.h"
|
||||
#include "pcsx2/Recording/InputRecordingControls.h"
|
||||
#include "pcsx2/VMManager.h"
|
||||
|
||||
#include "DisplayWidget.h"
|
||||
|
@ -148,10 +147,6 @@ void EmuThread::setVMPaused(bool paused)
|
|||
return;
|
||||
}
|
||||
|
||||
// if we were surfaceless (view->game list, system->unpause), get our display widget back
|
||||
if (!paused && m_is_surfaceless)
|
||||
setSurfaceless(false);
|
||||
|
||||
VMManager::SetPaused(paused);
|
||||
}
|
||||
|
||||
|
@ -844,6 +839,11 @@ void Host::OnVMResumed()
|
|||
// exit the event loop when we eventually return
|
||||
g_emu_thread->getEventLoop()->quit();
|
||||
g_emu_thread->stopBackgroundControllerPollTimer();
|
||||
|
||||
// if we were surfaceless (view->game list, system->unpause), get our display widget back
|
||||
if (g_emu_thread->isSurfaceless())
|
||||
g_emu_thread->setSurfaceless(false);
|
||||
|
||||
emit g_emu_thread->onVMResumed();
|
||||
}
|
||||
|
||||
|
@ -1001,10 +1001,14 @@ void Host::RequestExit(bool save_state_if_running)
|
|||
QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void Host::RequestVMShutdown(bool save_state)
|
||||
void Host::RequestVMShutdown(bool allow_confirm, bool allow_save_state)
|
||||
{
|
||||
if (VMManager::HasValidVM())
|
||||
g_emu_thread->shutdownVM(save_state);
|
||||
if (!VMManager::HasValidVM())
|
||||
return;
|
||||
|
||||
// Run it on the host thread, that way we get the confirm prompt (if enabled).
|
||||
QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection,
|
||||
Q_ARG(bool, allow_confirm), Q_ARG(bool, allow_save_state), Q_ARG(bool, false));
|
||||
}
|
||||
|
||||
bool Host::IsFullscreen()
|
||||
|
@ -1029,27 +1033,4 @@ SysMtgsThread& GetMTGS()
|
|||
// ------------------------------------------------------------------------
|
||||
|
||||
BEGIN_HOTKEY_LIST(g_host_hotkeys)
|
||||
DEFINE_HOTKEY("ShutdownVM", "System", "Shut Down Virtual Machine", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
{
|
||||
// run it on the host thread, that way we get the confirm prompt (if enabled)
|
||||
QMetaObject::invokeMethod(g_main_window, "requestShutdown", Qt::QueuedConnection,
|
||||
Q_ARG(bool, true), Q_ARG(bool, true), Q_ARG(bool, true));
|
||||
}
|
||||
})
|
||||
DEFINE_HOTKEY("TogglePause", "System", "Toggle Pause", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
g_emu_thread->setVMPaused(VMManager::GetState() != VMState::Paused);
|
||||
})
|
||||
DEFINE_HOTKEY("ToggleFullscreen", "General", "Toggle Fullscreen", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
g_emu_thread->toggleFullscreen();
|
||||
})
|
||||
// Input Recording Hot Keys
|
||||
DEFINE_HOTKEY("InputRecToggleMode", "Input Recording", "Toggle Recording Mode", [](s32 pressed) {
|
||||
if (!pressed) // ?? - not pressed so it is on key up?
|
||||
{
|
||||
g_InputRecordingControls.RecordModeToggle();
|
||||
}
|
||||
})
|
||||
END_HOTKEY_LIST()
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
__fi QEventLoop* getEventLoop() const { return m_event_loop; }
|
||||
__fi bool isFullscreen() const { return m_is_fullscreen; }
|
||||
__fi bool isRenderingToMain() const { return m_is_rendering_to_main; }
|
||||
__fi bool isSurfaceless() const { return m_is_surfaceless; }
|
||||
|
||||
bool isOnEmuThread() const;
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ static std::array<std::unique_ptr<InputSource>, static_cast<u32>(InputSourceType
|
|||
// ------------------------------------------------------------------------
|
||||
// Hotkeys
|
||||
// ------------------------------------------------------------------------
|
||||
static const HotkeyInfo* const s_hotkey_list[] = {g_vm_manager_hotkeys, g_gs_hotkeys, g_host_hotkeys};
|
||||
static const HotkeyInfo* const s_hotkey_list[] = {g_host_hotkeys, g_vm_manager_hotkeys, g_gs_hotkeys};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tracking host mouse movement and turning into relative events
|
||||
|
@ -496,12 +496,6 @@ std::vector<const HotkeyInfo*> InputManager::GetHotkeyList()
|
|||
for (const HotkeyInfo* hotkey = hotkey_list; hotkey->name != nullptr; hotkey++)
|
||||
ret.push_back(hotkey);
|
||||
}
|
||||
std::sort(ret.begin(), ret.end(), [](const HotkeyInfo* left, const HotkeyInfo* right) {
|
||||
// category -> display name
|
||||
if (const int res = StringUtil::Strcasecmp(left->category, right->category); res != 0)
|
||||
return (res < 0);
|
||||
return (StringUtil::Strcasecmp(left->display_name, right->display_name) < 0);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "PAD/Host/PAD.h"
|
||||
#include "Sio.h"
|
||||
#include "ps2/BiosTools.h"
|
||||
#include "Recording/InputRecordingControls.h"
|
||||
|
||||
#include "DebugTools/MIPSAnalyst.h"
|
||||
#include "DebugTools/SymbolMap.h"
|
||||
|
@ -1721,6 +1722,14 @@ static void HotkeySaveStateSlot(s32 slot)
|
|||
}
|
||||
|
||||
BEGIN_HOTKEY_LIST(g_vm_manager_hotkeys)
|
||||
DEFINE_HOTKEY("TogglePause", "System", "Toggle Pause", [](s32 pressed) {
|
||||
if (!pressed && VMManager::HasValidVM())
|
||||
VMManager::SetPaused(VMManager::GetState() != VMState::Paused);
|
||||
})
|
||||
DEFINE_HOTKEY("ToggleFullscreen", "System", "Toggle Fullscreen", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
Host::SetFullscreen(Host::IsFullscreen());
|
||||
})
|
||||
DEFINE_HOTKEY("ToggleFrameLimit", "System", "Toggle Frame Limit", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
{
|
||||
|
@ -1737,20 +1746,6 @@ DEFINE_HOTKEY("ToggleTurbo", "System", "Toggle Turbo", [](s32 pressed) {
|
|||
LimiterModeType::Nominal);
|
||||
}
|
||||
})
|
||||
DEFINE_HOTKEY("HoldTurbo", "System", "Turbo (Hold)", [](s32 pressed) {
|
||||
if (pressed > 0 && !s_limiter_mode_prior_to_hold_interaction.has_value())
|
||||
{
|
||||
s_limiter_mode_prior_to_hold_interaction = VMManager::GetLimiterMode();
|
||||
VMManager::SetLimiterMode((s_limiter_mode_prior_to_hold_interaction.value() != LimiterModeType::Turbo) ?
|
||||
LimiterModeType::Turbo :
|
||||
LimiterModeType::Nominal);
|
||||
}
|
||||
else if (pressed >= 0 && s_limiter_mode_prior_to_hold_interaction.has_value())
|
||||
{
|
||||
VMManager::SetLimiterMode(s_limiter_mode_prior_to_hold_interaction.value());
|
||||
s_limiter_mode_prior_to_hold_interaction.reset();
|
||||
}
|
||||
})
|
||||
DEFINE_HOTKEY("ToggleSlowMotion", "System", "Toggle Slow Motion", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
{
|
||||
|
@ -1759,6 +1754,20 @@ DEFINE_HOTKEY("ToggleSlowMotion", "System", "Toggle Slow Motion", [](s32 pressed
|
|||
LimiterModeType::Nominal);
|
||||
}
|
||||
})
|
||||
DEFINE_HOTKEY("HoldTurbo", "System", "Turbo (Hold)", [](s32 pressed) {
|
||||
if (pressed > 0 && !s_limiter_mode_prior_to_hold_interaction.has_value())
|
||||
{
|
||||
s_limiter_mode_prior_to_hold_interaction = VMManager::GetLimiterMode();
|
||||
VMManager::SetLimiterMode((s_limiter_mode_prior_to_hold_interaction.value() != LimiterModeType::Turbo) ?
|
||||
LimiterModeType::Turbo :
|
||||
LimiterModeType::Nominal);
|
||||
}
|
||||
else if (pressed >= 0 && s_limiter_mode_prior_to_hold_interaction.has_value())
|
||||
{
|
||||
VMManager::SetLimiterMode(s_limiter_mode_prior_to_hold_interaction.value());
|
||||
s_limiter_mode_prior_to_hold_interaction.reset();
|
||||
}
|
||||
})
|
||||
DEFINE_HOTKEY("IncreaseSpeed", "System", "Increase Target Speed", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
HotkeyAdjustTargetSpeed(0.1);
|
||||
|
@ -1767,13 +1776,21 @@ DEFINE_HOTKEY("DecreaseSpeed", "System", "Decrease Target Speed", [](s32 pressed
|
|||
if (!pressed)
|
||||
HotkeyAdjustTargetSpeed(-0.1);
|
||||
})
|
||||
DEFINE_HOTKEY("FrameAdvance", "System", "Frame Advance", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
VMManager::FrameAdvance(1);
|
||||
})
|
||||
DEFINE_HOTKEY("ShutdownVM", "System", "Shut Down Virtual Machine", [](s32 pressed) {
|
||||
if (!pressed && VMManager::HasValidVM())
|
||||
Host::RequestVMShutdown(true, true);
|
||||
})
|
||||
DEFINE_HOTKEY("ResetVM", "System", "Reset Virtual Machine", [](s32 pressed) {
|
||||
if (!pressed && VMManager::HasValidVM())
|
||||
VMManager::Reset();
|
||||
})
|
||||
DEFINE_HOTKEY("FrameAdvance", "System", "Frame Advance", [](s32 pressed) {
|
||||
DEFINE_HOTKEY("InputRecToggleMode", "System", "Toggle Input Recording Mode", [](s32 pressed) {
|
||||
if (!pressed)
|
||||
VMManager::FrameAdvance(1);
|
||||
g_InputRecordingControls.RecordModeToggle();
|
||||
})
|
||||
|
||||
DEFINE_HOTKEY("PreviousSaveStateSlot", "Save States", "Select Previous Save Slot", [](s32 pressed) {
|
||||
|
@ -1793,34 +1810,33 @@ DEFINE_HOTKEY("LoadStateFromSlot", "Save States", "Load State From Selected Slot
|
|||
HotkeyLoadStateSlot(s_current_save_slot);
|
||||
})
|
||||
|
||||
#define DEFINE_HOTKEY_SAVESTATE_X(slotnum, slotnumstr) DEFINE_HOTKEY("SaveStateToSlot" #slotnum, \
|
||||
"Save States", "Save State To Slot " #slotnumstr, [](s32 pressed) { if (!pressed) HotkeySaveStateSlot(slotnum); })
|
||||
DEFINE_HOTKEY_SAVESTATE_X(1, 01)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(2, 02)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(3, 03)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(4, 04)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(5, 05)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(6, 06)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(7, 07)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(8, 08)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(9, 09)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(10, 10)
|
||||
#define DEFINE_HOTKEY_LOADSTATE_X(slotnum, slotnumstr) DEFINE_HOTKEY("LoadStateFromSlot" #slotnum, \
|
||||
"Save States", "Load State From Slot " #slotnumstr, [](s32 pressed) { \
|
||||
#define DEFINE_HOTKEY_SAVESTATE_X(slotnum) DEFINE_HOTKEY("SaveStateToSlot" #slotnum, \
|
||||
"Save States", "Save State To Slot " #slotnum, [](s32 pressed) { if (!pressed) HotkeySaveStateSlot(slotnum); })
|
||||
#define DEFINE_HOTKEY_LOADSTATE_X(slotnum) DEFINE_HOTKEY("LoadStateFromSlot" #slotnum, \
|
||||
"Save States", "Load State From Slot " #slotnum, [](s32 pressed) { \
|
||||
if (!pressed) \
|
||||
HotkeyLoadStateSlot(slotnum); \
|
||||
})
|
||||
DEFINE_HOTKEY_LOADSTATE_X(1, 01)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(2, 02)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(3, 03)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(4, 04)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(5, 05)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(6, 06)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(7, 07)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(8, 08)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(9, 09)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(10, 10)
|
||||
|
||||
DEFINE_HOTKEY_SAVESTATE_X(1)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(1)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(2)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(2)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(3)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(3)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(4)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(4)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(5)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(5)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(6)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(6)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(7)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(7)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(8)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(8)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(9)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(9)
|
||||
DEFINE_HOTKEY_SAVESTATE_X(10)
|
||||
DEFINE_HOTKEY_LOADSTATE_X(10)
|
||||
#undef DEFINE_HOTKEY_SAVESTATE_X
|
||||
#undef DEFINE_HOTKEY_LOADSTATE_X
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ namespace Host
|
|||
void RequestExit(bool save_state_if_running);
|
||||
|
||||
/// Requests shut down of the current virtual machine.
|
||||
void RequestVMShutdown(bool save_state);
|
||||
void RequestVMShutdown(bool allow_confirm, bool allow_save_state);
|
||||
|
||||
/// Returns true if the hosting application is currently fullscreen.
|
||||
bool IsFullscreen();
|
||||
|
|
Loading…
Reference in New Issue