Clean up some magic numbers between code and axaml.
This commit is contained in:
parent
d01c67f7bf
commit
e3e16f0345
2 changed files with 30 additions and 25 deletions
|
@ -3,7 +3,6 @@ using Ryujinx.Ava.Input;
|
||||||
using Ryujinx.Ava.UI.Models.Input;
|
using Ryujinx.Ava.UI.Models.Input;
|
||||||
using Ryujinx.Ava.UI.Views.Input;
|
using Ryujinx.Ava.UI.Views.Input;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using System;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -12,7 +11,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
public class ControllerInputViewModel : BaseModel
|
public class ControllerInputViewModel : BaseModel
|
||||||
{
|
{
|
||||||
private const int StickUiPollMs = 50; // Milliseconds per poll.
|
private const int StickUiPollMs = 50; // Milliseconds per poll.
|
||||||
private const float CanvasCenterOffset = 47.5f;
|
private const int StickCircumference = 5;
|
||||||
|
|
||||||
|
private const int CanvasSize = 100;
|
||||||
|
private const int StickBorderSize = CanvasSize + 5;
|
||||||
|
private const float CanvasCenterOffset = (CanvasSize - StickCircumference) / 2;
|
||||||
private const int StickScaleFactor = 45;
|
private const int StickScaleFactor = 45;
|
||||||
|
|
||||||
private IGamepad _selectedGamepad;
|
private IGamepad _selectedGamepad;
|
||||||
|
@ -100,15 +103,17 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float canvasCenter => CanvasCenterOffset;
|
public int UiStickCircumference => StickCircumference;
|
||||||
|
public int UiCanvasSize => CanvasSize;
|
||||||
|
public int UiStickBorderSize => StickBorderSize;
|
||||||
|
|
||||||
public float UiStickLeftX => UiStickLeft.Item1 + CanvasCenterOffset;
|
public float UiStickLeftX => UiStickLeft.Item1 + CanvasCenterOffset;
|
||||||
public float UiStickLeftY => UiStickLeft.Item2 + CanvasCenterOffset;
|
public float UiStickLeftY => UiStickLeft.Item2 + CanvasCenterOffset;
|
||||||
public float UiStickRightX => UiStickRight.Item1 + CanvasCenterOffset;
|
public float UiStickRightX => UiStickRight.Item1 + CanvasCenterOffset;
|
||||||
public float UiStickRightY => UiStickRight.Item2 + CanvasCenterOffset;
|
public float UiStickRightY => UiStickRight.Item2 + CanvasCenterOffset;
|
||||||
|
|
||||||
public float UiDeadzoneLeft => Config.DeadzoneLeft * 95;
|
public float UiDeadzoneLeft => Config.DeadzoneLeft * (CanvasSize - StickCircumference);
|
||||||
public float UiDeadzoneRight => Config.DeadzoneRight * 95;
|
public float UiDeadzoneRight => Config.DeadzoneRight * (CanvasSize - StickCircumference);
|
||||||
|
|
||||||
public readonly InputViewModel ParentModel;
|
public readonly InputViewModel ParentModel;
|
||||||
|
|
||||||
|
|
|
@ -333,15 +333,15 @@
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
CornerRadius="5"
|
CornerRadius="5"
|
||||||
Height="105"
|
Height="{Binding UiStickBorderSize}"
|
||||||
Width="105">
|
Width="{Binding UiStickBorderSize}">
|
||||||
<Canvas
|
<Canvas
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
Background="{DynamicResource ThemeBackgroundColor}"
|
||||||
Height="100"
|
Height="{Binding UiCanvasSize}"
|
||||||
Width="100">
|
Width="{Binding UiCanvasSize}">
|
||||||
<Grid
|
<Grid
|
||||||
Height="100"
|
Height="{Binding UiCanvasSize}"
|
||||||
Width="100"
|
Width="{Binding UiCanvasSize}"
|
||||||
Background="{DynamicResource ThemeBackgroundColor}">
|
Background="{DynamicResource ThemeBackgroundColor}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
@ -351,8 +351,8 @@
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Stroke="Black"
|
Stroke="Black"
|
||||||
StrokeThickness="1"
|
StrokeThickness="1"
|
||||||
Width="100"
|
Width="{Binding UiCanvasSize}"
|
||||||
Height="100"
|
Height="{Binding UiCanvasSize}"
|
||||||
Canvas.Bottom="2"
|
Canvas.Bottom="2"
|
||||||
Canvas.Left="2" />
|
Canvas.Left="2" />
|
||||||
<Ellipse
|
<Ellipse
|
||||||
|
@ -365,8 +365,8 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
<Ellipse
|
<Ellipse
|
||||||
Fill="Red"
|
Fill="Red"
|
||||||
Width="5"
|
Width="{Binding UiStickCircumference}"
|
||||||
Height="5"
|
Height="{Binding UiStickCircumference}"
|
||||||
Canvas.Bottom="{Binding UiStickLeftY}"
|
Canvas.Bottom="{Binding UiStickLeftY}"
|
||||||
Canvas.Left="{Binding UiStickLeftX}" />
|
Canvas.Left="{Binding UiStickLeftX}" />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
@ -375,15 +375,15 @@
|
||||||
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
BorderBrush="{DynamicResource ThemeControlBorderColor}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
CornerRadius="5"
|
CornerRadius="5"
|
||||||
Height="105"
|
Height="{Binding UiStickBorderSize}"
|
||||||
Width="105">
|
Width="{Binding UiStickBorderSize}">
|
||||||
<Canvas
|
<Canvas
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
Background="{DynamicResource ThemeBackgroundColor}"
|
||||||
Height="100"
|
Height="{Binding UiCanvasSize}"
|
||||||
Width="100">
|
Width="{Binding UiCanvasSize}">
|
||||||
<Grid
|
<Grid
|
||||||
Height="100"
|
Height="{Binding UiCanvasSize}"
|
||||||
Width="100"
|
Width="{Binding UiCanvasSize}"
|
||||||
Background="{DynamicResource ThemeBackgroundColor}">
|
Background="{DynamicResource ThemeBackgroundColor}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
@ -393,8 +393,8 @@
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Stroke="Black"
|
Stroke="Black"
|
||||||
StrokeThickness="1"
|
StrokeThickness="1"
|
||||||
Width="100"
|
Width="{Binding UiCanvasSize}"
|
||||||
Height="100"
|
Height="{Binding UiCanvasSize}"
|
||||||
Canvas.Bottom="2"
|
Canvas.Bottom="2"
|
||||||
Canvas.Left="2" />
|
Canvas.Left="2" />
|
||||||
<Ellipse
|
<Ellipse
|
||||||
|
@ -407,8 +407,8 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
<Ellipse
|
<Ellipse
|
||||||
Fill="Red"
|
Fill="Red"
|
||||||
Width="5"
|
Width="{Binding UiStickCircumference}"
|
||||||
Height="5"
|
Height="{Binding UiStickCircumference}"
|
||||||
Canvas.Bottom="{Binding UiStickRightY}"
|
Canvas.Bottom="{Binding UiStickRightY}"
|
||||||
Canvas.Left="{Binding UiStickRightX}" />
|
Canvas.Left="{Binding UiStickRightX}" />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
|
Loading…
Reference in a new issue