Implement proper frame delay and VRR for IS Nitro Emulator

This commit is contained in:
Lorenzooone
2024-08-25 09:37:30 +02:00
parent 718294ba02
commit 6f56918f3f
17 changed files with 565 additions and 135 deletions

View File

@@ -109,6 +109,7 @@ void WindowScreen::init_menus() {
this->shortcut_menu = new ShortcutMenu(this->font_load_success, this->text_font);
this->action_selection_menu = new ActionSelectionMenu(this->font_load_success, this->text_font);
this->scaling_ratio_menu = new ScalingRatioMenu(this->font_load_success, this->text_font);
this->is_nitro_menu = new ISNitroMenu(this->font_load_success, this->text_font);
}
void WindowScreen::destroy_menus() {
@@ -130,6 +131,7 @@ void WindowScreen::destroy_menus() {
delete this->shortcut_menu;
delete this->action_selection_menu;
delete this->scaling_ratio_menu;
delete this->is_nitro_menu;
}
void WindowScreen::set_close(int ret_val) {
@@ -174,6 +176,15 @@ void WindowScreen::fast_poll_change() {
this->print_notification_on_off("Slow Poll", this->display_data->fast_poll);
}
void WindowScreen::is_nitro_capture_type_change(bool positive) {
int new_value = (int)(this->capture_status->capture_type);
if(positive)
new_value += 1;
else
new_value += CAPTURE_SCREENS_ENUM_END - 1;
this->capture_status->capture_type = static_cast<CaptureScreensType>(new_value % CAPTURE_SCREENS_ENUM_END);
}
void WindowScreen::padding_change() {
if(this->m_info.is_fullscreen)
return;
@@ -615,14 +626,14 @@ void WindowScreen::setup_no_menu() {
this->last_menu_change_time = std::chrono::high_resolution_clock::now();
}
void WindowScreen::setup_main_menu(bool reset_data) {
if(!this->can_setup_menu())
void WindowScreen::setup_main_menu(bool reset_data, bool skip_setup_check) {
if((!skip_setup_check) && (!this->can_setup_menu()))
return;
if(this->curr_menu != MAIN_MENU_TYPE) {
this->curr_menu = MAIN_MENU_TYPE;
if(reset_data)
this->main_menu->reset_data();
this->main_menu->insert_data(this->m_stype, this->m_info.is_fullscreen, this->display_data->mono_app_mode, is_shortcut_valid());
this->main_menu->insert_data(this->m_stype, this->m_info.is_fullscreen, this->display_data->mono_app_mode, is_shortcut_valid(), this->capture_status->device.cc_type, this->capture_status->connected);
this->last_menu_change_time = std::chrono::high_resolution_clock::now();
}
}
@@ -900,6 +911,18 @@ void WindowScreen::setup_scaling_ratio_menu(bool reset_data) {
}
}
void WindowScreen::setup_is_nitro_menu(bool reset_data) {
if(!this->can_setup_menu())
return;
if(this->curr_menu != ISN_MENU_TYPE) {
this->curr_menu = ISN_MENU_TYPE;
if(reset_data)
this->is_nitro_menu->reset_data();
this->is_nitro_menu->insert_data();
this->last_menu_change_time = std::chrono::high_resolution_clock::now();
}
}
void WindowScreen::update_save_menu() {
if(this->curr_menu == SAVE_MENU_TYPE) {
this->curr_menu = DEFAULT_MENU_TYPE;
@@ -1234,6 +1257,10 @@ void WindowScreen::poll(bool do_everything) {
this->setup_shortcuts_menu();
done = true;
break;
case MAIN_MENU_ISN_SETTINGS:
this->setup_is_nitro_menu();
done = true;
break;
case MAIN_MENU_SHUTDOWN:
this->set_close(1);
this->setup_no_menu();
@@ -1771,6 +1798,30 @@ void WindowScreen::poll(bool do_everything) {
continue;
}
break;
case ISN_MENU_TYPE:
if(this->is_nitro_menu->poll(event_data)) {
switch(this->is_nitro_menu->selected_index) {
case ISN_MENU_BACK:
this->setup_main_menu(false);
done = true;
break;
case ISN_MENU_NO_ACTION:
break;
case ISN_MENU_DELAY:
break;
case ISN_MENU_TYPE_DEC:
this->is_nitro_capture_type_change(false);
break;
case ISN_MENU_TYPE_INC:
this->is_nitro_capture_type_change(true);
break;
default:
break;
}
this->is_nitro_menu->reset_output_option();
continue;
}
break;
default:
break;
}
@@ -1800,6 +1851,15 @@ void WindowScreen::update_ds_3ds_connection(bool changed_type) {
this->future_operations.call_crop = true;
}
void WindowScreen::update_capture_specific_settings() {
if(this->curr_menu == MAIN_MENU_TYPE) {
this->setup_no_menu();
this->setup_main_menu(true, true);
}
if(this->curr_menu == ISN_MENU_TYPE)
this->setup_no_menu();
}
int WindowScreen::load_data() {
int ret_val = this->m_prepare_load;
this->m_prepare_load = 0;
@@ -1985,6 +2045,9 @@ void WindowScreen::prepare_menu_draws(int view_size_x, int view_size_y) {
case SCALING_RATIO_MENU_TYPE:
this->scaling_ratio_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, &this->loaded_info);
break;
case ISN_MENU_TYPE:
this->is_nitro_menu->prepare(this->loaded_info.menu_scaling_factor, view_size_x, view_size_y, this->capture_status);
break;
default:
break;
}
@@ -2052,6 +2115,9 @@ void WindowScreen::execute_menu_draws() {
case SCALING_RATIO_MENU_TYPE:
this->scaling_ratio_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
case ISN_MENU_TYPE:
this->is_nitro_menu->draw(this->loaded_info.menu_scaling_factor, this->m_win);
break;
default:
break;
}