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",
|
"GamepadRightShoulder": "Right Shoulder",
|
||||||
"GamepadLeftTrigger": "Left Trigger",
|
"GamepadLeftTrigger": "Left Trigger",
|
||||||
"GamepadRightTrigger": "Right Trigger",
|
"GamepadRightTrigger": "Right Trigger",
|
||||||
"GamepadDpadUp": "D-Pad Up",
|
"GamepadDpadUp": "Up",
|
||||||
"GamepadDpadDown": "D-Pad Down",
|
"GamepadDpadDown": "Down",
|
||||||
"GamepadDpadLeft": "D-Pad Left",
|
"GamepadDpadLeft": "Left",
|
||||||
"GamepadDpadRight": "D-Pad Right",
|
"GamepadDpadRight": "Right",
|
||||||
"GamepadMinus": "Gamepad Minus",
|
"GamepadMinus": "-",
|
||||||
"GamepadPlus": "Gamepad Plus",
|
"GamepadPlus": "+",
|
||||||
"GamepadGuide": "Guide",
|
"GamepadGuide": "Guide",
|
||||||
"GamepadMisc1": "Misc",
|
"GamepadMisc1": "Misc",
|
||||||
"GamepadPaddle1": "Paddle 1",
|
"GamepadPaddle1": "Paddle 1",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Data;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.LogicalTree;
|
using Avalonia.LogicalTree;
|
||||||
|
@ -17,11 +19,13 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
{
|
{
|
||||||
public ToggleButton Button { get; }
|
public ToggleButton Button { get; }
|
||||||
public bool IsAssigned { 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;
|
Button = button;
|
||||||
IsAssigned = isAssigned;
|
IsAssigned = isAssigned;
|
||||||
|
Key = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,15 +83,11 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
|
||||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
string pressedButton = assigner.GetPressedButton();
|
object pressedButton = assigner.GetPressedButton();
|
||||||
|
|
||||||
if (_shouldUnbind)
|
if (_shouldUnbind)
|
||||||
{
|
{
|
||||||
SetButtonText(ToggledButton, LocaleManager.Instance[LocaleKeys.KeyUnbound]);
|
pressedButton = null;
|
||||||
}
|
|
||||||
else if (pressedButton != "")
|
|
||||||
{
|
|
||||||
SetButtonText(ToggledButton, pressedButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_shouldUnbind = false;
|
_shouldUnbind = false;
|
||||||
|
@ -95,17 +95,8 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
|
||||||
ToggledButton.IsChecked = false;
|
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)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
object key = null;
|
throw new NotSupportedException();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsTriggerZL}"
|
Text="{locale:Locale ControllerSettingsTriggerZL}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonZl">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonZl, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonZl, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -90,9 +90,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsTriggerL}"
|
Text="{locale:Locale ControllerSettingsTriggerL}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonL">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonL, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonL, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -106,9 +106,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsButtonMinus}"
|
Text="{locale:Locale ControllerSettingsButtonMinus}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonMinus">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonMinus, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonMinus, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -140,9 +140,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsStickButton}"
|
Text="{locale:Locale ControllerSettingsStickButton}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="LeftStickButton">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.LeftStickButton, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.LeftStickButton, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -157,9 +157,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsStickStick}"
|
Text="{locale:Locale ControllerSettingsStickStick}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton Tag="stick">
|
<ToggleButton Name="LeftJoystick" Tag="stick">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.LeftJoystick, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.LeftJoystick, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -250,9 +250,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsDPadUp}"
|
Text="{locale:Locale ControllerSettingsDPadUp}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="DpadUp">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.DpadUp, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.DpadUp, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -267,9 +267,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsDPadDown}"
|
Text="{locale:Locale ControllerSettingsDPadDown}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="DpadDown">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.DpadDown, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.DpadDown, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -284,9 +284,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsDPadLeft}"
|
Text="{locale:Locale ControllerSettingsDPadLeft}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="DpadLeft">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.DpadLeft, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.DpadLeft, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -301,9 +301,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsDPadRight}"
|
Text="{locale:Locale ControllerSettingsDPadRight}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="DpadRight">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.DpadRight, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.DpadRight, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -354,9 +354,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsLeftSR}"
|
Text="{locale:Locale ControllerSettingsLeftSR}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="LeftButtonSr">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.LeftButtonSr, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.LeftButtonSr, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -372,9 +372,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsLeftSL}"
|
Text="{locale:Locale ControllerSettingsLeftSL}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="LeftButtonSl">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.LeftButtonSl, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.LeftButtonSl, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -390,9 +390,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsRightSR}"
|
Text="{locale:Locale ControllerSettingsRightSR}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="RightButtonSr">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.RightButtonSr, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.RightButtonSr, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -408,9 +408,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsRightSL}"
|
Text="{locale:Locale ControllerSettingsRightSL}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="RightButtonSl">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.RightButtonSl, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.RightButtonSl, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -516,9 +516,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsTriggerZR}"
|
Text="{locale:Locale ControllerSettingsTriggerZR}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonZr">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonZr, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonZr, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -534,9 +534,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsTriggerR}"
|
Text="{locale:Locale ControllerSettingsTriggerR}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonR">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonR, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonR, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -552,9 +552,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsButtonPlus}"
|
Text="{locale:Locale ControllerSettingsButtonPlus}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonPlus">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonPlus, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonPlus, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -587,9 +587,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsButtonA}"
|
Text="{locale:Locale ControllerSettingsButtonA}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonA">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonA, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonA, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -604,9 +604,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsButtonB}"
|
Text="{locale:Locale ControllerSettingsButtonB}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonB">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonB, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonB, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -621,9 +621,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsButtonX}"
|
Text="{locale:Locale ControllerSettingsButtonX}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonX">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonX, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonX, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -638,9 +638,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsButtonY}"
|
Text="{locale:Locale ControllerSettingsButtonY}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="ButtonY">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.ButtonY, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.ButtonY, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -672,9 +672,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsStickButton}"
|
Text="{locale:Locale ControllerSettingsStickButton}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton>
|
<ToggleButton Name="RightStickButton">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.RightStickButton, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.RightStickButton, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -690,9 +690,9 @@
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{locale:Locale ControllerSettingsStickStick}"
|
Text="{locale:Locale ControllerSettingsStickStick}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
<ToggleButton Tag="stick">
|
<ToggleButton Name="RightJoystick" Tag="stick">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding Config.RightJoystick, Mode=TwoWay, Converter={StaticResource Key}}"
|
Text="{Binding Config.RightJoystick, Converter={StaticResource Key}}"
|
||||||
TextAlignment="Center" />
|
TextAlignment="Center" />
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -8,6 +8,8 @@ using Ryujinx.Ava.UI.ViewModels.Input;
|
||||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.Assigner;
|
using Ryujinx.Input.Assigner;
|
||||||
|
using System;
|
||||||
|
using StickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Input
|
namespace Ryujinx.Ava.UI.Views.Input
|
||||||
{
|
{
|
||||||
|
@ -65,7 +67,82 @@ namespace Ryujinx.Ava.UI.Views.Input
|
||||||
{
|
{
|
||||||
if (e.IsAssigned)
|
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;
|
return _gamepad == null || !_gamepad.IsConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetPressedButton()
|
public object GetPressedButton()
|
||||||
{
|
{
|
||||||
IEnumerable<GamepadButtonInputId> pressedButtons = _detector.GetPressedButtons();
|
IEnumerable<GamepadButtonInputId> pressedButtons = _detector.GetPressedButtons();
|
||||||
|
|
||||||
if (pressedButtons.Any())
|
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()
|
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.
|
/// Get the pressed button that was read in <see cref="ReadInput"/> by the button assigner.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The pressed button that was read</returns>
|
/// <returns>The pressed button that was read</returns>
|
||||||
string GetPressedButton();
|
object GetPressedButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Input.Assigner
|
||||||
|
|
||||||
public bool HasAnyButtonPressed()
|
public bool HasAnyButtonPressed()
|
||||||
{
|
{
|
||||||
return GetPressedButton().Length != 0;
|
return GetPressedButton() is not null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShouldCancel()
|
public bool ShouldCancel()
|
||||||
|
@ -31,20 +31,20 @@ namespace Ryujinx.Input.Assigner
|
||||||
return _keyboardState.IsPressed(Key.Escape);
|
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++)
|
for (Key key = Key.Unknown; key < Key.Count; key++)
|
||||||
{
|
{
|
||||||
if (_keyboardState.IsPressed(key))
|
if (_keyboardState.IsPressed(key))
|
||||||
{
|
{
|
||||||
keyPressed = key.ToString();
|
keyPressed = key;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !ShouldCancel() ? keyPressed : "";
|
return !ShouldCancel() ? keyPressed : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue