MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / keyboard_read

Function keyboard_read

bsp/x86/drivers/keyboard.c:56–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 set_leds();
55}
56PUBLIC rt_bool_t keyboard_read(rt_uint32_t *pkey)
57{
58 t_8 scan_code;
59 t_bool make; /* TRUE : make */
60 /* FALSE: break */
61 t_32 key = 0;
62 t_32* keyrow;
63
64 if(kb_in.count > 0){
65 code_with_E0 = FALSE;
66 scan_code = get_byte_from_kb_buf();
67
68 /* start scan */
69 if (scan_code == 0xE1) {
70 int i;
71 static const t_8 pausebreak_scan_code[] = {0xE1, 0x1D, 0x45, 0xE1, 0x9D, 0xC5};
72 t_bool is_pausebreak = TRUE;
73 for(i=1;i<6;i++){
74 if (get_byte_from_kb_buf() != pausebreak_scan_code[i]) {
75 is_pausebreak = FALSE;
76 break;
77 }
78 }
79 if (is_pausebreak) {
80 key = PAUSEBREAK;
81 }
82 }
83 else if (scan_code == 0xE0) {
84 code_with_E0 = TRUE;
85 scan_code = get_byte_from_kb_buf();
86
87 /* PrintScreen pressed */
88 if (scan_code == 0x2A) {
89 code_with_E0 = FALSE;
90 if ((scan_code = get_byte_from_kb_buf()) == 0xE0) {
91 code_with_E0 = TRUE;
92 if ((scan_code = get_byte_from_kb_buf()) == 0x37) {
93 key = PRINTSCREEN;
94 make = TRUE;
95 }
96 }
97 }
98 /* PrintScreen released */
99 else if (scan_code == 0xB7) {
100 code_with_E0 = FALSE;
101 if ((scan_code = get_byte_from_kb_buf()) == 0xE0) {
102 code_with_E0 = TRUE;
103 if ((scan_code = get_byte_from_kb_buf()) == 0xAA) {
104 key = PRINTSCREEN;
105 make = FALSE;
106 }
107 }
108 }
109 } /* if is not PrintScreen, scan_code is the one after 0xE0 */
110 if ((key != PAUSEBREAK) && (key != PRINTSCREEN)) {
111 /* is Make Code or Break Code */
112 make = (scan_code & FLAG_BREAK ? FALSE : TRUE);
113

Callers 1

rt_keyboard_getcFunction · 0.85

Calls 2

get_byte_from_kb_bufFunction · 0.85
set_ledsFunction · 0.85

Tested by

no test coverage detected