mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-20 07:36:38 +00:00
32 lines
1 KiB
C#
32 lines
1 KiB
C#
|
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 ShMemKeyboard keyboard = ref _device.Hid.SharedMemory.Keyboard;
|
||
|
|
||
|
int currentIndex = UpdateEntriesHeader(ref keyboard.Header, out int previousIndex);
|
||
|
|
||
|
if (!Active)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ref KeyboardState currentEntry = ref keyboard.Entries[currentIndex];
|
||
|
KeyboardState previousEntry = keyboard.Entries[previousIndex];
|
||
|
|
||
|
currentEntry.SampleTimestamp = previousEntry.SampleTimestamp + 1;
|
||
|
currentEntry.SampleTimestamp2 = previousEntry.SampleTimestamp2 + 1;
|
||
|
|
||
|
for (int i = 0; i < 8; ++i)
|
||
|
{
|
||
|
currentEntry.Keys[i] = (uint)keyState.Keys[i];
|
||
|
}
|
||
|
|
||
|
currentEntry.Modifier = (ulong)keyState.Modifier;
|
||
|
}
|
||
|
}
|
||
|
}
|