// read scancode created by djfeeler
#include <acknex.h>
#include <default.c>
STRING* VG_str_letter = "";
TEXT* Txt_tape =
{
pos_x = 10;
pos_y = 10;
layer = 1;
font = "Arial#14";
}
TEXT* Txt_youHaveTape =
{
pos_x = 10;
pos_y = 30;
layer = 1;
font = "Arial#14";
}
TEXT* Txt_hisScanCode =
{
pos_x = 10;
pos_y = 50;
layer = 1;
font = "Arial#14";
}
TEXT* Txt_restart =
{
pos_x = 10;
pos_y = 70;
layer = 1;
font = "Arial#14";
}
void main()
{
STRING* VL_str = "Press a letter : ";
STRING* VL_str_key = "";
STRING* VL_str_youHaveTape = "";
STRING* VL_str_hisScanCodeis = "";
STRING* VL_str_scanCode = "";
STRING* VL_str_restart = "Restart ? y / n";
video_window(NULL,NULL,0,"Scancode");
while(1)
{
// Display Press a letter
(Txt_tape.pstring)[0] = VL_str;
set(Txt_tape,SHOW);
while (!key_any) { wait(1); } // we expect the key to be pressed
while (key_any){ wait(1); }
if(key_lastpressed == 280 || key_lastpressed == 281 || key_lastpressed == 282)
{
str_cpy(VL_str_key,"");
switch(key_lastpressed)
{
case 280 :
str_cat(VL_str_key,"left mouse button");
break;
case 281 :
str_cat(VL_str_key,"right mouse button");
break;
case 282 :
str_cat(VL_str_key,"middle mouse button");
break;
}
}
else
str_for_key(VL_str_key,key_lastpressed); // recovering key
// Display You pressed the letter :
str_cpy(VL_str_youHaveTape,"You pressed the letter : ");
str_cat(VL_str_youHaveTape,VL_str_key);
(Txt_youHaveTape.pstring)[0] = VL_str_youHaveTape;
set(Txt_youHaveTape,SHOW);
// Display His ScanCode is
str_cpy(VL_str_hisScanCodeis,"His ScanCode is : ");
str_for_num(VL_str_scanCode,key_lastpressed);
str_cat(VL_str_hisScanCodeis,VL_str_scanCode);
(Txt_hisScanCode.pstring)[0] = VL_str_hisScanCodeis;
set(Txt_hisScanCode,SHOW);
// restart
(Txt_restart.pstring)[0] = VL_str_restart;
set(Txt_restart,SHOW);
while (!key_any) { wait(1); } // on attends que la touche soit pressée
while (key_any){ wait(1); }
switch(key_lastpressed)
{
case 49 : // for key n
sys_exit(NULL);
break;
case 21 : // for key y
reset(Txt_restart,SHOW);
reset(Txt_hisScanCode,SHOW);
reset(Txt_youHaveTape,SHOW);
break;
default :
sys_exit(NULL);
break;
}
wait(1);
}
}