From feb0ea245ee78374fce25421fe85fe5b97d78755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 23 Aug 2023 22:14:51 +0200 Subject: [PATCH] Add mappable key to toggle networking Fixes #17352 Requested in #17343 --- Common/System/OSD.cpp | 11 +++++------ Core/KeyMap.cpp | 2 ++ Core/KeyMap.h | 1 + UI/EmuScreen.cpp | 10 ++++++++++ assets/lang/en_US.ini | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Common/System/OSD.cpp b/Common/System/OSD.cpp index 73fb2bf3c7..5b2972caa0 100644 --- a/Common/System/OSD.cpp +++ b/Common/System/OSD.cpp @@ -91,6 +91,11 @@ void OnScreenDisplay::Show(OSDType type, const std::string &text, const std::str entries_.insert(entries_.begin(), msg); } +void OnScreenDisplay::ShowOnOff(const std::string &message, bool on, float duration_s) { + // TODO: translate "on" and "off"? Or just get rid of this whole thing? + Show(OSDType::MESSAGE_INFO, message + ": " + (on ? "on" : "off"), duration_s); +} + void OnScreenDisplay::ShowAchievementUnlocked(int achievementID) { double now = time_now_d(); @@ -201,18 +206,12 @@ void OnScreenDisplay::ShowLeaderboardTracker(int leaderboardTrackerID, const cha void OnScreenDisplay::ShowLeaderboardStartEnd(const std::string &title, const std::string &description, bool started) { g_OSD.Show(OSDType::LEADERBOARD_STARTED_FAILED, title, description, 3.0f); - } void OnScreenDisplay::ShowLeaderboardSubmitted(const std::string &title, const std::string &value) { g_OSD.Show(OSDType::MESSAGE_SUCCESS, title, value, 3.0f); } -void OnScreenDisplay::ShowOnOff(const std::string &message, bool on, float duration_s) { - // TODO: translate "on" and "off"? Or just get rid of this whole thing? - Show(OSDType::MESSAGE_INFO, message + ": " + (on ? "on" : "off"), duration_s); -} - void OnScreenDisplay::SetProgressBar(std::string id, std::string &&message, float minValue, float maxValue, float progress, float delay) { _dbg_assert_(!my_isnanorinf(progress)); _dbg_assert_(!my_isnanorinf(minValue)); diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index b86644dd97..e3a135a15a 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -431,6 +431,8 @@ const KeyMap_IntStrPair psp_button_names[] = { {VIRTKEY_SCREEN_ROTATION_HORIZONTAL180, "Display Landscape Reversed"}, #endif + {VIRTKEY_TOGGLE_WLAN, "Toggle WLAN"}, + {CTRL_HOME, "Home"}, {CTRL_HOLD, "Hold"}, {CTRL_WLAN, "Wlan"}, diff --git a/Core/KeyMap.h b/Core/KeyMap.h index 660c907652..c9ae1c333d 100644 --- a/Core/KeyMap.h +++ b/Core/KeyMap.h @@ -72,6 +72,7 @@ enum { VIRTKEY_VR_CAMERA_ADJUST = 0x40000025, VIRTKEY_VR_CAMERA_RESET = 0x40000026, VIRTKEY_PREVIOUS_SLOT = 0x40000027, + VIRTKEY_TOGGLE_WLAN = 0x40000028, VIRTKEY_LAST, VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST }; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 4ecbb02402..5e517e1fc8 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -794,6 +794,16 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) { if (down) g_Config.iInternalScreenRotation = ROTATION_LOCKED_HORIZONTAL180; break; + case VIRTKEY_TOGGLE_WLAN: + if (down) { + auto n = GetI18NCategory(I18NCat::NETWORKING); + auto di = GetI18NCategory(I18NCat::DIALOG); + g_Config.bEnableWlan = !g_Config.bEnableWlan; + // Try to avoid adding more strings so we piece together a message from existing ones. + g_OSD.Show(OSDType::MESSAGE_INFO, StringFromFormat( + "%s: %s", n->T("Enable networking"), g_Config.bEnableWlan ? di->T("Enabled") : di->T("Disabled")), 2.0, "toggle_wlan"); + } + break; } } diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index df40b93a1e..ccae3be914 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -804,6 +804,7 @@ Texture Dumping = Texture dumping Texture Replacement = Texture replacement Toggle Fullscreen = Toggle fullscreen Toggle mode = Toggle mode +Toggle WLAN = Toggle WLAN Triangle = Triangle Fast-forward = Fast-forward Up = Dpad Up