示例#1
0
文件: Hid.cs 项目: zpoo32/Ryujinx
        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;
        }
示例#2
0
文件: Hid.cs 项目: zpoo32/Ryujinx
        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;
        }