代码拉取完成,页面将自动刷新
#include "macro.h"
#include "asm.h"
#include "types.h"
Pipe8 kbdp;
char kbdbuf[32];
void init_kbd(){
pipe_init(&kbdp,kbdbuf,32);
cputs("init_kbd(): Keyboard buffer OK\n",GREY);
}
static const char keymap[]={
0,k_esc,'1','2','3','4','5','6','7','8','9','0','-','=','\b','\t',
'q','w','e','r','t','y','u','i','o','p','[',']','\n',k_ctrl_l,'a','s',
'd','f','g','h','j','k','l',';','\'','`',k_shift_l,'\\','z','x','c','v',
'b','n','m',',','.','/',k_shift_r,'*',k_alt_l,' ',k_caps,k_f1,k_f2,k_f3,k_f4,k_f5,
k_f6,k_f7,k_f8,k_f9,k_f10,k_nums,k_scr,'7','8','9','-','4','5','6','+','1',
'2','3','0','1',0,0,0,k_f11,k_f12
};
static const char keymap_s[]={
0,k_esc,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t',
'Q','W','E','R','T','Y','U','I','O','P','{','}','\n',k_ctrl_l,'A','S',
'D','F','G','H','J','K','L',':','\"','~',k_shift_l,'|','Z','X','C','V',
'B','N','M','<','>','?',k_shift_r,'*',k_alt_l,' ',k_caps,k_f1,k_f2,k_f3,k_f4,k_f5,
k_f6,k_f7,k_f8,k_f9,k_f10,k_nums,k_scr,k_home,k_up,k_pgup,'-',k_left,0,k_right,'+',k_end,
k_down,k_pgdn,k_ins,k_del,0,0,0,k_f11,k_f12
};
/*
static const char keymap_e[]={
[0x1d]k_ctrl_r,
[0x35]'/',
[0x38]k_alt_r
};
others are the same as keymap_s
*/
/*
Specified:
prtsc //it's like some 2 keys' combination
e0 2a e0 37
e0 b7 e0 aa
pause //this key seems independent
e1 1d 45 e1 9d c5
none
*/
u8 read_kbdp(){
while(pipe_size(&kbdp)==0);
return read_pipe8(&kbdp);
}
int seekbd(){
while(True){
u8 code=read_kbdp();
u8 ret;
if(code<0x80){
if(keystat&1)ret=keymap_s[code];
else ret=keymap[code];
if(keystat&2){
if('a'<=ret && ret<='z')ret-=0x20;
elif('A'<=ret && ret<='Z')ret+=0x20;
}
return ret;
}
elif(code==0xaa)return k_shift_ld;
elif(code==0xb6)return k_shift_rd;
elif(code==0x9d)return k_ctrl_ld;
elif(code==0xb8)return k_alt_ld;
elif(code==0xe0){
u8 c1=read_kbdp();
if(c1<0x80){
if(c1==0x1c)ret='\n';
elif(c1==0x1d)ret=k_ctrl_r;
elif(c1==0x2a){
read_kbdp();
read_kbdp();
ret=k_prtsc;
}
elif(c1==0x35)ret='/';
elif(c1==0x38)ret=k_alt_r;
else ret=keymap_s[c1];
return ret;
}else{
if(c1==0xb7){
read_kbdp();
read_kbdp();
}
elif(c1==0x9d)return k_ctrl_rd;
elif(c1==0xb8)return k_alt_rd;
}
}
elif(code==0xe1){
for(int i=0;i<5;i++)read_kbdp();
return k_pause;
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。