📄 kb.c
字号:
//s++;
}
//QuitFlag=CheckPressed(); // Check, if all key pressed.
//Press [Fn]+[Right] to quit
}
else if((ExtE0Key[curkey].keyCode+0x80)==keyCode && ExtE0Key[curkey].Status==MID)
{
// If i=ExtE0Max , can't found the key in struct.
// If Status=PRESSED, don't show it.
ExtE0Key[curkey].Status=PRESSED; //Set key status
SetColor(BLACK,LIGHTGREEN);
gotoxy(ExtE0Key[curkey].x,ExtE0Key[curkey].y); //Get position
cprintf("%s",ExtE0Key[curkey].str); // Show key
s++;
}
}
if(ext_Num==1) // Endin E0 sequence. E0 has one Extened code.
leadingFlag=0; //Reset Flag
}
}
//=======================
//Processing Stand Code
//=======================
if(keystu==0)
{
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
gotoxy(X1+34,Y1+19);printf("[Scan Code: ");
gotoxy(X1+46,Y1+19);printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
if((keyCode & bit7) != bit7 ) //if hold down the key, bit 7=0
{
if(StandKey[curkey].Status!=PRESSED && StandKey[curkey].keyCode==keyCode && StandKey[curkey].Status!=MID )
{
StandKey[curkey].Status=MID;
if((curkey<14&&curkey>0)||(curkey==60))
SetColor(BLACK,WHITE);
else
SetColor(BLACK,LIGHTGREEN);
SetColor(BLACK,BLUE);
gotoxy(StandKey[curkey].x,StandKey[curkey].y);
cprintf("%s",StandKey[curkey].str);
//s++;
}
}
else if(StandKey[curkey].Status==MID && (StandKey[curkey].keyCode+0x80)==keyCode)
{
StandKey[curkey].Status=PRESSED;
if((curkey<14&&curkey>0)||(curkey==60))
SetColor(BLACK,WHITE);
else
SetColor(BLACK,LIGHTGREEN);
//SetColor(BLACK,BLUE);
gotoxy(StandKey[curkey].x,StandKey[curkey].y);
cprintf("%s",StandKey[curkey].str);
s++;
}
}
//preKeyCode=keyCode; //Save KeyCode
TurnOff_Interrupt();
enable();
Send8042Cmd(Enable_KB); // ensure keyboard is enable
}
//Hook INT 09H to get scan code
void interrupt Code_Int9H(void)
{
int i=0;
unsigned short int keyCode;
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//Re-draw
//clrscr();
//gotoxy(X1+27,Y1+8);printf("[Scan Code: ");
Send8042Cmd(Disable_KB);// ensure keyboard is disable
disable();
keyCode=Read_8042Data();
SetColor(WHITE,BLACK); //Normal color
QuitFlag=CheckPressed();
//=======================
//Is leading code = E0 ?
//=======================
if(keyCode==E0) //Is E0 ?
{
leadingFlag=E0; //Yes, set Flag
ext_Num=0; //E0 1c , there is 1 extened code.
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//gotoxy(X1+34,Y1+18);printf("[Scan Code: ");
gotoxy(X1+28,Y1+8);printf(" ");
gotoxy(X1+44,Y1+8);printf(" ");
gotoxy(X1+39,Y1+8);printf("%x ",keyCode);
gotoxy(X1+57,Y1+8);printf("]");
}
//=======================
//Is leading code = E1 ?
//=======================
else if(keyCode==E1)
{
gotoxy(X1+28,Y1+8);printf(" ");
leadingFlag=E1;
ext_Num=0;
gotoxy(X1+39+leading_ext_Num*10,Y1+8);printf("%x ",keyCode);
gotoxy(X1+57,Y1+8);printf("]");
}
//=======================
//Processing E0 code
//=======================
else if(leadingFlag==E0)
{
gotoxy(X1+39+(ext_Num+1)*3,Y1+8);
printf("%x ",keyCode); //Show scan code
gotoxy(X1+57,Y1+8);printf("]");
if(ext_Num++ != 2)
{
for(i=0;i<ExtE0Max;i++)
{
if(ExtE0Key[i].keyCode==keyCode)
break;
if(ExtE0Key[i].keyCode==(keyCode-0x80))
break;
}
if(i!=ExtE0Max)
{
gotoxy(X1+28,Y1+8);
printf("%s",ExtE0Key[i].str);
}
}
if(ext_Num==1) // Endin E0 sequence. E0 has one Extened code.
leadingFlag=0; //Reset Flag
}
//=======================
//Processing E1 Code
//=======================
else if(leadingFlag==E1)
{
gotoxy(X1+39+leading_ext_Num*10+(ext_Num+1)*3,Y1+8);//Set position
printf("%x ",keyCode);
gotoxy(X1+57,Y1+8);printf("]");
//ext_Num+=1;
if(ext_Num++ != 2)
{
for(i=0;i<ExtE1Max;i++)
{
if(ExtE1Key[i].keyCode==keyCode)
break;
if(ExtE1Key[i].keyCode==(keyCode-0x80))
break;
}
if(i!=ExtE1Max)
{
gotoxy(X1+28,Y1+8);
printf("%s",ExtE1Key[i].str);
}
}
if(ext_Num==2) //E1 has 2 extened code
{
if(leading_ext_Num++==1) // Endin E1 sequence.0,1,2....
{ // E1 has 2 leading code.
leading_ext_Num=0; // Reset Flag;
}
leadingFlag=0; //Reset leading Flag
}
}
//=======================
//Processing Stand Code
//=======================
else
{
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
gotoxy(X1+28,Y1+8);printf(" ");
gotoxy(X1+38,Y1+8);printf(" ");
gotoxy(X1+39,Y1+8);printf("%x ",keyCode);
gotoxy(X1+57,Y1+8);printf("]");
//QuitFlag=CheckPressed();
for(i=0;i<StandMax;i++)
{
if(StandKey[i].keyCode==keyCode)
break;
if(StandKey[i].keyCode==(keyCode-0x80))
break;
}
if(i!=StandMax)
{
gotoxy(X1+28,Y1+8);
printf("%s",StandKey[i].str);
}
if(keyCode==1) //Press ESC 5 times(0,1,2,3,4) to quit
{
if(ESC++ == 4)
{
QuitFlag=1;
FailFlag=1;
}
}
/*if(keyCode==0x13) //Press 'R' 5 times(0,1,2,3,4) to set RetestFlag=1
{
if(RETEST++ == 4)
RetestFlag=1;
} */
}
//preKeyCode=keyCode; //Save KeyCode
TurnOff_Interrupt();
enable();
Send8042Cmd(Enable_KB); // ensure keyboard is enable
}
void interrupt Special_Hook2(void)
{
int i=0;
unsigned short int keyCode;
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//Re-draw
gotoxy(X1+34,Y1+19);printf("[Scan Code: ");
Send8042Cmd(Disable_KB);// ensure keyboard is disable
disable();
keyCode=Read_8042Data();
SetColor(WHITE,BLACK); //Normal color
QuitFlag=CheckPressed();
//=======================
//Is leading code = E0 ?
//=======================
if(keyCode==E0) //Is E0 ?
{
leadingFlag=E0; //Yes, set Flag
ext_Num=0; //E0 1c , there is 1 extened code.
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//gotoxy(X1+34,Y1+18);printf("[Scan Code: ");
gotoxy(X1+51,Y1+19);printf(" ");
gotoxy(X1+46,Y1+19);printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
}
//=======================
//Is leading code = E1 ?
//=======================
else if(keyCode==E1)
{
if(leading_ext_Num ==2) //if second times pressed.
{
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//gotoxy(X1+34,Y1+19);printf("Scan Code: ");
}
leadingFlag=E1;
ext_Num=0;
gotoxy(X1+46+leading_ext_Num*10,Y1+19);printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
}
//=======================
//Processing E0 code
//=======================
else if(leadingFlag==E0)
{
//gotoxy(X1+34,Y1+18);printf("[Scan Code: ");
gotoxy(X1+46+(ext_Num+1)*3,Y1+19);
printf("%x ",keyCode); //Show scan code
gotoxy(X1+65,Y1+19);printf("]");
if(ext_Num++ != 2) //E1 1d 45 , there are 2 extened code.
{
if((keyCode & bit7) != bit7 ) //Hold down key
{
//CheckTiming();
for(i=0;i<ExtE0Max;i++) //Search Key in struct.
{
if(ExtE0Key[i].keyCode==keyCode)
break; //Stop search, Struct[i]=keyCode
}
if((i != ExtE0Max) && (ExtE0Key[i].Status!=PRESSED))
{
// If i=ExtE0Max , can't found the key in struct.
// If Status=PRESSED, don't show it.
ExtE0Key[i].Status=MID; //Set key status
SetColor(YELLOW,RED);
gotoxy(ExtE0Key[i].x,ExtE0Key[i].y); //Get position
cprintf("%s",ExtE0Key[i].str); // Show key
openflag=i;
}
//QuitFlag=CheckPressed(); // Check, if all key pressed.
//Press [Fn]+[Right] to quit
if(keyCode==0x4f) //Press ESC 5 times(0,1,2,3,4) to quit
{
QuitFlag=1;
FailFlag=1;
}
if(keyCode==0x47)
{
RetestFlag=1;
}
}
else if((openflag != ExtE0Max) && (ExtE0Key[openflag].Status==MID) && ((ExtE0Key[openflag].keyCode+0x80)==keyCode))
{
// If i=ExtE0Max , can't found the key in struct.
// If Status=PRESSED, don't show it.
ExtE0Key[openflag].Status=PRESSED; //Set key status
SetColor(WHITE,BLUE);
gotoxy(ExtE0Key[openflag].x,ExtE0Key[openflag].y); //Get position
cprintf("%s",ExtE0Key[openflag].str); // Show key
}
}
if(ext_Num==1) // Endin E0 sequence. E0 has one Extened code.
leadingFlag=0; //Reset Flag
}
//=======================
//Processing E1 Code
//=======================
else if(leadingFlag==E1)
{
gotoxy(X1+46+leading_ext_Num*10+(ext_Num+1)*3,Y1+19);//Set position
printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
if(ext_Num++ != 2)
{
if((keyCode & bit7) != bit7 ) //Hold down key
{
//CheckTiming();
for(i=0;i<ExtE1Max;i++)
{
if(ExtE1Key[i].keyCode==keyCode)
break;
}
if((i != ExtE1Max ) && (ExtE1Key[i].Status!=PRESSED) && (ExtE1Key[i].Status!=MID))
{
ExtE1Key[i].Status=MID;
SetColor(YELLOW,RED);
gotoxy(ExtE1Key[i].x,ExtE1Key[i].y);
cprintf("%s",ExtE1Key[i].str);
openflag=i;
}
//QuitFlag=CheckPressed();
}
else if((openflag != ExtE1Max ) && ((ExtE1Key[openflag].keyCode+0x80)==keyCode))
{
ExtE1Key[openflag].Status=PRESSED;
SetColor(WHITE,BLUE);
gotoxy(ExtE1Key[openflag].x,ExtE1Key[openflag].y);
cprintf("%s",ExtE1Key[openflag].str);
}
}
if(ext_Num==2) //E1 has 2 extened code
{
if(leading_ext_Num++==1) // Endin E1 sequence.0,1,2....
{ // E1 has 2 leading code.
leading_ext_Num=0; // Reset Flag;
}
leadingFlag=0; //Reset leading Flag
}
}
//=======================
//Processing Stand Code
//=======================
else
{
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
gotoxy(X1+34,Y1+19);printf("[Scan Code: ");
gotoxy(X1+46,Y1+19);printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
if((keyCode & bit7) != bit7 ) //if hold down the key, bit 7=0
{
//CheckTiming();
for(i=0;i<StandMax;i++)
{
if((StandKey[i].keyCode==keyCode) && (StandKey[i].Status!=PRESSED))
break;
}
if((i != StandMax) && (StandKey[i].Status!=PRESSED))
{
StandKey[i].Status=MID;
SetColor(YELLOW,RED);
gotoxy(StandKey[i].x,StandKey[i].y);
cprintf("%s",StandKey[i].str);
if(StandKey[i].keyCode==0x1c)
{
gotoxy(X1+56,Y1+9);
cprintf(" ");
gotoxy(X1+56,Y1+10);
cprintf(" ");
}
openflag=i;
}
}
else if((openflag != StandMax) && (StandKey[openflag].Status==MID) && (StandKey[openflag].keyCode+0x80)==keyCode)
{
StandKey[openflag].Status=PRESSED;
SetColor(WHITE,BLUE);
gotoxy(StandKey[openflag].x,StandKey[openflag].y);
cprintf("%s",StandKey[openflag].str);
if(StandKey[openflag].keyCode==0x1c)
{
gotoxy(X1+56,Y1+9);
cprintf(" ");
gotoxy(X1+56,Y1+10);
cprintf(" ");
}
//openflag=i;
}
}
//preKeyCode=keyCode; //Save KeyCode
TurnOff_Interrupt();
enable();
Send8042Cmd(Enable_KB); // ensure keyboard is enable
}
void interrupt Hook_Int9H(void)
{
int i=0;
unsigned short int keyCode;
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//Re-draw
gotoxy(X1+34,Y1+19);printf("[Scan Code: ");
Send8042Cmd(Disable_KB);// ensure keyboard is disable
disable();
keyCode=Read_8042Data();
SetColor(WHITE,BLACK); //Normal color
QuitFlag=CheckPressed();
//=======================
//Is leading code = E0 ?
//=======================
if(keyCode==E0) //Is E0 ?
{
leadingFlag=E0; //Yes, set Flag
ext_Num=0; //E0 1c , there is 1 extened code.
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//gotoxy(X1+34,Y1+18);printf("[Scan Code: ");
gotoxy(X1+51,Y1+19);printf(" ");
gotoxy(X1+46,Y1+19);printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
}
//=======================
//Is leading code = E1 ?
//=======================
else if(keyCode==E1)
{
if(leading_ext_Num ==2) //if second times pressed.
{
//Draw_Frame(X1+32,Y1+18,X1+64,Y1+20,LIGHTGREEN,BLACK);
//gotoxy(X1+34,Y1+19);printf("Scan Code: ");
}
leadingFlag=E1;
ext_Num=0;
gotoxy(X1+46+leading_ext_Num*10,Y1+19);printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
}
//=======================
//Processing E0 code
//=======================
else if(leadingFlag==E0)
{
//gotoxy(X1+34,Y1+18);printf("[Scan Code: ");
gotoxy(X1+46+(ext_Num+1)*3,Y1+19);
printf("%x ",keyCode); //Show scan code
gotoxy(X1+65,Y1+19);printf("]");
if(ext_Num++ != 2) //E1 1d 45 , there are 2 extened code.
{
if((keyCode & bit7) != bit7 ) //Hold down key
{
//CheckTiming();
for(i=0;i<ExtE0Max;i++) //Search Key in struct.
{
if(ExtE0Key[i].keyCode==keyCode)
break; //Stop search, Struct[i]=keyCode
}
if((i != ExtE0Max) && (ExtE0Key[i].Status!=PRESSED))
{
// If i=ExtE0Max , can't found the key in struct.
// If Status=PRESSED, don't show it.
ExtE0Key[i].Status=PRESSED; //Set key status
SetColor(WHITE,BLUE);
gotoxy(ExtE0Key[i].x,ExtE0Key[i].y); //Get position
cprintf("%s",ExtE0Key[i].str); // Show key
}
//QuitFlag=CheckPressed(); // Check, if all key pressed.
//Press [Fn]+[Right] to quit
if(keyCode==0x4f) //Press ESC 5 times(0,1,2,3,4) to quit
{
QuitFlag=1;
FailFlag=1;
}
if(keyCode==0x47)
{
RetestFlag=1;
}
}
}
if(ext_Num==1) // Endin E0 sequence. E0 has one Extened code.
leadingFlag=0; //Reset Flag
}
//=======================
//Processing E1 Code
//=======================
else if(leadingFlag==E1)
{
gotoxy(X1+46+leading_ext_Num*10+(ext_Num+1)*3,Y1+19);//Set position
printf("%x ",keyCode);
gotoxy(X1+65,Y1+19);printf("]");
if(ext_Num++ != 2)
{
if((keyCode & bit7) != bit7 ) //Hold down key
{
//CheckTiming();
for(i=0;i<ExtE1Max;i++)
{
if(ExtE1Key[i].keyCode==keyCode)
break;
}
if(i != ExtE1Max)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -