mercredi 4 août 2010

Clef USB password: code fonctionnel

 

J'ai changé à l'arrache le début de la fonction : 

void Keyboard(void) { static unsigned char key = 4;//4 static unsigned char position = 0; static unsigned char texte[100]; texte[0]=4; texte[1]=5; texte[2]=6; texte[3]=7; texte[4]=8; texte[5]=43;//tab texte[6]=9; texte[7]=10; texte[8]=11; texte[9]=88;//enter texte[10]=0;//fin //Check if the IN endpoint is not busy, and if it isn't check if we want to send //keystroke data to the host. if(!HIDTxHandleBusy(lastINTransmission)) { if(sw2==0)//sw2//Switch3IsPressed() { //Load the HID buffer hid_report_in[0] = 0; hid_report_in[1] = 0; hid_report_in[2] = texte[position];//key++ hid_report_in[3] = 0;//0 hid_report_in[4] = 0; hid_report_in[5] = 0; hid_report_in[6] = 0; hid_report_in[7] = 0; if(texte[position]==0) { // while(sw2==0);; key = 40; hid_report_in[2] = 0;//key++ }else{ position++; } //Send the 8 byte packet over USB to the host. lastINTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x08); } else { //Load the HID buffer hid_report_in[0] = 0; hid_report_in[1] = 0; hid_report_in[2] = 0; //Indicate no character pressed hid_report_in[3] = 0; hid_report_in[4] = 0; hid_report_in[5] = 0; hid_report_in[6] = 0; hid_report_in[7] = 0; //Send the 8 byte packet over USB to the host. lastINTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x08); position = 0; key = 4; } } 

Ce qui a pour effet de tapé : abcde[tabulation]fgh[enter] 
Il y a plus qu'à traduire des touches pour que ça marche.

Aucun commentaire: