/ src / Ryujinx / UI / ViewModels / Input / ControllerInputViewModel.cs
ControllerInputViewModel.cs
 1  using Avalonia.Svg.Skia;
 2  using Ryujinx.Ava.UI.Models.Input;
 3  using Ryujinx.Ava.UI.Views.Input;
 4  
 5  namespace Ryujinx.Ava.UI.ViewModels.Input
 6  {
 7      public class ControllerInputViewModel : BaseModel
 8      {
 9          private GamepadInputConfig _config;
10          public GamepadInputConfig Config
11          {
12              get => _config;
13              set
14              {
15                  _config = value;
16                  OnPropertyChanged();
17              }
18          }
19  
20          private bool _isLeft;
21          public bool IsLeft
22          {
23              get => _isLeft;
24              set
25              {
26                  _isLeft = value;
27                  OnPropertyChanged();
28                  OnPropertyChanged(nameof(HasSides));
29              }
30          }
31  
32          private bool _isRight;
33          public bool IsRight
34          {
35              get => _isRight;
36              set
37              {
38                  _isRight = value;
39                  OnPropertyChanged();
40                  OnPropertyChanged(nameof(HasSides));
41              }
42          }
43  
44          public bool HasSides => IsLeft ^ IsRight;
45  
46          private SvgImage _image;
47          public SvgImage Image
48          {
49              get => _image;
50              set
51              {
52                  _image = value;
53                  OnPropertyChanged();
54              }
55          }
56  
57          public readonly InputViewModel ParentModel;
58  
59          public ControllerInputViewModel(InputViewModel model, GamepadInputConfig config)
60          {
61              ParentModel = model;
62              model.NotifyChangesEvent += OnParentModelChanged;
63              OnParentModelChanged();
64              Config = config;
65          }
66  
67          public async void ShowMotionConfig()
68          {
69              await MotionInputView.Show(this);
70          }
71  
72          public async void ShowRumbleConfig()
73          {
74              await RumbleInputView.Show(this);
75          }
76  
77          public void OnParentModelChanged()
78          {
79              IsLeft = ParentModel.IsLeft;
80              IsRight = ParentModel.IsRight;
81              Image = ParentModel.Image;
82          }
83      }
84  }