diff --git a/src/localization/localization.h b/src/localization/localization.h index b3d8441..9ba5fb0 100644 --- a/src/localization/localization.h +++ b/src/localization/localization.h @@ -28,6 +28,8 @@ static std::vector exit_fullscreen = {u8" 退出全屏", " Exit fullscreen"}; static std::vector control_mouse = {u8" 控制", " Control"}; static std::vector release_mouse = {u8" 释放", " Release"}; +static std::vector audio_capture = {u8" 声音", " Audio"}; +static std::vector mute = {u8" 静音", " Mute"}; static std::vector settings = {u8"设置", "Settings"}; static std::vector language = {u8"语言:", "Language:"}; static std::vector language_zh = {u8"中文", "Chinese"}; diff --git a/src/single_window/control_bar.cpp b/src/single_window/control_bar.cpp index c170128..eb19cd5 100644 --- a/src/single_window/control_bar.cpp +++ b/src/single_window/control_bar.cpp @@ -11,7 +11,7 @@ int Render::ControlBar() { if (control_bar_expand_) { ImGui::SetCursorPosX(is_control_bar_in_left_ ? (control_window_width_ + 5) - : 87); + : 53); // Mouse control std::string mouse = ICON_FA_COMPUTER_MOUSE; if (ImGui::Button(mouse.c_str(), ImVec2(25, 25))) { @@ -30,6 +30,26 @@ int Render::ControlBar() { mouse_control_button_pressed_ = !mouse_control_button_pressed_; } + ImGui::SameLine(); + // Audio capture + std::string audio = audio_capture_button_pressed_ ? ICON_FA_VOLUME_HIGH + : ICON_FA_VOLUME_XMARK; + if (ImGui::Button(audio.c_str(), ImVec2(25, 25))) { + if (mouse_control_button_label_ == + localization::audio_capture[localization_language_index_] && + connection_established_) { + audio_capture_button_pressed_ = true; + audio_capture_ = true; + audio_capture_button_label_ = + localization::mute[localization_language_index_]; + } else { + control_mouse_ = false; + audio_capture_button_label_ = + localization::audio_capture[localization_language_index_]; + } + audio_capture_button_pressed_ = !audio_capture_button_pressed_; + } + ImGui::SameLine(); // Fullscreen std::string fullscreen = diff --git a/src/single_window/render.h b/src/single_window/render.h index 28bb23d..bbc57d4 100644 --- a/src/single_window/render.h +++ b/src/single_window/render.h @@ -117,6 +117,7 @@ class Render { std::string connect_button_label_ = "Connect"; std::string fullscreen_button_label_ = "Fullscreen"; std::string mouse_control_button_label_ = "Mouse Control"; + std::string audio_capture_button_label_ = "Audio Capture"; std::string settings_button_label_ = "Setting"; char input_password_tmp_[7] = ""; char input_password_[7] = ""; @@ -187,12 +188,14 @@ class Render { bool control_bar_expand_ = true; bool fullscreen_button_pressed_ = false; bool mouse_control_button_pressed_ = false; + bool audio_capture_button_pressed_ = true; bool show_settings_window_ = false; bool received_frame_ = false; bool is_create_connection_ = false; bool audio_buffer_fresh_ = false; bool rejoin_ = false; bool control_mouse_ = false; + bool audio_capture_ = true; bool local_id_copied_ = false; bool show_password_ = true; bool password_inited_ = false; diff --git a/xmake.lua b/xmake.lua index c3a4b69..d30074e 100644 --- a/xmake.lua +++ b/xmake.lua @@ -19,7 +19,7 @@ end add_requires("spdlog 1.14.1", {system = false}) add_requires("imgui v1.91.0", {configs = {sdl2 = true, sdl2_renderer = true}}) add_requires("libyuv") -add_requires("miniaudio") +add_requires("miniaudio 0.11.21") if is_os("windows") then add_links("Shell32", "windowsapp", "dwmapi", "User32", "kernel32",