Skip to content

Commit 2a160fa

Browse files
supercomputer7awesomekling
authored andcommitted
Kernel: Run clang-format on KeyboardDevice.cpp
1 parent ce6864d commit 2a160fa

File tree

1 file changed

+200
-42
lines changed

1 file changed

+200
-42
lines changed

Kernel/Devices/KeyboardDevice.cpp

Lines changed: 200 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include <Kernel/Arch/i386/CPU.h>
3030
#include <Kernel/Arch/i386/PIC.h>
3131
#include <Kernel/Devices/KeyboardDevice.h>
32-
#include <Kernel/TTY/VirtualConsole.h>
3332
#include <Kernel/IO.h>
33+
#include <Kernel/TTY/VirtualConsole.h>
3434

3535
//#define KEYBOARD_DEBUG
3636

@@ -43,37 +43,201 @@
4343
#define I8042_MOUSE_BUFFER 0x20
4444
#define I8042_KEYBOARD_BUFFER 0x00
4545

46-
char *map;
47-
char *shift_map;
48-
char *alt_map;
49-
char *altgr_map;
46+
char* map;
47+
char* shift_map;
48+
char* alt_map;
49+
char* altgr_map;
5050

5151
static const char en_map[0x80] = {
52-
0, '\033', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08, '\t',
53-
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0,
54-
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\',
55-
'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
56-
0, '*', 0, ' ', 0, 0,
52+
0,
53+
'\033',
54+
'1',
55+
'2',
56+
'3',
57+
'4',
58+
'5',
59+
'6',
60+
'7',
61+
'8',
62+
'9',
63+
'0',
64+
'-',
65+
'=',
66+
0x08,
67+
'\t',
68+
'q',
69+
'w',
70+
'e',
71+
'r',
72+
't',
73+
'y',
74+
'u',
75+
'i',
76+
'o',
77+
'p',
78+
'[',
79+
']',
80+
'\n',
81+
0,
82+
'a',
83+
's',
84+
'd',
85+
'f',
86+
'g',
87+
'h',
88+
'j',
89+
'k',
90+
'l',
91+
';',
92+
'\'',
93+
'`',
94+
0,
95+
'\\',
96+
'z',
97+
'x',
98+
'c',
99+
'v',
100+
'b',
101+
'n',
102+
'm',
103+
',',
104+
'.',
105+
'/',
106+
0,
107+
'*',
108+
0,
109+
' ',
110+
0,
111+
0,
57112
//60
58-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
113+
0,
114+
0,
115+
0,
116+
0,
117+
0,
118+
0,
119+
0,
120+
0,
121+
0,
122+
0,
59123
//70
60-
0, 0, 0, 0, '-', 0, 0, 0, '+', 0,
124+
0,
125+
0,
126+
0,
127+
0,
128+
'-',
129+
0,
130+
0,
131+
0,
132+
'+',
133+
0,
61134
//80
62-
0, 0, 0, 0, 0, 0, '\\', 0, 0, 0,
135+
0,
136+
0,
137+
0,
138+
0,
139+
0,
140+
0,
141+
'\\',
142+
0,
143+
0,
144+
0,
63145
};
64146

65147
static const char en_shift_map[0x80] = {
66-
0, '\033', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0x08, '\t',
67-
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0,
68-
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|',
69-
'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?',
70-
0, '*', 0, ' ', 0, 0,
148+
0,
149+
'\033',
150+
'!',
151+
'@',
152+
'#',
153+
'$',
154+
'%',
155+
'^',
156+
'&',
157+
'*',
158+
'(',
159+
')',
160+
'_',
161+
'+',
162+
0x08,
163+
'\t',
164+
'Q',
165+
'W',
166+
'E',
167+
'R',
168+
'T',
169+
'Y',
170+
'U',
171+
'I',
172+
'O',
173+
'P',
174+
'{',
175+
'}',
176+
'\n',
177+
0,
178+
'A',
179+
'S',
180+
'D',
181+
'F',
182+
'G',
183+
'H',
184+
'J',
185+
'K',
186+
'L',
187+
':',
188+
'"',
189+
'~',
190+
0,
191+
'|',
192+
'Z',
193+
'X',
194+
'C',
195+
'V',
196+
'B',
197+
'N',
198+
'M',
199+
'<',
200+
'>',
201+
'?',
202+
0,
203+
'*',
204+
0,
205+
' ',
206+
0,
207+
0,
71208
//60
72-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
209+
0,
210+
0,
211+
0,
212+
0,
213+
0,
214+
0,
215+
0,
216+
0,
217+
0,
218+
0,
73219
//70
74-
0, 0, 0, 0, '-', 0, 0, 0, '+', 0,
220+
0,
221+
0,
222+
0,
223+
0,
224+
'-',
225+
0,
226+
0,
227+
0,
228+
'+',
229+
0,
75230
//80
76-
0, 0, 0, 0, 0, 0, '|', 0, 0, 0,
231+
0,
232+
0,
233+
0,
234+
0,
235+
0,
236+
0,
237+
'|',
238+
0,
239+
0,
240+
0,
77241
};
78242

79243
static const char numpad_map[13] = { '7', '8', '9', 0, '4', '5', '6', 0, '1', '2', '3', '0', ',' };
@@ -135,8 +299,8 @@ static const KeyCode unshifted_key_map[0x80] = {
135299
Key_Slash,
136300
Key_RightShift, // 54
137301
Key_Asterisk,
138-
Key_Alt, // 56
139-
Key_Space, // 57
302+
Key_Alt, // 56
303+
Key_Space, // 57
140304
Key_CapsLock, // 58
141305
Key_F1,
142306
Key_F2,
@@ -231,7 +395,7 @@ static const KeyCode shifted_key_map[0x100] = {
231395
Key_RightShift, // 54
232396
Key_Asterisk,
233397
Key_Alt,
234-
Key_Space, // 57
398+
Key_Space, // 57
235399
Key_CapsLock, // 58
236400
Key_F1,
237401
Key_F2,
@@ -278,24 +442,19 @@ void KeyboardDevice::key_state_changed(u8 raw, bool pressed)
278442
if (key == Key_NumLock && pressed)
279443
m_num_lock_on = !m_num_lock_on;
280444

281-
if (m_num_lock_on && !m_has_e0_prefix)
282-
{
283-
if (raw >= 0x47 && raw <= 0x53)
284-
{
445+
if (m_num_lock_on && !m_has_e0_prefix) {
446+
if (raw >= 0x47 && raw <= 0x53) {
285447
u8 index = raw - 0x47;
286448
KeyCode newKey = numpad_key_map[index];
287449

288-
if (newKey != Key_Invalid)
289-
{
450+
if (newKey != Key_Invalid) {
290451
key = newKey;
291452
character = numpad_map[index];
292453
}
293454
}
294-
}
295-
else
296-
{
297-
if(m_has_e0_prefix) {
298-
if(key == Key_Slash) {
455+
} else {
456+
if (m_has_e0_prefix) {
457+
if (key == Key_Slash) {
299458
character = '/'; // On Turkish-QWERTY Keyboard Key_Slash mapped to '.' char, if e0 prefix is true remap to '/' char
300459
}
301460
}
@@ -304,8 +463,7 @@ void KeyboardDevice::key_state_changed(u8 raw, bool pressed)
304463
if (key == Key_CapsLock && pressed)
305464
m_caps_lock_on = !m_caps_lock_on;
306465

307-
if (m_caps_lock_on && (m_modifiers == 0 || m_modifiers == Mod_Shift))
308-
{
466+
if (m_caps_lock_on && (m_modifiers == 0 || m_modifiers == Mod_Shift)) {
309467
if (character >= 'a' && character <= 'z')
310468
character &= ~0x20;
311469
else if (character >= 'A' && character <= 'Z')
@@ -449,12 +607,12 @@ void KeyboardDevice::set_maps(const char* n_map, const char* n_shift_map, const
449607
kfree(alt_map);
450608
kfree(altgr_map);
451609

452-
map = (char*) kmalloc(0x80);
453-
shift_map = (char*) kmalloc(0x80);
454-
alt_map = (char*) kmalloc(0x80);
455-
altgr_map = (char*) kmalloc(0x80);
610+
map = (char*)kmalloc(0x80);
611+
shift_map = (char*)kmalloc(0x80);
612+
alt_map = (char*)kmalloc(0x80);
613+
altgr_map = (char*)kmalloc(0x80);
456614

457-
for(int i=0; i < 0x80; i++) {
615+
for (int i = 0; i < 0x80; i++) {
458616
map[i] = n_map[i];
459617
shift_map[i] = n_shift_map[i];
460618
alt_map[i] = n_alt_map[i];

0 commit comments

Comments
 (0)