From b0bd4b8cfeb0eb4501ac47d81953cdd5e253bba0 Mon Sep 17 00:00:00 2001 From: soaresden <54243866+soaresden@users.noreply.github.com> Date: Sat, 17 Apr 2021 17:02:00 +0200 Subject: [PATCH 1/2] Adding Shortcut to Change Disc Adding ShortCut to F8 simplifying simplifying the code --- src/frontend-common/common_host_interface.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index a9a676ea3..05002d843 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -35,6 +35,7 @@ #include #include #include +#include "fullscreen_ui.h" #ifdef WITH_SDL2 #include "sdl_audio_stream.h" @@ -54,6 +55,7 @@ #include #include #endif +#include Log_SetChannel(CommonHostInterface); @@ -1869,6 +1871,17 @@ void CommonHostInterface::RegisterGeneralHotkeys() SaveScreenshot(); }); + RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ChangeDisc"), + StaticString(TRANSLATABLE("Hotkeys", "ChangeDisc")), [this](bool pressed) { + if (pressed && System::IsValid()) + { + int current = System::GetMediaSubImageIndex(); + int next = (current + 1) % System::GetMediaSubImageCount(); + if (current != next) + System::SwitchMediaSubImage(static_cast(next)); + } + }); + RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("FrameStep"), StaticString(TRANSLATABLE("Hotkeys", "Frame Step")), [this](bool pressed) { if (pressed && System::IsValid()) @@ -2550,6 +2563,7 @@ void CommonHostInterface::SetDefaultSettings(SettingsInterface& si) si.SetStringValue("Hotkeys", "IncreaseResolutionScale", "Keyboard/PageUp"); si.SetStringValue("Hotkeys", "DecreaseResolutionScale", "Keyboard/PageDown"); si.SetStringValue("Hotkeys", "ToggleSoftwareRendering", "Keyboard/End"); + si.SetStringValue("Hotkeys", "ChangeDisc", "Keyboard/F8"); si.SetStringValue("Main", "ControllerBackend", ControllerInterface::GetBackendName(ControllerInterface::GetDefaultBackend())); From 64bd840195cafb7c41fe71b833692edfe19ef355 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 18 Apr 2021 13:52:17 +1000 Subject: [PATCH 2/2] Update common_host_interface.cpp --- src/frontend-common/common_host_interface.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 05002d843..cdeeb3d7d 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -35,7 +35,6 @@ #include #include #include -#include "fullscreen_ui.h" #ifdef WITH_SDL2 #include "sdl_audio_stream.h" @@ -55,7 +54,6 @@ #include #include #endif -#include Log_SetChannel(CommonHostInterface); @@ -1871,14 +1869,14 @@ void CommonHostInterface::RegisterGeneralHotkeys() SaveScreenshot(); }); - RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ChangeDisc"), + RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ChangeDisc"), StaticString(TRANSLATABLE("Hotkeys", "ChangeDisc")), [this](bool pressed) { - if (pressed && System::IsValid()) + if (pressed && System::IsValid() && System::HasMediaSubImages()) { - int current = System::GetMediaSubImageIndex(); - int next = (current + 1) % System::GetMediaSubImageCount(); + const u32 current = System::GetMediaSubImageIndex(); + const u32 next = (current + 1) % System::GetMediaSubImageCount(); if (current != next) - System::SwitchMediaSubImage(static_cast(next)); + System::SwitchMediaSubImage(next); } });