KeyboardDevice.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. namespace Ryujinx.HLE.HOS.Services.Hid
  2. {
  3. public class KeyboardDevice : BaseDevice
  4. {
  5. public KeyboardDevice(Switch device, bool active) : base(device, active) { }
  6. public unsafe void Update(KeyboardInput keyState)
  7. {
  8. ref ShMemKeyboard keyboard = ref _device.Hid.SharedMemory.Keyboard;
  9. int currentIndex = UpdateEntriesHeader(ref keyboard.Header, out int previousIndex);
  10. if (!Active)
  11. {
  12. return;
  13. }
  14. ref KeyboardState currentEntry = ref keyboard.Entries[currentIndex];
  15. KeyboardState previousEntry = keyboard.Entries[previousIndex];
  16. currentEntry.SampleTimestamp = previousEntry.SampleTimestamp + 1;
  17. currentEntry.SampleTimestamp2 = previousEntry.SampleTimestamp2 + 1;
  18. for (int i = 0; i < 8; ++i)
  19. {
  20. currentEntry.Keys[i] = (uint)keyState.Keys[i];
  21. }
  22. currentEntry.Modifier = (ulong)keyState.Modifier;
  23. }
  24. }
  25. }