Move all remaining input controls to Input VM

This commit is contained in:
Isaac Marovitz 2024-04-18 16:35:24 -04:00
parent c141b248a8
commit ea80d922a6
No known key found for this signature in database
GPG key ID: 97250B2B09A132E1
4 changed files with 254 additions and 249 deletions

View file

@ -51,6 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private object _configViewModel; private object _configViewModel;
private string _profileName; private string _profileName;
private bool _isLoaded; private bool _isLoaded;
private bool _enableDockedMode;
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
@ -70,6 +71,17 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool IsRight { get; set; } public bool IsRight { get; set; }
public bool IsLeft { get; set; } public bool IsLeft { get; set; }
public bool EnableDockedMode
{
get => _enableDockedMode;
set
{
_enableDockedMode = value;
}
}
public bool EnableKeyboard { get; set; }
public bool EnableMouse { get; set; }
public bool IsModified { get; set; } public bool IsModified { get; set; }
public event Action NotifyChangesEvent; public event Action NotifyChangesEvent;
@ -288,6 +300,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
ConfigViewModel = new ControllerInputViewModel(this, new GamepadInputConfig(controllerInputConfig)); ConfigViewModel = new ControllerInputViewModel(this, new GamepadInputConfig(controllerInputConfig));
} }
EnableDockedMode = ConfigurationState.Instance.System.EnableDockedMode;
EnableKeyboard = ConfigurationState.Instance.Hid.EnableKeyboard;
EnableMouse = ConfigurationState.Instance.Hid.EnableMouse;
} }
public void LoadDevice() public void LoadDevice()
@ -853,6 +869,10 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
// NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event. // NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event.
ConfigurationState.Instance.Hid.InputConfig.Value = newConfig; ConfigurationState.Instance.Hid.InputConfig.Value = newConfig;
ConfigurationState.Instance.System.EnableDockedMode.Value = EnableDockedMode;
ConfigurationState.Instance.Hid.EnableKeyboard.Value = EnableKeyboard;
ConfigurationState.Instance.Hid.EnableMouse.Value = EnableMouse;
ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath); ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
} }

View file

@ -146,9 +146,6 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool ShowConfirmExit { get; set; } public bool ShowConfirmExit { get; set; }
public bool RememberWindowState { get; set; } public bool RememberWindowState { get; set; }
public int HideCursor { get; set; } public int HideCursor { get; set; }
public bool EnableDockedMode { get; set; }
public bool EnableKeyboard { get; set; }
public bool EnableMouse { get; set; }
public bool EnableVsync { get; set; } public bool EnableVsync { get; set; }
public bool EnablePptc { get; set; } public bool EnablePptc { get; set; }
public bool EnableInternetAccess { get; set; } public bool EnableInternetAccess { get; set; }
@ -418,11 +415,6 @@ namespace Ryujinx.Ava.UI.ViewModels
_ => 0 _ => 0
}; };
// Input
EnableDockedMode = config.System.EnableDockedMode;
EnableKeyboard = config.Hid.EnableKeyboard;
EnableMouse = config.Hid.EnableMouse;
// Keyboard Hotkeys // Keyboard Hotkeys
KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value); KeyboardHotkey = new HotkeyConfig(config.Hid.Hotkeys.Value);
@ -513,11 +505,6 @@ namespace Ryujinx.Ava.UI.ViewModels
_ => "Auto" _ => "Auto"
}; };
// Input
config.System.EnableDockedMode.Value = EnableDockedMode;
config.Hid.EnableKeyboard.Value = EnableKeyboard;
config.Hid.EnableMouse.Value = EnableMouse;
// Keyboard Hotkeys // Keyboard Hotkeys
config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig(); config.Hid.Hotkeys.Value = KeyboardHotkey.GetConfig();

View file

@ -27,199 +27,237 @@
<Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
</Style> </Style>
</UserControl.Styles> </UserControl.Styles>
<StackPanel <Grid>
HorizontalAlignment="Stretch" <Grid.RowDefinitions>
VerticalAlignment="Stretch" <RowDefinition Height="Auto"/>
Orientation="Vertical"> <RowDefinition Height="*" />
<StackPanel <RowDefinition Height="Auto" />
Margin="0 0 0 5" </Grid.RowDefinitions>
Orientation="Vertical" <StackPanel
Spacing="5"> Grid.Row="0"
<Grid> HorizontalAlignment="Stretch"
<Grid.ColumnDefinitions> VerticalAlignment="Stretch"
<ColumnDefinition Width="*" /> Orientation="Vertical">
<ColumnDefinition Width="10" /> <StackPanel
<ColumnDefinition Width="*" /> Margin="0 0 0 5"
</Grid.ColumnDefinitions> Orientation="Vertical"
<!-- Player Selection --> Spacing="5">
<Grid <Grid>
Grid.Column="0" <Grid.ColumnDefinitions>
Margin="2" <ColumnDefinition Width="*" />
HorizontalAlignment="Stretch" <ColumnDefinition Width="10" />
VerticalAlignment="Center"> <ColumnDefinition Width="*" />
<Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <!-- Player Selection -->
<ColumnDefinition Width="*" /> <Grid
</Grid.ColumnDefinitions> Grid.Column="0"
<TextBlock Margin="2"
Margin="5,0,10,0" HorizontalAlignment="Stretch"
Width="90" VerticalAlignment="Center">
HorizontalAlignment="Left" <Grid.ColumnDefinitions>
VerticalAlignment="Center" <ColumnDefinition Width="Auto"/>
Text="{locale:Locale ControllerSettingsPlayer}" /> <ColumnDefinition Width="*" />
<ComboBox </Grid.ColumnDefinitions>
Grid.Column="1" <TextBlock
Name="PlayerIndexBox" Margin="5,0,10,0"
HorizontalAlignment="Stretch" Width="90"
VerticalAlignment="Center" HorizontalAlignment="Left"
SelectionChanged="PlayerIndexBox_OnSelectionChanged" VerticalAlignment="Center"
ItemsSource="{Binding PlayerIndexes}" Text="{locale:Locale ControllerSettingsPlayer}" />
SelectedIndex="{Binding PlayerId}"> <ComboBox
<ComboBox.ItemTemplate> Grid.Column="1"
<DataTemplate> Name="PlayerIndexBox"
<TextBlock Text="{Binding Name}" /> HorizontalAlignment="Stretch"
</DataTemplate> VerticalAlignment="Center"
</ComboBox.ItemTemplate> SelectionChanged="PlayerIndexBox_OnSelectionChanged"
</ComboBox> ItemsSource="{Binding PlayerIndexes}"
</Grid> SelectedIndex="{Binding PlayerId}">
<!-- Profile Selection --> <ComboBox.ItemTemplate>
<Grid <DataTemplate>
Grid.Column="2" <TextBlock Text="{Binding Name}" />
Margin="2" </DataTemplate>
HorizontalAlignment="Stretch" </ComboBox.ItemTemplate>
VerticalAlignment="Center"> </ComboBox>
<Grid.ColumnDefinitions> </Grid>
<ColumnDefinition Width="Auto"/> <!-- Profile Selection -->
<ColumnDefinition Width="*" /> <Grid
<ColumnDefinition Width="Auto"/> Grid.Column="2"
<ColumnDefinition Width="Auto"/> Margin="2"
<ColumnDefinition Width="Auto"/> HorizontalAlignment="Stretch"
</Grid.ColumnDefinitions> VerticalAlignment="Center">
<TextBlock <Grid.ColumnDefinitions>
Margin="5,0,10,0" <ColumnDefinition Width="Auto"/>
Width="90" <ColumnDefinition Width="*" />
HorizontalAlignment="Left" <ColumnDefinition Width="Auto"/>
VerticalAlignment="Center" <ColumnDefinition Width="Auto"/>
Text="{locale:Locale ControllerSettingsProfile}" /> <ColumnDefinition Width="Auto"/>
<ui:FAComboBox </Grid.ColumnDefinitions>
Grid.Column="1" <TextBlock
IsEditable="True" Margin="5,0,10,0"
Name="ProfileBox" Width="90"
HorizontalAlignment="Stretch" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
SelectedIndex="0" Text="{locale:Locale ControllerSettingsProfile}" />
ItemsSource="{Binding ProfilesList}" <ui:FAComboBox
Text="{Binding ProfileName, Mode=TwoWay}" /> Grid.Column="1"
<Button IsEditable="True"
Grid.Column="2" Name="ProfileBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
SelectedIndex="0"
ItemsSource="{Binding ProfilesList}"
Text="{Binding ProfileName, Mode=TwoWay}" />
<Button
Grid.Column="2"
MinWidth="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
ToolTip.Tip="{locale:Locale ControllerSettingsLoadProfileToolTip}"
Command="{Binding LoadProfile}">
<ui:SymbolIcon
Symbol="Upload"
FontSize="15"
Height="20" />
</Button>
<Button
Grid.Column="3"
MinWidth="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
ToolTip.Tip="{locale:Locale ControllerSettingsSaveProfileToolTip}"
Command="{Binding SaveProfile}">
<ui:SymbolIcon
Symbol="Save"
FontSize="15"
Height="20" />
</Button>
<Button
Grid.Column="4"
MinWidth="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
ToolTip.Tip="{locale:Locale ControllerSettingsRemoveProfileToolTip}"
Command="{Binding RemoveProfile}">
<ui:SymbolIcon
Symbol="Delete"
FontSize="15"
Height="20" />
</Button>
</Grid>
</Grid>
<Separator />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Input Device -->
<Grid
Grid.Column="0"
Margin="2"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="5,0,10,0"
Width="90"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{locale:Locale ControllerSettingsInputDevice}" />
<ComboBox
Grid.Column="1"
Name="DeviceBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
ItemsSource="{Binding DeviceList}"
SelectedIndex="{Binding Device}" />
<Button
Grid.Column="2"
MinWidth="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
Command="{Binding LoadDevices}">
<ui:SymbolIcon
Symbol="Refresh"
FontSize="15"
Height="20"/>
</Button>
</Grid>
<!-- Controller Type -->
<Grid
Grid.Column="2"
Margin="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="5,0,10,0"
Width="90"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{locale:Locale ControllerSettingsControllerType}" />
<ComboBox
Grid.Column="1"
HorizontalAlignment="Stretch"
ItemsSource="{Binding Controllers}"
SelectedIndex="{Binding Controller}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="models:ControllerModel">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Grid>
</StackPanel>
<ContentControl Content="{Binding ConfigViewModel}" IsVisible="{Binding ShowSettings}">
<ContentControl.DataTemplates>
<DataTemplate DataType="viewModels:ControllerInputViewModel">
<views:ControllerInputView />
</DataTemplate>
<DataTemplate DataType="viewModels:KeyboardInputViewModel">
<views:KeyboardInputView />
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
</StackPanel>
<StackPanel
Orientation="Vertical"
Grid.Row="2">
<Separator
Margin="0 10"
Height="1" />
<StackPanel
Orientation="Horizontal"
Spacing="10">
<CheckBox
ToolTip.Tip="{locale:Locale DockModeToggleTooltip}"
MinWidth="0" MinWidth="0"
Margin="5,0,0,0" IsChecked="{Binding EnableDockedMode}">
VerticalAlignment="Center" <TextBlock
ToolTip.Tip="{locale:Locale ControllerSettingsLoadProfileToolTip}" Text="{locale:Locale SettingsTabInputEnableDockedMode}" />
Command="{Binding LoadProfile}"> </CheckBox>
<ui:SymbolIcon <CheckBox
Symbol="Upload" ToolTip.Tip="{locale:Locale DirectKeyboardTooltip}"
FontSize="15" IsChecked="{Binding EnableKeyboard}">
Height="20" /> <TextBlock
</Button> Text="{locale:Locale SettingsTabInputDirectKeyboardAccess}" />
<Button </CheckBox>
Grid.Column="3" <CheckBox
MinWidth="0" ToolTip.Tip="{locale:Locale DirectMouseTooltip}"
Margin="5,0,0,0" IsChecked="{Binding EnableMouse}">
VerticalAlignment="Center" <TextBlock
ToolTip.Tip="{locale:Locale ControllerSettingsSaveProfileToolTip}" Text="{locale:Locale SettingsTabInputDirectMouseAccess}" />
Command="{Binding SaveProfile}"> </CheckBox>
<ui:SymbolIcon </StackPanel>
Symbol="Save" </StackPanel>
FontSize="15" </Grid>
Height="20" />
</Button>
<Button
Grid.Column="4"
MinWidth="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
ToolTip.Tip="{locale:Locale ControllerSettingsRemoveProfileToolTip}"
Command="{Binding RemoveProfile}">
<ui:SymbolIcon
Symbol="Delete"
FontSize="15"
Height="20" />
</Button>
</Grid>
</Grid>
<Separator />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Input Device -->
<Grid
Grid.Column="0"
Margin="2"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="5,0,10,0"
Width="90"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{locale:Locale ControllerSettingsInputDevice}" />
<ComboBox
Grid.Column="1"
Name="DeviceBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
ItemsSource="{Binding DeviceList}"
SelectedIndex="{Binding Device}" />
<Button
Grid.Column="2"
MinWidth="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
Command="{Binding LoadDevices}">
<ui:SymbolIcon
Symbol="Refresh"
FontSize="15"
Height="20"/>
</Button>
</Grid>
<!-- Controller Type -->
<Grid
Grid.Column="2"
Margin="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="5,0,10,0"
Width="90"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{locale:Locale ControllerSettingsControllerType}" />
<ComboBox
Grid.Column="1"
HorizontalAlignment="Stretch"
ItemsSource="{Binding Controllers}"
SelectedIndex="{Binding Controller}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="models:ControllerModel">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
</Grid>
</StackPanel>
<ContentControl Content="{Binding ConfigViewModel}" IsVisible="{Binding ShowSettings}">
<ContentControl.DataTemplates>
<DataTemplate DataType="viewModels:ControllerInputViewModel">
<views:ControllerInputView />
</DataTemplate>
<DataTemplate DataType="viewModels:KeyboardInputViewModel">
<views:KeyboardInputView />
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
</StackPanel>
</UserControl> </UserControl>

View file

@ -4,7 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
xmlns:views="clr-namespace:Ryujinx.Ava.UI.Views.Input" xmlns:views="clr-namespace:Ryujinx.Ava.UI.Views.Input"
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels" xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
mc:Ignorable="d" mc:Ignorable="d"
@ -21,47 +20,8 @@
<Border Classes="settings"> <Border Classes="settings">
<Panel <Panel
Margin="10"> Margin="10">
<Grid> <views:InputView Name="InputView" />
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<views:InputView
Grid.Row="0"
Name="InputView" />
<StackPanel
Orientation="Vertical"
Grid.Row="2">
<Separator
Margin="0 10"
Height="1" />
<StackPanel
Orientation="Horizontal"
Spacing="10">
<CheckBox
ToolTip.Tip="{locale:Locale DockModeToggleTooltip}"
MinWidth="0"
IsChecked="{Binding EnableDockedMode}">
<TextBlock
Text="{locale:Locale SettingsTabInputEnableDockedMode}" />
</CheckBox>
<CheckBox
ToolTip.Tip="{locale:Locale DirectKeyboardTooltip}"
IsChecked="{Binding EnableKeyboard}">
<TextBlock
Text="{locale:Locale SettingsTabInputDirectKeyboardAccess}" />
</CheckBox>
<CheckBox
ToolTip.Tip="{locale:Locale DirectMouseTooltip}"
IsChecked="{Binding EnableMouse}">
<TextBlock
Text="{locale:Locale SettingsTabInputDirectMouseAccess}" />
</CheckBox>
</StackPanel>
</StackPanel>
</Grid>
</Panel> </Panel>
</Border> </Border>
</ScrollViewer> </ScrollViewer>
</UserControl> </UserControl>