Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit a610e2f

Browse files
authored
Merge pull request #211 from anttitn/3.x
Add setting to disable auto refresh game controllers
2 parents 98ccddc + a769417 commit a610e2f

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

XOutput/Resources/Languages/English.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"DiagnosticsMenu": "Diagnostics",
1717
"DirectInput": "DirectInput",
1818
"Disable": "Disable",
19+
"DisableAutoRefresh": "Disable automatic device status detection",
1920
"Edit": "Edit",
2021
"EmulationStarted": "{0} is emulated as controller #{1}.",
2122
"EmulationStopped": "{0} is no longer emulated.",

XOutput/Tools/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static Settings Load(string filePath)
3434
public bool CloseToTray { get; set; }
3535
public bool ShowAll { get; set; }
3636
public bool HidGuardianEnabled { get; set; }
37+
public bool DisableAutoRefresh { get; set; }
3738
public string Language
3839
{
3940
get => LanguageManager.Instance.Language;

XOutput/UI/Windows/MainWindowViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ public MainWindowViewModel(MainWindowModel model, Dispatcher dispatcher, HidGuar
4040
{
4141
this.dispatcher = dispatcher;
4242
this.hidGuardianManager = hidGuardianManager;
43-
timer.Interval = TimeSpan.FromMilliseconds(5000);
44-
timer.Tick += (object sender1, EventArgs e1) => { RefreshGameControllers(); };
45-
timer.Start();
4643
}
4744

4845
public void Dispose()
@@ -147,6 +144,10 @@ public void Initialize(Action<string> log)
147144
Model.Settings = settings;
148145
RefreshGameControllers();
149146

147+
timer.Interval = TimeSpan.FromMilliseconds(5000);
148+
timer.Tick += (object sender1, EventArgs e1) => { if (!settings.DisableAutoRefresh) { RefreshGameControllers(); } };
149+
timer.Start();
150+
150151
logger.Debug("Creating keyboard controller");
151152
Devices.Input.Keyboard.Keyboard keyboard = new Devices.Input.Keyboard.Keyboard();
152153
settings.GetOrCreateInputConfiguration(keyboard.ToString(), keyboard.InputConfiguration);

XOutput/UI/Windows/SettingsModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ public bool HidGuardianEnabled
6969
}
7070
}
7171

72+
public bool DisableAutoRefresh
73+
{
74+
get => settings.DisableAutoRefresh;
75+
set
76+
{
77+
if (settings.DisableAutoRefresh != value)
78+
{
79+
settings.DisableAutoRefresh = value;
80+
OnPropertyChanged(nameof(DisableAutoRefresh));
81+
}
82+
}
83+
}
84+
7285
public SettingsModel(RegistryModifier registryModifier, Settings settings)
7386
{
7487
this.registryModifier = registryModifier;

XOutput/UI/Windows/SettingsWindow.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<RowDefinition Height="*"/>
1818
<RowDefinition Height="*"/>
1919
<RowDefinition Height="*"/>
20+
<RowDefinition Height="*"/>
2021
</Grid.RowDefinitions>
2122
<Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Content="{Binding LanguageModel.Data, Converter={StaticResource LanguageConverter}, ConverterParameter='Language'}"/>
2223
<ComboBox Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" Width="200" Height="25" ItemsSource="{Binding Model.Languages}" SelectedItem="{Binding Model.SelectedLanguage}"/>
@@ -26,5 +27,7 @@
2627
<CheckBox Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" Width="200" VerticalAlignment="Center" IsChecked="{Binding Model.RunAtStartup}"/>
2728
<Label Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" Content="{Binding LanguageModel.Data, Converter={StaticResource LanguageConverter}, ConverterParameter='HidGuardianEnabled'}"/>
2829
<CheckBox Grid.Column="1" Grid.Row="3" Width="200" VerticalAlignment="Center" IsChecked="{Binding Model.HidGuardianEnabled}"/>
30+
<Label Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" Content="{Binding LanguageModel.Data, Converter={StaticResource LanguageConverter}, ConverterParameter='DisableAutoRefresh'}"/>
31+
<CheckBox Grid.Column="1" Grid.Row="4" Width="200" VerticalAlignment="Center" IsChecked="{Binding Model.DisableAutoRefresh}"/>
2932
</Grid>
3033
</Window>

0 commit comments

Comments
 (0)