summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2026-10-31 16:17:25 +0100
committerGitHub <noreply@github.com>2026-10-31 16:17:25 +0100
commitc4856ead6420cceb48744815d79d6be59febb5ff (patch)
treebc662fe345ab37ebc861b1d013da411d06688729 /Source/Core
parent78a8ab40c3b28a6d477c9c6b6260dc3993cfe491 (diff)
parent9e6659a2d8c890d60be9a3609e4e55d3a75a1216 (diff)
Merge pull request #14878 from vhoxha08/add-global-hotkeys-android
Android: Add global hotkeys
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HotkeyManager.cpp2
-rw-r--r--Source/Core/Core/State.cpp41
-rw-r--r--Source/Core/Core/State.h11
-rw-r--r--Source/Core/DolphinQt/MainWindow.cpp24
-rw-r--r--Source/Core/DolphinQt/MainWindow.h1
5 files changed, 61 insertions, 18 deletions
diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp
index 915dc0d6d7..4f3e4d8739 100644
--- a/Source/Core/Core/HotkeyManager.cpp
+++ b/Source/Core/Core/HotkeyManager.cpp
@@ -396,6 +396,7 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
{
EmulatedController::LoadDefaults(ciface);
+#ifndef ANDROID
auto set_key_expression = [this](int index, const std::string& expression) {
m_keys[FindGroupByID(index)]
->controls[GetIndexForGroup(FindGroupByID(index), index)]
@@ -473,4 +474,5 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
set_key_expression(HK_SKYLANDERS_PORTAL, hotkey_string({"Ctrl", "P"}));
set_key_expression(HK_INFINITY_BASE, hotkey_string({"Ctrl", "I"}));
+#endif
}
diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp
index cecda5f4e8..952a23ffaa 100644
--- a/Source/Core/Core/State.cpp
+++ b/Source/Core/Core/State.cpp
@@ -78,6 +78,8 @@ static Common::UniqueBuffer<u8> s_undo_load_buffer;
// Used to estimate buffer size for the next save.
static u32 s_last_state_size = 0;
+static u32 s_selected_slot = 1;
+
// Shared locks are acquired for each state save task.
// Tasks generally transition from: Calling thread -> CPU thread -> Compress/Write thread.
// Holding an "exclusive" lock will:
@@ -913,6 +915,45 @@ void Load(Core::System& system, u32 slot)
LoadAs(system, MakeStateFilename(slot));
}
+u32 GetSelectedSlot()
+{
+ return s_selected_slot;
+}
+
+void SetSelectedSlot(u32 slot)
+{
+ s_selected_slot = std::clamp<u32>(slot, 1, NUM_STATES);
+}
+
+void SelectSlot(u32 slot)
+{
+ SetSelectedSlot(slot);
+
+ Core::DisplayMessage(fmt::format("Selected slot {} - {}", s_selected_slot,
+ GetInfoStringOfSlot(s_selected_slot, false)),
+ 2500);
+}
+
+u32 GetNextSlot()
+{
+ return s_selected_slot >= NUM_STATES ? 1 : s_selected_slot + 1;
+}
+
+u32 GetPreviousSlot()
+{
+ return s_selected_slot <= 1 ? NUM_STATES : s_selected_slot - 1;
+}
+
+void SaveSelected(Core::System& system)
+{
+ Save(system, s_selected_slot);
+}
+
+void LoadSelected(Core::System& system)
+{
+ Load(system, s_selected_slot);
+}
+
void LoadLastSaved(Core::System& system, int i)
{
if (!CheckIfStateLoadIsAllowed(system))
diff --git a/Source/Core/Core/State.h b/Source/Core/Core/State.h
index cd35ea1af0..e1bf3384a1 100644
--- a/Source/Core/Core/State.h
+++ b/Source/Core/Core/State.h
@@ -95,6 +95,17 @@ u64 GetUnixTimeOfSlot(u32 slot);
void Save(Core::System& system, u32 slot);
void Load(Core::System& system, u32 slot);
+u32 GetSelectedSlot();
+void SetSelectedSlot(u32 slot);
+
+void SelectSlot(u32 slot);
+
+u32 GetNextSlot();
+u32 GetPreviousSlot();
+
+void SaveSelected(Core::System& system);
+void LoadSelected(Core::System& system);
+
void SaveAs(Core::System& system, std::string filename);
void LoadAs(Core::System& system, std::string filename);
diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp
index 688ae6ffcd..7905402013 100644
--- a/Source/Core/DolphinQt/MainWindow.cpp
+++ b/Source/Core/DolphinQt/MainWindow.cpp
@@ -297,8 +297,8 @@ MainWindow::MainWindow(Core::System& system, std::unique_ptr<BootParameters> boo
}
}
- m_state_slot =
- std::clamp(Settings::Instance().GetStateSlot(), 1, static_cast<int>(State::NUM_STATES));
+ State::SetSelectedSlot(
+ std::clamp(Settings::Instance().GetStateSlot(), 1, static_cast<int>(State::NUM_STATES)));
m_render_widget_geometry = settings.value(QStringLiteral("renderwidget/geometry")).toByteArray();
@@ -1531,12 +1531,12 @@ void MainWindow::StateSave()
void MainWindow::StateLoadSlot()
{
- State::Load(m_system, m_state_slot);
+ State::LoadSelected(m_system);
}
void MainWindow::StateSaveSlot()
{
- State::Save(m_system, m_state_slot);
+ State::SaveSelected(m_system);
}
void MainWindow::StateLoadSlotAt(int slot)
@@ -1572,27 +1572,17 @@ void MainWindow::StateSaveOldest()
void MainWindow::SetStateSlot(int slot)
{
Settings::Instance().SetStateSlot(slot);
- m_state_slot = slot;
-
- Core::DisplayMessage(fmt::format("Selected slot {} - {}", m_state_slot,
- State::GetInfoStringOfSlot(m_state_slot, false)),
- 2500);
+ State::SelectSlot(slot);
}
void MainWindow::IncrementSelectedStateSlot()
{
- u32 state_slot = m_state_slot + 1;
- if (state_slot > State::NUM_STATES)
- state_slot = 1;
- m_menu_bar->SetStateSlot(state_slot);
+ m_menu_bar->SetStateSlot(State::GetNextSlot());
}
void MainWindow::DecrementSelectedStateSlot()
{
- u32 state_slot = m_state_slot - 1;
- if (state_slot < 1)
- state_slot = State::NUM_STATES;
- m_menu_bar->SetStateSlot(state_slot);
+ m_menu_bar->SetStateSlot(State::GetPreviousSlot());
}
void MainWindow::PerformOnlineUpdate(const std::string& region)
diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h
index 93490eaad6..c342dc0a65 100644
--- a/Source/Core/DolphinQt/MainWindow.h
+++ b/Source/Core/DolphinQt/MainWindow.h
@@ -250,7 +250,6 @@ private:
bool m_exit_requested = false;
bool m_fullscreen_requested = false;
bool m_is_screensaver_inhibited = false;
- u32 m_state_slot = 1;
std::unique_ptr<BootParameters> m_pending_boot;
SettingsWindow* m_settings_window = nullptr;