1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-14 12:36:40 +00:00
Ryujinx/Ryujinx.HLE/HOS/Services/Hid/HidDevices/KeyboardDevice.cs

35 lines
1,014 B
C#
Raw Normal View History

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);
}
}
}