键盘加入 Ctrl 按键监听

This commit is contained in:
xiaoyi1212 2024-04-10 22:21:09 +08:00
parent 048f85123d
commit 0702be2565
2 changed files with 13 additions and 0 deletions

View File

@ -102,12 +102,18 @@ int handle_keyboard_input(){
int release = key & 0xb10000000;
char c = key_status->is_shift ? shift_keyboard_map[(unsigned char )key] : keyboard_map[(unsigned char )key];
if(!release) {
if(c == -1) {
key_status->is_shift = 1;
return 0;
}
if(key == 29){
key_status->is_ctrl = 1;
return 0;
}
if(c == 0) return 0;
queue_push(key_char_queue,(char)c);
@ -115,6 +121,11 @@ int handle_keyboard_input(){
if(c == -1){
key_status->is_shift = 0;
}
if(key == 29){
key_status->is_ctrl = 0;
return 0;
}
}
return 0;

View File

@ -6,6 +6,8 @@
typedef struct {
int is_shift;
int is_ctrl;
int is_esc;
}KEY_STATUS;
typedef struct {