SteamController: Fix PS button and Gyro support for DS4

Make DS4 fields be readonly and optimise DS4 packets.
This commit is contained in:
Kamil Trzciński 2023-02-11 13:37:17 +01:00
parent eed1453daf
commit 00a30cbf5c
5 changed files with 65 additions and 54 deletions

View file

@ -1,6 +1,6 @@
namespace CommonHelpers
{
public class TimedValue<T> where T : struct
public struct TimedValue<T> where T : struct
{
public T Value { get; }
public DateTime ExpiryDate { get; }
@ -32,9 +32,19 @@ namespace CommonHelpers
return Valid;
}
public T? GetValue()
{
return Valid ? Value : null;
}
public T GetValueOrDefault(T defaultValue)
{
return Valid ? Value : defaultValue;
}
public static implicit operator T?(TimedValue<T> tv)
{
return tv.Valid ? tv.Value : null;
return tv.GetValue();
}
}
}