public Hid(Switch device, long hidPosition) { _device = device; HidPosition = hidPosition; device.Memory.FillWithZeros(hidPosition, Horizon.HidSize); _currentTouchHeader = new TouchHeader() { CurrentEntryIndex = -1, }; _currentKeyboardHeader = new KeyboardHeader() { CurrentEntryIndex = -1, }; _currentKeyboardEntry = new KeyboardEntry() { SamplesTimestamp = -1, SamplesTimestamp2 = -1 }; _touchScreenOffset = HidPosition + HidTouchScreenOffset; _touchEntriesOffset = _touchScreenOffset + HidTouchHeaderSize; _keyboardOffset = HidPosition + HidKeyboardOffset; }
public unsafe void WriteKeyboard(Keyboard keyboard) { long timestamp = GetTimestamp(); var newKeyboardHeader = new KeyboardHeader() { CurrentEntryIndex = (_currentKeyboardHeader.CurrentEntryIndex + 1) % HidEntryCount, EntryCount = HidEntryCount, MaxEntries = HidEntryCount - 1, Timestamp = timestamp, }; _device.Memory.WriteStruct(_keyboardOffset, newKeyboardHeader); long keyboardEntryOffset = _keyboardOffset + HidKeyboardHeaderSize; keyboardEntryOffset += newKeyboardHeader.CurrentEntryIndex * HidKeyboardEntrySize; var newkeyboardEntry = new KeyboardEntry() { SamplesTimestamp = _currentKeyboardEntry.SamplesTimestamp + 1, SamplesTimestamp2 = _currentKeyboardEntry.SamplesTimestamp2 + 1, Keys = keyboard.Keys, Modifier = keyboard.Modifier, }; _device.Memory.WriteStruct(keyboardEntryOffset, newkeyboardEntry); _currentKeyboardEntry = newkeyboardEntry; _currentKeyboardHeader = newKeyboardHeader; }