blob: 3ca0a8b4580e2b382632734cad1b4202bf9785df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Atomic.h>
#include <AK/CircularQueue.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/RefPtr.h>
#include <AK/Time.h>
#include <AK/Types.h>
#include <Kernel/API/KeyCode.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/KResult.h>
#include <Kernel/SpinLock.h>
#include <Kernel/UnixTypes.h>
#include <LibKeyboard/CharacterMap.h>
namespace Kernel {
extern Atomic<bool> g_caps_lock_remapped_to_ctrl;
class HIDDevice;
class I8042Controller;
class MouseDevice;
class KeyboardDevice;
class KeyboardClient;
class HIDManagement {
friend class KeyboardDevice;
friend class MouseDevice;
AK_MAKE_ETERNAL;
public:
HIDManagement();
static void initialize();
static HIDManagement& the();
void enumerate();
const String& keymap_name() const { return m_character_map.character_map_name(); }
const Keyboard::CharacterMapData& character_maps() const { return m_character_map.character_map_data(); }
const Keyboard::CharacterMap& character_map() const { return m_character_map; }
void set_client(KeyboardClient* client) { m_client = client; }
void set_maps(const Keyboard::CharacterMapData& character_map, const String& character_map_name);
private:
size_t generate_minor_device_number_for_mouse();
size_t generate_minor_device_number_for_keyboard();
size_t m_mouse_minor_number { 0 };
size_t m_keyboard_minor_number { 0 };
Keyboard::CharacterMap m_character_map;
KeyboardClient* m_client { nullptr };
RefPtr<I8042Controller> m_i8042_controller;
NonnullRefPtrVector<HIDDevice> m_hid_devices;
};
class KeyboardClient {
public:
virtual ~KeyboardClient();
virtual void on_key_pressed(KeyEvent) = 0;
};
}
|