2022-07-05 19:06:31 +01:00
|
|
|
using Avalonia.Controls;
|
|
|
|
using FluentAvalonia.UI.Controls;
|
|
|
|
using Ryujinx.Ava.Common.Locale;
|
2022-12-29 14:24:05 +00:00
|
|
|
using Ryujinx.Ava.UI.Models;
|
|
|
|
using Ryujinx.Ava.UI.ViewModels;
|
2022-07-05 19:06:31 +01:00
|
|
|
using Ryujinx.Common.Configuration.Hid.Controller;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2022-12-29 14:24:05 +00:00
|
|
|
namespace Ryujinx.Ava.UI.Windows
|
2022-07-05 19:06:31 +01:00
|
|
|
{
|
2022-07-24 18:38:38 +01:00
|
|
|
public partial class MotionSettingsWindow : UserControl
|
2022-07-05 19:06:31 +01:00
|
|
|
{
|
|
|
|
private readonly InputConfiguration<GamepadInputId, StickInputId> _viewmodel;
|
|
|
|
|
|
|
|
public MotionSettingsWindow()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
2022-07-24 18:38:38 +01:00
|
|
|
DataContext = _viewmodel;
|
2022-07-05 19:06:31 +01: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 18:38:38 +01:00
|
|
|
public static async Task Show(ControllerSettingsViewModel viewmodel)
|
2022-07-05 19:06:31 +01:00
|
|
|
{
|
|
|
|
MotionSettingsWindow content = new MotionSettingsWindow(viewmodel);
|
|
|
|
|
2022-07-24 18:38:38 +01:00
|
|
|
ContentDialog contentDialog = new ContentDialog
|
2022-07-05 19:06:31 +01:00
|
|
|
{
|
2022-07-24 18:38:38 +01:00
|
|
|
Title = LocaleManager.Instance["ControllerMotionTitle"],
|
|
|
|
PrimaryButtonText = LocaleManager.Instance["ControllerSettingsSave"],
|
|
|
|
SecondaryButtonText = "",
|
|
|
|
CloseButtonText = LocaleManager.Instance["ControllerSettingsClose"],
|
|
|
|
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 19:06:31 +01:00
|
|
|
|
2022-07-24 18:38:38 +01:00
|
|
|
await contentDialog.ShowAsync();
|
2022-07-05 19:06:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|