mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-04-29 18:12:55 +00:00
* misc: Move Ryujinx project to Ryujinx.Gtk3 This breaks release CI for now but that's fine. Signed-off-by: Mary Guillemard <mary@mary.zone> * misc: Move Ryujinx.Ava project to Ryujinx This breaks CI for now, but it's fine. Signed-off-by: Mary Guillemard <mary@mary.zone> * infra: Make Avalonia the default UI Should fix CI after the previous changes. GTK3 isn't build by the release job anymore, only by PR CI. This also ensure that the test-ava update package is still generated to allow update from the old testing channel. Signed-off-by: Mary Guillemard <mary@mary.zone> * Fix missing copy in create_app_bundle.sh Signed-off-by: Mary Guillemard <mary@mary.zone> * Fix syntax error Signed-off-by: Mary Guillemard <mary@mary.zone> --------- Signed-off-by: Mary Guillemard <mary@mary.zone>
82 lines
2.4 KiB
C#
82 lines
2.4 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Controls.Primitives;
|
|
using Avalonia.Input;
|
|
using Avalonia.Interactivity;
|
|
using Ryujinx.Ava.Input;
|
|
using Ryujinx.Ava.UI.Helpers;
|
|
using Ryujinx.Input;
|
|
using Ryujinx.Input.Assigner;
|
|
|
|
namespace Ryujinx.Ava.UI.Views.Settings
|
|
{
|
|
public partial class SettingsHotkeysView : UserControl
|
|
{
|
|
private ButtonKeyAssigner _currentAssigner;
|
|
private readonly IGamepadDriver _avaloniaKeyboardDriver;
|
|
|
|
public SettingsHotkeysView()
|
|
{
|
|
InitializeComponent();
|
|
_avaloniaKeyboardDriver = new AvaloniaKeyboardDriver(this);
|
|
}
|
|
|
|
private void MouseClick(object sender, PointerPressedEventArgs e)
|
|
{
|
|
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
|
|
|
|
_currentAssigner?.Cancel(shouldUnbind);
|
|
|
|
PointerPressed -= MouseClick;
|
|
}
|
|
|
|
private void Button_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is ToggleButton button)
|
|
{
|
|
if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (_currentAssigner == null && button.IsChecked != null && (bool)button.IsChecked)
|
|
{
|
|
_currentAssigner = new ButtonKeyAssigner(button);
|
|
|
|
this.Focus(NavigationMethod.Pointer);
|
|
|
|
PointerPressed += MouseClick;
|
|
|
|
var keyboard = (IKeyboard)_avaloniaKeyboardDriver.GetGamepad(_avaloniaKeyboardDriver.GamepadsIds[0]);
|
|
IButtonAssigner assigner = new KeyboardKeyAssigner(keyboard);
|
|
|
|
_currentAssigner.GetInputAndAssign(assigner);
|
|
}
|
|
else
|
|
{
|
|
if (_currentAssigner != null)
|
|
{
|
|
ToggleButton oldButton = _currentAssigner.ToggledButton;
|
|
|
|
_currentAssigner.Cancel();
|
|
_currentAssigner = null;
|
|
|
|
button.IsChecked = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Button_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
_currentAssigner?.Cancel();
|
|
_currentAssigner = null;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_currentAssigner?.Cancel();
|
|
_currentAssigner = null;
|
|
}
|
|
}
|
|
}
|