forked from Bananymous/banan-os
Kernel: TTY input process is now single instance
Process sends key events to the active (currently only) tty
This commit is contained in:
parent
f139fc2229
commit
4e859bedbc
|
@ -22,6 +22,8 @@
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static Process* s_input_process = nullptr;
|
||||||
|
|
||||||
static dev_t next_tty_rdev()
|
static dev_t next_tty_rdev()
|
||||||
{
|
{
|
||||||
static dev_t major = DeviceManager::get().get_next_rdev();
|
static dev_t major = DeviceManager::get().get_next_rdev();
|
||||||
|
@ -55,18 +57,19 @@ namespace Kernel
|
||||||
m_name = BAN::String::formatted("tty{}", minor(m_rdev));
|
m_name = BAN::String::formatted("tty{}", minor(m_rdev));
|
||||||
DeviceManager::get().add_device(this);
|
DeviceManager::get().add_device(this);
|
||||||
|
|
||||||
Process::create_kernel(
|
if (s_input_process)
|
||||||
[](void* tty_)
|
return;
|
||||||
|
s_input_process = Process::create_kernel(
|
||||||
|
[](void*)
|
||||||
{
|
{
|
||||||
TTY* tty = (TTY*)tty_;
|
|
||||||
int fd = MUST(Process::current().open("/dev/input0"sv, O_RDONLY));
|
int fd = MUST(Process::current().open("/dev/input0"sv, O_RDONLY));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Input::KeyEvent event;
|
Input::KeyEvent event;
|
||||||
MUST(Process::current().read(fd, &event, sizeof(event)));
|
ASSERT(MUST(Process::current().read(fd, &event, sizeof(event))) == sizeof(event));
|
||||||
tty->on_key(event);
|
TTY::current()->on_key(event);
|
||||||
}
|
}
|
||||||
}, this
|
}, nullptr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue