Add GTK+ preferences for dynamic rate control.

This commit is contained in:
Brandon Wright 2017-11-20 13:06:13 -06:00
parent 0e3893c686
commit 7a368ededd
5 changed files with 94 additions and 11 deletions

View File

@ -226,7 +226,7 @@ GtkBuilderWindow::set_combo (const char *name, unsigned char value)
}
void
GtkBuilderWindow::set_spin (const char *name, unsigned int value)
GtkBuilderWindow::set_spin (const char *name, double value)
{
gtk_spin_button_set_value (GTK_SPIN_BUTTON (get_widget (name)),
(double) value);
@ -260,11 +260,10 @@ GtkBuilderWindow::get_window (void)
return GTK_WINDOW (window);
}
unsigned int
double
GtkBuilderWindow::get_spin (const char *name)
{
return (unsigned int)
gtk_spin_button_get_value (GTK_SPIN_BUTTON (get_widget (name)));
return gtk_spin_button_get_value (GTK_SPIN_BUTTON (get_widget (name)));
}
int

View File

@ -30,13 +30,13 @@ class GtkBuilderWindow
unsigned char get_combo (const char *name);
void combo_box_append (const char *name, const char *value);
void combo_box_append (GtkComboBox *combo, const char *value);
unsigned int get_spin (const char *name);
double get_spin (const char *name);
float get_slider (const char *name);
void set_check (const char *name, unsigned char value);
void set_entry_value (const char *name, unsigned int value);
void set_entry_text (const char *name, const char *text);
void set_combo (const char *name, unsigned char value);
void set_spin (const char *name, unsigned int value);
void set_spin (const char *name, double value);
void set_slider (const char *name, float value);
int has_focus (const char *widget);

View File

@ -253,6 +253,8 @@ Snes9xConfig::load_defaults (void)
Settings.FrameTime = Settings.FrameTimeNTSC;
Settings.BlockInvalidVRAMAccessMaster = TRUE;
Settings.SoundSync = 1;
Settings.DynamicRateControl = 0;
Settings.DynamicRateLimit = 1000;
Settings.HDMATimingHack = 100;
Settings.ApplyCheats = 1;
@ -402,6 +404,8 @@ Snes9xConfig::save_config_file (void)
xml_out_int (xml, "sound_driver", sound_driver);
xml_out_int (xml, "sound_input_rate", sound_input_rate);
xml_out_int (xml, "sound_sync", Settings.SoundSync);
xml_out_int (xml, "dynamic_rate_control", Settings.DynamicRateControl);
xml_out_int (xml, "dynamic_rate_limit", Settings.DynamicRateLimit);
/* Snes9X core-stored variables */
xml_out_int (xml, "transparency", Settings.Transparency);
@ -664,6 +668,14 @@ Snes9xConfig::set_option (const char *name, const char *value)
{
Settings.ReverseStereo = atoi (value);
}
else if (!strcasecmp (name, "dynamic_rate_control"))
{
Settings.DynamicRateControl = atoi (value);
}
else if (!strcasecmp (name, "dynamic_rate_limit"))
{
Settings.DynamicRateLimit = atoi (value);
}
else if (!strcasecmp (name, "gaussian_interpolation"))
{
}

View File

@ -661,6 +661,8 @@ Snes9xPreferences::move_settings_to_dialog (void)
set_spin ("sound_buffer_size", config->sound_buffer_size);
set_slider ("sound_input_rate", config->sound_input_rate);
set_check ("sync_sound", Settings.SoundSync);
set_check ("dynamic_rate_control", Settings.DynamicRateControl);
set_spin ("dynamic_rate_limit", Settings.DynamicRateLimit / 100000.0);
set_spin ("rewind_buffer_size", config->rewind_buffer_size);
set_spin ("rewind_granularity", config->rewind_granularity);
@ -816,6 +818,8 @@ Snes9xPreferences::get_settings_from_dialog (void)
Settings.SoundSync = get_check ("sync_sound");
config->mute_sound = get_check ("mute_sound_check");
config->mute_sound_turbo = get_check ("mute_sound_turbo_check");
Settings.DynamicRateControl = get_check ("dynamic_rate_control");
Settings.DynamicRateLimit = (uint32) (get_spin ("dynamic_rate_limit") * 100000);
store_ntsc_settings ();
config->ntsc_scanline_intensity = get_combo ("ntsc_scanline_intensity");

View File

@ -150,6 +150,13 @@
<property name="step_increment">0.01</property>
<property name="page_increment">0.10000000000000001</property>
</object>
<object class="GtkAdjustment" id="dynamic_rate_adjustment">
<property name="lower">0.001</property>
<property name="upper">0.100</property>
<property name="value">0.010</property>
<property name="step_increment">0.001</property>
<property name="page_increment">0.010</property>
</object>
<object class="GtkAdjustment" id="adjustment13">
<property name="lower">-1</property>
<property name="upper">1</property>
@ -4008,6 +4015,23 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="dynamic_rate_control">
<property name="label" translatable="yes">Dynamic rate control</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Adjust input rate automatically</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="mute_sound_check">
<property name="label" translatable="yes">Mute sound output</property>
@ -4021,7 +4045,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child>
@ -4037,7 +4061,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
@ -4053,14 +4077,14 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">4</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<property name="row_spacing">5</property>
@ -4135,6 +4159,50 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="dynamic_rate_limit_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Dynamic rate limit:</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox_dynamic_rate">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkSpinButton" id="dynamic_rate_limit">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<property name="digits">3</property>
<property name="adjustment">dynamic_rate_adjustment</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options">GTK_FILL</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="sound_input_rate_label">
<property name="visible">True</property>
@ -4229,7 +4297,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
</object>