Compare commits

..

2 Commits

Author SHA1 Message Date
SpicerXD
e27f5522e2 Removed MotionInput Calibration (#4705)
Don't know why this is here.
It just seems to set the filter to an identity. Which then quickly returns to where its supposed to be anyways.
2023-04-22 15:31:28 +02:00
gdkchan
add2a9d151 Avoid LM service crashes by not reading more than the buffer size (#4701) 2023-04-20 17:10:17 +02:00
3 changed files with 11 additions and 27 deletions

View File

@@ -33,6 +33,11 @@ namespace Ryujinx.Common.Memory
return data;
}
public ReadOnlySpan<byte> GetSpanSafe(int size)
{
return GetSpan((int)Math.Min((uint)_input.Length, (uint)size));
}
public T ReadAt<T>(int offset) where T : unmanaged
{
return MemoryMarshal.Cast<byte, T>(_input.Slice(offset))[0];

View File

@@ -113,7 +113,7 @@ namespace Ryujinx.Horizon.LogManager.Ipc
}
else if (key == LogDataChunkKey.Message)
{
string text = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
string text = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
if (isHeadPacket && isTailPacket)
{
@@ -131,23 +131,23 @@ namespace Ryujinx.Horizon.LogManager.Ipc
}
else if (key == LogDataChunkKey.Filename)
{
_logPacket.Filename = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
_logPacket.Filename = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.Function)
{
_logPacket.Function = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
_logPacket.Function = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.Module)
{
_logPacket.Module = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
_logPacket.Module = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.Thread)
{
_logPacket.Thread = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
_logPacket.Thread = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
else if (key == LogDataChunkKey.ProgramName)
{
_logPacket.ProgramName = Encoding.UTF8.GetString(reader.GetSpan(size)).TrimEnd();
_logPacket.ProgramName = Encoding.UTF8.GetString(reader.GetSpanSafe(size)).TrimEnd();
}
}

View File

@@ -12,7 +12,6 @@ namespace Ryujinx.Input
public Vector3 Rotation { get; set; }
private readonly MotionSensorFilter _filter;
private int _calibrationFrame = 0;
public MotionInput()
{
@@ -29,26 +28,6 @@ namespace Ryujinx.Input
{
if (TimeStamp != 0)
{
if (gyro.Length() <= 1f && accel.Length() >= 0.8f && accel.Z >= 0.8f)
{
_calibrationFrame++;
if (_calibrationFrame >= 90)
{
gyro = Vector3.Zero;
Rotation = Vector3.Zero;
_filter.Reset();
_calibrationFrame = 0;
}
}
else
{
_calibrationFrame = 0;
}
Accelerometer = -accel;
if (gyro.Length() < deadzone)