-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard.h
125 lines (115 loc) · 2.79 KB
/
keyboard.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/time.h>
#include <asm/io.h>
#include <linux/mutex.h>
#include "misc.h"
#include "log.h"
//#include "./file.h"
#define KBD_IRQ 0x01 /* IRQ number for keyboard (i8042) */
#define KBD_DATA_REG 0x60 /* I/O port for keyboard data */
#define KBD_SCANCODE_MASK 0x7f
#define KBD_STATUS_MASK 0x80
#define BUFF_SIZE 1024
#define MIN 0
#define MAJ 1
typedef struct s_key
{
unsigned char key; // Key code
unsigned char state; // 1 Presed, 0 Released
char name[15]; // Key name
struct timespec time; // time
struct s_key *next; // next
} t_key;
void add_tail(unsigned char scancode);
void free_lst(void);
// array for explicit name key
static const unsigned char *key_name[128] = {
0, // undefined
"escape", // escape
"1","2","3","4","5","6","7","8","9","0","-","=",
"backspace", // backspace
"tab", // tab
"q","w","e","r","t","y","u","i","o","p","[","]","enter",
"left ctrl", // Ctrl
"a","s","d","f","g","h","j","k","l",";","\"","`",
"left shift", // Left shift
"\\","z","x","c","v","b","n","m",",",".","/",
"right shift", // Right shift
"*", // (Keypad *)
"left alt", // left alt
" ",
"CapsLock", // Caps lock
"F1", // <F1>
"F2", // <F2>
"F3", // <F3>
"F4", // <F4>
"F5", // <F5>
"F6", // <F6>
"F7", // <F7>
"F8", // <F8>
"F9", // <F9>
"F10", // <F10>
"NumberLock", // Num lock
"ScrollLock", // Scroll Lock
"Home", // Home key
"cursor up", // Up Arrow
"page up", // Page Up
"-",
"cursor left", // Left Arrow
"",
"cursor right", // Right Arrow
"+",
"end", // End key
"cursor down", // Down Arrow
"page down", // Page Down
"insert", // Insert Key
"delete", // Delete Key
"", "", "", // ?
"F11", // <F11>
"F12", // <F12>
"", "", // ?
"super",
"","","","","","","","","","","","","","","","","","","","","","","","","",
"","","","","","","","","","",""
};
// array for key
static const unsigned char keyboard_map[2][128] = {
{
0, // undefined
0, // escape
'1','2','3','4','5','6','7','8','9','0','-','=',
'\b', // backspace
'\t', // tab
'q','w','e','r','t','y','u','i','o','p','[',']','\n',
0, // Ctrl
'a','s','d','f','g','h','j','k','l',';','\'','`',
0, // Left shift
'\\','z','x','c','v','b','n','m',',','.','/',
0, // Right shift
'*', // (Keypad *)
0, // left alt
' '
},
{
0, // undefined
0, // escape
'!','@','#','$','%','^','&','*','(',')','_','+',
'\b', // backspace
'\t', // tab
'Q','W','E','R','T','Y','U','I','O','P','{','}','\n',
0, // Ctrl
'A','S','D','F','G','H','J','K','L',':','"','~',
0, // Left shift
'|','Z','X','C','V','B','N','M','<','>','?',
0, // Right shift
'*', // (Keypad *)
0, // left alt
' '
}
};
#endif