/ src / Ryujinx / UI / Views / Input / MotionInputView.axaml.cs
MotionInputView.axaml.cs
 1  using Avalonia.Controls;
 2  using FluentAvalonia.UI.Controls;
 3  using Ryujinx.Ava.Common.Locale;
 4  using Ryujinx.Ava.UI.ViewModels.Input;
 5  using System.Threading.Tasks;
 6  
 7  namespace Ryujinx.Ava.UI.Views.Input
 8  {
 9      public partial class MotionInputView : UserControl
10      {
11          private readonly MotionInputViewModel _viewModel;
12  
13          public MotionInputView()
14          {
15              InitializeComponent();
16          }
17  
18          public MotionInputView(ControllerInputViewModel viewModel)
19          {
20              var config = viewModel.Config;
21  
22              _viewModel = new MotionInputViewModel
23              {
24                  Slot = config.Slot,
25                  AltSlot = config.AltSlot,
26                  DsuServerHost = config.DsuServerHost,
27                  DsuServerPort = config.DsuServerPort,
28                  MirrorInput = config.MirrorInput,
29                  Sensitivity = config.Sensitivity,
30                  GyroDeadzone = config.GyroDeadzone,
31                  EnableCemuHookMotion = config.EnableCemuHookMotion,
32              };
33  
34              InitializeComponent();
35              DataContext = _viewModel;
36          }
37  
38          public static async Task Show(ControllerInputViewModel viewModel)
39          {
40              MotionInputView content = new(viewModel);
41  
42              ContentDialog contentDialog = new()
43              {
44                  Title = LocaleManager.Instance[LocaleKeys.ControllerMotionTitle],
45                  PrimaryButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsSave],
46                  SecondaryButtonText = "",
47                  CloseButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsClose],
48                  Content = content,
49              };
50              contentDialog.PrimaryButtonClick += (sender, args) =>
51              {
52                  var config = viewModel.Config;
53                  config.Slot = content._viewModel.Slot;
54                  config.Sensitivity = content._viewModel.Sensitivity;
55                  config.GyroDeadzone = content._viewModel.GyroDeadzone;
56                  config.AltSlot = content._viewModel.AltSlot;
57                  config.DsuServerHost = content._viewModel.DsuServerHost;
58                  config.DsuServerPort = content._viewModel.DsuServerPort;
59                  config.EnableCemuHookMotion = content._viewModel.EnableCemuHookMotion;
60                  config.MirrorInput = content._viewModel.MirrorInput;
61              };
62  
63              await contentDialog.ShowAsync();
64          }
65      }
66  }