Thomas Horler / Mbed 2 deprecated QSB_Scandcode_USB

Dependencies:   USBDevice mbed

qsb_scan.cpp

Committer:
ThomasSonderDesign
Date:
2016-02-25
Revision:
0:2a3d940c3621

File content as of revision 0:2a3d940c3621:

/*
Sends a scan code to the PC over usb HID
*/
#include "mbed.h"
#include "USBHID.h"
#include "VKCodes.h"

DigitalOut led (P0_7);
USBHID hid(8, 8,0x1234,0x3241); //Create a HID conection with and 8 byte input and output report, PID0x1234 VID 3241
HID_REPORT send_report;
HID_REPORT recv_report;


int main(void){
    send_report.length = 8;
    while(1){
        if(hid.readNB(&recv_report)){
            if(recv_report.data[1]==0xaa){    //reciev 0xaa puts the device into keyboard mode
                for (int i = 0; i<10;i++){                
                    send_report.data[0] = 0;
    send_report.data[1] = 99;        //send code for mod key comibination
    send_report.data[2] = 55;        //send code for specific key
    send_report.data[3] = 0;
    send_report.data[4] = 0;
    send_report.data[5] = 0;
    send_report.data[6] = 0;
    send_report.data[7] = 0;
    wait_ms(58);
    hid.send(&send_report);
                }
            }
        }
    }
}