diff --git a/include/Menus/VideoMenu.hpp b/include/Menus/VideoMenu.hpp index 24f8f34..52f78a8 100755 --- a/include/Menus/VideoMenu.hpp +++ b/include/Menus/VideoMenu.hpp @@ -36,13 +36,14 @@ enum VideoMenuOutAction{ VIDEO_MENU_TOP_ROTATION_INC, VIDEO_MENU_BOTTOM_ROTATION_DEC, VIDEO_MENU_BOTTOM_ROTATION_INC, + VIDEO_MENU_FAST_POLL, }; class VideoMenu : public OptionSelectionMenu { public: VideoMenu(bool font_load_success, sf::Font &text_font); ~VideoMenu(); - void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info); + void prepare(float scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info, bool fast_poll); void insert_data(ScreenType s_type, bool is_fullscreen); VideoMenuOutAction selected_index = VideoMenuOutAction::VIDEO_MENU_NO_ACTION; void reset_output_option(); diff --git a/include/display_structs.hpp b/include/display_structs.hpp index bfe7a67..ace3569 100755 --- a/include/display_structs.hpp +++ b/include/display_structs.hpp @@ -35,6 +35,7 @@ struct ScreenInfo { struct DisplayData { bool split; bool mono_app_mode; + bool fast_poll; }; #pragma pack(push, 1) diff --git a/include/frontend.hpp b/include/frontend.hpp index bfb5fbc..ed1e5ab 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -179,6 +179,7 @@ private: void async_change(); void vsync_change(); void blur_change(); + void fast_poll_change(); void padding_change(); void crop_value_change(int new_crop_value); void par_value_change(int new_par_value, bool is_top); diff --git a/source/Menus/VideoMenu.cpp b/source/Menus/VideoMenu.cpp index 2b0ddb7..26afe15 100755 --- a/source/Menus/VideoMenu.cpp +++ b/source/Menus/VideoMenu.cpp @@ -150,6 +150,13 @@ static const VideoMenuOptionInfo bottom_one_rotation_option = { .is_inc = true, .dec_str = "Left", .inc_str = "Right", .inc_out_action = VIDEO_MENU_BOTTOM_ROTATION_INC, .out_action = VIDEO_MENU_BOTTOM_ROTATION_DEC}; +static const VideoMenuOptionInfo fast_poll_option = { +.base_name = "Disable Fast Poll", .false_name = "Enable Fast Poll", +.active_fullscreen = true, .active_windowed_screen = true, +.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true, +.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION, +.out_action = VIDEO_MENU_FAST_POLL}; + static const VideoMenuOptionInfo* pollable_options[] = { &crop_option, &window_scaling_option, @@ -159,6 +166,7 @@ static const VideoMenuOptionInfo* pollable_options[] = { &vsync_option, &async_option, &blur_option, +&fast_poll_option, &small_screen_offset_option, &offset_settings_option, &rotation_settings_option, @@ -265,7 +273,7 @@ std::string VideoMenu::setTextOptionDualPercentage(int index, int value_1, int v return this->get_string_option(index, DEFAULT_ACTION) + ": " + std::to_string(value_1) + " - " + std::to_string(value_2); } -void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info) { +void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, ScreenInfo *info, bool fast_poll) { int num_pages = this->get_num_pages(); if(this->future_data.page >= num_pages) this->future_data.page = num_pages - 1; @@ -307,6 +315,8 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz case VIDEO_MENU_BOTTOM_ROTATION_DEC: this->labels[index]->setText(this->setTextOptionInt(real_index, info->bot_rotation)); break; + case VIDEO_MENU_FAST_POLL: + this->labels[index]->setText(this->setTextOptionBool(real_index, fast_poll)); default: break; } diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index 5be0168..f13d375 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -718,9 +718,8 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) { } void WindowScreen::create_window(bool re_prepare_size) { - if(!this->m_info.is_fullscreen) { - this->m_info.show_mouse = true; - } + if(!this->m_info.is_fullscreen) + this->m_info.show_mouse = !this->display_data->mono_app_mode; else { bool success = false; if((this->m_info.fullscreen_mode_width > 0) && (this->m_info.fullscreen_mode_height > 0) && (this->m_info.fullscreen_mode_bpp > 0)) { diff --git a/source/WindowScreen_Menu.cpp b/source/WindowScreen_Menu.cpp index 828101b..3b82e55 100755 --- a/source/WindowScreen_Menu.cpp +++ b/source/WindowScreen_Menu.cpp @@ -124,6 +124,11 @@ void WindowScreen::blur_change() { this->print_notification_on_off("Blur", this->m_info.is_blurred); } +void WindowScreen::fast_poll_change() { + this->display_data->fast_poll = !this->display_data->fast_poll; + this->print_notification_on_off("Fast Poll", this->display_data->fast_poll); +} + void WindowScreen::padding_change() { if(this->m_info.is_fullscreen) return; @@ -350,24 +355,18 @@ bool WindowScreen::common_poll(SFEvent &event_data) { break; case sf::Event::MouseMoved: - if(this->m_info.is_fullscreen) { - this->m_info.show_mouse = true; - this->last_mouse_action_time = std::chrono::high_resolution_clock::now(); - } + this->m_info.show_mouse = true; + this->last_mouse_action_time = std::chrono::high_resolution_clock::now(); consumed = false; break; case sf::Event::MouseButtonPressed: - if(this->m_info.is_fullscreen) { - this->m_info.show_mouse = true; - this->last_mouse_action_time = std::chrono::high_resolution_clock::now(); - } + this->m_info.show_mouse = true; + this->last_mouse_action_time = std::chrono::high_resolution_clock::now(); consumed = false; break; case sf::Event::MouseButtonReleased: - if(this->m_info.is_fullscreen) { - this->m_info.show_mouse = true; - this->last_mouse_action_time = std::chrono::high_resolution_clock::now(); - } + this->m_info.show_mouse = true; + this->last_mouse_action_time = std::chrono::high_resolution_clock::now(); consumed = false; break; case sf::Event::JoystickButtonPressed: @@ -783,7 +782,7 @@ bool WindowScreen::main_poll(SFEvent &event_data) { void WindowScreen::poll() { if(this->close_capture()) return; - if(this->m_info.is_fullscreen && this->m_info.show_mouse) { + if((this->m_info.is_fullscreen || this->display_data->mono_app_mode) && this->m_info.show_mouse) { auto curr_time = std::chrono::high_resolution_clock::now(); const std::chrono::duration diff = curr_time - this->last_mouse_action_time; if(diff.count() > this->mouse_timeout) @@ -975,6 +974,9 @@ void WindowScreen::poll() { case VIDEO_MENU_BLUR: this->blur_change(); break; + case VIDEO_MENU_FAST_POLL: + this->fast_poll_change(); + break; case VIDEO_MENU_PADDING: this->padding_change(); break; @@ -1474,7 +1476,7 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) { this->main_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->capture_status->connected); break; case VIDEO_MENU_TYPE: - this->video_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info); + this->video_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info, this->display_data->fast_poll); break; case CROP_MENU_TYPE: this->crop_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->loaded_info.crop_kind); diff --git a/source/cc3dsfs.cpp b/source/cc3dsfs.cpp index b260ff6..2d76b20 100755 --- a/source/cc3dsfs.cpp +++ b/source/cc3dsfs.cpp @@ -91,6 +91,11 @@ static bool load(const std::string path, const std::string name, ScreenInfo &top continue; } + if(key == "fast_poll") { + display_data.fast_poll = std::stoi(value); + continue; + } + if(audio_data->load_audio_data(key, value)) continue; } @@ -157,6 +162,7 @@ static bool save(const std::string path, const std::string name, const std::stri file << save_screen_info("joint_", joint_info); file << save_screen_info("top_", top_info); file << "split=" << display_data.split << std::endl; + file << "fast_poll=" << display_data.fast_poll << std::endl; file << audio_data->save_audio_data(); file.close(); @@ -238,6 +244,15 @@ static void soundCall(AudioData *audio_data, CaptureData* capture_data) { audio.stop(); } +static void poll_all_windows(FrontendData *frontend_data, bool &polled) { + if(!polled) { + frontend_data->top_screen->poll(); + frontend_data->bot_screen->poll(); + frontend_data->joint_screen->poll(); + polled = true; + } +} + static void check_close_application(WindowScreen &screen, CaptureData* capture_data, int &ret_val) { if(screen.close_capture() && capture_data->status.running) { capture_data->status.running = false; @@ -289,6 +304,7 @@ static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, while(capture_data->status.running) { + bool polled = false; VideoOutputData *chosen_buf = out_buf; bool blank_out = false; if(capture_data->status.connected) { @@ -324,12 +340,14 @@ static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, chosen_buf = NULL; } - top_screen.poll(); - bot_screen.poll(); - joint_screen.poll(); + if(frontend_data.display_data.fast_poll) + poll_all_windows(&frontend_data, polled); update_output(&frontend_data, last_frame_time, chosen_buf); + if(!frontend_data.display_data.fast_poll) + poll_all_windows(&frontend_data, polled); + int load_index = 0; int save_index = 0; diff --git a/source/frontend.cpp b/source/frontend.cpp index cdd961f..36c6665 100755 --- a/source/frontend.cpp +++ b/source/frontend.cpp @@ -161,6 +161,7 @@ void insert_basic_pars(std::vector &par_vector) { void reset_display_data(DisplayData *display_data) { display_data->split = false; + display_data->fast_poll = false; } void reset_fullscreen_info(ScreenInfo &info) {