MotionSettingsWindow.axaml.cs 2.8 KB

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