Example #1
0
        public async Task Initialise()
        {
            _eventBuffer.Clear();
            _controlRegister = 0x00;
            _nextKeyPressId  = 0;
            _current         = null;

            await SendControlRegister();
        }
Example #2
0
        public void Write(ushort address, byte value)
        {
            lock (this)
            {
                switch (address)
                {
                case STATUS_REGISTER:
                    _current = null;
                    break;

                case CONTROL_REGISTER:
                    _controlRegister = (byte)(value & 0x7);
                    AsyncUtil.RunSync(SendControlRegister);
                    break;
                }
            }
        }
Example #3
0
        public byte Read(ushort address)
        {
            lock (this)
            {
                Debug.Assert(address < Size);
                KeyboardEvent evt;

                switch (address)
                {
                case CONTROL_REGISTER:
                    return(_controlRegister);

                case STATUS_REGISTER:
                    if (_eventBuffer.Read(out evt))
                    {
                        _current = evt;
                        return(evt.Status);
                    }
                    _current = null;
                    break;

                case DATA_REGISTER:
                    if (_current != null)
                    {
                        return(_current.Data);
                    }
                    return(0x00);

                case SCAN_CODE_REGISTER:
                    if (_current != null)
                    {
                        return(_current.Data);
                    }
                    return(0x00);
                }
            }

            return(0x00);
        }