Formatting and error

More Ava 11-ness

Whoops
This commit is contained in:
Isaac Marovitz 2023-08-12 11:52:46 +01:00 committed by Isaac Marovitz
parent 5e8eedae37
commit 02b355eebf
12 changed files with 260 additions and 258 deletions

View file

@ -1,7 +1,7 @@
using Avalonia;
using Avalonia.Data;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.LogicalTree;
using Avalonia.Threading;
using Ryujinx.Ava.Common.Locale;
@ -19,7 +19,7 @@ namespace Ryujinx.Ava.UI.Helpers
{
public ToggleButton Button { get; }
public bool IsAssigned { get; }
public object Key { get; }
public object Key { get; }
public ButtonAssignedEventArgs(ToggleButton button, bool isAssigned, object key)
{
@ -107,4 +107,4 @@ namespace Ryujinx.Ava.UI.Helpers
_shouldUnbind = shouldUnbind;
}
}
}
}

View file

@ -565,7 +565,7 @@ namespace Ryujinx.Ava.UI.Models.Input
}
else
{
config.Motion = new MotionConfigController
config.Motion = new MotionConfigController
{
EnableMotion = EnableMotion,
MotionBackend = MotionInputBackendType.GamepadDriver,
@ -577,4 +577,4 @@ namespace Ryujinx.Ava.UI.Models.Input
return config;
}
}
}
}

View file

@ -419,4 +419,4 @@ namespace Ryujinx.Ava.UI.Models.Input
return config;
}
}
}
}

View file

@ -81,4 +81,4 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
Image = parentModel.Image;
}
}
}
}

View file

@ -889,4 +889,4 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
AvaloniaKeyboardDriver.Dispose();
}
}
}
}

View file

@ -70,4 +70,4 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
Image = parentModel.Image;
}
}
}
}

View file

@ -25,8 +25,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if (visual is ToggleButton button && !(visual is CheckBox))
{
button.Checked += Button_Checked;
button.Unchecked += Button_Unchecked;
button.IsCheckedChanged += Button_IsCheckedChanged;
}
}
}
@ -41,129 +40,131 @@ namespace Ryujinx.Ava.UI.Views.Input
}
}
private void Button_Checked(object sender, RoutedEventArgs e)
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton button)
{
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
if ((bool)button.IsChecked)
{
return;
}
bool isStick = button.Tag != null && button.Tag.ToString() == "stick";
if (_currentAssigner == null && (bool)button.IsChecked)
{
_currentAssigner = new ButtonKeyAssigner(button);
FocusManager.Instance.Focus(this, NavigationMethod.Pointer);
PointerPressed += MouseClick;
IKeyboard keyboard = (IKeyboard)(DataContext as ControllerInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
IButtonAssigner assigner = CreateButtonAssigner(isStick);
_currentAssigner.ButtonAssigned += (sender, e) =>
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{
if (e.IsAssigned)
return;
}
bool isStick = button.Tag != null && button.Tag.ToString() == "stick";
if (_currentAssigner == null && (bool)button.IsChecked)
{
_currentAssigner = new ButtonKeyAssigner(button);
this.Focus(NavigationMethod.Pointer);
PointerPressed += MouseClick;
IKeyboard keyboard = (IKeyboard)(DataContext as ControllerInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
IButtonAssigner assigner = CreateButtonAssigner(isStick);
_currentAssigner.ButtonAssigned += (sender, e) =>
{
var viewModel = (DataContext as ControllerInputViewModel);
viewModel.parentModel.IsModified = true;
switch (button.Name)
if (e.IsAssigned)
{
case "ButtonZl":
viewModel.Config.ButtonZl = (GamepadInputId)e.Key;
break;
case "ButtonL":
viewModel.Config.ButtonL = (GamepadInputId)e.Key;
break;
case "ButtonMinus":
viewModel.Config.ButtonMinus = (GamepadInputId)e.Key;
break;
case "LeftStickButton":
viewModel.Config.LeftStickButton = (GamepadInputId)e.Key;
break;
case "LeftJoystick":
viewModel.Config.LeftJoystick = (StickInputId)e.Key;
break;
case "DpadUp":
viewModel.Config.DpadUp = (GamepadInputId)e.Key;
break;
case "DpadDown":
viewModel.Config.DpadDown = (GamepadInputId)e.Key;
break;
case "DpadLeft":
viewModel.Config.DpadLeft = (GamepadInputId)e.Key;
break;
case "DpadRight":
viewModel.Config.DpadRight = (GamepadInputId)e.Key;
break;
case "LeftButtonSr":
viewModel.Config.LeftButtonSr = (GamepadInputId)e.Key;
break;
case "LeftButtonSl":
viewModel.Config.LeftButtonSl = (GamepadInputId)e.Key;
break;
case "RightButtonSr":
viewModel.Config.RightButtonSr = (GamepadInputId)e.Key;
break;
case "RightButtonSl":
viewModel.Config.RightButtonSl = (GamepadInputId)e.Key;
break;
case "ButtonZr":
viewModel.Config.ButtonZr = (GamepadInputId)e.Key;
break;
case "ButtonR":
viewModel.Config.ButtonR = (GamepadInputId)e.Key;
break;
case "ButtonPlus":
viewModel.Config.ButtonPlus = (GamepadInputId)e.Key;
break;
case "ButtonA":
viewModel.Config.ButtonA = (GamepadInputId)e.Key;
break;
case "ButtonB":
viewModel.Config.ButtonB = (GamepadInputId)e.Key;
break;
case "ButtonX":
viewModel.Config.ButtonX = (GamepadInputId)e.Key;
break;
case "ButtonY":
viewModel.Config.ButtonY = (GamepadInputId)e.Key;
break;
case "RightStickButton":
viewModel.Config.RightStickButton = (GamepadInputId)e.Key;
break;
case "RightJoystick":
viewModel.Config.RightJoystick = (StickInputId)e.Key;
break;
}
}
};
var viewModel = (DataContext as ControllerInputViewModel);
viewModel.parentModel.IsModified = true;
_currentAssigner.GetInputAndAssign(assigner, keyboard);
switch (button.Name)
{
case "ButtonZl":
viewModel.Config.ButtonZl = (GamepadInputId)e.Key;
break;
case "ButtonL":
viewModel.Config.ButtonL = (GamepadInputId)e.Key;
break;
case "ButtonMinus":
viewModel.Config.ButtonMinus = (GamepadInputId)e.Key;
break;
case "LeftStickButton":
viewModel.Config.LeftStickButton = (GamepadInputId)e.Key;
break;
case "LeftJoystick":
viewModel.Config.LeftJoystick = (StickInputId)e.Key;
break;
case "DpadUp":
viewModel.Config.DpadUp = (GamepadInputId)e.Key;
break;
case "DpadDown":
viewModel.Config.DpadDown = (GamepadInputId)e.Key;
break;
case "DpadLeft":
viewModel.Config.DpadLeft = (GamepadInputId)e.Key;
break;
case "DpadRight":
viewModel.Config.DpadRight = (GamepadInputId)e.Key;
break;
case "LeftButtonSr":
viewModel.Config.LeftButtonSr = (GamepadInputId)e.Key;
break;
case "LeftButtonSl":
viewModel.Config.LeftButtonSl = (GamepadInputId)e.Key;
break;
case "RightButtonSr":
viewModel.Config.RightButtonSr = (GamepadInputId)e.Key;
break;
case "RightButtonSl":
viewModel.Config.RightButtonSl = (GamepadInputId)e.Key;
break;
case "ButtonZr":
viewModel.Config.ButtonZr = (GamepadInputId)e.Key;
break;
case "ButtonR":
viewModel.Config.ButtonR = (GamepadInputId)e.Key;
break;
case "ButtonPlus":
viewModel.Config.ButtonPlus = (GamepadInputId)e.Key;
break;
case "ButtonA":
viewModel.Config.ButtonA = (GamepadInputId)e.Key;
break;
case "ButtonB":
viewModel.Config.ButtonB = (GamepadInputId)e.Key;
break;
case "ButtonX":
viewModel.Config.ButtonX = (GamepadInputId)e.Key;
break;
case "ButtonY":
viewModel.Config.ButtonY = (GamepadInputId)e.Key;
break;
case "RightStickButton":
viewModel.Config.RightStickButton = (GamepadInputId)e.Key;
break;
case "RightJoystick":
viewModel.Config.RightJoystick = (StickInputId)e.Key;
break;
}
}
};
_currentAssigner.GetInputAndAssign(assigner, keyboard);
}
else
{
if (_currentAssigner != null)
{
ToggleButton oldButton = _currentAssigner.ToggledButton;
_currentAssigner.Cancel();
_currentAssigner = null;
button.IsChecked = false;
}
}
}
else
{
if (_currentAssigner != null)
{
ToggleButton oldButton = _currentAssigner.ToggledButton;
_currentAssigner.Cancel();
_currentAssigner = null;
button.IsChecked = false;
}
_currentAssigner?.Cancel();
_currentAssigner = null;
}
}
}
private void Button_Unchecked(object sender, RoutedEventArgs e)
{
_currentAssigner?.Cancel();
_currentAssigner = null;
}
private void MouseClick(object sender, PointerPressedEventArgs e)
{
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
@ -189,4 +190,4 @@ namespace Ryujinx.Ava.UI.Views.Input
_currentAssigner = null;
}
}
}
}

View file

@ -63,7 +63,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
SelectionChanged="PlayerIndexBox_OnSelectionChanged"
Items="{Binding PlayerIndexes}"
ItemsSource="{Binding PlayerIndexes}"
SelectedIndex="{Binding PlayerId}">
<ComboBox.ItemTemplate>
<DataTemplate>
@ -91,14 +91,14 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{locale:Locale ControllerSettingsProfile}" />
<ui:ComboBox
<ui:FAComboBox
Grid.Column="1"
IsEditable="True"
Name="ProfileBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
SelectedIndex="0"
Items="{Binding ProfilesList}"
ItemsSource="{Binding ProfilesList}"
Text="{Binding ProfileName}" />
<Button
Grid.Column="2"
@ -167,7 +167,7 @@
Name="DeviceBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Items="{Binding DeviceList}"
ItemsSource="{Binding DeviceList}"
SelectedIndex="{Binding Device}" />
<Button
Grid.Column="2"
@ -200,7 +200,7 @@
<ComboBox
Grid.Column="1"
HorizontalAlignment="Stretch"
Items="{ReflectionBinding Controllers}"
ItemsSource="{ReflectionBinding Controllers}"
SelectedIndex="{ReflectionBinding Controller}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="models:ControllerModel">
@ -222,4 +222,4 @@
</ContentControl.DataTemplates>
</ContentControl>
</StackPanel>
</UserControl>
</UserControl>

View file

@ -58,4 +58,4 @@ namespace Ryujinx.Ava.UI.Views.Input
ViewModel.Dispose();
}
}
}
}

View file

@ -24,8 +24,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{
if (visual is ToggleButton button && !(visual is CheckBox))
{
button.Checked += Button_Checked;
button.Unchecked += Button_Unchecked;
button.IsCheckedChanged += Button_IsCheckedChanged;
}
}
}
@ -40,147 +39,149 @@ namespace Ryujinx.Ava.UI.Views.Input
}
}
private void Button_Checked(object sender, RoutedEventArgs e)
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton button)
{
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
if ((bool)button.IsChecked)
{
return;
}
bool isStick = button.Tag != null && button.Tag.ToString() == "stick";
if (_currentAssigner == null && (bool)button.IsChecked)
{
_currentAssigner = new ButtonKeyAssigner(button);
FocusManager.Instance.Focus(this, NavigationMethod.Pointer);
PointerPressed += MouseClick;
IKeyboard keyboard = (IKeyboard)(DataContext as KeyboardInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
IButtonAssigner assigner = CreateButtonAssigner(isStick);
_currentAssigner.ButtonAssigned += (sender, e) =>
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{
if (e.IsAssigned)
return;
}
bool isStick = button.Tag != null && button.Tag.ToString() == "stick";
if (_currentAssigner == null && (bool)button.IsChecked)
{
_currentAssigner = new ButtonKeyAssigner(button);
this.Focus(NavigationMethod.Pointer);
PointerPressed += MouseClick;
IKeyboard keyboard = (IKeyboard)(DataContext as KeyboardInputViewModel).parentModel.AvaloniaKeyboardDriver.GetGamepad("0"); // Open Avalonia keyboard for cancel operations.
IButtonAssigner assigner = CreateButtonAssigner(isStick);
_currentAssigner.ButtonAssigned += (sender, e) =>
{
var viewModel = (DataContext as KeyboardInputViewModel);
viewModel.parentModel.IsModified = true;
switch (button.Name)
if (e.IsAssigned)
{
case "ButtonZl":
viewModel.Config.ButtonZl = (Key)e.Key;
break;
case "ButtonL":
viewModel.Config.ButtonL = (Key)e.Key;
break;
case "ButtonMinus":
viewModel.Config.ButtonMinus = (Key)e.Key;
break;
case "LeftStickButton":
viewModel.Config.LeftStickButton = (Key)e.Key;
break;
case "LeftStickUp":
viewModel.Config.LeftStickUp = (Key)e.Key;
break;
case "LeftStickDown":
viewModel.Config.LeftStickDown = (Key)e.Key;
break;
case "LeftStickRight":
viewModel.Config.LeftStickRight = (Key)e.Key;
break;
case "LeftStickLeft":
viewModel.Config.LeftStickLeft = (Key)e.Key;
break;
case "DpadUp":
viewModel.Config.DpadUp = (Key)e.Key;
break;
case "DpadDown":
viewModel.Config.DpadDown = (Key)e.Key;
break;
case "DpadLeft":
viewModel.Config.DpadLeft = (Key)e.Key;
break;
case "DpadRight":
viewModel.Config.DpadRight = (Key)e.Key;
break;
case "LeftButtonSr":
viewModel.Config.LeftButtonSr = (Key)e.Key;
break;
case "LeftButtonSl":
viewModel.Config.LeftButtonSl = (Key)e.Key;
break;
case "RightButtonSr":
viewModel.Config.RightButtonSr = (Key)e.Key;
break;
case "RightButtonSl":
viewModel.Config.RightButtonSl = (Key)e.Key;
break;
case "ButtonZr":
viewModel.Config.ButtonZr = (Key)e.Key;
break;
case "ButtonR":
viewModel.Config.ButtonR = (Key)e.Key;
break;
case "ButtonPlus":
viewModel.Config.ButtonPlus = (Key)e.Key;
break;
case "ButtonA":
viewModel.Config.ButtonA = (Key)e.Key;
break;
case "ButtonB":
viewModel.Config.ButtonB = (Key)e.Key;
break;
case "ButtonX":
viewModel.Config.ButtonX = (Key)e.Key;
break;
case "ButtonY":
viewModel.Config.ButtonY = (Key)e.Key;
break;
case "RightStickButton":
viewModel.Config.RightStickButton = (Key)e.Key;
break;
case "RightStickUp":
viewModel.Config.RightStickUp = (Key)e.Key;
break;
case "RightStickDown":
viewModel.Config.RightStickDown = (Key)e.Key;
break;
case "RightStickRight":
viewModel.Config.RightStickRight = (Key)e.Key;
break;
case "RightStickLeft":
viewModel.Config.RightStickLeft = (Key)e.Key;
break;
}
}
};
var viewModel = (DataContext as KeyboardInputViewModel);
viewModel.parentModel.IsModified = true;
_currentAssigner.GetInputAndAssign(assigner, keyboard);
switch (button.Name)
{
case "ButtonZl":
viewModel.Config.ButtonZl = (Key)e.Key;
break;
case "ButtonL":
viewModel.Config.ButtonL = (Key)e.Key;
break;
case "ButtonMinus":
viewModel.Config.ButtonMinus = (Key)e.Key;
break;
case "LeftStickButton":
viewModel.Config.LeftStickButton = (Key)e.Key;
break;
case "LeftStickUp":
viewModel.Config.LeftStickUp = (Key)e.Key;
break;
case "LeftStickDown":
viewModel.Config.LeftStickDown = (Key)e.Key;
break;
case "LeftStickRight":
viewModel.Config.LeftStickRight = (Key)e.Key;
break;
case "LeftStickLeft":
viewModel.Config.LeftStickLeft = (Key)e.Key;
break;
case "DpadUp":
viewModel.Config.DpadUp = (Key)e.Key;
break;
case "DpadDown":
viewModel.Config.DpadDown = (Key)e.Key;
break;
case "DpadLeft":
viewModel.Config.DpadLeft = (Key)e.Key;
break;
case "DpadRight":
viewModel.Config.DpadRight = (Key)e.Key;
break;
case "LeftButtonSr":
viewModel.Config.LeftButtonSr = (Key)e.Key;
break;
case "LeftButtonSl":
viewModel.Config.LeftButtonSl = (Key)e.Key;
break;
case "RightButtonSr":
viewModel.Config.RightButtonSr = (Key)e.Key;
break;
case "RightButtonSl":
viewModel.Config.RightButtonSl = (Key)e.Key;
break;
case "ButtonZr":
viewModel.Config.ButtonZr = (Key)e.Key;
break;
case "ButtonR":
viewModel.Config.ButtonR = (Key)e.Key;
break;
case "ButtonPlus":
viewModel.Config.ButtonPlus = (Key)e.Key;
break;
case "ButtonA":
viewModel.Config.ButtonA = (Key)e.Key;
break;
case "ButtonB":
viewModel.Config.ButtonB = (Key)e.Key;
break;
case "ButtonX":
viewModel.Config.ButtonX = (Key)e.Key;
break;
case "ButtonY":
viewModel.Config.ButtonY = (Key)e.Key;
break;
case "RightStickButton":
viewModel.Config.RightStickButton = (Key)e.Key;
break;
case "RightStickUp":
viewModel.Config.RightStickUp = (Key)e.Key;
break;
case "RightStickDown":
viewModel.Config.RightStickDown = (Key)e.Key;
break;
case "RightStickRight":
viewModel.Config.RightStickRight = (Key)e.Key;
break;
case "RightStickLeft":
viewModel.Config.RightStickLeft = (Key)e.Key;
break;
}
}
};
_currentAssigner.GetInputAndAssign(assigner, keyboard);
}
else
{
if (_currentAssigner != null)
{
ToggleButton oldButton = _currentAssigner.ToggledButton;
_currentAssigner.Cancel();
_currentAssigner = null;
button.IsChecked = false;
}
}
}
else
{
if (_currentAssigner != null)
{
ToggleButton oldButton = _currentAssigner.ToggledButton;
_currentAssigner.Cancel();
_currentAssigner = null;
button.IsChecked = false;
}
_currentAssigner?.Cancel();
_currentAssigner = null;
}
}
}
private void Button_Unchecked(object sender, RoutedEventArgs e)
{
_currentAssigner?.Cancel();
_currentAssigner = null;
}
private void MouseClick(object sender, PointerPressedEventArgs e)
{
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
@ -206,4 +207,4 @@ namespace Ryujinx.Ava.UI.Views.Input
_currentAssigner = null;
}
}
}
}

View file

@ -194,4 +194,4 @@ namespace Ryujinx.Input.Assigner
}
}
}
}
}

View file

@ -1227,4 +1227,4 @@ namespace Ryujinx.UI.Windows
Dispose();
}
}
}
}