hid: Rewrite shared memory management (#2257)
* hid: Rewrite shared memory management This entirely rewrite our ancient (and original) HID shared memory interface to be more usable and accurate. HID update logics were updated to reflect those changes but should work still the same way it previously did. This need heavy testing just in case to avoid possible regressions. * Silence warnings * Address gdkchan's comments * Address Ac_K's comments * Address one missing nit
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common;
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.DebugPad;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
{
|
||||
public class DebugPadDevice : BaseDevice
|
||||
@@ -6,20 +9,20 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
|
||||
public void Update()
|
||||
{
|
||||
ref ShMemDebugPad debugPad = ref _device.Hid.SharedMemory.DebugPad;
|
||||
ref RingLifo<DebugPadState> lifo = ref _device.Hid.SharedMemory.DebugPad;
|
||||
|
||||
int currentIndex = UpdateEntriesHeader(ref debugPad.Header, out int previousIndex);
|
||||
ref DebugPadState previousEntry = ref lifo.GetCurrentEntryRef();
|
||||
|
||||
if (!Active)
|
||||
DebugPadState newState = new DebugPadState();
|
||||
|
||||
if (Active)
|
||||
{
|
||||
return;
|
||||
// TODO: This is a debug device only present in dev environment, do we want to support it?
|
||||
}
|
||||
|
||||
ref DebugPadEntry currentEntry = ref debugPad.Entries[currentIndex];
|
||||
DebugPadEntry previousEntry = debugPad.Entries[previousIndex];
|
||||
newState.SamplingNumber = previousEntry.SamplingNumber + 1;
|
||||
|
||||
currentEntry.SampleTimestamp = previousEntry.SampleTimestamp + 1;
|
||||
currentEntry.SampleTimestamp2 = previousEntry.SampleTimestamp2 + 1;
|
||||
lifo.Write(ref newState);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user