mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-09 01:38:39 +00:00
3443023a08
* 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
35 lines
1,014 B
C#
35 lines
1,014 B
C#
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common;
|
|
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Keyboard;
|
|
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
|
{
|
|
public class KeyboardDevice : BaseDevice
|
|
{
|
|
public KeyboardDevice(Switch device, bool active) : base(device, active) { }
|
|
|
|
public unsafe void Update(KeyboardInput keyState)
|
|
{
|
|
ref RingLifo<KeyboardState> lifo = ref _device.Hid.SharedMemory.Keyboard;
|
|
|
|
if (!Active)
|
|
{
|
|
lifo.Clear();
|
|
|
|
return;
|
|
}
|
|
|
|
ref KeyboardState previousEntry = ref lifo.GetCurrentEntryRef();
|
|
|
|
KeyboardState newState = new KeyboardState
|
|
{
|
|
SamplingNumber = previousEntry.SamplingNumber + 1,
|
|
};
|
|
|
|
keyState.Keys.AsSpan().CopyTo(newState.Keys.RawData.ToSpan());
|
|
newState.Modifiers = (KeyboardModifier)keyState.Modifier;
|
|
|
|
lifo.Write(ref newState);
|
|
}
|
|
}
|
|
} |