opuntiaOS - an operating system targeting x86 and ARMv7
at master 1.1 kB view raw
1/* 2 * Copyright (C) 2020-2022 The opuntiaOS Project Authors. 3 * + Contributed by Nikita Melekhin <nimelehin@gmail.com> 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#include "Devices.h" 10#include <fcntl.h> 11#include <libfoundation/Logger.h> 12 13namespace WinServer { 14 15Devices* s_WinServer_Devices_the = nullptr; 16 17Devices::Devices() 18{ 19 s_WinServer_Devices_the = this; 20 m_mouse_fd = open("/dev/mouse", O_RDONLY); 21 if (m_mouse_fd < 0) { 22 Logger::debug << "Can't open mouse" << std::endl; 23 std::abort(); 24 } 25 26 m_keyboard_fd = open("/dev/kbd", O_RDONLY); 27 if (m_keyboard_fd < 0) { 28 Logger::debug << "Can't open keyboard" << std::endl; 29 std::abort(); 30 } 31 32 LFoundation::EventLoop::the().add( 33 m_mouse_fd, [] { 34 Devices::the().pump_mouse(); 35 }, 36 nullptr); 37 38 LFoundation::EventLoop::the().add( 39 m_keyboard_fd, [] { 40 Devices::the().pump_keyboard(); 41 }, 42 nullptr); 43} 44 45} // namespace WinServer