2010年12月6日月曜日

スイッチをBS(バックスペース)キーにする-USB Device - HID - Keyboard-PIC18F2550

キーコードを調べます。
USB HID toPS/2 Scan Code Translation Table
によると、バックスペースは、2A のようです。

  1. void Keyboard(void)  
  2. {  
  3.  static unsigned char key = 4;   
  4.   
  5.  //Check if the IN endpoint is not busy, and if it isn't check if we want to send   
  6.  //keystroke data to the host.  
  7.     if(!HIDTxHandleBusy(lastINTransmission))  
  8.     {  
  9.         if(Switch3IsPressed())  
  10.         {  
  11.          //Load the HID buffer  
  12.          hid_report_in[0] = 0;  
  13.          hid_report_in[1] = 0;  
  14.          hid_report_in[2] = key++;  
  15.          hid_report_in[3] = 0;  
  16.          hid_report_in[4] = 0;  
  17.          hid_report_in[5] = 0;  
  18.          hid_report_in[6] = 0;  
  19.          hid_report_in[7] = 0;  
  20.             //Send the 8 byte packet over USB to the host.  
  21.             lastINTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x08);  
  22.    

とりあえずkey++の場所に0x2Aと記入すれば動きます。

0 件のコメント:

コメントを投稿