Enable nullability in AxisSpec and related types

This commit is contained in:
YoshiRulz 2020-06-26 15:03:28 +10:00
parent d0f96339ce
commit 4f7c1a0b76
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 20 additions and 8 deletions

View File

@ -1,9 +1,11 @@
#nullable enable
namespace BizHawk.Emulation.Common
{
public interface AxisConstraint
{
public string Class { get; }
public string? Class { get; }
public string PairedAxis { get; }
public string? PairedAxis { get; }
}
}

View File

@ -1,3 +1,5 @@
#nullable enable
using System.Collections;
using System.Collections.Generic;

View File

@ -1,3 +1,5 @@
#nullable enable
namespace BizHawk.Emulation.Common
{
/// <summary>represents the direction of <c>(+, +)</c></summary>

View File

@ -1,3 +1,5 @@
#nullable enable
using System;
using BizHawk.Common;
@ -11,7 +13,7 @@ namespace BizHawk.Emulation.Common
/// For instance, a N64 controller's analog range is actually larger than the amount allowed by the plastic that artificially constrains it to lower values
/// Axis constraints provide a way to technically allow the full range but have a user option to constrain down to typical values that a real control would have
/// </summary>
public readonly AxisConstraint Constraint;
public readonly AxisConstraint? Constraint;
public Range<float> FloatRange => ((float) Min).RangeTo(Max);
@ -27,11 +29,11 @@ namespace BizHawk.Emulation.Common
public int Min => Range.Start;
public string PairedAxis => Constraint?.PairedAxis;
public string? PairedAxis => Constraint?.PairedAxis;
public readonly Range<int> Range;
public AxisSpec(Range<int> range, int mid, bool isReversed = false, AxisConstraint constraint = null)
public AxisSpec(Range<int> range, int mid, bool isReversed = false, AxisConstraint? constraint = null)
{
Constraint = constraint;
IsReversed = isReversed;

View File

@ -1,10 +1,12 @@
#nullable enable
using System;
namespace BizHawk.Emulation.Common
{
public sealed class CircularAxisConstraint : AxisConstraint
{
public string Class { get; }
public string? Class { get; }
private readonly float Magnitude;

View File

@ -1,10 +1,12 @@
#nullable enable
namespace BizHawk.Emulation.Common
{
public sealed class NoOpAxisConstraint : AxisConstraint
{
public string Class { get; } = null;
public string? Class { get; } = null;
public string PairedAxis { get; }
public string? PairedAxis { get; }
public NoOpAxisConstraint(string pairedAxis) => PairedAxis = pairedAxis;
}