Example #1
0
        /// <summary>
        /// Creates TVC keyboard emulation
        /// </summary>
        /// <param name="in_tvc">TVC hardware which owns this keyboard</param>
        public TVCKeyboard(TVComputer in_tvc)
        {
            m_tvc = in_tvc;

            // init matrx
            m_keyboard_matrix = new byte[KeyboardRowCount];
            for (int i = 0; i < m_keyboard_matrix.Length; i++)
            {
                m_keyboard_matrix[i] = 0xff;
            }

            // create key mapping table
            LoadKeyMappingTableFromResource("TVCEmu.Resources.DefaultKeyMapping.txt");

            // clear pressed key table
            m_pressed_keys = new Key[PressedKeyCount];
            for (int i = 0; i < PressedKeyCount; i++)
            {
                m_pressed_keys[i] = Key.None;
            }

            // add port access handlers
            m_tvc.Ports.AddPortWriter(0x03, PortWrite03H);
            m_tvc.Ports.AddPortReader(0x58, PortRead58H);

            // setup injection service
            m_keyboard_injection_pos  = -1;
            m_keyboard_injection_rate = m_tvc.MillisecToCPUTicks(KeyboardInjectionRate);
        }