Merge pull request #3594 from valentinvanelslande/hotkeys

citra_qt: Add Continue/Pause & Toggle Speed Limit hotkeys
This commit is contained in:
James Rowe 2018-05-29 22:19:23 -06:00 committed by GitHub
commit 0095c20b8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -304,11 +304,14 @@ void GMainWindow::InitializeRecentFileMenuActions() {
void GMainWindow::InitializeHotkeys() { void GMainWindow::InitializeHotkeys() {
RegisterHotkey("Main Window", "Load File", QKeySequence::Open); RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
RegisterHotkey("Main Window", "Start Emulation"); RegisterHotkey("Main Window", "Start Emulation");
RegisterHotkey("Main Window", "Swap Screens", QKeySequence("F9")); RegisterHotkey("Main Window", "Continue/Pause", QKeySequence(Qt::Key_F4));
RegisterHotkey("Main Window", "Toggle Screen Layout", QKeySequence("F10")); RegisterHotkey("Main Window", "Swap Screens", QKeySequence(tr("F9")));
RegisterHotkey("Main Window", "Toggle Screen Layout", QKeySequence(tr("F10")));
RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen); RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen);
RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape), RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape),
Qt::ApplicationShortcut); Qt::ApplicationShortcut);
RegisterHotkey("Main Window", "Toggle Speed Limit", QKeySequence("CTRL+Z"),
Qt::ApplicationShortcut);
RegisterHotkey("Main Window", "Increase Speed Limit", QKeySequence("+"), RegisterHotkey("Main Window", "Increase Speed Limit", QKeySequence("+"),
Qt::ApplicationShortcut); Qt::ApplicationShortcut);
RegisterHotkey("Main Window", "Decrease Speed Limit", QKeySequence("-"), RegisterHotkey("Main Window", "Decrease Speed Limit", QKeySequence("-"),
@ -319,6 +322,15 @@ void GMainWindow::InitializeHotkeys() {
&GMainWindow::OnMenuLoadFile); &GMainWindow::OnMenuLoadFile);
connect(GetHotkey("Main Window", "Start Emulation", this), &QShortcut::activated, this, connect(GetHotkey("Main Window", "Start Emulation", this), &QShortcut::activated, this,
&GMainWindow::OnStartGame); &GMainWindow::OnStartGame);
connect(GetHotkey("Main Window", "Continue/Pause", this), &QShortcut::activated, this, [&] {
if (emulation_running) {
if (emu_thread->IsRunning()) {
OnPauseGame();
} else {
OnStartGame();
}
}
});
connect(GetHotkey("Main Window", "Swap Screens", render_window), &QShortcut::activated, connect(GetHotkey("Main Window", "Swap Screens", render_window), &QShortcut::activated,
ui.action_Screen_Layout_Swap_Screens, &QAction::trigger); ui.action_Screen_Layout_Swap_Screens, &QAction::trigger);
connect(GetHotkey("Main Window", "Toggle Screen Layout", render_window), &QShortcut::activated, connect(GetHotkey("Main Window", "Toggle Screen Layout", render_window), &QShortcut::activated,
@ -333,6 +345,10 @@ void GMainWindow::InitializeHotkeys() {
ToggleFullscreen(); ToggleFullscreen();
} }
}); });
connect(GetHotkey("Main Window", "Toggle Speed Limit", this), &QShortcut::activated, this, [&] {
Settings::values.use_frame_limit = !Settings::values.use_frame_limit;
UpdateStatusBar();
});
constexpr u16 SPEED_LIMIT_STEP = 5; constexpr u16 SPEED_LIMIT_STEP = 5;
connect(GetHotkey("Main Window", "Increase Speed Limit", this), &QShortcut::activated, this, connect(GetHotkey("Main Window", "Increase Speed Limit", this), &QShortcut::activated, this,
[&] { [&] {