diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-30 15:33:37 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-30 15:33:37 +0100 |
commit | 7a7956a59526e21262675e7647a89c865d93d551 (patch) | |
tree | d906ffe5fe57904e1a78ed4b8965dfd85e2b9f16 /Kernel/Keyboard.cpp | |
parent | 68739dc43e6bc42f9cac79fe5cbec714ddeeb218 (diff) | |
download | serenity-7a7956a59526e21262675e7647a89c865d93d551.zip |
Virtual consoles kinda work!
We now make three VirtualConsoles at boot: tty0, tty1, and tty2.
We launch an instance of /bin/sh in each one.
You switch between them with Alt+1/2/3
How very very cool :^)
Diffstat (limited to 'Kernel/Keyboard.cpp')
-rw-r--r-- | Kernel/Keyboard.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/Kernel/Keyboard.cpp b/Kernel/Keyboard.cpp index 9a34c2f88c..bcde36a17f 100644 --- a/Kernel/Keyboard.cpp +++ b/Kernel/Keyboard.cpp @@ -38,6 +38,12 @@ static char shift_map[0x100] = 0, 0, 0, ' ' }; +void Keyboard::emit(byte ch) +{ + if (m_client) + m_client->onKeyPress(ch); + m_queue.enqueue(ch); +} void Keyboard::handleIRQ() { @@ -50,7 +56,7 @@ void Keyboard::handleIRQ() case 0x9D: m_modifiers &= ~MOD_CTRL; break; case 0x2A: m_modifiers |= MOD_SHIFT; break; case 0xAA: m_modifiers &= ~MOD_SHIFT; break; - case 0x1C: /* enter */ m_queue.enqueue('\n'); break; + case 0x1C: /* enter */ emit('\n'); break; case 0xFA: /* i8042 ack */ break; default: if (ch & 0x80) { @@ -69,31 +75,33 @@ void Keyboard::handleIRQ() } } if (!m_modifiers) { - if (m_client) - m_client->onKeyPress(map[ch]); - m_queue.enqueue(map[ch]); + emit(map[ch]); } else if (m_modifiers & MOD_SHIFT) { - if (m_client) - m_client->onKeyPress(shift_map[ch]); - m_queue.enqueue(shift_map[ch]); + emit(shift_map[ch]); } else if (m_modifiers & MOD_CTRL) { // FIXME: This is obviously not a good enough way to process ctrl+whatever. - if (m_client) { - m_client->onKeyPress('^'); - m_client->onKeyPress(shift_map[ch]); - } - m_queue.enqueue('^'); - m_queue.enqueue(shift_map[ch]); + emit('^'); + emit(shift_map[ch]); } } //break; } } +static Keyboard* s_the; + +Keyboard& Keyboard::the() +{ + ASSERT(s_the); + return *s_the; +} + Keyboard::Keyboard() : IRQHandler(IRQ_KEYBOARD) , CharacterDevice(85, 1) { + s_the = this; + // Empty the buffer of any pending data. // I don't care what you've been pressing until now! while (IO::in8(I8042_STATUS ) & DATA_AVAILABLE) |