2022-07-05 20:06:31 +02:00
|
|
|
using Avalonia.Controls;
|
|
|
|
using FluentAvalonia.UI.Controls;
|
|
|
|
using Ryujinx.Ava.Common.Locale;
|
2022-12-29 15:24:05 +01:00
|
|
|
using Ryujinx.Ava.UI.Models;
|
|
|
|
using Ryujinx.Ava.UI.ViewModels;
|
2022-07-05 20:06:31 +02:00
|
|
|
using Ryujinx.Common.Configuration.Hid.Controller;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2022-12-29 15:24:05 +01:00
|
|
|
namespace Ryujinx.Ava.UI.Windows
|
2022-07-05 20:06:31 +02:00
|
|
|
{
|
2022-07-24 19:38:38 +02:00
|
|
|
public partial class MotionSettingsWindow : UserControl
|
2022-07-05 20:06:31 +02:00
|
|
|
{
|
|
|
|
private readonly InputConfiguration<GamepadInputId, StickInputId> _viewmodel;
|
|
|
|
|
|
|
|
public MotionSettingsWindow()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
2022-07-24 19:38:38 +02:00
|
|
|
DataContext = _viewmodel;
|
2022-07-05 20:06:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public MotionSettingsWindow(ControllerSettingsViewModel viewmodel)
|
|
|
|
{
|
|
|
|
var config = viewmodel.Configuration as InputConfiguration<GamepadInputId, StickInputId>;
|
|
|
|
|
|
|
|
_viewmodel = new InputConfiguration<GamepadInputId, StickInputId>()
|
|
|
|
{
|
|
|
|
Slot = config.Slot,
|
|
|
|
AltSlot = config.AltSlot,
|
|
|
|
DsuServerHost = config.DsuServerHost,
|
|
|
|
DsuServerPort = config.DsuServerPort,
|
|
|
|
MirrorInput = config.MirrorInput,
|
|
|
|
EnableMotion = config.EnableMotion,
|
|
|
|
Sensitivity = config.Sensitivity,
|
|
|
|
GyroDeadzone = config.GyroDeadzone,
|
|
|
|
EnableCemuHookMotion = config.EnableCemuHookMotion
|
|
|
|
};
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
DataContext = _viewmodel;
|
|
|
|
}
|
|
|
|
|
2022-07-24 19:38:38 +02:00
|
|
|
public static async Task Show(ControllerSettingsViewModel viewmodel)
|
2022-07-05 20:06:31 +02:00
|
|
|
{
|
|
|
|
MotionSettingsWindow content = new MotionSettingsWindow(viewmodel);
|
|
|
|
|
2022-07-24 19:38:38 +02:00
|
|
|
ContentDialog contentDialog = new ContentDialog
|
2022-07-05 20:06:31 +02:00
|
|
|
{
|
2023-01-03 19:45:08 +01:00
|
|
|
Title = LocaleManager.Instance[LocaleKeys.ControllerMotionTitle],
|
|
|
|
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsSave],
|
2022-07-24 19:38:38 +02:00
|
|
|
SecondaryButtonText = "",
|
2023-01-03 19:45:08 +01:00
|
|
|
CloseButtonText = LocaleManager.Instance[LocaleKeys.ControllerSettingsClose],
|
2022-07-24 19:38:38 +02:00
|
|
|
Content = content
|
|
|
|
};
|
|
|
|
contentDialog.PrimaryButtonClick += (sender, args) =>
|
|
|
|
{
|
|
|
|
var config = viewmodel.Configuration as InputConfiguration<GamepadInputId, StickInputId>;
|
|
|
|
config.Slot = content._viewmodel.Slot;
|
|
|
|
config.EnableMotion = content._viewmodel.EnableMotion;
|
|
|
|
config.Sensitivity = content._viewmodel.Sensitivity;
|
|
|
|
config.GyroDeadzone = content._viewmodel.GyroDeadzone;
|
|
|
|
config.AltSlot = content._viewmodel.AltSlot;
|
|
|
|
config.DsuServerHost = content._viewmodel.DsuServerHost;
|
|
|
|
config.DsuServerPort = content._viewmodel.DsuServerPort;
|
|
|
|
config.EnableCemuHookMotion = content._viewmodel.EnableCemuHookMotion;
|
|
|
|
config.MirrorInput = content._viewmodel.MirrorInput;
|
|
|
|
};
|
2022-07-05 20:06:31 +02:00
|
|
|
|
2022-07-24 19:38:38 +02:00
|
|
|
await contentDialog.ShowAsync();
|
2022-07-05 20:06:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|