mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-10 12:49:13 +00:00
Crimes against code
This commit is contained in:
parent
1231e1e87d
commit
2b0fce3e9d
8 changed files with 147 additions and 121 deletions
|
@ -346,12 +346,12 @@
|
|||
"GamepadRightShoulder": "Right Shoulder",
|
||||
"GamepadLeftTrigger": "Left Trigger",
|
||||
"GamepadRightTrigger": "Right Trigger",
|
||||
"GamepadDpadUp": "D-Pad Up",
|
||||
"GamepadDpadDown": "D-Pad Down",
|
||||
"GamepadDpadLeft": "D-Pad Left",
|
||||
"GamepadDpadRight": "D-Pad Right",
|
||||
"GamepadMinus": "Gamepad Minus",
|
||||
"GamepadPlus": "Gamepad Plus",
|
||||
"GamepadDpadUp": "Up",
|
||||
"GamepadDpadDown": "Down",
|
||||
"GamepadDpadLeft": "Left",
|
||||
"GamepadDpadRight": "Right",
|
||||
"GamepadMinus": "-",
|
||||
"GamepadPlus": "+",
|
||||
"GamepadGuide": "Guide",
|
||||
"GamepadMisc1": "Misc",
|
||||
"GamepadPaddle1": "Paddle 1",
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.LogicalTree;
|
||||
|
@ -17,11 +19,13 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
{
|
||||
public ToggleButton Button { get; }
|
||||
public bool IsAssigned { get; }
|
||||
public object Key { get; }
|
||||
|
||||
public ButtonAssignedEventArgs(ToggleButton button, bool isAssigned)
|
||||
public ButtonAssignedEventArgs(ToggleButton button, bool isAssigned, object key)
|
||||
{
|
||||
Button = button;
|
||||
IsAssigned = isAssigned;
|
||||
Key = key;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,15 +83,11 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
string pressedButton = assigner.GetPressedButton();
|
||||
object pressedButton = assigner.GetPressedButton();
|
||||
|
||||
if (_shouldUnbind)
|
||||
{
|
||||
SetButtonText(ToggledButton, LocaleManager.Instance[LocaleKeys.KeyUnbound]);
|
||||
}
|
||||
else if (pressedButton != "")
|
||||
{
|
||||
SetButtonText(ToggledButton, pressedButton);
|
||||
pressedButton = null;
|
||||
}
|
||||
|
||||
_shouldUnbind = false;
|
||||
|
@ -95,17 +95,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
|
||||
ToggledButton.IsChecked = false;
|
||||
|
||||
ButtonAssigned?.Invoke(this, new ButtonAssignedEventArgs(ToggledButton, pressedButton != null));
|
||||
ButtonAssigned?.Invoke(this, new ButtonAssignedEventArgs(ToggledButton, pressedButton != null, pressedButton));
|
||||
|
||||
static void SetButtonText(ToggleButton button, string text)
|
||||
{
|
||||
ILogical textBlock = button.GetLogicalDescendants().First(x => x is TextBlock);
|
||||
|
||||
if (textBlock != null && textBlock is TextBlock block)
|
||||
{
|
||||
block.Text = text;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -164,49 +164,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
object key = null;
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
if (targetType == typeof(Key))
|
||||
{
|
||||
var optionalKey = KeysMap.FirstOrOptional(x => LocaleManager.Instance[x.Value] == value.ToString());
|
||||
if (optionalKey.HasValue)
|
||||
{
|
||||
key = optionalKey.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = Enum.Parse<Key>(value.ToString());
|
||||
}
|
||||
}
|
||||
else if (targetType == typeof(GamepadInputId))
|
||||
{
|
||||
var optionalKey = GamepadInputIdMap.FirstOrOptional(x => LocaleManager.Instance[x.Value] == value.ToString());
|
||||
if (optionalKey.HasValue)
|
||||
{
|
||||
key = optionalKey.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = Enum.Parse<Key>(value.ToString());
|
||||
}
|
||||
}
|
||||
else if (targetType == typeof(StickInputId))
|
||||
{
|
||||
var optionalKey = StickInputIdMap.FirstOrOptional(x => LocaleManager.Instance[x.Value] == value.ToString());
|
||||
if (optionalKey.HasValue)
|
||||
{
|
||||
key = optionalKey.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = Enum.Parse<Key>(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsTriggerZL}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonZl">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonZl, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonZl, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -90,9 +90,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsTriggerL}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonL">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonL, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonL, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -106,9 +106,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsButtonMinus}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonMinus">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonMinus, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonMinus, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -140,9 +140,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsStickButton}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="LeftStickButton">
|
||||
<TextBlock
|
||||
Text="{Binding Config.LeftStickButton, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.LeftStickButton, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -157,9 +157,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsStickStick}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton Tag="stick">
|
||||
<ToggleButton Name="LeftJoystick" Tag="stick">
|
||||
<TextBlock
|
||||
Text="{Binding Config.LeftJoystick, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.LeftJoystick, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -250,9 +250,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsDPadUp}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="DpadUp">
|
||||
<TextBlock
|
||||
Text="{Binding Config.DpadUp, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.DpadUp, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -267,9 +267,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsDPadDown}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="DpadDown">
|
||||
<TextBlock
|
||||
Text="{Binding Config.DpadDown, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.DpadDown, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -284,9 +284,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsDPadLeft}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="DpadLeft">
|
||||
<TextBlock
|
||||
Text="{Binding Config.DpadLeft, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.DpadLeft, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -301,9 +301,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsDPadRight}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="DpadRight">
|
||||
<TextBlock
|
||||
Text="{Binding Config.DpadRight, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.DpadRight, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -354,9 +354,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsLeftSR}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="LeftButtonSr">
|
||||
<TextBlock
|
||||
Text="{Binding Config.LeftButtonSr, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.LeftButtonSr, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -372,9 +372,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsLeftSL}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="LeftButtonSl">
|
||||
<TextBlock
|
||||
Text="{Binding Config.LeftButtonSl, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.LeftButtonSl, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -390,9 +390,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsRightSR}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="RightButtonSr">
|
||||
<TextBlock
|
||||
Text="{Binding Config.RightButtonSr, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.RightButtonSr, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -408,9 +408,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsRightSL}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="RightButtonSl">
|
||||
<TextBlock
|
||||
Text="{Binding Config.RightButtonSl, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.RightButtonSl, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -516,9 +516,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsTriggerZR}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonZr">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonZr, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonZr, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -534,9 +534,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsTriggerR}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonR">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonR, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonR, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -552,9 +552,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsButtonPlus}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonPlus">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonPlus, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonPlus, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -587,9 +587,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsButtonA}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonA">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonA, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonA, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -604,9 +604,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsButtonB}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonB">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonB, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonB, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -621,9 +621,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsButtonX}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonX">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonX, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonX, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -638,9 +638,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsButtonY}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="ButtonY">
|
||||
<TextBlock
|
||||
Text="{Binding Config.ButtonY, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.ButtonY, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -672,9 +672,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsStickButton}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton>
|
||||
<ToggleButton Name="RightStickButton">
|
||||
<TextBlock
|
||||
Text="{Binding Config.RightStickButton, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.RightStickButton, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
@ -690,9 +690,9 @@
|
|||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale ControllerSettingsStickStick}"
|
||||
TextAlignment="Center" />
|
||||
<ToggleButton Tag="stick">
|
||||
<ToggleButton Name="RightJoystick" Tag="stick">
|
||||
<TextBlock
|
||||
Text="{Binding Config.RightJoystick, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
Text="{Binding Config.RightJoystick, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
|
|
|
@ -8,6 +8,8 @@ using Ryujinx.Ava.UI.ViewModels.Input;
|
|||
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.Assigner;
|
||||
using System;
|
||||
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.Input
|
||||
{
|
||||
|
@ -65,7 +67,82 @@ namespace Ryujinx.Ava.UI.Views.Input
|
|||
{
|
||||
if (e.IsAssigned)
|
||||
{
|
||||
(DataContext as ControllerInputViewModel).parentModel.IsModified = true;
|
||||
var viewModel = (DataContext as ControllerInputViewModel);
|
||||
viewModel.parentModel.IsModified = true;
|
||||
|
||||
// This is a crime against code but I can't think of anything better rn
|
||||
switch (button.Name)
|
||||
{
|
||||
case "ButtonZl":
|
||||
viewModel.Config.ButtonZl = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonL":
|
||||
viewModel.Config.ButtonL = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonMinus":
|
||||
viewModel.Config.ButtonMinus = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "LeftStickButton":
|
||||
viewModel.Config.LeftStickButton = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "LeftJoystick":
|
||||
viewModel.Config.LeftJoystick = (StickInputId)e.Key;
|
||||
break;
|
||||
case "DpadUp":
|
||||
viewModel.Config.DpadUp = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "DpadDown":
|
||||
viewModel.Config.DpadDown = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "DpadLeft":
|
||||
viewModel.Config.DpadLeft = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "DpadRight":
|
||||
viewModel.Config.DpadRight = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "LeftButtonSr":
|
||||
viewModel.Config.LeftButtonSr = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "LeftButtonSl":
|
||||
viewModel.Config.LeftButtonSl = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "RightButtonSr":
|
||||
viewModel.Config.RightButtonSr = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "RightButtonSl":
|
||||
viewModel.Config.RightButtonSl = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonZr":
|
||||
viewModel.Config.ButtonZr = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonR":
|
||||
viewModel.Config.ButtonR = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonPlus":
|
||||
viewModel.Config.ButtonPlus = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonA":
|
||||
viewModel.Config.ButtonA = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonB":
|
||||
viewModel.Config.ButtonB = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonX":
|
||||
viewModel.Config.ButtonX = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "ButtonY":
|
||||
viewModel.Config.ButtonY = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "RightStickButton":
|
||||
viewModel.Config.RightStickButton = (GamepadInputId)e.Key;
|
||||
break;
|
||||
case "RightJoystick":
|
||||
viewModel.Config.RightJoystick = (StickInputId)e.Key;
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine(button.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -59,16 +59,16 @@ namespace Ryujinx.Input.Assigner
|
|||
return _gamepad == null || !_gamepad.IsConnected;
|
||||
}
|
||||
|
||||
public string GetPressedButton()
|
||||
public object GetPressedButton()
|
||||
{
|
||||
IEnumerable<GamepadButtonInputId> pressedButtons = _detector.GetPressedButtons();
|
||||
|
||||
if (pressedButtons.Any())
|
||||
{
|
||||
return !_forStick ? pressedButtons.First().ToString() : ((StickInputId)pressedButtons.First()).ToString();
|
||||
return !_forStick ? pressedButtons.First() : ((StickInputId)pressedButtons.First());
|
||||
}
|
||||
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
private void CollectButtonStats()
|
||||
|
|
|
@ -31,6 +31,6 @@ namespace Ryujinx.Input.Assigner
|
|||
/// Get the pressed button that was read in <see cref="ReadInput"/> by the button assigner.
|
||||
/// </summary>
|
||||
/// <returns>The pressed button that was read</returns>
|
||||
string GetPressedButton();
|
||||
object GetPressedButton();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Input.Assigner
|
|||
|
||||
public bool HasAnyButtonPressed()
|
||||
{
|
||||
return GetPressedButton().Length != 0;
|
||||
return GetPressedButton() is not null;
|
||||
}
|
||||
|
||||
public bool ShouldCancel()
|
||||
|
@ -31,20 +31,20 @@ namespace Ryujinx.Input.Assigner
|
|||
return _keyboardState.IsPressed(Key.Escape);
|
||||
}
|
||||
|
||||
public string GetPressedButton()
|
||||
public object GetPressedButton()
|
||||
{
|
||||
string keyPressed = "";
|
||||
object keyPressed = null;
|
||||
|
||||
for (Key key = Key.Unknown; key < Key.Count; key++)
|
||||
{
|
||||
if (_keyboardState.IsPressed(key))
|
||||
{
|
||||
keyPressed = key.ToString();
|
||||
keyPressed = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return !ShouldCancel() ? keyPressed : "";
|
||||
return !ShouldCancel() ? keyPressed : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue