diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 82d5c51b8b..2a161bdf45 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -20,7 +20,7 @@ #include "InputCommon/GCPadStatus.h" // clang-format off -constexpr std::array s_hotkey_labels{{ +constexpr std::array s_hotkey_labels{{ _trans("Open"), _trans("Change Disc"), _trans("Eject Disc"), @@ -31,6 +31,7 @@ constexpr std::array s_hotkey_labels{{ _trans("Toggle Fullscreen"), _trans("Take Screenshot"), _trans("Exit"), + _trans("Activate NetPlay Chat"), _trans("Volume Down"), _trans("Volume Up"), @@ -274,7 +275,7 @@ struct HotkeyGroupInfo }; constexpr std::array s_groups_info = { - {{_trans("General"), HK_OPEN, HK_EXIT}, + {{_trans("General"), HK_OPEN, HK_ACTIVATE_CHAT}, {_trans("Volume"), HK_VOLUME_DOWN, HK_VOLUME_TOGGLE_MUTE}, {_trans("Emulation Speed"), HK_DECREASE_EMULATION_SPEED, HK_TOGGLE_THROTTLE}, {_trans("Frame Advance"), HK_FRAME_ADVANCE, HK_FRAME_ADVANCE_RESET_SPEED}, diff --git a/Source/Core/Core/HotkeyManager.h b/Source/Core/Core/HotkeyManager.h index 24ffe4eb58..3dbb88ce9b 100644 --- a/Source/Core/Core/HotkeyManager.h +++ b/Source/Core/Core/HotkeyManager.h @@ -29,6 +29,7 @@ enum Hotkey HK_FULLSCREEN, HK_SCREENSHOT, HK_EXIT, + HK_ACTIVATE_CHAT, HK_VOLUME_DOWN, HK_VOLUME_UP, diff --git a/Source/Core/DolphinQt/HotkeyScheduler.cpp b/Source/Core/DolphinQt/HotkeyScheduler.cpp index 7cab2eb8a7..956de04486 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt/HotkeyScheduler.cpp @@ -196,6 +196,10 @@ void HotkeyScheduler::Run() auto& settings = Settings::Instance(); + // Toggle Chat + if (IsHotkey(HK_ACTIVATE_CHAT)) + emit ActivateChat(); + // Recording if (IsHotkey(HK_START_RECORDING)) emit StartRecording(); diff --git a/Source/Core/DolphinQt/HotkeyScheduler.h b/Source/Core/DolphinQt/HotkeyScheduler.h index 998bda3a02..ca5aee36ec 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.h +++ b/Source/Core/DolphinQt/HotkeyScheduler.h @@ -26,6 +26,7 @@ signals: void ChangeDisc(); void ExitHotkey(); + void ActivateChat(); void FullScreenHotkey(); void StopHotkey(); void ResetHotkey(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index f4526ee49c..577e525b81 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -106,6 +106,7 @@ #include "UICommon/UICommon.h" +#include "VideoCommon/NetPlayChatUI.h" #include "VideoCommon/VideoConfig.h" #if defined(HAVE_XRANDR) && HAVE_XRANDR @@ -482,6 +483,7 @@ void MainWindow::ConnectHotkeys() connect(m_hotkey_scheduler, &HotkeyScheduler::EjectDisc, this, &MainWindow::EjectDisc); connect(m_hotkey_scheduler, &HotkeyScheduler::ExitHotkey, this, &MainWindow::close); connect(m_hotkey_scheduler, &HotkeyScheduler::TogglePauseHotkey, this, &MainWindow::TogglePause); + connect(m_hotkey_scheduler, &HotkeyScheduler::ActivateChat, this, &MainWindow::OnActivateChat); connect(m_hotkey_scheduler, &HotkeyScheduler::RefreshGameListHotkey, this, &MainWindow::RefreshGameList); connect(m_hotkey_scheduler, &HotkeyScheduler::StopHotkey, this, &MainWindow::RequestStop); @@ -1587,6 +1589,12 @@ void MainWindow::OnExportRecording() Core::SetState(Core::State::Running); } +void MainWindow::OnActivateChat() +{ + if (g_netplay_chat_ui) + g_netplay_chat_ui->Activate(); +} + void MainWindow::ShowTASInput() { for (int i = 0; i < num_gc_controllers; i++) diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index 4c5224fb6a..f2ac8f512f 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -168,6 +168,7 @@ private: void OnStartRecording(); void OnStopRecording(); void OnExportRecording(); + void OnActivateChat(); void ShowTASInput(); void ChangeDisc(); diff --git a/Source/Core/VideoCommon/NetPlayChatUI.cpp b/Source/Core/VideoCommon/NetPlayChatUI.cpp index 2388d94b91..7587229ee0 100644 --- a/Source/Core/VideoCommon/NetPlayChatUI.cpp +++ b/Source/Core/VideoCommon/NetPlayChatUI.cpp @@ -60,7 +60,12 @@ void NetPlayChatUI::Display() ImGuiInputTextFlags_EnterReturnsTrue)) { SendMessage(); + } + + if (m_activate) + { ImGui::SetKeyboardFocusHere(-1); + m_activate = false; } ImGui::PopItemWidth(); @@ -97,3 +102,11 @@ void NetPlayChatUI::SendMessage() m_message_buf[0] = '\0'; } } + +void NetPlayChatUI::Activate() +{ + if (ImGui::IsItemFocused()) + ImGui::SetWindowFocus(NULL); + else + m_activate = true; +} diff --git a/Source/Core/VideoCommon/NetPlayChatUI.h b/Source/Core/VideoCommon/NetPlayChatUI.h index c355aa462d..baef71329b 100644 --- a/Source/Core/VideoCommon/NetPlayChatUI.h +++ b/Source/Core/VideoCommon/NetPlayChatUI.h @@ -22,10 +22,12 @@ public: void Display(); void AppendChat(const std::string& message, Color color); void SendMessage(); + void Activate(); private: char m_message_buf[256] = {}; bool m_scroll_to_bottom = false; + bool m_activate = false; bool m_is_scrolled_to_bottom = true; std::deque> m_messages;