Thomas Horler / Mbed 2 deprecated QSB_Scandcode_USB

Dependencies:   USBDevice mbed

Committer:
ThomasSonderDesign
Date:
Thu Feb 25 00:44:58 2016 +0000
Revision:
0:2a3d940c3621
Test Sending scancodes over usb

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasSonderDesign 0:2a3d940c3621 1 /*
ThomasSonderDesign 0:2a3d940c3621 2 Sends a scan code to the PC over usb HID
ThomasSonderDesign 0:2a3d940c3621 3 */
ThomasSonderDesign 0:2a3d940c3621 4 #include "mbed.h"
ThomasSonderDesign 0:2a3d940c3621 5 #include "USBHID.h"
ThomasSonderDesign 0:2a3d940c3621 6 #include "VKCodes.h"
ThomasSonderDesign 0:2a3d940c3621 7
ThomasSonderDesign 0:2a3d940c3621 8 DigitalOut led (P0_7);
ThomasSonderDesign 0:2a3d940c3621 9 USBHID hid(8, 8,0x1234,0x3241); //Create a HID conection with and 8 byte input and output report, PID0x1234 VID 3241
ThomasSonderDesign 0:2a3d940c3621 10 HID_REPORT send_report;
ThomasSonderDesign 0:2a3d940c3621 11 HID_REPORT recv_report;
ThomasSonderDesign 0:2a3d940c3621 12
ThomasSonderDesign 0:2a3d940c3621 13
ThomasSonderDesign 0:2a3d940c3621 14 int main(void){
ThomasSonderDesign 0:2a3d940c3621 15 send_report.length = 8;
ThomasSonderDesign 0:2a3d940c3621 16 while(1){
ThomasSonderDesign 0:2a3d940c3621 17 if(hid.readNB(&recv_report)){
ThomasSonderDesign 0:2a3d940c3621 18 if(recv_report.data[1]==0xaa){ //reciev 0xaa puts the device into keyboard mode
ThomasSonderDesign 0:2a3d940c3621 19 for (int i = 0; i<10;i++){
ThomasSonderDesign 0:2a3d940c3621 20 send_report.data[0] = 0;
ThomasSonderDesign 0:2a3d940c3621 21 send_report.data[1] = 99; //send code for mod key comibination
ThomasSonderDesign 0:2a3d940c3621 22 send_report.data[2] = 55; //send code for specific key
ThomasSonderDesign 0:2a3d940c3621 23 send_report.data[3] = 0;
ThomasSonderDesign 0:2a3d940c3621 24 send_report.data[4] = 0;
ThomasSonderDesign 0:2a3d940c3621 25 send_report.data[5] = 0;
ThomasSonderDesign 0:2a3d940c3621 26 send_report.data[6] = 0;
ThomasSonderDesign 0:2a3d940c3621 27 send_report.data[7] = 0;
ThomasSonderDesign 0:2a3d940c3621 28 wait_ms(58);
ThomasSonderDesign 0:2a3d940c3621 29 hid.send(&send_report);
ThomasSonderDesign 0:2a3d940c3621 30 }
ThomasSonderDesign 0:2a3d940c3621 31 }
ThomasSonderDesign 0:2a3d940c3621 32 }
ThomasSonderDesign 0:2a3d940c3621 33 }
ThomasSonderDesign 0:2a3d940c3621 34 }