mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-04-24 06:47:44 +02:00
Added the ability to delete assigned buttons with the right mouse button in the settings.
- for keyboard - for hotkeys
This commit is contained in:
parent
a0594e8169
commit
1951fe0077
2 changed files with 93 additions and 0 deletions
|
@ -8,6 +8,8 @@ using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.ViewModels.Input;
|
using Ryujinx.Ava.UI.ViewModels.Input;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.Assigner;
|
using Ryujinx.Input.Assigner;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
using Button = Ryujinx.Input.Button;
|
using Button = Ryujinx.Input.Button;
|
||||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||||
|
|
||||||
|
@ -193,11 +195,65 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
{
|
{
|
||||||
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
|
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
|
||||||
|
|
||||||
|
bool shouldRemoveBinding = e.GetCurrentPoint(this).Properties.IsRightButtonPressed;
|
||||||
|
|
||||||
|
if (shouldRemoveBinding)
|
||||||
|
{
|
||||||
|
DeleteBind();
|
||||||
|
}
|
||||||
|
|
||||||
_currentAssigner?.Cancel(shouldUnbind);
|
_currentAssigner?.Cancel(shouldUnbind);
|
||||||
|
|
||||||
PointerPressed -= MouseClick;
|
PointerPressed -= MouseClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeleteBind()
|
||||||
|
{
|
||||||
|
if (DataContext is not KeyboardInputViewModel viewModel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_currentAssigner != null)
|
||||||
|
{
|
||||||
|
Dictionary<string, Action> buttonActions = new Dictionary<string, Action>
|
||||||
|
{
|
||||||
|
{ "ButtonZl", () => viewModel.Config.ButtonZl = Key.Unbound },
|
||||||
|
{ "ButtonL", () => viewModel.Config.ButtonL = Key.Unbound },
|
||||||
|
{ "ButtonMinus", () => viewModel.Config.ButtonMinus = Key.Unbound },
|
||||||
|
{ "LeftStickButton", () => viewModel.Config.LeftStickButton = Key.Unbound },
|
||||||
|
{ "LeftStickUp", () => viewModel.Config.LeftStickUp = Key.Unbound },
|
||||||
|
{ "LeftStickDown", () => viewModel.Config.LeftStickDown = Key.Unbound },
|
||||||
|
{ "LeftStickRight", () => viewModel.Config.LeftStickRight = Key.Unbound },
|
||||||
|
{ "LeftStickLeft", () => viewModel.Config.LeftStickLeft = Key.Unbound },
|
||||||
|
{ "DpadUp", () => viewModel.Config.DpadUp = Key.Unbound },
|
||||||
|
{ "DpadDown", () => viewModel.Config.DpadDown = Key.Unbound },
|
||||||
|
{ "DpadLeft", () => viewModel.Config.DpadLeft = Key.Unbound },
|
||||||
|
{ "DpadRight", () => viewModel.Config.DpadRight = Key.Unbound },
|
||||||
|
{ "LeftButtonSr", () => viewModel.Config.LeftButtonSr = Key.Unbound },
|
||||||
|
{ "LeftButtonSl", () => viewModel.Config.LeftButtonSl = Key.Unbound },
|
||||||
|
{ "RightButtonSr", () => viewModel.Config.RightButtonSr = Key.Unbound },
|
||||||
|
{ "RightButtonSl", () => viewModel.Config.RightButtonSl = Key.Unbound },
|
||||||
|
{ "ButtonZr", () => viewModel.Config.ButtonZr = Key.Unbound },
|
||||||
|
{ "ButtonR", () => viewModel.Config.ButtonR = Key.Unbound },
|
||||||
|
{ "ButtonPlus", () => viewModel.Config.ButtonPlus = Key.Unbound },
|
||||||
|
{ "ButtonA", () => viewModel.Config.ButtonA = Key.Unbound },
|
||||||
|
{ "ButtonB", () => viewModel.Config.ButtonB = Key.Unbound },
|
||||||
|
{ "ButtonX", () => viewModel.Config.ButtonX = Key.Unbound },
|
||||||
|
{ "ButtonY", () => viewModel.Config.ButtonY = Key.Unbound },
|
||||||
|
{ "RightStickButton", () => viewModel.Config.RightStickButton = Key.Unbound },
|
||||||
|
{ "RightStickUp", () => viewModel.Config.RightStickUp = Key.Unbound },
|
||||||
|
{ "RightStickDown", () => viewModel.Config.RightStickDown = Key.Unbound },
|
||||||
|
{ "RightStickRight", () => viewModel.Config.RightStickRight = Key.Unbound },
|
||||||
|
{ "RightStickLeft", () => viewModel.Config.RightStickLeft = Key.Unbound }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (buttonActions.TryGetValue(_currentAssigner.ToggledButton.Name, out Action action))
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
FlagInputConfigChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnDetachedFromVisualTree(e);
|
base.OnDetachedFromVisualTree(e);
|
||||||
|
|
|
@ -8,6 +8,8 @@ using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.Assigner;
|
using Ryujinx.Input.Assigner;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
using Button = Ryujinx.Input.Button;
|
using Button = Ryujinx.Input.Button;
|
||||||
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
using Key = Ryujinx.Common.Configuration.Hid.Key;
|
||||||
|
|
||||||
|
@ -46,12 +48,47 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
private void MouseClick(object sender, PointerPressedEventArgs e)
|
private void MouseClick(object sender, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
|
bool shouldUnbind = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
|
||||||
|
bool shouldRemoveBinding = e.GetCurrentPoint(this).Properties.IsRightButtonPressed;
|
||||||
|
|
||||||
|
if (shouldRemoveBinding)
|
||||||
|
{
|
||||||
|
DeleteBind();
|
||||||
|
}
|
||||||
|
|
||||||
_currentAssigner?.Cancel(shouldUnbind);
|
_currentAssigner?.Cancel(shouldUnbind);
|
||||||
|
|
||||||
PointerPressed -= MouseClick;
|
PointerPressed -= MouseClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeleteBind()
|
||||||
|
{
|
||||||
|
if (DataContext is not SettingsViewModel viewModel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_currentAssigner != null)
|
||||||
|
{
|
||||||
|
Dictionary<string, Action> buttonActions = new Dictionary<string, Action>
|
||||||
|
{
|
||||||
|
{ "ToggleVSyncMode", () => viewModel.KeyboardHotkey.ToggleVSyncMode = Key.Unbound },
|
||||||
|
{ "Screenshot", () => viewModel.KeyboardHotkey.Screenshot = Key.Unbound },
|
||||||
|
{ "ShowUI", () => viewModel.KeyboardHotkey.ShowUI = Key.Unbound },
|
||||||
|
{ "Pause", () => viewModel.KeyboardHotkey.Pause = Key.Unbound },
|
||||||
|
{ "ToggleMute", () => viewModel.KeyboardHotkey.ToggleMute = Key.Unbound },
|
||||||
|
{ "ResScaleUp", () => viewModel.KeyboardHotkey.ResScaleUp = Key.Unbound },
|
||||||
|
{ "ResScaleDown", () => viewModel.KeyboardHotkey.ResScaleDown = Key.Unbound },
|
||||||
|
{ "VolumeUp", () => viewModel.KeyboardHotkey.VolumeUp = Key.Unbound },
|
||||||
|
{ "VolumeDown", () => viewModel.KeyboardHotkey.VolumeDown = Key.Unbound },
|
||||||
|
{ "CustomVSyncIntervalIncrement", () => viewModel.KeyboardHotkey.CustomVSyncIntervalIncrement = Key.Unbound },
|
||||||
|
{ "CustomVSyncIntervalDecrement", () => viewModel.KeyboardHotkey.CustomVSyncIntervalDecrement = Key.Unbound }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (buttonActions.TryGetValue(_currentAssigner.ToggledButton.Name, out Action action))
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
|
private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is ToggleButton button)
|
if (sender is ToggleButton button)
|
||||||
|
|
Loading…
Add table
Reference in a new issue